From 09111f2cdc6cccc280083ba78ae364d593c6c072 Mon Sep 17 00:00:00 2001 From: chanchalyadav272 Date: Thu, 27 Jul 2023 21:14:59 +0530 Subject: [PATCH] home drawer --- assets/images/logo.svg | 6 ++ lib/pages/home/home.dart | 5 ++ lib/pages/profile/profile_page.dart | 73 ++++++++-------- lib/services/api.dart | 1 - lib/widgets/home/home_drawer.dart | 129 ++++++++++++++++++++++++++++ lib/widgets/ui/appbar.dart | 72 +++++++++------- pubspec.yaml | 1 + 7 files changed, 217 insertions(+), 70 deletions(-) create mode 100644 assets/images/logo.svg create mode 100644 lib/widgets/home/home_drawer.dart diff --git a/assets/images/logo.svg b/assets/images/logo.svg new file mode 100644 index 00000000..b78ef571 --- /dev/null +++ b/assets/images/logo.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/lib/pages/home/home.dart b/lib/pages/home/home.dart index 13bed50b..b51ec909 100644 --- a/lib/pages/home/home.dart +++ b/lib/pages/home/home.dart @@ -14,6 +14,8 @@ import 'package:onestop_dev/widgets/ui/appbar.dart'; import 'package:onestop_dev/widgets/ui/onestop_upgrade.dart'; import 'package:provider/provider.dart'; +import '../../widgets/home/home_drawer.dart'; + final GlobalKey scaffoldKey = GlobalKey(); class HomePage extends StatefulWidget { static String id = "/home2"; const HomePage({Key? key}) : super(key: key); @@ -32,11 +34,14 @@ class _HomePageState extends State { ]; @override Widget build(BuildContext context) { + SizeConfig().init(context); return OneStopUpgrader( child: Provider( create: (_) => TimetableStore(), child: Scaffold( + key: scaffoldKey, + drawer: const HomeDrawer(), appBar: appBar(context), bottomNavigationBar: NavigationBarTheme( data: NavigationBarThemeData( diff --git a/lib/pages/profile/profile_page.dart b/lib/pages/profile/profile_page.dart index dc79fd02..2acaf41e 100644 --- a/lib/pages/profile/profile_page.dart +++ b/lib/pages/profile/profile_page.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:onestop_dev/pages/home/home.dart'; import 'package:provider/provider.dart'; import '../../globals/my_colors.dart'; @@ -12,15 +13,15 @@ import '../../widgets/profile/data_tile.dart'; import '../../widgets/profile/feedback.dart'; import 'edit_profile.dart'; -class Profile extends StatefulWidget { +class ProfilePage extends StatefulWidget { final ProfileModel profileModel; - const Profile({super.key, required this.profileModel}); + const ProfilePage({super.key, required this.profileModel}); @override - State createState() => _ProfileState(); + State createState() => _ProfilePageState(); } -class _ProfileState extends State { +class _ProfilePageState extends State { @override Widget build(BuildContext context) { print(widget.profileModel!.toJson()); @@ -40,38 +41,38 @@ class _ProfileState extends State { textAlign: TextAlign.left, style: MyFonts.w500.size(23).setColor(kWhite), ), - actions: [ - if (!context.read().isGuestUser) - IconButton( - onPressed: (() { - showModalBottomSheet( - context: context, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(20), - ), - ), - clipBehavior: Clip.antiAliasWithSaveLayer, - isScrollControlled: true, - builder: (BuildContext context) { - return const FeedBack(); - }); - }), - icon: const Icon( - Icons.bug_report_outlined, - color: kWhite, - )), - IconButton( - onPressed: (() { - context.read().logOut(() => Navigator.of(context) - .pushNamedAndRemoveUntil( - '/', (Route route) => false)); - }), - icon: const Icon( - Icons.logout_outlined, - color: kWhite, - )) - ], + // actions: [ + // if (!context.read().isGuestUser) + // IconButton( + // onPressed: (() { + // showModalBottomSheet( + // context: context, + // shape: const RoundedRectangleBorder( + // borderRadius: BorderRadius.vertical( + // top: Radius.circular(20), + // ), + // ), + // clipBehavior: Clip.antiAliasWithSaveLayer, + // isScrollControlled: true, + // builder: (BuildContext context) { + // return const FeedBack(); + // }); + // }), + // icon: const Icon( + // Icons.bug_report_outlined, + // color: kWhite, + // )), + // IconButton( + // onPressed: (() { + // context.read().logOut(() => Navigator.of(context) + // .pushNamedAndRemoveUntil( + // '/', (Route route) => false)); + // }), + // icon: const Icon( + // Icons.logout_outlined, + // color: kWhite, + // )) + // ], ), body: SafeArea( child: SingleChildScrollView( diff --git a/lib/services/api.dart b/lib/services/api.dart index dd858c98..96197688 100644 --- a/lib/services/api.dart +++ b/lib/services/api.dart @@ -13,7 +13,6 @@ import 'package:onestop_dev/models/buy_sell/sell_model.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../functions/utility/show_snackbar.dart'; import '../functions/utility/auth_user_helper.dart'; -import '../pages/timetable/test.dart'; class APIService { final dio = Dio(BaseOptions( diff --git a/lib/widgets/home/home_drawer.dart b/lib/widgets/home/home_drawer.dart new file mode 100644 index 00000000..089b2a64 --- /dev/null +++ b/lib/widgets/home/home_drawer.dart @@ -0,0 +1,129 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:onestop_dev/pages/home/home.dart'; +import 'package:onestop_dev/widgets/ui/appbar.dart'; +import 'package:provider/provider.dart'; + +import '../../globals/my_colors.dart'; +import '../../globals/my_fonts.dart'; +import '../../models/profile/profile_model.dart'; +import '../../pages/profile/profile_page.dart'; +import '../../stores/login_store.dart'; +import '../profile/feedback.dart'; + +class HomeDrawer extends StatelessWidget { + const HomeDrawer({super.key}); + + @override + Widget build(BuildContext context) { + return SizedBox( + width: MediaQuery.of(context).size.width * 0.6, + child: Scaffold( + appBar: AppBar(backgroundColor: kBackground, + elevation: 0, + leadingWidth: 0, + leading: Container(), + centerTitle: true, + title: RichText(text: TextSpan( + children: [ + TextSpan(text: "Onestop",style: MyFonts.w600.size(23).letterSpace(1.0).setColor(lBlue2),), + TextSpan(text: ".",style: MyFonts.w500.size(23).setColor(kYellow),) + ] + )),), + body: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + // const SizedBox( + // height: 25, + // ), + // Center( + // child: Stack(alignment: Alignment.bottomRight, children: [ + // ClipRRect( + // borderRadius: BorderRadius.circular(75.0), + // child: const Image( + // image: ResizeImage( + // AssetImage('assets/images/app_launcher_icon.png'), + // width: 75, + // height: 75), + // fit: BoxFit.fitWidth, + // )), + // ])), + + Container(height: 1,color: Colors.white38,), + const SizedBox( + height: 16, + ), + GestureDetector( + onTap:() { + Navigator.push( + context, + MaterialPageRoute( + builder: (buildContext) => ProfilePage( + profileModel: ProfileModel.fromJson( + LoginStore.userData), + ))); + scaffoldKey.currentState!.closeDrawer(); + } , + + child: Container( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8,vertical: 4), + child: Text( + "View Profile", + style: MyFonts.w400.size(14).setColor(kWhite), + ), + ), + + ), + ), + if (!context.read().isGuestUser) + GestureDetector( + onTap:() { + showModalBottomSheet( + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(20), + ), + ), + clipBehavior: Clip.antiAliasWithSaveLayer, + isScrollControlled: true, + builder: (BuildContext context) { + return const FeedBack(); + }); + } , + child: Container( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8,vertical: 4), + child: Text( + "Bug/Feature Request", + textAlign: TextAlign.center, + style: MyFonts.w400.size(14).setColor(kWhite), + ), + ), + ), + ), + Expanded(child: Container()), + + SvgPicture.asset("assets/images/logo.svg"), + TextButton( + child: Text( + "Logout", + style: MyFonts.w400.size(18).setColor(kRed), + ), + onPressed: () { + { + context.read().logOut(() => + Navigator.of(context).pushNamedAndRemoveUntil( + '/', (Route route) => false)); + } + }, + ), + const SizedBox(height: 16,) + ], + ), + ), + )); + } +} diff --git a/lib/widgets/ui/appbar.dart b/lib/widgets/ui/appbar.dart index e2bd90d5..09494981 100644 --- a/lib/widgets/ui/appbar.dart +++ b/lib/widgets/ui/appbar.dart @@ -4,13 +4,14 @@ import 'package:onestop_dev/functions/notifications/get_notifications.dart'; import 'package:onestop_dev/globals/my_colors.dart'; import 'package:onestop_dev/globals/my_fonts.dart'; import 'package:onestop_dev/models/profile/profile_model.dart'; +import 'package:onestop_dev/pages/home/home.dart'; import 'package:onestop_dev/pages/profile/profile_page.dart'; import 'package:onestop_dev/stores/login_store.dart'; import 'package:onestop_dev/pages/notifications/notifications.dart'; import 'package:onestop_dev/pages/profile/edit_profile.dart'; import 'package:badges/badges.dart' as badges; -AppBar appBar(BuildContext context, {bool displayIcon = true}) { +AppBar appBar(BuildContext context, {bool displayIcon = true,}) { return AppBar( backgroundColor: kBackground, iconTheme: const IconThemeData(color: kAppBarGrey), @@ -24,14 +25,18 @@ AppBar appBar(BuildContext context, {bool displayIcon = true}) { backgroundColor: kAppBarGrey, child: IconButton( icon: const Icon( - FluentIcons.person_24_filled, + // FluentIcons.person_24_filled, + Icons.menu, color: lBlue2, ), - onPressed: () { - // Navigator.pushNamed(context, ProfilePage.id); - print(ProfileModel.fromJson(LoginStore.userData)); - print(LoginStore.userData); - Navigator.push(context, MaterialPageRoute(builder: (buildContext) => Profile(profileModel: ProfileModel.fromJson(LoginStore.userData),))); + // onPressed: () { + // // Navigator.pushNamed(context, ProfilePage.id); + // // print(ProfileModel.fromJson(LoginStore.userData)); + // // print(LoginStore.userData); + // // Navigator.push(context, MaterialPageRoute(builder: (buildContext) => ProfilePage(profileModel: ProfileModel.fromJson(LoginStore.userData),))); + // }, + onPressed: (){ + scaffoldKey.currentState!.openDrawer(); }, ), ) @@ -74,34 +79,35 @@ AppBar appBar(BuildContext context, {bool displayIcon = true}) { // textAlign: TextAlign.start, ), FutureBuilder>( - future: getSavedNotifications(false), - builder: (context,snapshot) { - var badgeColor = Colors.transparent; - if (snapshot.hasData) { - int unread = snapshot.data!.where((element) => element.read == false).length; - if (unread > 0) { - badgeColor = kYellow; + future: getSavedNotifications(false), + builder: (context, snapshot) { + var badgeColor = Colors.transparent; + if (snapshot.hasData) { + int unread = snapshot.data! + .where((element) => element.read == false) + .length; + if (unread > 0) { + badgeColor = kYellow; + } } - } - return CircleAvatar( - backgroundColor: kAppBarGrey, - child: IconButton( - onPressed: () { - Navigator.pushNamed(context, NotificationPage.id); - }, - icon: badges.Badge( - badgeColor: badgeColor, - elevation: 0, - position: badges.BadgePosition.topStart(), - child: const Icon( - FluentIcons.alert_24_filled, - color: lBlue2, + return CircleAvatar( + backgroundColor: kAppBarGrey, + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, NotificationPage.id); + }, + icon: badges.Badge( + badgeColor: badgeColor, + elevation: 0, + position: badges.BadgePosition.topStart(), + child: const Icon( + FluentIcons.alert_24_filled, + color: lBlue2, + ), ), - ), - color: lBlue2, - )); - } - ), + color: lBlue2, + )); + }), ], ), elevation: 0.0, diff --git a/pubspec.yaml b/pubspec.yaml index c49eb76f..bf844778 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -83,6 +83,7 @@ dependencies: firebase_messaging: ^14.1.3 flutter_local_notifications: ^13.0.0 firebase_core: ^2.3.0 + flutter_svg: ^1.1.6 dev_dependencies: flutter_test: