buildMediaItemContent method

  1. @override
Widget buildMediaItemContent(
  1. MediaItem item
)
override

Build the widget visually representing the MediaItem's history tile.

Implementation

@override
Widget buildMediaItemContent(MediaItem item) {
  return Container(
    padding: Spacing.of(context).insets.all.normal,
    child: Stack(
      alignment: Alignment.bottomLeft,
      children: [
        ColoredBox(
          color: Colors.grey.shade800.withOpacity(0.3),
          child: AspectRatio(
            aspectRatio: mediaSource.aspectRatio,
            child: FadeInImage(
              key: UniqueKey(),
              imageErrorBuilder: (_, __, ___) => const SizedBox.shrink(),
              placeholder: MemoryImage(kTransparentImage),
              image: mediaSource.getDisplayThumbnailFromMediaItem(
                appModel: appModel,
                item: item,
              ),
              alignment: Alignment.topCenter,
              fit: BoxFit.fitHeight,
            ),
          ),
        ),
        LayoutBuilder(builder: (context, constraints) {
          return Container(
            alignment: Alignment.center,
            padding: const EdgeInsets.fromLTRB(2, 2, 2, 4),
            height: constraints.maxHeight * 0.25,
            width: double.maxFinite,
            color: Colors.black.withOpacity(0.6),
            child: Text(
              mediaSource.getDisplayTitleFromMediaItem(item),
              overflow: TextOverflow.ellipsis,
              maxLines: 2,
              textAlign: TextAlign.center,
              softWrap: true,
              style: textTheme.bodySmall!.copyWith(
                  color: Colors.white,
                  fontSize: textTheme.bodySmall!.fontSize! * 0.9),
            ),
          );
        }),
        LinearProgressIndicator(
          value: (item.position / item.duration).isNaN ||
                  (item.position / item.duration) == double.infinity ||
                  (item.position == 0 && item.duration == 0)
              ? 0
              : ((item.position / item.duration) > 0.97)
                  ? 1
                  : (item.position / item.duration),
          backgroundColor: Colors.white.withOpacity(0.6),
          valueColor: const AlwaysStoppedAnimation<Color>(Colors.red),
          minHeight: 2,
        ),
      ],
    ),
  );
}