From dfe653080895a77981ade0806fab3a79acb2944d Mon Sep 17 00:00:00 2001 From: doodlezucc <electerminator@gmail.com> Date: Tue, 21 Nov 2023 14:30:59 +0100 Subject: [PATCH] introduce drawer header --- lib/drawer/drawer.dart | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/lib/drawer/drawer.dart b/lib/drawer/drawer.dart index 8d6ce2b..9fe2ed7 100644 --- a/lib/drawer/drawer.dart +++ b/lib/drawer/drawer.dart @@ -20,6 +20,18 @@ class _ClassDrawerState extends State<ClassDrawer> { late final searchTextController = TextEditingController(text: activeQuery); List<Class> get availableClasses => widget.appContext.classes ?? []; + Set<Class> get selectedClasses => + widget.appContext.profile.value!.selectedClasses + .map((id) => availableClasses.firstWhere((cls) => cls.id == id)) + .toSet(); + + String get headerText { + final classes = selectedClasses; + final selectedNames = + classes.map((cls) => cls.codeWithoutFaculty).join(', '); + + return selectedNames; + } @override void initState() { @@ -109,13 +121,26 @@ class _ClassDrawerState extends State<ClassDrawer> { return Drawer( child: Column( children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: TextField( - controller: searchTextController, - decoration: const InputDecoration( - hintText: 'Suche...', - ), + DrawerHeader( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + headerText, + style: TextStyle( + // fontWeight: FontWeight.bold, + color: Theme.of(context).primaryColor, + ), + ), + Expanded(child: Container()), + TextField( + controller: searchTextController, + decoration: const InputDecoration( + hintText: 'Suche...', + ), + ), + ], ), ), Expanded( -- GitLab