From 3f3ef66fcf63b06f7468492a041a9762ddc53467 Mon Sep 17 00:00:00 2001 From: Rafael <1024481@stud.hs-mannheim.de> Date: Mon, 29 Apr 2024 17:11:35 +0200 Subject: [PATCH] Added MyDrawer and an empty SettingsPage --- lib/components/my_drawer.dart | 130 ++++++++++++++++++++++++++++++++++ lib/main.dart | 3 +- lib/pages/home_page.dart | 17 ++--- lib/pages/settings_page.dart | 14 ++++ 4 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 lib/components/my_drawer.dart create mode 100644 lib/pages/settings_page.dart diff --git a/lib/components/my_drawer.dart b/lib/components/my_drawer.dart new file mode 100644 index 0000000..9d7838a --- /dev/null +++ b/lib/components/my_drawer.dart @@ -0,0 +1,130 @@ +import 'package:cofounderella/auth/auth_service.dart'; +import 'package:cofounderella/pages/settings_page.dart'; +import 'package:flutter/material.dart'; + +class MyDrawer extends StatelessWidget { + const MyDrawer({super.key}); + + void logout() { + // get auth service + final auth = AuthService(); + auth.signOut(); + } + + @override + Widget build(BuildContext context) { + return Drawer( + backgroundColor: Theme.of(context).colorScheme.background, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // logo + Column( + children: [ + DrawerHeader( + child: Center( + child: Icon( + Icons.people_alt, + color: Theme.of(context).colorScheme.primary, + size: 40, + ), + ), + ), + + // home list tile + Padding( + padding: const EdgeInsets.only(left: 25), + child: ListTile( + title: const Text("Home"), + leading: const Icon(Icons.home), + onTap: () { + // pop the drawer + Navigator.pop(context); + // TODO navigate to Homepage? + }, + ), + ), + + // matching list tile + Padding( + padding: const EdgeInsets.only(left: 25), + child: ListTile( + title: const Text("Find Matches"), + leading: const Icon(Icons.person_search), + onTap: () {}, // TODO + ), + ), + + // chats list tile + Padding( + padding: const EdgeInsets.only(left: 25), + child: ListTile( + title: const Text("Conversations"), + leading: const Icon(Icons.chat), + onTap: () {}, // TODO + ), + ), + + // settings list tile + Padding( + padding: const EdgeInsets.only(left: 25), + child: ListTile( + title: const Text("My Profile"), + leading: const Icon(Icons.settings), + onTap: () { + // pop the drawer + Navigator.pop(context); + + //navigate to settings page + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const SettingsPage(), + )); + }, + ), + ), + + // horizontal line + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Divider( + color: Theme.of(context).colorScheme.primary, + ), + ), + + // about tile + Padding( + padding: const EdgeInsets.only(left: 25), + child: ListTile( + title: const Text("About the app"), + leading: const Icon(Icons.perm_device_info), + onTap: () {}, // TODO + ), + ), + + // feedback tile + Padding( + padding: const EdgeInsets.only(left: 25), + child: ListTile( + title: const Text("Send feedback"), + leading: const Icon(Icons.sentiment_neutral), + onTap: () {}, // TODO + ), + ), + ], + ), + + // logout list tile + Padding( + padding: const EdgeInsets.only(left: 25, bottom: 25), + child: ListTile( + title: const Text("L O G O U T"), + leading: const Icon(Icons.logout), + onTap: logout, + ), + ), + ], + )); + } +} diff --git a/lib/main.dart b/lib/main.dart index 4183f8b..af2a05f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,4 @@ import 'package:cofounderella/auth/auth_gate.dart'; -import 'package:cofounderella/auth/login_or_register.dart'; import 'package:cofounderella/themes/light_mode.dart'; import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; @@ -24,7 +23,7 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - title: 'Flutter Demo', + title: 'Flutter Demo', // TODO change title theme: lightMode, home: const AuthGate(), ); diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index ae1edd6..7b5632a 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -1,4 +1,4 @@ -import 'package:cofounderella/auth/auth_service.dart'; +import 'package:cofounderella/components/my_drawer.dart'; import 'package:flutter/material.dart'; class MyHomePage extends StatefulWidget { @@ -33,12 +33,6 @@ class _MyHomePageState extends State { }); } - void logout(){ - // get auth service - final _auth = AuthService(); - _auth.signOut(); - } - @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done @@ -52,15 +46,12 @@ class _MyHomePageState extends State { // TRY THIS: Try changing the color here to a specific color (to // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar // change color while the other colors stay the same. - backgroundColor: Theme.of(context).colorScheme.inversePrimary, + backgroundColor: Theme.of(context).colorScheme.primary, // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: Text(widget.title), - actions: [ - // logout button - IconButton(onPressed: logout, icon: Icon(Icons.logout)) - ], ), + drawer: const MyDrawer(), body: Center( // Center is a layout widget. It takes a single child and positions it // in the middle of the parent. @@ -97,4 +88,4 @@ class _MyHomePageState extends State { ), // This trailing comma makes auto-formatting nicer for build methods. ); } -} \ No newline at end of file +} diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart new file mode 100644 index 0000000..8ac7287 --- /dev/null +++ b/lib/pages/settings_page.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +class SettingsPage extends StatelessWidget { + const SettingsPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("Settings"), + ), + ); + } +}