Added custom Appbar for each page

This commit is contained in:
Elias Müller 2023-03-18 13:21:32 +01:00
parent cc47f9bee7
commit 3e7dd1b0c7
4 changed files with 178 additions and 145 deletions

View File

@ -68,8 +68,10 @@ class _AppState extends State<App> {
context,
controller: tabController,
navBarStyle: NavBarStyle.style3,
backgroundColor: Colors.white70,
screenTransitionAnimation: ScreenTransitionAnimation(animateTabTransition: true, curve: Curves.ease, duration: Duration(milliseconds: 200)),
decoration: const NavBarDecoration(
border: Border.symmetric(vertical: BorderSide.none, horizontal: BorderSide(color: Colors.grey, width: 2))
),
screenTransitionAnimation: const ScreenTransitionAnimation(animateTabTransition: true, curve: Curves.ease, duration: Duration(milliseconds: 200)),
screens: [
const Timetable(),
const ChatList(),

View File

@ -42,25 +42,40 @@ class _FilesState extends State<Files> {
@override
Widget build(BuildContext context) {
return Consumer<FilesProps>(
builder: (context, value, child) {
if(value.primaryLoading()) return const Center(child: CircularProgressIndicator());
return Scaffold(
appBar: AppBar(
title: const Text("Dateien"),
actions: [
IconButton(
icon: const Icon(Icons.search),
onPressed: () => {},
),
IconButton(
icon: const Icon(Icons.sort),
onPressed: () => {},
)
],
),
body: Consumer<FilesProps>(
builder: (context, value, child) {
if(value.primaryLoading()) return const Center(child: CircularProgressIndicator());
if(value.listFilesResponse.files.isEmpty) {
return const ErrorView(text: "Der Ordner ist leer", icon: Icons.folder_off_outlined);
}
if(value.listFilesResponse.files.isEmpty) {
return const ErrorView(text: "Der Ordner ist leer", icon: Icons.folder_off_outlined);
}
List<CacheableFile> files = value.listFilesResponse.files.toList();
files.sort((a, b) => a.isDirectory ? -1 : 1);
List<CacheableFile> files = value.listFilesResponse.files.toList();
files.sort((a, b) => a.isDirectory ? -1 : 1);
return ListView.builder(
itemCount: files.length,
itemBuilder: (context, index) {
CacheableFile file = files.skip(index).first;
return FileElement(file, updateAppBar);
},
);
}
return ListView.builder(
itemCount: files.length,
itemBuilder: (context, index) {
CacheableFile file = files.skip(index).first;
return FileElement(file, updateAppBar);
},
);
}
),
);
}
}

View File

@ -36,71 +36,82 @@ class _ChatListState extends State<ChatList> {
@override
Widget build(BuildContext context) {
return Consumer<ChatListProps>(
builder: (context, data, child) {
return Scaffold(
appBar: AppBar(
title: const Text("Talk"),
actions: [
IconButton(
icon: const Icon(Icons.search),
onPressed: () => {},
)
],
),
body: Consumer<ChatListProps>(
builder: (context, data, child) {
if(data.primaryLoading()) {
return const Center(child: CircularProgressIndicator());
}
if(data.primaryLoading()) {
return const Center(child: CircularProgressIndicator());
}
List<ListTile> chats = List<ListTile>.empty(growable: true);
List<ListTile> chats = List<ListTile>.empty(growable: true);
for (var chatRoom in data.getRoomsResponse.sortByLastActivity()) {
for (var chatRoom in data.getRoomsResponse.sortByLastActivity()) {
CircleAvatar circleAvatar = CircleAvatar(
foregroundImage: chatRoom.type == GetRoomResponseObjectConversationType.oneToOne ? Image.network("https://cloud.marianum-fulda.de/avatar/${chatRoom.name}/128").image : null,
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Colors.white,
child: chatRoom.type == GetRoomResponseObjectConversationType.group ? const Icon(Icons.group) : const Icon(Icons.person),
);
CircleAvatar circleAvatar = CircleAvatar(
foregroundImage: chatRoom.type == GetRoomResponseObjectConversationType.oneToOne ? Image.network("https://cloud.marianum-fulda.de/avatar/${chatRoom.name}/128").image : null,
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Colors.white,
child: chatRoom.type == GetRoomResponseObjectConversationType.group ? const Icon(Icons.group) : const Icon(Icons.person),
);
chats.add(ListTile(
title: Text(chatRoom.displayName),
subtitle: Text("${Jiffy.unixFromSecondsSinceEpoch(chatRoom.lastMessage.timestamp).fromNow()}: ${RichObjectStringProcessor.parseToString(chatRoom.lastMessage.message.replaceAll("\n", " "), chatRoom.lastMessage.messageParameters)}", overflow: TextOverflow.ellipsis),
trailing: Visibility(
visible: chatRoom.unreadMessages > 0,
child: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(30),
),
constraints: const BoxConstraints(
minWidth: 20,
minHeight: 20,
),
child: Text(
"${chatRoom.unreadMessages}",
style: const TextStyle(
color: Colors.white,
fontSize: 15,
chats.add(ListTile(
title: Text(chatRoom.displayName),
subtitle: Text("${Jiffy.unixFromSecondsSinceEpoch(chatRoom.lastMessage.timestamp).fromNow()}: ${RichObjectStringProcessor.parseToString(chatRoom.lastMessage.message.replaceAll("\n", " "), chatRoom.lastMessage.messageParameters)}", overflow: TextOverflow.ellipsis),
trailing: Visibility(
visible: chatRoom.unreadMessages > 0,
child: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(30),
),
constraints: const BoxConstraints(
minWidth: 20,
minHeight: 20,
),
child: Text(
"${chatRoom.unreadMessages}",
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
textAlign: TextAlign.center,
),
textAlign: TextAlign.center,
),
),
),
leading: circleAvatar,
onTap: () async {
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return ChatView(
room: chatRoom,
selfId: username,
avatar: circleAvatar,
);
}));
},
));
}
leading: circleAvatar,
onTap: () async {
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return ChatView(
room: chatRoom,
selfId: username,
avatar: circleAvatar,
);
}));
},
));
}
return RefreshIndicator(
color: Theme.of(context).primaryColor,
onRefresh: () {
Provider.of<ChatListProps>(context, listen: false).run(renew: true);
return Future.delayed(const Duration(seconds: 3));
},
child: ListView(children: chats),
);
},
return RefreshIndicator(
color: Theme.of(context).primaryColor,
onRefresh: () {
Provider.of<ChatListProps>(context, listen: false).run(renew: true);
return Future.delayed(const Duration(seconds: 3));
},
child: ListView(children: chats),
);
},
),
);
}
}

