Skip to content

Commit

Permalink
ThumbnailWidget Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
umberto-sonnino committed Dec 21, 2018
1 parent 43328ea commit 15a8318
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/lib/main_menu/thumbnail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,32 @@ import "package:flutter/material.dart";
import "package:timeline/timeline/timeline_entry.dart";
import "package:timeline/article/timeline_entry_widget.dart";

/// This widget is responsible for drawing the circular thumbnail within the [ThumbnailDetailWidget].
///
/// It uses an inactive [TimelineEntryWidget] for the image, with a [CustomClipper] for the circular image.
class ThumbnailWidget extends StatelessWidget {
static const double radius = 17;
/// Reference to the entry to get the thumbnail image information.
final TimelineEntry entry;
final double radius;

ThumbnailWidget(this.entry, {this.radius = 17, Key key}) : super(key: key);
ThumbnailWidget(this.entry, {Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
TimelineAsset asset = entry.asset;
Widget thumbnail;
/// Check if the [entry.asset] provided is already a [TimelineImage].
if (asset is TimelineImage) {
thumbnail = RawImage(image: asset.image);
} else if (asset is TimelineNima || asset is TimelineFlare) {
/// If not, retrieve the image from the Nima/Flare [TimelineAsset], and set it as inactive (i.e. a static image).
thumbnail = TimelineEntryWidget(
isActive: false,
timelineEntry: entry,
);
} else {
thumbnail = Container(
color: Colors.blueAccent,
color: Colors.transparent,
);
}

Expand All @@ -33,6 +39,7 @@ class ThumbnailWidget extends StatelessWidget {
}
}

/// Custom Clipper for the desired circular effect.
class CircleClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Expand Down

0 comments on commit 15a8318

Please sign in to comment.