Added MyDrawer and an empty SettingsPage

master
Rafael 2024-04-29 17:11:35 +02:00
parent b7cd48f403
commit 3f3ef66fcf
4 changed files with 149 additions and 15 deletions

View File

@ -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,
),
),
],
));
}
}

View File

@ -1,5 +1,4 @@
import 'package:cofounderella/auth/auth_gate.dart'; import 'package:cofounderella/auth/auth_gate.dart';
import 'package:cofounderella/auth/login_or_register.dart';
import 'package:cofounderella/themes/light_mode.dart'; import 'package:cofounderella/themes/light_mode.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
@ -24,7 +23,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
title: 'Flutter Demo', title: 'Flutter Demo', // TODO change title
theme: lightMode, theme: lightMode,
home: const AuthGate(), home: const AuthGate(),
); );

View File

@ -1,4 +1,4 @@
import 'package:cofounderella/auth/auth_service.dart'; import 'package:cofounderella/components/my_drawer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
@ -33,12 +33,6 @@ class _MyHomePageState extends State<MyHomePage> {
}); });
} }
void logout(){
// get auth service
final _auth = AuthService();
_auth.signOut();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done // This method is rerun every time setState is called, for instance as done
@ -52,15 +46,12 @@ class _MyHomePageState extends State<MyHomePage> {
// TRY THIS: Try changing the color here to a specific color (to // TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same. // 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 // 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. // the App.build method, and use it to set our appbar title.
title: Text(widget.title), title: Text(widget.title),
actions: [
// logout button
IconButton(onPressed: logout, icon: Icon(Icons.logout))
],
), ),
drawer: const MyDrawer(),
body: Center( body: Center(
// Center is a layout widget. It takes a single child and positions it // Center is a layout widget. It takes a single child and positions it
// in the middle of the parent. // in the middle of the parent.
@ -97,4 +88,4 @@ class _MyHomePageState extends State<MyHomePage> {
), // This trailing comma makes auto-formatting nicer for build methods. ), // This trailing comma makes auto-formatting nicer for build methods.
); );
} }
} }

View File

@ -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"),
),
);
}
}