feat: wire up app shell, log mood screen, and fix Android build

- Bootstrap ProviderScope in main.dart and move App to app.dart with light/dark theming
- Add initial LogMoodScreen with mood entry flow and shared activity/mood widgets
- Add kIsWeb guard in app_database.dart for drift web support
- Enable Android core library desugaring required by flutter_local_notifications 21.x
- Guard all async notifier state assignments with ref.mounted checks to prevent
  use-after-dispose errors when providers are auto-disposed mid-operation
This commit is contained in:
2026-04-26 12:00:14 +10:00
parent 33d1713f51
commit 59597c7a4f
12 changed files with 337 additions and 22 deletions
+42
View File
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/providers/activity_provider.dart';
class ActivityGrid extends ConsumerWidget {
const ActivityGrid({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final activitiesAsync = ref.watch(activitiesProvider);
final selected = ref.watch(selectedActivitiesProvider);
final theme = Theme.of(context);
return activitiesAsync.when(
data: (activities) => Wrap(
spacing: 8,
runSpacing: 8,
children: activities.map((a) {
final isSelected = selected.contains(a.id);
return FilterChip(
avatar: Text(
String.fromCharCode(a.iconCodepoint),
style: const TextStyle(fontFamily: 'MaterialIcons'),
),
label: Text(a.name),
selected: isSelected,
onSelected: (_) =>
ref.read(selectedActivitiesProvider.notifier).toggle(a.id),
selectedColor: Color(
int.parse(a.colourHex.replaceFirst('#', '0xFF')),
).withOpacity(0.2),
checkmarkColor: Color(
int.parse(a.colourHex.replaceFirst('#', '0xFF')),
),
);
}).toList(),
),
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, _) => Text('Error loading activities: $e'),
);
}
}
+53
View File
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
class MoodSelector extends StatelessWidget {
final int selected;
final List<String> emojis;
final List<String> labels;
final List<Color> colors;
final ValueChanged<int> onChanged;
const MoodSelector({
super.key,
required this.selected,
required this.emojis,
required this.labels,
required this.colors,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: List.generate(5, (i) {
final level = i + 1;
final isSelected = selected == level;
return GestureDetector(
onTap: () => onChanged(level),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut,
width: isSelected ? 64 : 52,
height: isSelected ? 64 : 52,
decoration: BoxDecoration(
color:
isSelected ? colors[i].withOpacity(0.15) : Colors.transparent,
shape: BoxShape.circle,
border: Border.all(
color: isSelected ? colors[i] : Colors.transparent,
width: 2,
),
),
child: Center(
child: Text(
emojis[i],
style: TextStyle(fontSize: isSelected ? 36 : 28),
),
),
),
);
}),
);
}
}