2024-01-05 07:20:55 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2023-06-27 23:00:20 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2024-02-18 05:31:34 +02:00
|
|
|
import 'package:immich_mobile/modules/home/ui/asset_grid/thumbnail_placeholder.dart';
|
2023-06-27 23:00:20 +02:00
|
|
|
import 'package:immich_mobile/modules/memories/providers/memory.provider.dart';
|
|
|
|
import 'package:immich_mobile/routing/router.dart';
|
2024-04-15 07:50:47 +02:00
|
|
|
import 'package:immich_mobile/shared/providers/haptic_feedback.provider.dart';
|
2023-06-27 23:00:20 +02:00
|
|
|
import 'package:immich_mobile/shared/ui/immich_image.dart';
|
|
|
|
|
|
|
|
class MemoryLane extends HookConsumerWidget {
|
|
|
|
const MemoryLane({super.key});
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final memoryLaneFutureProvider = ref.watch(memoryFutureProvider);
|
|
|
|
|
|
|
|
final memoryLane = memoryLaneFutureProvider
|
|
|
|
.whenData(
|
|
|
|
(memories) => memories != null
|
2024-02-05 21:12:33 +02:00
|
|
|
? SizedBox(
|
2023-06-27 23:00:20 +02:00
|
|
|
height: 200,
|
|
|
|
child: ListView.builder(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: memories.length,
|
2024-02-05 21:12:33 +02:00
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
right: 8.0,
|
|
|
|
bottom: 8,
|
|
|
|
top: 10,
|
|
|
|
left: 10,
|
|
|
|
),
|
2023-06-27 23:00:20 +02:00
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final memory = memories[index];
|
|
|
|
|
2024-02-05 21:12:33 +02:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
2024-04-15 07:50:47 +02:00
|
|
|
ref
|
|
|
|
.read(hapticFeedbackProvider.notifier)
|
|
|
|
.heavyImpact();
|
2024-02-05 21:12:33 +02:00
|
|
|
context.pushRoute(
|
|
|
|
MemoryRoute(
|
|
|
|
memories: memories,
|
|
|
|
memoryIndex: index,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Card(
|
|
|
|
elevation: 3,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(13.0),
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
2024-02-05 21:12:33 +02:00
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
child: ColorFiltered(
|
|
|
|
colorFilter: ColorFilter.mode(
|
|
|
|
Colors.black.withOpacity(0.2),
|
|
|
|
BlendMode.darken,
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
2024-02-05 21:12:33 +02:00
|
|
|
child: Hero(
|
|
|
|
tag: 'memory-${memory.assets[0].id}',
|
2023-06-27 23:00:20 +02:00
|
|
|
child: ImmichImage(
|
|
|
|
memory.assets[0],
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: 130,
|
|
|
|
height: 200,
|
2024-02-18 05:31:34 +02:00
|
|
|
placeholder: const ThumbnailPlaceholder(
|
|
|
|
width: 130,
|
|
|
|
height: 200,
|
|
|
|
),
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-02-05 21:12:33 +02:00
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: 16,
|
|
|
|
left: 16,
|
|
|
|
child: ConstrainedBox(
|
|
|
|
constraints: const BoxConstraints(
|
|
|
|
maxWidth: 114,
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
memory.title,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 15,
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-02-05 21:12:33 +02:00
|
|
|
),
|
|
|
|
],
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: const SizedBox(),
|
|
|
|
)
|
|
|
|
.value;
|
|
|
|
|
|
|
|
return memoryLane ?? const SizedBox();
|
|
|
|
}
|
|
|
|
}
|