View File

@ -26,80 +26,85 @@ class _TimetableState extends State<Timetable> {
@override
Widget build(BuildContext context) {
return Consumer<TimetableProps>(
builder: (context, value, child) {
if(value.primaryLoading()) {
return const Center(child: CircularProgressIndicator());
}
return Scaffold(
appBar: AppBar(
title: const Text("Vertretungsplan"),
),
body: Consumer<TimetableProps>(
builder: (context, value, child) {
if(value.primaryLoading()) {
return const Center(child: CircularProgressIndicator());
}
TimetableProps timetable = Provider.of<TimetableProps>(context, listen: false);
return Column(
children: [
Expanded(
child: GestureDetector(
child: WeekView(value),
onHorizontalDragUpdate: (details) {
if(!draggable) return;
if(details.delta.dx > 5) {
draggable = false;
timetable.switchWeek(previous: true);
} else if(details.delta.dx < 5) {
draggable = false;
timetable.switchWeek();
}
},
onHorizontalDragEnd: (details) {
draggable = true;
},
),
),
// Flexible(
// child:
// ),
Visibility(
visible: false,
child: Container(
padding: const EdgeInsets.only(top: 5, bottom: 5),
decoration: BoxDecoration(
border: Border(
top: BorderSide(width: 2, color: Theme.of(context).disabledColor)
)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: () => timetable.switchWeek(previous: true),
icon: const Icon(Icons.navigate_before_sharp),
color: Theme.of(context).primaryColor,
iconSize: 30,
),
Row(
children: [
IconButton(
onPressed: () => timetable.nearest(),
icon: const Icon(Icons.home),
color: Theme.of(context).primaryColor,
iconSize: 30,
),
],
),
IconButton(
onPressed: () => timetable.switchWeek(),
icon: const Icon(Icons.navigate_next_sharp),
color: Theme.of(context).primaryColor,
iconSize: 30,
)
],
TimetableProps timetable = Provider.of<TimetableProps>(context, listen: false);
return Column(
children: [
Expanded(
child: GestureDetector(
child: WeekView(value),
onHorizontalDragUpdate: (details) {
if(!draggable) return;
if(details.delta.dx > 5) {
draggable = false;
timetable.switchWeek(previous: true);
} else if(details.delta.dx < 5) {
draggable = false;
timetable.switchWeek();
}
},
onHorizontalDragEnd: (details) {
draggable = true;
},
),
),
)
],
);
},
// Flexible(
// child:
// ),
Visibility(
visible: false,
child: Container(
padding: const EdgeInsets.only(top: 5, bottom: 5),
decoration: BoxDecoration(
border: Border(
top: BorderSide(width: 2, color: Theme.of(context).disabledColor)
)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: () => timetable.switchWeek(previous: true),
icon: const Icon(Icons.navigate_before_sharp),
color: Theme.of(context).primaryColor,
iconSize: 30,
),
Row(
children: [
IconButton(
onPressed: () => timetable.nearest(),
icon: const Icon(Icons.home),
color: Theme.of(context).primaryColor,
iconSize: 30,
),
],
),
IconButton(
onPressed: () => timetable.switchWeek(),
icon: const Icon(Icons.navigate_next_sharp),
color: Theme.of(context).primaryColor,
iconSize: 30,
)
],
),
),
)
],
);
},
),
);
}
}