Skip to content

Commit

Permalink
home drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
chanchalyadav272 committed Jul 27, 2023
1 parent fabba47 commit 09111f2
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 70 deletions.
6 changes: 6 additions & 0 deletions assets/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions lib/pages/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
class HomePage extends StatefulWidget {
static String id = "/home2";
const HomePage({Key? key}) : super(key: key);
Expand All @@ -32,11 +34,14 @@ class _HomePageState extends State<HomePage> {
];
@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(
Expand Down
73 changes: 37 additions & 36 deletions lib/pages/profile/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<Profile> createState() => _ProfileState();
State<ProfilePage> createState() => _ProfilePageState();
}

class _ProfileState extends State<Profile> {
class _ProfilePageState extends State<ProfilePage> {
@override
Widget build(BuildContext context) {
print(widget.profileModel!.toJson());
Expand All @@ -40,38 +41,38 @@ class _ProfileState extends State<Profile> {
textAlign: TextAlign.left,
style: MyFonts.w500.size(23).setColor(kWhite),
),
actions: [
if (!context.read<LoginStore>().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<LoginStore>().logOut(() => Navigator.of(context)
.pushNamedAndRemoveUntil(
'/', (Route<dynamic> route) => false));
}),
icon: const Icon(
Icons.logout_outlined,
color: kWhite,
))
],
// actions: [
// if (!context.read<LoginStore>().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<LoginStore>().logOut(() => Navigator.of(context)
// .pushNamedAndRemoveUntil(
// '/', (Route<dynamic> route) => false));
// }),
// icon: const Icon(
// Icons.logout_outlined,
// color: kWhite,
// ))
// ],
),
body: SafeArea(
child: SingleChildScrollView(
Expand Down
1 change: 0 additions & 1 deletion lib/services/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
129 changes: 129 additions & 0 deletions lib/widgets/home/home_drawer.dart
Original file line number Diff line number Diff line change
@@ -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<LoginStore>().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<LoginStore>().logOut(() =>
Navigator.of(context).pushNamedAndRemoveUntil(
'/', (Route<dynamic> route) => false));
}
},
),
const SizedBox(height: 16,)
],
),
),
));
}
}
72 changes: 39 additions & 33 deletions lib/widgets/ui/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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();
},
),
)
Expand Down Expand Up @@ -74,34 +79,35 @@ AppBar appBar(BuildContext context, {bool displayIcon = true}) {
// textAlign: TextAlign.start,
),
FutureBuilder<List<NotifsModel>>(
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,
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 09111f2

Please sign in to comment.