step 12 : add proteksi login di tiap page
This commit is contained in:
@@ -13,6 +13,7 @@ import 'package:intl/intl.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
import '../../model/list_category_model.dart';
|
||||
import '../../provider/current_user_provider.dart';
|
||||
import '../../widget/custom_drawer.dart';
|
||||
import '../../widget/sankbar_widget.dart';
|
||||
import '../login/custom_text_field.dart';
|
||||
@@ -143,6 +144,21 @@ class TransaksiScreen extends HookConsumerWidget {
|
||||
},
|
||||
);
|
||||
|
||||
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 () {};
|
||||
}, []);
|
||||
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
// list Type Provider
|
||||
@@ -308,7 +324,8 @@ class TransaksiScreen extends HookConsumerWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Radio<ListType>(
|
||||
activeColor: Constant.confirmed,
|
||||
activeColor:
|
||||
Constant.pcBtnBackgroundColor,
|
||||
value: listTypeData.value[i],
|
||||
groupValue:
|
||||
selectedListTypeData.value,
|
||||
@@ -681,13 +698,14 @@ class TransaksiScreen extends HookConsumerWidget {
|
||||
top: Constant.getActualYPhone(context: context, y: 10),
|
||||
),
|
||||
child: BottomAppBar(
|
||||
elevation: 2.0,
|
||||
child: Container(
|
||||
width: Constant.getActualXPhone(context: context, x: 336),
|
||||
height: Constant.getActualYPhone(context: context, y: 42),
|
||||
child: ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateColor.resolveWith((st) =>
|
||||
Constant.pcBtnBackgroundColor),
|
||||
backgroundColor: MaterialStateColor.resolveWith(
|
||||
(st) => Constant.pcBtnBackgroundColor),
|
||||
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
|
||||
Reference in New Issue
Block a user