From c1965e2453cd0708b845c2c0efb87b4d50c27e88 Mon Sep 17 00:00:00 2001 From: Kima Date: Sun, 3 Mar 2024 23:26:11 +0100 Subject: [PATCH] started new navigation bar --- refilc/lib/database/init.dart | 7 +- refilc/lib/models/settings.dart | 13 +- refilc/pubspec.yaml | 1 + .../screens/navigation/navigation_screen.dart | 160 +++++++++++++----- 4 files changed, 135 insertions(+), 46 deletions(-) diff --git a/refilc/lib/database/init.dart b/refilc/lib/database/init.dart index ee963a7..80d0286 100644 --- a/refilc/lib/database/init.dart +++ b/refilc/lib/database/init.dart @@ -45,11 +45,10 @@ const settingsDB = DatabaseStruct("settings", { "show_breaks": int, "font_family": String, "plus_session_id": String, - "cal_sync_room_location": String, - "cal_sync_show_exams": int, - "cal_sync_show_teacher": int, - "cal_sync_renamed": int, + "cal_sync_room_location": String, "cal_sync_show_exams": int, + "cal_sync_show_teacher": int, "cal_sync_renamed": int, "calendar_id": String, + "nav_shadow": int, }); // DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING // YOU'VE BEEN WARNED!!! diff --git a/refilc/lib/models/settings.dart b/refilc/lib/models/settings.dart index d238964..6e9ca8c 100644 --- a/refilc/lib/models/settings.dart +++ b/refilc/lib/models/settings.dart @@ -98,6 +98,7 @@ class SettingsProvider extends ChangeNotifier { bool _calSyncShowTeacher; bool _calSyncRenamed; String _calendarId; + bool _navShadow; SettingsProvider({ DatabaseProvider? database, @@ -161,6 +162,7 @@ class SettingsProvider extends ChangeNotifier { required bool calSyncShowTeacher, required bool calSyncRenamed, required String calendarId, + required bool navShadow, }) : _database = database, _language = language, _startPage = startPage, @@ -221,7 +223,8 @@ class SettingsProvider extends ChangeNotifier { _calSyncShowExams = calSyncShowExams, _calSyncShowTeacher = calSyncShowTeacher, _calSyncRenamed = calSyncRenamed, - _calendarId = calendarId; + _calendarId = calendarId, + _navShadow = navShadow; factory SettingsProvider.fromMap(Map map, {required DatabaseProvider database}) { @@ -302,6 +305,7 @@ class SettingsProvider extends ChangeNotifier { calSyncShowTeacher: map['cal_sync_show_teacher'] == 1, calSyncRenamed: map['cal_sync_renamed'] == 1, calendarId: map['calendar_id'], + navShadow: map['nav_shadow'] == 1, ); } @@ -370,6 +374,7 @@ class SettingsProvider extends ChangeNotifier { "cal_sync_show_teacher": _calSyncShowTeacher ? 1 : 0, "cal_sync_renamed": _calSyncRenamed ? 1 : 0, "calendar_id": _calendarId, + "nav_shadow": _navShadow ? 1 : 0, }; } @@ -442,6 +447,7 @@ class SettingsProvider extends ChangeNotifier { calSyncShowTeacher: true, calSyncRenamed: false, calendarId: '', + navShadow: true, ); } @@ -505,6 +511,7 @@ class SettingsProvider extends ChangeNotifier { bool get calSyncShowTeacher => _calSyncShowTeacher; bool get calSyncRenamed => _calSyncRenamed; String get calendarId => _calendarId; + bool get navShadow => _navShadow; Future update({ bool store = true, @@ -564,6 +571,7 @@ class SettingsProvider extends ChangeNotifier { bool? calSyncShowTeacher, bool? calSyncRenamed, String? calendarId, + bool? navShadow, }) async { if (language != null && language != _language) _language = language; if (startPage != null && startPage != _startPage) _startPage = startPage; @@ -731,6 +739,9 @@ class SettingsProvider extends ChangeNotifier { if (calendarId != null && calendarId != _calendarId) { _calendarId = calendarId; } + if (navShadow != null && navShadow != _navShadow) { + _navShadow = navShadow; + } // store or not if (store) await _database?.store.storeSettings(this); notifyListeners(); diff --git a/refilc/pubspec.yaml b/refilc/pubspec.yaml index 96e3087..075552e 100644 --- a/refilc/pubspec.yaml +++ b/refilc/pubspec.yaml @@ -96,6 +96,7 @@ flutter: - assets/images/subject_covers/ - assets/launch_icons/ - assets/images/ext_logo/ + - assets/svg/menu_icons/ fonts: - family: FilcIcons diff --git a/refilc_mobile_ui/lib/screens/navigation/navigation_screen.dart b/refilc_mobile_ui/lib/screens/navigation/navigation_screen.dart index 4659feb..e57cd77 100644 --- a/refilc_mobile_ui/lib/screens/navigation/navigation_screen.dart +++ b/refilc_mobile_ui/lib/screens/navigation/navigation_screen.dart @@ -1,3 +1,5 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:refilc/api/providers/update_provider.dart'; import 'package:refilc/helpers/quick_actions.dart'; import 'package:refilc/models/settings.dart'; @@ -234,6 +236,9 @@ class NavigationScreenState extends State _navigatorState.currentState?.pushReplacementNamed(page); }); + // SvgTheme navIcTheme = + // SvgTheme(currentColor: Theme.of(context).colorScheme.primary); + // ignore: deprecated_member_use return WillPopScope( onWillPop: () async { @@ -255,6 +260,7 @@ class NavigationScreenState extends State child: Scaffold( body: Column( children: [ + // actual page Expanded( child: Stack( alignment: Alignment.bottomCenter, @@ -269,49 +275,121 @@ class NavigationScreenState extends State ), ), - // Status bar - Material( - color: Theme.of(context).colorScheme.background, - child: const StatusBar(), - ), + // navbar + Container( + decoration: settings.navShadow + ? BoxDecoration( + boxShadow: [ + BoxShadow( + color: Theme.of(context).scaffoldBackgroundColor, + offset: const Offset(0, -4), + blurRadius: 14, + spreadRadius: 18, + ), + ], + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + stops: const [0.0, 0.175], + colors: [ + Theme.of(context).scaffoldBackgroundColor, + Theme.of(context).scaffoldBackgroundColor, + ], + ), + ) + : null, + child: Column( + children: [ + // Status bar + Material( + color: Theme.of(context).colorScheme.background, + child: const StatusBar(), + ), - // Bottom Navigaton Bar - Material( - color: Theme.of(context).scaffoldBackgroundColor, - child: MediaQuery.removePadding( - context: context, - removeTop: true, - child: Navbar( - selectedIndex: selected.index, - onSelected: onPageSelected, - items: [ - NavItem( - title: "home".i18n, - icon: const Icon(FilcIcons.home), - activeIcon: const Icon(FilcIcons.homefill), + // Bottom Navigaton Bar + Material( + color: Theme.of(context).scaffoldBackgroundColor, + child: MediaQuery.removePadding( + context: context, + removeTop: true, + child: Navbar( + selectedIndex: selected.index, + onSelected: onPageSelected, + items: [ + NavItem( + title: "home".i18n, + icon: Stack( + alignment: AlignmentDirectional.center, + children: [ + SvgPicture.asset( + 'assets/svg/menu_icons/today.svg', + color: + Theme.of(context).colorScheme.secondary, + height: 24, + ), + Transform.translate( + offset: const Offset(0, 1.6), + child: Text( + DateTime.now().day.toString(), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary, + fontWeight: FontWeight.w500, + ), + ), + ), + ], + ), + activeIcon: Stack( + alignment: AlignmentDirectional.center, + children: [ + SvgPicture.asset( + 'assets/svg/menu_icons/today_selected.svg', + color: + Theme.of(context).colorScheme.secondary, + height: 24, + ), + Transform.translate( + offset: const Offset(0, 1.8), + child: Text( + DateTime.now().day.toString(), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .background, + fontWeight: FontWeight.w500, + ), + ), + ), + ], + ), + ), + NavItem( + title: "grades".i18n, + icon: const Icon(FeatherIcons.bookmark), + activeIcon: const Icon(FilcIcons.gradesfill), + ), + NavItem( + title: "timetable".i18n, + icon: const Icon(FeatherIcons.calendar), + activeIcon: const Icon(FilcIcons.timetablefill), + ), + NavItem( + title: "messages".i18n, + icon: const Icon(FeatherIcons.messageSquare), + activeIcon: const Icon(FilcIcons.messagesfill), + ), + NavItem( + title: "absences".i18n, + icon: const Icon(FeatherIcons.clock), + activeIcon: const Icon(FilcIcons.absencesfill), + ), + ], + ), ), - NavItem( - title: "grades".i18n, - icon: const Icon(FeatherIcons.bookmark), - activeIcon: const Icon(FilcIcons.gradesfill), - ), - NavItem( - title: "timetable".i18n, - icon: const Icon(FeatherIcons.calendar), - activeIcon: const Icon(FilcIcons.timetablefill), - ), - NavItem( - title: "messages".i18n, - icon: const Icon(FeatherIcons.messageSquare), - activeIcon: const Icon(FilcIcons.messagesfill), - ), - NavItem( - title: "absences".i18n, - icon: const Icon(FeatherIcons.clock), - activeIcon: const Icon(FilcIcons.absencesfill), - ), - ], - ), + ), + ], ), ), ],