From cc47f9bee77e981aa4722e6ffdebd9e95a2292e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Fri, 17 Mar 2023 23:31:42 +0100 Subject: [PATCH] WIP: Persistent Bottom navigation bar, moved appbar layer to page view --- .idea/codeStyles/Project.xml | 117 +++++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/libraries/Dart_Packages.xml | 16 +++ lib/app.dart | 146 ++++++++++----------------- pubspec.yaml | 2 + 5 files changed, 196 insertions(+), 90 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..4bec4ea --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,117 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index e7f3432..4eb975c 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -58,6 +58,13 @@ + + + + + + @@ -611,6 +618,13 @@ + + + + + + @@ -1016,6 +1030,7 @@ + @@ -1090,6 +1105,7 @@ + diff --git a/lib/app.dart b/lib/app.dart index ac27a35..d56f22a 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -4,12 +4,15 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:marianum_mobile/data/chatList/chatListProps.dart'; import 'package:marianum_mobile/screen/pages/timetable/timetable.dart'; +import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart'; import 'package:provider/provider.dart'; import 'screen/pages/files/files.dart'; import 'screen/pages/more/overhang.dart'; import 'screen/pages/talk/chatList.dart'; import 'screen/settings/settings.dart'; +import 'package:badges/badges.dart' as badges; + class App extends StatefulWidget { const App({Key? key}) : super(key: key); @@ -59,97 +62,60 @@ class _AppState extends State { @override Widget build(BuildContext context) { - final PageController pageController = PageController(); - return Scaffold( - resizeToAvoidBottomInset: false, - appBar: _appBar, - body: Column( - children: [ - Visibility( - visible: false, - child: LinearProgressIndicator( - backgroundColor: Colors.transparent, - valueColor: AlwaysStoppedAnimation(Theme.of(context).primaryColor), - minHeight: 5, - ), + PersistentTabController tabController = PersistentTabController(initialIndex: 0); + + return PersistentTabView( + context, + controller: tabController, + navBarStyle: NavBarStyle.style3, + backgroundColor: Colors.white70, + screenTransitionAnimation: ScreenTransitionAnimation(animateTabTransition: true, curve: Curves.ease, duration: Duration(milliseconds: 200)), + screens: [ + const Timetable(), + const ChatList(), + Files(setAppBar), + const Overhang(), + ], + items: [ + PersistentBottomNavBarItem( + activeColorPrimary: Theme.of(context).primaryColor, + inactiveColorPrimary: Theme.of(context).disabledColor, + icon: const Icon(Icons.calendar_month), + title: "Vertretung" + ), + PersistentBottomNavBarItem( + activeColorPrimary: Theme.of(context).primaryColor, + inactiveColorPrimary: Theme.of(context).disabledColor, + icon: Consumer( + builder: (context, value, child) { + if(value.primaryLoading()) return const SizedBox.shrink(); + int messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b); + return badges.Badge( + showBadge: messages > 0, + badgeStyle: const badges.BadgeStyle( + badgeColor: Colors.white + ), + badgeContent: Text("$messages", style: const TextStyle(color: Colors.black)), + child: const Icon(Icons.chat), + ); + }, ), - Flexible( - child: PageView( - controller: pageController, - children: [ - const Timetable(), - const ChatList(), - Files(setAppBar), - const Overhang(), - ], - onPageChanged: (page) { - setState(() { - currentPage = page; - }); - }, - ), - ) - ], - ), - - bottomNavigationBar: BottomNavigationBar( - items: [ - const BottomNavigationBarItem(icon: Icon(Icons.calendar_month), label: "Vertretung"), - BottomNavigationBarItem(icon: Stack( - children: [ - const Icon(Icons.chat), - Consumer( - builder: (context, value, child) { - if(value.primaryLoading()) return const SizedBox.shrink(); - int messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b); - return Visibility( - visible: messages > 0, - child: Positioned( - right: 0, - top: 0, - child: Container( - padding: const EdgeInsets.all(1), - decoration: BoxDecoration( - color: Theme.of(context).primaryColor, - borderRadius: BorderRadius.circular(6), - ), - constraints: const BoxConstraints( - minWidth: 13, - minHeight: 13, - ), - child: Text( - "$messages", - style: const TextStyle( - color: Colors.white, - fontSize: 10, - ), - textAlign: TextAlign.center, - ), - ), - ), - ); - }, - ) - ], - ), label: "Talk"), - const BottomNavigationBarItem(icon: Icon(Icons.folder), label: "Dateien"), - const BottomNavigationBarItem(icon: Icon(Icons.more_horiz), label: "Mehr"), - ], - selectedItemColor: Theme.of(context).primaryColor, - unselectedItemColor: Colors.grey, - showUnselectedLabels: true, - showSelectedLabels: true, - type: BottomNavigationBarType.fixed, - - currentIndex: currentPage, - onTap: (item) { - setAppBar(context, null); - setState(() { - currentPage = item; - pageController.jumpToPage(item); - }); - }, - ), + title: "Talk" + ), + PersistentBottomNavBarItem( + activeColorPrimary: Theme.of(context).primaryColor, + inactiveColorPrimary: Theme.of(context).disabledColor, + icon: const Icon(Icons.folder), + title: "Dateien" + ), + PersistentBottomNavBarItem( + activeColorPrimary: Theme.of(context).primaryColor, + inactiveColorPrimary: Theme.of(context).disabledColor, + icon: const Icon(Icons.more_horiz), + title: "Mehr" + ), + ], ); + } } \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index ba40ad1..dd633ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,6 +62,8 @@ dependencies: flowder: git: url: https://github.com/Harsh223/flowder.git + persistent_bottom_nav_bar: ^5.0.2 + badges: ^3.0.2 dependency_overrides: xml: ^6.2.2