refactor(mobile): enhance thumbnail layout and owner name display

This commit is contained in:
idubnori
2025-12-18 19:26:11 +09:00
parent 85086cdb02
commit cc3307d335

View File

@@ -55,6 +55,9 @@ class ThumbnailTile extends ConsumerWidget {
Container(color: lockSelection ? context.colorScheme.surfaceContainerHighest : assetContainerColor), Container(color: lockSelection ? context.colorScheme.surfaceContainerHighest : assetContainerColor),
LayoutBuilder( LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final horizontalPadding = constraints.maxWidth * 0.02;
final verticalPadding = constraints.maxHeight * 0.02;
return AnimatedContainer( return AnimatedContainer(
duration: Durations.short4, duration: Durations.short4,
curve: Curves.decelerate, curve: Curves.decelerate,
@@ -77,50 +80,51 @@ class ThumbnailTile extends ConsumerWidget {
if (asset != null) if (asset != null)
Align( Align(
alignment: Alignment.topRight, alignment: Alignment.topRight,
child: _AssetTypeIcons(asset: asset),
),
if (shouldShowOwnerName)
Align(
alignment: Alignment.bottomRight,
child: Padding( child: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.symmetric(horizontal: horizontalPadding * 0.5, vertical: verticalPadding),
right: constraints.maxWidth * 0.03, child: Row(
left: constraints.maxWidth * 0.3, mainAxisAlignment: MainAxisAlignment.end,
bottom: constraints.maxWidth * 0.01, crossAxisAlignment: CrossAxisAlignment.center,
children: [_AssetTypeIcons(asset: asset)],
), ),
),
),
if (shouldShowOwnerName ||
(storageIndicator && asset != null) ||
(asset != null && asset.isFavorite))
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: horizontalPadding, vertical: verticalPadding * 0.1),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (asset != null && asset.isFavorite)
const Padding(
padding: EdgeInsets.only(right: 1.0),
child: _TileOverlayIcon(Icons.favorite_rounded),
)
else
const SizedBox.shrink(),
if (shouldShowOwnerName)
Flexible(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 1.0),
child: _OwnerNameLabel(ownerName: ownerName!), child: _OwnerNameLabel(ownerName: ownerName!),
), ),
), ),
if (storageIndicator && asset != null) if (storageIndicator && asset != null)
switch (asset.storage) { Padding(
AssetState.local => const Align( padding: const EdgeInsets.only(right: 2.0),
alignment: Alignment.bottomRight, child: _TileOverlayIcon(switch (asset.storage) {
child: Padding( AssetState.local => Icons.cloud_off_outlined,
padding: EdgeInsets.only(right: 10.0, bottom: 6.0), AssetState.remote => Icons.cloud_outlined,
child: _TileOverlayIcon(Icons.cloud_off_outlined), AssetState.merged => Icons.cloud_done_outlined,
}),
), ),
],
), ),
AssetState.remote => const Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.only(right: 10.0, bottom: 6.0),
child: _TileOverlayIcon(Icons.cloud_outlined),
),
),
AssetState.merged => const Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.only(right: 10.0, bottom: 6.0),
child: _TileOverlayIcon(Icons.cloud_done_outlined),
),
),
},
if (asset != null && asset.isFavorite)
const Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: EdgeInsets.only(left: 10.0, bottom: 6.0),
child: _TileOverlayIcon(Icons.favorite_rounded),
), ),
), ),
], ],
@@ -183,7 +187,6 @@ class _VideoIndicator extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(
spacing: 3,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
// CrossAxisAlignment.start looks more centered vertically than CrossAxisAlignment.center // CrossAxisAlignment.start looks more centered vertically than CrossAxisAlignment.center
@@ -198,6 +201,7 @@ class _VideoIndicator extends StatelessWidget {
shadows: [Shadow(blurRadius: 5.0, color: Color.fromRGBO(0, 0, 0, 0.6))], shadows: [Shadow(blurRadius: 5.0, color: Color.fromRGBO(0, 0, 0, 0.6))],
), ),
), ),
const SizedBox(width: 2),
const _TileOverlayIcon(Icons.play_circle_outline_rounded), const _TileOverlayIcon(Icons.play_circle_outline_rounded),
], ],
); );
@@ -230,22 +234,14 @@ class _AssetTypeIcons extends StatelessWidget {
final hasStack = asset is RemoteAsset && (asset as RemoteAsset).stackId != null; final hasStack = asset is RemoteAsset && (asset as RemoteAsset).stackId != null;
final isLivePhoto = asset is RemoteAsset && asset.livePhotoVideoId != null; final isLivePhoto = asset is RemoteAsset && asset.livePhotoVideoId != null;
return Column( return Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
if (asset.isVideo) if (asset.isVideo) Padding(padding: const EdgeInsets.only(right: 2.0), child: _VideoIndicator(asset.duration)),
Padding(padding: const EdgeInsets.only(right: 10.0, top: 6.0), child: _VideoIndicator(asset.duration)),
if (hasStack) if (hasStack)
const Padding( const Padding(padding: EdgeInsets.only(right: 2.0), child: _TileOverlayIcon(Icons.burst_mode_rounded)),
padding: EdgeInsets.only(right: 10.0, top: 6.0),
child: _TileOverlayIcon(Icons.burst_mode_rounded),
),
if (isLivePhoto) if (isLivePhoto)
const Padding( const Padding(padding: EdgeInsets.only(right: 2.0), child: _TileOverlayIcon(Icons.motion_photos_on_rounded)),
padding: EdgeInsets.only(right: 10.0, top: 6.0),
child: _TileOverlayIcon(Icons.motion_photos_on_rounded),
),
], ],
); );
} }
@@ -258,20 +254,17 @@ class _OwnerNameLabel extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Text(
constraints: const BoxConstraints(maxWidth: 120),
child: Text(
ownerName, ownerName,
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 14, fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.bold,
shadows: [Shadow(blurRadius: 5.0, color: Color.fromRGBO(0, 0, 0, 0.6), offset: Offset(0.0, 0.0))], shadows: [Shadow(blurRadius: 5.0, color: Color.fromRGBO(0, 0, 0, 0.6), offset: Offset(0.0, 0.0))],
), ),
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
softWrap: false, softWrap: false,
maxLines: 1, maxLines: 1,
),
); );
} }
} }