Files
Immich/mobile/lib/presentation/widgets/memory/memory_lane.widget.dart
T
Adam Gastineau c04c81a979 chore(mobile): remove Drift* prefixes from classes and variables (#31038)
* chore(mobile): remove Drift* prefixes from classes and variables

* Remove *Drift* from related mocks
2026-08-26 19:11:12 +00:00

86 lines
2.8 KiB
Dart

import 'dart:async';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/domain/models/memory.model.dart';
import 'package:immich_mobile/generated/translations.g.dart';
import 'package:immich_mobile/presentation/pages/memory.page.dart';
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
import 'package:immich_mobile/providers/haptic_feedback.provider.dart';
import 'package:immich_mobile/providers/infrastructure/memory.provider.dart';
import 'package:immich_mobile/routing/router.dart';
class MemoryLane extends ConsumerWidget {
const MemoryLane({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final memoryLane = ref.watch(memoryLaneProvider);
final memories = memoryLane.value ?? const [];
if (memories.isEmpty) {
return const SizedBox.shrink();
}
return ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 200),
child: CarouselView(
itemExtent: 145.0,
shrinkExtent: 1.0,
elevation: 2,
backgroundColor: Colors.black,
overlayColor: WidgetStateProperty.all(Colors.white.withValues(alpha: 0.1)),
onTap: (index) {
ref.read(hapticFeedbackProvider.notifier).heavyImpact();
if (memories[index].assets.isNotEmpty) {
MemoryPage.setMemory(ref, memories[index]);
}
unawaited(context.pushRoute(MemoryRoute(memories: memories, memoryIndex: index)));
},
children: memories.map((memory) => MemoryCard(key: Key(memory.id), memory: memory)).toList(growable: false),
),
);
}
}
class MemoryCard extends StatelessWidget {
const MemoryCard({super.key, required this.memory});
final Memory memory;
@override
Widget build(BuildContext context) {
final yearsAgo = DateTime.now().year - memory.data.year;
final title = context.t.years_ago(years: yearsAgo);
return Center(
child: Stack(
children: [
ColorFiltered(
colorFilter: ColorFilter.mode(Colors.black.withValues(alpha: 0.2), BlendMode.darken),
child: SizedBox(
width: 205,
height: 200,
child: Thumbnail.remote(
remoteId: memory.assets[0].id,
thumbhash: memory.assets[0].thumbHash ?? "",
fit: BoxFit.cover,
),
),
),
Positioned(
bottom: 16,
left: 16,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 114),
child: Text(
title,
style: const TextStyle(fontWeight: FontWeight.w600, color: Colors.white, fontSize: 15),
),
),
),
],
),
);
}
}