Browse Source

Added navigation drawer

main
root 4 months ago
parent
commit
660dfb8425
  1. 2
      .flutter-plugins-dependencies
  2. 38
      lib/fragments/Drawer.dart
  3. 8
      lib/pages/MoodDashboard.dart
  4. 2
      lib/pages/MoodForm.dart

2
.flutter-plugins-dependencies

@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"android":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"macos":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"sqflite","dependencies":[]}],"date_created":"2021-08-13 19:21:06.692848","version":"2.2.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"android":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"macos":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"sqflite","dependencies":[]}],"date_created":"2021-08-13 20:13:43.393911","version":"2.2.3"}

38
lib/fragments/Drawer.dart

@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
ListTile drawerTile(
BuildContext ctx, IconData icon, String label, String routeName) =>
ListTile(
leading: Icon(icon),
title: Text(label),
onTap: () {
Navigator.pushNamedAndRemoveUntil(ctx, routeName, (_) => false);
},
selected: routeName == ModalRoute.of(ctx)!.settings.name,
);
class AppDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Drawer(
child: ListView(
children: [
DrawerHeader(
decoration: BoxDecoration(
color: theme.primaryColor,
),
child: Text(
'MoodDroid',
style: theme.textTheme.headline6,
),
),
drawerTile(context, Icons.house, 'Recent moods', 'dashboard'),
drawerTile(context, Icons.add, 'How do you feel?', 'mood-picker'),
drawerTile(context, Icons.settings, 'Settings', 'settings'),
],
),
);
}
}

8
lib/pages/MoodDashboard.dart

@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mood_droid/constants.dart';
import 'package:mood_droid/data/db.dart';
import 'package:mood_droid/data/mood.dart';
import 'package:mood_droid/fragments/Drawer.dart';
import 'package:mood_droid/fragments/LoadingPage.dart';
import 'package:mood_droid/fragments/MoodGraph.dart';
import 'package:mood_droid/helpers/date.dart';
@ -19,6 +20,7 @@ class MoodDashboard extends ConsumerWidget {
appBar: AppBar(
title: Text(AppTitle),
),
drawer: AppDrawer(),
body: loading<AppDatabase>(
$db,
(db) => FutureBuilder<List<Mood>>(
@ -61,12 +63,6 @@ class MoodDashboard extends ConsumerWidget {
},
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
Navigator.popAndPushNamed(context, 'mood-picker');
},
),
);
}
}

2
lib/pages/MoodForm.dart

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mood_droid/constants.dart';
import 'package:mood_droid/data/mood.dart';
import 'package:mood_droid/fragments/Drawer.dart';
import 'package:mood_droid/helpers/human-readable.dart';
import 'package:mood_droid/providers/db.dart';
@ -60,6 +61,7 @@ class MoodPickerState extends State<MoodPicker> {
)
],
),
drawer: AppDrawer(),
);
}