handelled the left bar employee names

This commit is contained in:
Vaibhav Surve 2025-05-03 12:08:25 +05:30
parent 48255f0d72
commit 70943aad01
3 changed files with 50 additions and 40 deletions

View File

@ -1,6 +1,8 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:marco/helpers/services/storage/local_storage.dart';
import 'package:marco/controller/permission_controller.dart';
import 'package:get/get.dart';
class AuthService {
static bool isLoggedIn = false;
@ -35,7 +37,7 @@ class AuthService {
// Save the login state in local storage
await LocalStorage.setLoggedInUser(true);
Get.put(PermissionController());
// Return null to indicate success
return null;
} else if (response.statusCode == 401) {

View File

@ -11,7 +11,6 @@ import 'package:marco/helpers/theme/theme_customizer.dart';
import 'package:marco/routes.dart';
import 'package:provider/provider.dart';
import 'package:url_strategy/url_strategy.dart';
import 'package:marco/controller/permission_controller.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
setPathUrlStrategy();
@ -19,7 +18,6 @@ Future<void> main() async {
await LocalStorage.init();
AppStyle.init();
await ThemeCustomizer.init();
Get.put(PermissionController());
runApp(ChangeNotifierProvider<AppNotifier>(
create: (context) => AppNotifier(),
child: MyApp(),

View File

@ -56,7 +56,13 @@ class _LeftBarState extends State<LeftBar>
@override
void initState() {
super.initState();
employeeInfo = LocalStorage.getEmployeeInfo();
_loadEmployeeInfo();
}
void _loadEmployeeInfo() {
setState(() {
employeeInfo = LocalStorage.getEmployeeInfo();
});
}
@override
@ -125,43 +131,47 @@ class _LeftBarState extends State<LeftBar>
);
}
Widget userInfoSection() {
return Padding(
padding: MySpacing.fromLTRB(16, 8, 16, 8),
child: Row(
children: [
Avatar(
firstName: employeeInfo?.firstName ?? 'First',
lastName: employeeInfo?.lastName ?? 'Name',
),
MySpacing.width(16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
MyText.labelSmall(
"${employeeInfo?.firstName ?? 'First Name'} ${employeeInfo?.lastName ?? 'Last Name'}",
fontWeight: 600,
muted: true,
),
],
),
),
MyContainer(
onTap: () {
Get.offNamed('/auth/login');
},
color: leftBarTheme.activeItemBackground,
paddingAll: 8,
child: Icon(LucideIcons.log_out,
size: 16, color: leftBarTheme.activeItemColor),
)
],
),
);
Widget userInfoSection() {
if (employeeInfo == null) {
return Center(child: CircularProgressIndicator()); // Show loading indicator if employeeInfo is not yet loaded.
}
return Padding(
padding: MySpacing.fromLTRB(16, 8, 16, 8),
child: Row(
children: [
Avatar(
firstName: employeeInfo?.firstName ?? 'First',
lastName: employeeInfo?.lastName ?? 'Name',
),
MySpacing.width(16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
MyText.labelSmall(
"${employeeInfo?.firstName ?? 'First Name'} ${employeeInfo?.lastName ?? 'Last Name'}",
fontWeight: 600,
muted: true,
),
],
),
),
MyContainer(
onTap: () {
Get.offNamed('/auth/login');
},
color: leftBarTheme.activeItemBackground,
paddingAll: 8,
child: Icon(LucideIcons.log_out,
size: 16, color: leftBarTheme.activeItemColor),
)
],
),
);
}
Widget labelWidget(String label) {
return isCondensed
? MySpacing.empty()