Skip to content

Commit c29fd09

Browse files
committed
better stack thumbnails
1 parent 4cec192 commit c29fd09

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed

mobile/lib/presentation/widgets/asset_viewer/asset_stack.widget.dart

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
33
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
44
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_stack.provider.dart';
55
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
6-
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
6+
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
77
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
88

99
class AssetStackRow extends ConsumerWidget {
@@ -79,45 +79,40 @@ class _StackItemState extends ConsumerState<_StackItem> {
7979

8080
@override
8181
Widget build(BuildContext context) {
82-
Widget thumbnail = Image(
83-
fit: BoxFit.cover,
84-
image: getThumbnailImageProvider(remoteId: widget.asset.id, size: const Size(60, 40)),
85-
width: 60,
86-
height: 40,
82+
const playIcon = Center(
83+
child: Icon(
84+
Icons.play_circle_outline_rounded,
85+
color: Colors.white,
86+
size: 16,
87+
shadows: [Shadow(blurRadius: 5.0, color: Color.fromRGBO(0, 0, 0, 0.6), offset: Offset(0.0, 0.0))],
88+
),
89+
);
90+
const selectedDecoration = BoxDecoration(
91+
border: Border.fromBorderSide(BorderSide(color: Colors.white, width: 2)),
92+
borderRadius: BorderRadius.all(Radius.circular(10)),
8793
);
94+
const unselectedDecoration = BoxDecoration(
95+
border: Border.fromBorderSide(BorderSide(color: Colors.grey, width: 0.5)),
96+
borderRadius: BorderRadius.all(Radius.circular(10)),
97+
);
98+
99+
Widget thumbnail = Thumbnail.fromAsset(asset: widget.asset, size: const Size(60, 40));
88100
if (widget.asset.isVideo) {
89-
thumbnail = Stack(
90-
children: [
91-
thumbnail,
92-
const Center(
93-
child: Icon(
94-
Icons.play_circle_outline_rounded,
95-
color: Colors.white,
96-
size: 16,
97-
shadows: [Shadow(blurRadius: 5.0, color: Color.fromRGBO(0, 0, 0, 0.6), offset: Offset(0.0, 0.0))],
98-
),
99-
),
100-
],
101-
);
101+
thumbnail = Stack(children: [thumbnail, playIcon]);
102102
}
103103
thumbnail = ClipRRect(borderRadius: const BorderRadius.all(Radius.circular(10)), child: thumbnail);
104-
105104
final isSelected = ref.watch(assetViewerProvider.select((s) => s.stackIndex == widget.index));
106-
if (isSelected) {
107-
thumbnail = DecoratedBox(
108-
decoration: const BoxDecoration(
109-
border: Border.fromBorderSide(BorderSide(color: Colors.white, width: 2)),
110-
borderRadius: BorderRadius.all(Radius.circular(10)),
111-
),
112-
position: DecorationPosition.foreground,
113-
child: thumbnail,
114-
);
115-
}
116-
117105
return SizedBox(
118106
width: 60,
119107
height: 40,
120-
child: GestureDetector(onTap: _onTap, child: thumbnail),
108+
child: GestureDetector(
109+
onTap: _onTap,
110+
child: DecoratedBox(
111+
decoration: isSelected ? selectedDecoration : unselectedDecoration,
112+
position: DecorationPosition.foreground,
113+
child: thumbnail,
114+
),
115+
),
121116
);
122117
}
123118
}

0 commit comments

Comments
 (0)