[Drawer] 2. get company usr & fix css
This commit is contained in:
@@ -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,12 @@ 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 +26,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 +58,7 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
M_CompanyName.value = await getCompanyName();
|
||||||
});
|
});
|
||||||
return () {};
|
return () {};
|
||||||
}, []);
|
}, []);
|
||||||
@@ -69,18 +94,71 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
final currentMenu = ref.read(currentPageProvider);
|
final currentMenu = ref.read(currentPageProvider);
|
||||||
|
|
||||||
return Drawer(
|
return Drawer(
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(0))
|
||||||
|
),
|
||||||
|
|
||||||
|
child: Container(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
// padding: EdgeInsets.only(
|
// padding: EdgeInsets.only(
|
||||||
// top: Constant.getActualYPhone(context: context, y: 10),
|
// top: Constant.getActualYPhone(context: context, y: 10),
|
||||||
// ),
|
// ),
|
||||||
children: [
|
children: [
|
||||||
DrawerHeader(
|
Container(
|
||||||
|
|
||||||
// decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
// color: Colors.blue,
|
// border: Border(bottom: BorderSide(color: Colors.transparent)) // <--- use the global theme to change the dividerColor property
|
||||||
// ),
|
// ),
|
||||||
child:
|
child:
|
||||||
Image(image: AssetImage('images/logo_sismedika_landscape.png')),
|
Image(image: AssetImage('images/logo_sismedika_landscape.png')),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
height: Constant.getActualYPhone(context: context, y: 8),
|
||||||
|
),
|
||||||
|
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(
|
leading: Icon(
|
||||||
Icons.home,
|
Icons.home,
|
||||||
@@ -239,6 +317,7 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user