step 24 : fix drawer, login bg color
This commit is contained in:
BIN
app_petty_cash/images/logo_sismedika_landscape.png
Normal file
BIN
app_petty_cash/images/logo_sismedika_landscape.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
@@ -40,8 +40,8 @@ class MyApp extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
initialRoute: loginRoute,
|
// initialRoute: loginRoute,
|
||||||
// initialRoute: splashScreen,
|
initialRoute: splashScreen,
|
||||||
// initialRoute: transaksiRoute,
|
// initialRoute: transaksiRoute,
|
||||||
// initialRoute: reportRoute,
|
// initialRoute: reportRoute,
|
||||||
// initialRoute: testFilePickerRoute,
|
// initialRoute: testFilePickerRoute,
|
||||||
|
|||||||
@@ -55,22 +55,22 @@ class LoginScreen extends HookConsumerWidget {
|
|||||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
backgroundColor: Constant.backgroundColor,
|
// backgroundColor: Colors.transparent,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
width: Constant.getActualXPhone(context: context, x: 390),
|
||||||
height: Constant.getActualYPhone(context: context, y: 844),
|
height: Constant.getActualYPhone(context: context, y: 844),
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
// gradient: LinearGradient(
|
||||||
colors: [
|
// colors: [
|
||||||
Color(0xffdadae6),
|
// Color(0xffdadae6),
|
||||||
Color(0xfff6f7fb),
|
// Color(0xfff6f7fb),
|
||||||
],
|
// ],
|
||||||
begin: Alignment.centerLeft,
|
// begin: Alignment.centerLeft,
|
||||||
end: Alignment.centerRight,
|
// end: Alignment.centerRight,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
// child: BlockBodyV2(),
|
// child: BlockBodyV2(),
|
||||||
child: LoginFormScreen(),
|
child: LoginFormScreen(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
@@ -12,9 +13,11 @@ import '../provider/current_user_provider.dart';
|
|||||||
import '../screen/login/logout_provider.dart';
|
import '../screen/login/logout_provider.dart';
|
||||||
|
|
||||||
class CustomDrawer extends HookConsumerWidget {
|
class CustomDrawer extends HookConsumerWidget {
|
||||||
|
// final String userCompany;
|
||||||
const CustomDrawer({
|
const CustomDrawer({
|
||||||
super.key,
|
Key? key,
|
||||||
});
|
// required this.userCompany,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@@ -22,6 +25,26 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
final isLoading = useState(false);
|
final isLoading = useState(false);
|
||||||
final errorMessage = useState("");
|
final errorMessage = useState("");
|
||||||
final successMessage = useState("");
|
final successMessage = useState("");
|
||||||
|
final M_CompanyName = useState("-");
|
||||||
|
|
||||||
|
Future<String> getCompanyName() async {
|
||||||
|
final shared = await SharedPreferences.getInstance();
|
||||||
|
String M_CompanyName = "-";
|
||||||
|
|
||||||
|
if (shared != null) {
|
||||||
|
final bearerString = shared.get(Constant.bearerName).toString();
|
||||||
|
final xmodel = jsonDecode(bearerString);
|
||||||
|
if (xmodel != null) {
|
||||||
|
M_CompanyName = xmodel["model"]["M_CompanyName"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (M_CompanyName == "0") {
|
||||||
|
// throw BaseRepositoryException(message: 'Invalid Company ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
return M_CompanyName;
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
@@ -34,6 +57,7 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
M_CompanyName.value = await getCompanyName();
|
||||||
});
|
});
|
||||||
return () {};
|
return () {};
|
||||||
}, []);
|
}, []);
|
||||||
@@ -56,7 +80,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
shared.remove(bearerString);
|
shared.remove(bearerString);
|
||||||
shared.clear();
|
shared.clear();
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
|
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
||||||
}
|
}
|
||||||
@@ -69,152 +92,236 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
final currentMenu = ref.read(currentPageProvider);
|
final currentMenu = ref.read(currentPageProvider);
|
||||||
|
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: ListView(
|
elevation: 0,
|
||||||
// padding: EdgeInsets.only(
|
shape: RoundedRectangleBorder(
|
||||||
// top: Constant.getActualYPhone(context: context, y: 10),
|
borderRadius: BorderRadius.all(Radius.circular(0))),
|
||||||
// ),
|
child: Container(
|
||||||
children: [
|
child: ListView(
|
||||||
DrawerHeader(
|
// padding: EdgeInsets.only(
|
||||||
decoration: BoxDecoration(
|
// top: Constant.getActualYPhone(context: context, y: 10),
|
||||||
color: Colors.blue,
|
// ),
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border: Border(bottom: BorderSide(color: Colors.transparent)) // <--- use the global theme to change the dividerColor property
|
||||||
|
// ),
|
||||||
|
child: Image(
|
||||||
|
image: AssetImage('images/logo_sismedika_landscape.png')),
|
||||||
),
|
),
|
||||||
child: Text(
|
|
||||||
'Drawer Header',
|
SizedBox(
|
||||||
style: TextStyle(
|
height: Constant.getActualYPhone(context: context, y: 8),
|
||||||
color: Colors.white,
|
),
|
||||||
fontSize: 24,
|
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: Constant.getActualYPhone(context: context, y: 10),
|
||||||
|
bottom: Constant.getActualYPhone(context: context, y: 10),
|
||||||
|
right: Constant.getActualXPhone(context: context, x: 24),
|
||||||
|
left: Constant.getActualXPhone(context: context, x: 24),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
width: Constant.getActualXPhone(context: context, x: 300),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
ListTile(
|
// Expanded(
|
||||||
title: Text(
|
// child: Padding(
|
||||||
'Home',
|
// padding: EdgeInsets.only(
|
||||||
style: TextStyle(
|
// left: Constant.getActualXPhone(context: context, x: 24),
|
||||||
|
// right: Constant.getActualXPhone(context: context, x: 71),
|
||||||
|
// ),
|
||||||
|
// child: Container(
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// borderRadius: BorderRadius.circular(6),
|
||||||
|
// color: Constant.textGrey.withOpacity(0.16),
|
||||||
|
// ),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: EdgeInsets.only(
|
||||||
|
// left: Constant.getActualXPhone(context: context, x: 8),
|
||||||
|
// right: Constant.getActualXPhone(context: context, x: 8),
|
||||||
|
// ),
|
||||||
|
// child: Text(
|
||||||
|
// M_CompanyName.value,
|
||||||
|
// style: Constant.body3(context: context).copyWith(
|
||||||
|
// fontWeight: FontWeight.w700,
|
||||||
|
// color: Constant.textGreyv2,
|
||||||
|
// backgroundColor: Constant.textGrey.withOpacity(0.16),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
|
||||||
|
Chip(
|
||||||
|
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
||||||
|
label: Text(
|
||||||
|
M_CompanyName.value,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.home,
|
||||||
color: (currentMenu == 0)
|
color: (currentMenu == 0)
|
||||||
? Constant.textWhite
|
? Constant.pcBtnBackgroundColor
|
||||||
: Constant.textBlack,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
|
title: Text(
|
||||||
|
'Home',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 0)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 0)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Home screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 0);
|
||||||
|
Navigator.pushNamed(context, homeRoute);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
tileColor: (currentMenu == 0)
|
ListTile(
|
||||||
? Constant.pcBtnBackgroundColor
|
leading: Icon(
|
||||||
: Colors.transparent,
|
Icons.money,
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Home screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
Navigator.pushNamed(context, homeRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 1)
|
color: (currentMenu == 1)
|
||||||
? Constant.textWhite
|
? Constant.pcBtnBackgroundColor
|
||||||
: Constant.textBlack,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
|
title: Text(
|
||||||
|
'Transaksi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 1)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 1)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Transaksi screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 1);
|
||||||
|
Navigator.pushNamed(context, transaksiRoute);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
tileColor: (currentMenu == 1)
|
ListTile(
|
||||||
? Constant.pcBtnBackgroundColor
|
leading: Icon(
|
||||||
: Colors.transparent,
|
Icons.history,
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 1);
|
|
||||||
Navigator.pushNamed(context, transaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'History Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 2)
|
color: (currentMenu == 2)
|
||||||
? Constant.textWhite
|
? Constant.pcBtnBackgroundColor
|
||||||
: Constant.textBlack,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
|
title: Text(
|
||||||
|
'History Transaksi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 2)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 2)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to User screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 2);
|
||||||
|
Navigator.pushNamed(context, historyTransaksiRoute);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
tileColor: (currentMenu == 2)
|
ListTile(
|
||||||
? Constant.pcBtnBackgroundColor
|
leading: Icon(
|
||||||
: Colors.transparent,
|
Icons.feed,
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to User screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 2);
|
|
||||||
Navigator.pushNamed(context, historyTransaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Report',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 3)
|
color: (currentMenu == 3)
|
||||||
? Constant.textWhite
|
? Constant.pcBtnBackgroundColor
|
||||||
: Constant.textBlack,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
|
title: Text(
|
||||||
|
'Report',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 3)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 3)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Transaksi screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 3);
|
||||||
|
Navigator.pushNamed(context, reportRoute);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
tileColor: (currentMenu == 3)
|
// ListTile(
|
||||||
? Constant.pcBtnBackgroundColor
|
// title: Text(
|
||||||
: Colors.transparent,
|
// 'User',
|
||||||
onTap: () {
|
// style: TextStyle(
|
||||||
// Handle navigation to Transaksi screen
|
// color: (currentMenu == 4)
|
||||||
Navigator.pop(context);
|
// ? Constant.textWhite
|
||||||
ref.read(currentPageProvider.state).update((state) => 3);
|
// : Constant.textBlack,
|
||||||
Navigator.pushNamed(context, reportRoute);
|
// ),
|
||||||
},
|
// ),
|
||||||
),
|
// tileColor: (currentMenu == 4)
|
||||||
// ListTile(
|
// ? Constant.pcBtnBackgroundColor
|
||||||
// title: Text(
|
// : Colors.transparent,
|
||||||
// 'User',
|
// onTap: () {
|
||||||
// style: TextStyle(
|
// // Handle navigation to User screen
|
||||||
// color: (currentMenu == 4)
|
// Navigator.pop(context);
|
||||||
// ? Constant.textWhite
|
// ref.read(currentPageProvider.state).update((state) => 4);
|
||||||
// : Constant.textBlack,
|
// Navigator.pushNamed(context, userRoute);
|
||||||
// ),
|
// },
|
||||||
// ),
|
// ),
|
||||||
// tileColor: (currentMenu == 4)
|
// ListTile(
|
||||||
// ? Constant.pcBtnBackgroundColor
|
// title: Text(
|
||||||
// : Colors.transparent,
|
// 'Change Company',
|
||||||
// onTap: () {
|
// style: TextStyle(
|
||||||
// // Handle navigation to User screen
|
// color: (currentMenu == 5)
|
||||||
// Navigator.pop(context);
|
// ? Constant.textWhite
|
||||||
// ref.read(currentPageProvider.state).update((state) => 4);
|
// : Constant.textBlack,
|
||||||
// Navigator.pushNamed(context, userRoute);
|
// ),
|
||||||
// },
|
// ),
|
||||||
// ),
|
// tileColor: (currentMenu == 5)
|
||||||
// ListTile(
|
// ? Constant.pcBtnBackgroundColor
|
||||||
// title: Text(
|
// : Colors.transparent,
|
||||||
// 'Change Company',
|
// onTap: () {
|
||||||
// style: TextStyle(
|
// // Handle navigation to User screen
|
||||||
// color: (currentMenu == 5)
|
// Navigator.pop(context);
|
||||||
// ? Constant.textWhite
|
// ref.read(currentPageProvider.state).update((state) => 5);
|
||||||
// : Constant.textBlack,
|
// Navigator.pushNamed(context, changeCompanyRoute);
|
||||||
// ),
|
// },
|
||||||
// ),
|
// ),
|
||||||
// tileColor: (currentMenu == 5)
|
ListTile(
|
||||||
// ? Constant.pcBtnBackgroundColor
|
leading: Icon(
|
||||||
// : Colors.transparent,
|
Icons.logout,
|
||||||
// onTap: () {
|
color: Constant.textGreyv2,
|
||||||
// // Handle navigation to User screen
|
),
|
||||||
// Navigator.pop(context);
|
title: Text(
|
||||||
// ref.read(currentPageProvider.state).update((state) => 5);
|
'Logout',
|
||||||
// Navigator.pushNamed(context, changeCompanyRoute);
|
style: TextStyle(color: Constant.textGreyv2),
|
||||||
// },
|
),
|
||||||
// ),
|
onTap: () {
|
||||||
ListTile(
|
// di set ke 0 lagi
|
||||||
title: Text(
|
ref.read(currentPageProvider.state).update((state) => 0);
|
||||||
'Logout',
|
ref.read(logoutProvider.notifier).logout(
|
||||||
// style: TextStyle(color: Constant.textWhite),
|
M_UserID: selectedUser?.model.M_UserID ?? "",
|
||||||
|
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onTap: () {
|
],
|
||||||
// di set ke 0 lagi
|
),
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
ref.read(logoutProvider.notifier).logout(
|
|
||||||
M_UserID: selectedUser?.model.M_UserID ?? "",
|
|
||||||
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
221
app_petty_cash/lib/widget/custom_drawer_v1.dart
Normal file
221
app_petty_cash/lib/widget/custom_drawer_v1.dart
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import '../app/constant.dart';
|
||||||
|
import '../app/route.dart';
|
||||||
|
import '../provider/current_menu_provider.dart';
|
||||||
|
import '../provider/current_user_provider.dart';
|
||||||
|
import '../screen/login/logout_provider.dart';
|
||||||
|
|
||||||
|
class CustomDrawerV1 extends HookConsumerWidget {
|
||||||
|
const CustomDrawerV1({
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final selectedUser = ref.read(currentUserProvider);
|
||||||
|
final isLoading = useState(false);
|
||||||
|
final errorMessage = useState("");
|
||||||
|
final successMessage = useState("");
|
||||||
|
|
||||||
|
useEffect(() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
|
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
||||||
|
if (userID == "0") {
|
||||||
|
//not login
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
|
||||||
|
|
||||||
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return () {};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
ref.listen(logoutProvider, (prev, next) async {
|
||||||
|
if (next is LogoutStateLoading) {
|
||||||
|
isLoading.value = true;
|
||||||
|
} else if (next is LogoutStateError) {
|
||||||
|
isLoading.value = false;
|
||||||
|
errorMessage.value = next.message;
|
||||||
|
Timer(const Duration(seconds: 3), () {
|
||||||
|
errorMessage.value = "";
|
||||||
|
});
|
||||||
|
} else if (next is LogoutStateDone) {
|
||||||
|
isLoading.value = false;
|
||||||
|
final shared = await SharedPreferences.getInstance();
|
||||||
|
final bearerString = shared.get(Constant.bearerName).toString();
|
||||||
|
// print(bearerString);
|
||||||
|
if (bearerString.isNotEmpty) {
|
||||||
|
shared.remove(bearerString);
|
||||||
|
shared.clear();
|
||||||
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
|
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
||||||
|
}
|
||||||
|
Timer(const Duration(seconds: 3), () async {
|
||||||
|
successMessage.value = "";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final currentMenu = ref.read(currentPageProvider);
|
||||||
|
|
||||||
|
return Drawer(
|
||||||
|
child: ListView(
|
||||||
|
// padding: EdgeInsets.only(
|
||||||
|
// top: Constant.getActualYPhone(context: context, y: 10),
|
||||||
|
// ),
|
||||||
|
children: [
|
||||||
|
DrawerHeader(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Drawer Header',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Home',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 0)
|
||||||
|
? Constant.textWhite
|
||||||
|
: Constant.textBlack,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
tileColor: (currentMenu == 0)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Home screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 0);
|
||||||
|
Navigator.pushNamed(context, homeRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Transaksi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 1)
|
||||||
|
? Constant.textWhite
|
||||||
|
: Constant.textBlack,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
tileColor: (currentMenu == 1)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Transaksi screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 1);
|
||||||
|
Navigator.pushNamed(context, transaksiRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'History Transaksi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 2)
|
||||||
|
? Constant.textWhite
|
||||||
|
: Constant.textBlack,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
tileColor: (currentMenu == 2)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to User screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 2);
|
||||||
|
Navigator.pushNamed(context, historyTransaksiRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Report',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 3)
|
||||||
|
? Constant.textWhite
|
||||||
|
: Constant.textBlack,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
tileColor: (currentMenu == 3)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Transaksi screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 3);
|
||||||
|
Navigator.pushNamed(context, reportRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(
|
||||||
|
// 'User',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: (currentMenu == 4)
|
||||||
|
// ? Constant.textWhite
|
||||||
|
// : Constant.textBlack,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// tileColor: (currentMenu == 4)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
// onTap: () {
|
||||||
|
// // Handle navigation to User screen
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// ref.read(currentPageProvider.state).update((state) => 4);
|
||||||
|
// Navigator.pushNamed(context, userRoute);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(
|
||||||
|
// 'Change Company',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: (currentMenu == 5)
|
||||||
|
// ? Constant.textWhite
|
||||||
|
// : Constant.textBlack,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// tileColor: (currentMenu == 5)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
// onTap: () {
|
||||||
|
// // Handle navigation to User screen
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// ref.read(currentPageProvider.state).update((state) => 5);
|
||||||
|
// Navigator.pushNamed(context, changeCompanyRoute);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Logout',
|
||||||
|
// style: TextStyle(color: Constant.textWhite),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
// di set ke 0 lagi
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 0);
|
||||||
|
ref.read(logoutProvider.notifier).logout(
|
||||||
|
M_UserID: selectedUser?.model.M_UserID ?? "",
|
||||||
|
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user