WIP: Persistent Bottom navigation bar, moved appbar layer to page view

This commit is contained in:
Elias Müller 2023-03-17 23:31:42 +01:00
parent 35f2e3fe74
commit cc47f9bee7
5 changed files with 196 additions and 90 deletions

117
.idea/codeStyles/Project.xml generated Normal file
View File

@ -0,0 +1,117 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@ -58,6 +58,13 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="badges">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dev/badges-3.0.2/lib" />
</list>
</value>
</entry>
<entry key="better_open_file"> <entry key="better_open_file">
<value> <value>
<list> <list>
@ -611,6 +618,13 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="persistent_bottom_nav_bar">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dev/persistent_bottom_nav_bar-5.0.2/lib" />
</list>
</value>
</entry>
<entry key="petitparser"> <entry key="petitparser">
<value> <value>
<list> <list>
@ -1016,6 +1030,7 @@
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/args-2.4.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/args-2.4.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/asn1lib-1.4.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/asn1lib-1.4.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/async-2.10.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/async-2.10.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/badges-3.0.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/better_open_file-3.6.4/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/better_open_file-3.6.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/bubble-1.2.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/bubble-1.2.1/lib" />
@ -1090,6 +1105,7 @@
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider_platform_interface-2.0.6/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider_platform_interface-2.0.6/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.5/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.5/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/pedantic-1.11.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/pedantic-1.11.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/persistent_bottom_nav_bar-5.0.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/petitparser-5.1.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/petitparser-5.1.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/platform-3.1.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/platform-3.1.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/plugin_platform_interface-2.1.4/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/plugin_platform_interface-2.1.4/lib" />

View File

@ -4,12 +4,15 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:marianum_mobile/data/chatList/chatListProps.dart'; import 'package:marianum_mobile/data/chatList/chatListProps.dart';
import 'package:marianum_mobile/screen/pages/timetable/timetable.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 'package:provider/provider.dart';
import 'screen/pages/files/files.dart'; import 'screen/pages/files/files.dart';
import 'screen/pages/more/overhang.dart'; import 'screen/pages/more/overhang.dart';
import 'screen/pages/talk/chatList.dart'; import 'screen/pages/talk/chatList.dart';
import 'screen/settings/settings.dart'; import 'screen/settings/settings.dart';
import 'package:badges/badges.dart' as badges;
class App extends StatefulWidget { class App extends StatefulWidget {
const App({Key? key}) : super(key: key); const App({Key? key}) : super(key: key);
@ -59,97 +62,60 @@ class _AppState extends State<App> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final PageController pageController = PageController(); PersistentTabController tabController = PersistentTabController(initialIndex: 0);
return Scaffold(
resizeToAvoidBottomInset: false, return PersistentTabView(
appBar: _appBar, context,
body: Column( controller: tabController,
children: [ navBarStyle: NavBarStyle.style3,
Visibility( backgroundColor: Colors.white70,
visible: false, screenTransitionAnimation: ScreenTransitionAnimation(animateTabTransition: true, curve: Curves.ease, duration: Duration(milliseconds: 200)),
child: LinearProgressIndicator( screens: [
backgroundColor: Colors.transparent,
valueColor: AlwaysStoppedAnimation(Theme.of(context).primaryColor),
minHeight: 5,
),
),
Flexible(
child: PageView(
controller: pageController,
children: [
const Timetable(), const Timetable(),
const ChatList(), const ChatList(),
Files(setAppBar), Files(setAppBar),
const Overhang(), const Overhang(),
], ],
onPageChanged: (page) {
setState(() {
currentPage = page;
});
},
),
)
],
),
bottomNavigationBar: BottomNavigationBar(
items: [ items: [
const BottomNavigationBarItem(icon: Icon(Icons.calendar_month), label: "Vertretung"), PersistentBottomNavBarItem(
BottomNavigationBarItem(icon: Stack( activeColorPrimary: Theme.of(context).primaryColor,
children: [ inactiveColorPrimary: Theme.of(context).disabledColor,
const Icon(Icons.chat), icon: const Icon(Icons.calendar_month),
Consumer<ChatListProps>( title: "Vertretung"
),
PersistentBottomNavBarItem(
activeColorPrimary: Theme.of(context).primaryColor,
inactiveColorPrimary: Theme.of(context).disabledColor,
icon: Consumer<ChatListProps>(
builder: (context, value, child) { builder: (context, value, child) {
if(value.primaryLoading()) return const SizedBox.shrink(); if(value.primaryLoading()) return const SizedBox.shrink();
int messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b); int messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b);
return Visibility( return badges.Badge(
visible: messages > 0, showBadge: messages > 0,
child: Positioned( badgeStyle: const badges.BadgeStyle(
right: 0, badgeColor: Colors.white
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,
),
),
), ),
badgeContent: Text("$messages", style: const TextStyle(color: Colors.black)),
child: const Icon(Icons.chat),
); );
}, },
) ),
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"
),
], ],
), 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);
});
},
),
);
} }
} }

View File

@ -62,6 +62,8 @@ dependencies:
flowder: flowder:
git: git:
url: https://github.com/Harsh223/flowder.git url: https://github.com/Harsh223/flowder.git
persistent_bottom_nav_bar: ^5.0.2
badges: ^3.0.2
dependency_overrides: dependency_overrides:
xml: ^6.2.2 xml: ^6.2.2