90 lines
3.0 KiB
Dart
90 lines
3.0 KiB
Dart
import 'package:cheminova/controller/home_controller.dart';
|
|
import 'package:cheminova/screens/authentication/change_password_screen.dart';
|
|
import 'package:cheminova/screens/authentication/login_screen.dart';
|
|
import 'package:cheminova/screens/home_screen.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../screens/authentication/Profile.dart';
|
|
|
|
class MyDrawer extends StatefulWidget {
|
|
const MyDrawer({super.key});
|
|
|
|
@override
|
|
State<MyDrawer> createState() => _MyDrawerState();
|
|
}
|
|
|
|
class _MyDrawerState extends State<MyDrawer> {
|
|
final HomeController _homeController = Get.find();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Drawer(
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: <Widget>[
|
|
SizedBox(
|
|
height: 150,
|
|
child: Obx(() {
|
|
if (_homeController.isLoading.value) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
} else if (_homeController.error.value.isNotEmpty) {
|
|
return Center(child: Text(_homeController.error.value));
|
|
} else {
|
|
final user = _homeController.userProfile.value;
|
|
return user == null ?const SizedBox(): DrawerHeader(
|
|
decoration: const BoxDecoration(
|
|
color: Colors.black87,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
user!.myData!.name ?? "username",
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
Text(
|
|
user!.myData!.uniqueId ?? 'Employee ID',
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.home),
|
|
title: const Text('Home'),
|
|
onTap: () => Get.offAll(() => const HomeScreen()),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.account_circle),
|
|
title: const Text('Profile'),
|
|
onTap: () => Get.to(() => const ProfileScreen()),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.settings),
|
|
title: const Text('Change Password'),
|
|
onTap: () {
|
|
Get.to(const ChangePasswordScreen());
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.exit_to_app),
|
|
title: const Text('Logout'),
|
|
onTap: () => Get.offAll(() => const LoginScreen()),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|