Skip to content

Commit

Permalink
album file size display
Browse files Browse the repository at this point in the history
  • Loading branch information
nbonamy committed Mar 8, 2024
1 parent 7c60305 commit b2eba52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/components/album.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class _AlbumWidgetState extends State<AlbumWidget> {
@override
Widget build(BuildContext context) {
int trackCount = widget.tracks.length;
int filesize =
widget.tracks.fold(0, (size, track) => size + track.filesize);
int playtimeMinutes = (widget.tracks
.fold(0, (time, track) => time + track.safeTags.duration) /
60)
Expand Down Expand Up @@ -63,6 +65,7 @@ class _AlbumWidgetState extends State<AlbumWidget> {
trackCount: trackCount,
playtime: playtimeMinutes,
format: '$formatString $formatDescription',
filesize: filesize,
),
SizedBox(width: _artworkSize(constraints) == 0 ? 0 : 48),
Expanded(
Expand Down
12 changes: 12 additions & 0 deletions lib/components/album_artwork.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import '../model/track.dart';
import '../utils/consts.dart';
import '../utils/num_utils.dart';
import 'artwork_async.dart';

class AlbumArtworkWidget extends StatelessWidget {
Expand All @@ -10,13 +11,15 @@ class AlbumArtworkWidget extends StatelessWidget {
final int trackCount;
final int playtime;
final String format;
final int filesize;
const AlbumArtworkWidget({
super.key,
required this.track,
required this.size,
required this.trackCount,
required this.playtime,
required this.format,
required this.filesize,
});

@override
Expand Down Expand Up @@ -50,6 +53,15 @@ class AlbumArtworkWidget extends StatelessWidget {
color: Colors.black.withOpacity(Consts.fadedOpacity),
),
),
const SizedBox(height: 4),
Text(
filesize.formatFilesize(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.black.withOpacity(Consts.fadedOpacity),
),
),
],
),
);
Expand Down

0 comments on commit b2eba52

Please sign in to comment.