183 lines
7.1 KiB
Dart
183 lines
7.1 KiB
Dart
import 'package:diameter/screens/accuracy_detail.dart';
|
|
import 'package:diameter/screens/accuracy_list.dart';
|
|
import 'package:diameter/screens/basal/basal_detail.dart';
|
|
import 'package:diameter/screens/basal/basal_profile_detail.dart';
|
|
import 'package:diameter/screens/basal/basal_profiles_list.dart';
|
|
import 'package:diameter/screens/bolus/bolus_detail.dart';
|
|
import 'package:diameter/screens/bolus/bolus_profile_detail.dart';
|
|
import 'package:diameter/screens/bolus/bolus_profile_list.dart';
|
|
import 'package:diameter/screens/log/log.dart';
|
|
import 'package:diameter/screens/log/log_entry.dart';
|
|
import 'package:diameter/screens/log/log_event_detail.dart';
|
|
import 'package:diameter/screens/log/log_event_type_detail.dart';
|
|
import 'package:diameter/screens/log/log_event_type_list.dart';
|
|
import 'package:diameter/screens/log/log_meal_detail.dart';
|
|
import 'package:diameter/screens/meal/meal_category_detail.dart';
|
|
import 'package:diameter/screens/meal/meal_category_list.dart';
|
|
import 'package:diameter/screens/meal/meal_detail.dart';
|
|
import 'package:diameter/screens/meal/meal_list.dart';
|
|
import 'package:diameter/screens/meal/meal_portion_type_detail.dart';
|
|
import 'package:diameter/screens/meal/meal_portion_type_list.dart';
|
|
import 'package:diameter/screens/meal/meal_source_detail.dart';
|
|
import 'package:diameter/screens/meal/meal_source_list.dart';
|
|
import 'package:diameter/settings.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class Routes {
|
|
static const String basal = BasalDetailScreen.routeName;
|
|
static const String basalProfile = BasalProfileDetailScreen.routeName;
|
|
static const String basalProfiles = BasalProfileListScreen.routeName;
|
|
static const List<String> basalRoutes = [basal, basalProfile, basalProfiles];
|
|
|
|
static const String bolus = BolusDetailScreen.routeName;
|
|
static const String bolusProfile = BolusProfileDetailScreen.routeName;
|
|
static const String bolusProfiles = BolusProfileListScreen.routeName;
|
|
static const List<String> bolusRoutes = [bolus, bolusProfile, bolusProfiles];
|
|
|
|
static const String log = LogScreen.routeName;
|
|
static const String logEntry = LogEntryScreen.routeName;
|
|
static const String logEvent = LogEventDetailScreen.routeName;
|
|
static const String logMeal = LogMealDetailScreen.routeName;
|
|
static const List<String> logEntryRoutes = [logEntry, logEvent, logMeal];
|
|
static const String logEventType = LogEventTypeDetailScreen.routeName;
|
|
static const String logEventTypes = LogEventTypeListScreen.routeName;
|
|
static const List<String> logEventTypeRoutes = [logEventType, logEventTypes];
|
|
|
|
static const String meal = MealDetailScreen.routeName;
|
|
static const String meals = MealListScreen.routeName;
|
|
static const List<String> mealRoutes = [meal, meals];
|
|
static const String mealCategory = MealCategoryDetailScreen.routeName;
|
|
static const String mealCategories = MealCategoryListScreen.routeName;
|
|
static const List<String> mealCategoryRoutes = [mealCategory, mealCategories];
|
|
static const String mealPortionType = MealPortionTypeDetailScreen.routeName;
|
|
static const String mealPortionTypes = MealPortionTypeListScreen.routeName;
|
|
static const List<String> mealPortionTypeRoutes = [
|
|
mealPortionType,
|
|
mealPortionTypes
|
|
];
|
|
static const String mealSource = MealSourceDetailScreen.routeName;
|
|
static const String mealSources = MealSourceListScreen.routeName;
|
|
static const List<String> mealSourceRoutes = [mealSource, mealSources];
|
|
|
|
static const String accuracy = AccuracyDetailScreen.routeName;
|
|
static const String accuracies = AccuracyListScreen.routeName;
|
|
static const List<String> accuracyRoutes = [accuracy, accuracies];
|
|
|
|
static const String settings = SettingsScreen.routeName;
|
|
}
|
|
|
|
class Navigation extends StatefulWidget {
|
|
final String? currentLocation;
|
|
const Navigation({Key? key, this.currentLocation}) : super(key: key);
|
|
|
|
@override
|
|
State<Navigation> createState() => _NavigationState();
|
|
}
|
|
|
|
class _NavigationState extends State<Navigation> {
|
|
void selectDestination(String destination) {
|
|
Navigator.pushReplacementNamed(context, destination);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Drawer(
|
|
child: ListView(padding: EdgeInsets.zero, children: <Widget>[
|
|
const SizedBox(
|
|
child: UserAccountsDrawerHeader(
|
|
accountName: Text('Sarah'),
|
|
accountEmail: Text('sarah@sudo.ca'),
|
|
),
|
|
),
|
|
ListTile(
|
|
title: const Text('Log'),
|
|
leading: const Icon(Icons.dashboard),
|
|
onTap: () {
|
|
selectDestination(Routes.log);
|
|
},
|
|
selected: widget.currentLocation == Routes.log,
|
|
),
|
|
ListTile(
|
|
title: const Text('Log Entry'),
|
|
leading: const Icon(Icons.description),
|
|
onTap: () {
|
|
selectDestination(Routes.logEntry);
|
|
},
|
|
selected: Routes.logEntryRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Meals'),
|
|
leading: const Icon(Icons.restaurant),
|
|
onTap: () {
|
|
selectDestination(Routes.meals);
|
|
},
|
|
selected: Routes.mealRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Meal Categories'),
|
|
leading: const Icon(Icons.category),
|
|
onTap: () {
|
|
selectDestination(Routes.mealCategories);
|
|
},
|
|
selected: Routes.mealCategoryRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Meal Portion Types'),
|
|
leading: const Icon(Icons.pie_chart),
|
|
onTap: () {
|
|
selectDestination(Routes.mealPortionTypes);
|
|
},
|
|
selected: Routes.mealPortionTypeRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Meal Sources'),
|
|
leading: const Icon(Icons.local_grocery_store),
|
|
onTap: () {
|
|
selectDestination(Routes.mealSources);
|
|
},
|
|
selected: Routes.mealSourceRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Accuracies'),
|
|
leading: const Icon(Icons.architecture),
|
|
onTap: () {
|
|
selectDestination(Routes.accuracies);
|
|
},
|
|
selected: Routes.accuracyRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Log Event Types'),
|
|
leading: const Icon(Icons.event),
|
|
onTap: () {
|
|
selectDestination(Routes.logEventTypes);
|
|
},
|
|
selected: Routes.logEventTypeRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Basal Profiles'),
|
|
leading: const Icon(Icons.access_time),
|
|
onTap: () {
|
|
selectDestination(Routes.basalProfiles);
|
|
},
|
|
selected: Routes.basalRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Bolus Profiles'),
|
|
leading: const Icon(Icons.medication),
|
|
onTap: () {
|
|
selectDestination(Routes.bolusProfiles);
|
|
},
|
|
selected: Routes.bolusRoutes.contains(widget.currentLocation),
|
|
),
|
|
ListTile(
|
|
title: const Text('Settings'),
|
|
leading: const Icon(Icons.settings),
|
|
onTap: () {
|
|
selectDestination(Routes.settings);
|
|
},
|
|
selected: widget.currentLocation == Routes.settings,
|
|
)
|
|
]));
|
|
}
|
|
}
|