feat: Extracts home page drawer into reusable component

- Extracts the complex `Drawer` widget from the `HomePage` into a dedicated `DrawerComponent`. This enhances modularity, improves code readability, and allows for easier reuse of the navigation drawer across the application.
- Updates iOS project configuration files (`project.pbxproj` and `contents.xcworkspacedata`) to properly integrate CocoaPods dependencies. This typically occurs after running `pod install` and includes adding Pods frameworks, build phases, and xcconfig references.
- Updates the Flutter SDK path in VS Code settings to a newer version.
This commit is contained in:
mandreshope 2025-07-23 16:21:59 +03:00
parent c58d461762
commit 63d5a21079
7 changed files with 453 additions and 78 deletions

View File

@ -1,3 +1,3 @@
{
"dart.flutterSdkPath": "/opt/homebrew/Caskroom/flutter/3.32.1/flutter"
"dart.flutterSdkPath": "/opt/homebrew/Caskroom/flutter/3.32.6/flutter"
}

62
ios/Podfile.lock Normal file
View File

@ -0,0 +1,62 @@
PODS:
- connectivity_plus (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_secure_storage (6.0.0):
- Flutter
- mobile_scanner (7.0.0):
- Flutter
- FlutterMacOS
- ObjectBox (4.3.0)
- objectbox_flutter_libs (0.0.1):
- Flutter
- ObjectBox (= 4.3.0)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- Flutter (from `Flutter`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/darwin`)
- objectbox_flutter_libs (from `.symlinks/plugins/objectbox_flutter_libs/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
SPEC REPOS:
trunk:
- ObjectBox
EXTERNAL SOURCES:
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
Flutter:
:path: Flutter
flutter_secure_storage:
:path: ".symlinks/plugins/flutter_secure_storage/ios"
mobile_scanner:
:path: ".symlinks/plugins/mobile_scanner/darwin"
objectbox_flutter_libs:
:path: ".symlinks/plugins/objectbox_flutter_libs/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
SPEC CHECKSUMS:
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_secure_storage: 1ed9476fba7e7a782b22888f956cce43e2c62f13
mobile_scanner: 9157936403f5a0644ca3779a38ff8404c5434a93
ObjectBox: 7760fa9072adcffe102a6adf4646ca84ba70ab6b
objectbox_flutter_libs: 4014e38f57250b074b99893ae84579aba8f02876
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
PODFILE CHECKSUM: 4305caec6b40dde0ae97be1573c53de1882a07e5
COCOAPODS: 1.16.2

View File

@ -11,9 +11,11 @@
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
7C8F9118AE3168A999F930DE /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E24DFF9D30862E077920528D /* Pods_RunnerTests.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
E551AC72CC439E056518A699 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E3A2CEA5E4B2E1BD6B472A1D /* Pods_Runner.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -44,7 +46,11 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3AA6CD11E4768D4025EE87BD /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3CC6473DAE0B104E7F465531 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
4159967261DC6690855F4B5C /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
5109E12F046D7A4A4EB65A01 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@ -55,6 +61,10 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A83D5BA8D314F43BB051B498 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
E24DFF9D30862E077920528D /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E3A2CEA5E4B2E1BD6B472A1D /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E98FEBD5B1465AF05653F18C /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -62,12 +72,35 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E551AC72CC439E056518A699 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
AE3A35DC4A55F57905D237C1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7C8F9118AE3168A999F930DE /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
20F6BECC46EF248069B4DA34 /* Pods */ = {
isa = PBXGroup;
children = (
E98FEBD5B1465AF05653F18C /* Pods-Runner.debug.xcconfig */,
5109E12F046D7A4A4EB65A01 /* Pods-Runner.release.xcconfig */,
A83D5BA8D314F43BB051B498 /* Pods-Runner.profile.xcconfig */,
4159967261DC6690855F4B5C /* Pods-RunnerTests.debug.xcconfig */,
3CC6473DAE0B104E7F465531 /* Pods-RunnerTests.release.xcconfig */,
3AA6CD11E4768D4025EE87BD /* Pods-RunnerTests.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
331C8082294A63A400263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
@ -94,6 +127,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
20F6BECC46EF248069B4DA34 /* Pods */,
F993C4C1E71DCC3509C77F74 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -121,6 +156,15 @@
path = Runner;
sourceTree = "<group>";
};
F993C4C1E71DCC3509C77F74 /* Frameworks */ = {
isa = PBXGroup;
children = (
E3A2CEA5E4B2E1BD6B472A1D /* Pods_Runner.framework */,
E24DFF9D30862E077920528D /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -128,8 +172,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
177F348179881E43E0CC8292 /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
AE3A35DC4A55F57905D237C1 /* Frameworks */,
);
buildRules = (
);
@ -145,12 +191,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
58D90F9C4926EDF172C96640 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
DC141C645516148B1D51CCB9 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -222,6 +270,28 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
177F348179881E43E0CC8292 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@ -238,6 +308,28 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
58D90F9C4926EDF172C96640 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@ -253,6 +345,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
DC141C645516148B1D51CCB9 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@ -379,6 +488,7 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4159967261DC6690855F4B5C /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -396,6 +506,7 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3CC6473DAE0B104E7F465531 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -411,6 +522,7 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3AA6CD11E4768D4025EE87BD /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;

View File

@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,4 @@
export 'drawer_component.dart';
export 'loading_progress_component.dart';
export 'primary_button_component.dart';
export 'product_scanned_component.dart';

View File

@ -0,0 +1,269 @@
import 'package:barcode_scanner/backend/schema/user/user_struct.dart';
import 'package:barcode_scanner/pages/home_page/home_page_model.dart';
import 'package:barcode_scanner/pages/login_page/login_page_model.dart';
import 'package:barcode_scanner/router/go_router_builder.dart';
import 'package:barcode_scanner/router/go_secure_router_builder.dart';
import 'package:barcode_scanner/themes/app_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class DrawerComponent extends ConsumerStatefulWidget {
const DrawerComponent({
super.key,
this.isOperationExpanded = true,
this.isSettingsExpanded = false,
this.selectedMenuIndex = 0,
this.selectedSubMenuIndex = 0,
});
final bool isOperationExpanded;
final bool isSettingsExpanded;
final int selectedMenuIndex;
final int selectedSubMenuIndex;
@override
ConsumerState<DrawerComponent> createState() => _DrawerComponentState();
}
class _DrawerComponentState extends ConsumerState<DrawerComponent> {
bool _isOperationExpanded = false;
bool _isSettingsExpanded = false;
@override
void initState() {
super.initState();
_isOperationExpanded = widget.isOperationExpanded;
_isSettingsExpanded = widget.isSettingsExpanded;
}
@override
Widget build(BuildContext context) {
return Drawer(
backgroundColor: AppTheme.of(context).primaryBackground,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
child: Column(
children: [
const SizedBox(height: 50),
// === Profil utilisateur
Consumer(
builder: (context, ref, child) {
final state = ref.watch(homePageModelProvider);
return ListTile(
onTap: () => ProfileRoute().push(context),
contentPadding: EdgeInsets.zero,
leading: Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: AppTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(60),
),
),
title: Text(
state.user?.fullName ?? '',
style: AppTheme.of(context).titleMedium,
),
subtitle: Text(
state.user?.email ?? '',
style: AppTheme.of(context).bodyMedium,
),
);
},
),
const Divider(),
// === ExpansionTile Opérations
_ExpansionTileComponent(
leadingIcon: Icons.inbox,
isExpanded: _isOperationExpanded,
onExpansionChanged: (expanded) {
setState(() => _isOperationExpanded = expanded);
},
title: 'Opérations',
isActive: widget.selectedMenuIndex == 0,
children: [
_ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
leadingIcon: Icons.move_to_inbox,
isActive: widget.selectedSubMenuIndex == 0,
title: 'Réceptions',
),
_ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
leadingIcon: Icons.local_shipping,
title: 'Livraisons',
isActive: widget.selectedSubMenuIndex == 1,
),
_ListTile(
onTap: () {
Navigator.of(context).pop();
ProductListRoute().push(context);
},
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
leadingIcon: Icons.inventory,
title: 'Inventaires',
isActive: widget.selectedSubMenuIndex == 2,
),
],
),
// === Produits
_ListTile(
contentPadding: const EdgeInsetsDirectional.symmetric(
horizontal: 10,
),
leadingIcon: Icons.insert_chart,
title: "Produits",
isActive: widget.selectedMenuIndex == 1,
trailing: const Icon(Icons.keyboard_arrow_right),
),
// === Historique
_ListTile(
contentPadding: const EdgeInsetsDirectional.symmetric(
horizontal: 10,
),
leadingIcon: Icons.history,
title: "Historiques",
trailing: const Icon(Icons.keyboard_arrow_right),
isActive: widget.selectedMenuIndex == 2,
),
// === ExpansionTile Paramètres
_ExpansionTileComponent(
isActive: widget.selectedMenuIndex == 3,
isExpanded: _isSettingsExpanded,
onExpansionChanged: (expanded) {
setState(() => _isSettingsExpanded = expanded);
},
leadingIcon: Icons.settings,
title: "Paramètres",
children: [
_ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
leadingIcon: Icons.lock_open,
title: 'Connexion Odoo',
isActive: widget.selectedSubMenuIndex == 3,
),
_ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
leadingIcon: Icons.group,
title: 'Gestion des utilisateurs',
isActive: widget.selectedSubMenuIndex == 4,
),
],
),
const Spacer(),
// === Déconnexion
SafeArea(
child: ListTile(
onTap: () async {
await ref.read(loginPageModelProvider.notifier).logOut();
await UserStruct(id: '1').deleteLocalStorage();
WidgetsBinding.instance.addPostFrameCallback((_) {
SplashRoute().go(context);
});
},
leading: const Icon(Icons.logout),
title: Text(
'Se déconnecter',
style: AppTheme.of(context).bodyLarge,
),
),
),
],
),
),
);
}
}
class _ListTile extends StatelessWidget {
const _ListTile({
Key? key,
required this.title,
this.isActive = false,
this.onTap,
this.leadingIcon,
this.contentPadding,
this.trailing,
}) : super(key: key);
final bool isActive;
final String title;
final VoidCallback? onTap;
final IconData? leadingIcon;
final EdgeInsetsGeometry? contentPadding;
final Widget? trailing;
@override
Widget build(BuildContext context) {
return ListTile(
onTap: onTap,
contentPadding: contentPadding,
leading: Icon(
leadingIcon,
color: isActive ? AppTheme.of(context).primary : null,
),
title: Text(
title,
style: AppTheme.of(context).bodyLarge.copyWith(
color: isActive ? AppTheme.of(context).primary : null,
),
),
trailing: trailing,
);
}
}
class _ExpansionTileComponent extends StatelessWidget {
const _ExpansionTileComponent({
required this.title,
this.isExpanded = false,
this.onExpansionChanged,
this.isActive = false,
this.children = const <Widget>[],
this.leadingIcon,
});
final bool isExpanded;
final void Function(bool)? onExpansionChanged;
final bool isActive;
final List<Widget> children;
final String title;
final IconData? leadingIcon;
@override
Widget build(BuildContext context) {
return ExpansionTile(
initiallyExpanded: isExpanded,
onExpansionChanged: onExpansionChanged,
tilePadding: const EdgeInsetsDirectional.symmetric(horizontal: 10),
shape: LinearBorder.none,
title: Row(
children: [
Icon(
leadingIcon,
color: isActive ? AppTheme.of(context).primary : null,
),
const SizedBox(width: 12),
Expanded(
child: Text(
title,
style: AppTheme.of(context).bodyLarge.copyWith(
color: isActive ? AppTheme.of(context).primary : null,
),
),
),
],
),
trailing: Icon(
isExpanded ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_right,
),
children: children,
);
}
}

View File

@ -1,7 +1,5 @@
import 'package:barcode_scanner/backend/schema/user/user_struct.dart';
import 'package:barcode_scanner/components/components.dart';
import 'package:barcode_scanner/pages/home_page/home_page_model.dart';
import 'package:barcode_scanner/pages/login_page/login_page_model.dart';
import 'package:barcode_scanner/router/go_router_builder.dart';
import 'package:barcode_scanner/router/go_secure_router_builder.dart';
import 'package:barcode_scanner/themes/app_theme.dart';
import 'package:flutter/material.dart';
@ -27,80 +25,7 @@ class _HomePageState extends ConsumerState<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: Drawer(
backgroundColor: AppTheme.of(context).primaryBackground,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
child: Column(
children: [
SizedBox(height: 50),
Consumer(
builder: (context, ref, child) {
final state = ref.watch(homePageModelProvider);
return ListTile(
contentPadding: EdgeInsets.zero,
leading: Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: AppTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(60),
),
),
title: Text(
state.user?.fullName ?? '',
style: AppTheme.of(context).titleMedium,
),
subtitle: Text(
state.user?.email ?? '',
style: AppTheme.of(context).bodyMedium,
),
);
},
),
Divider(),
ListTile(
onTap: () {
ProfileRoute().push(context);
},
leading: Icon(Icons.person),
title: Text(
'Mon Profil',
style: AppTheme.of(context).bodyLarge,
),
),
ListTile(
onTap: () {
Navigator.of(context).pop();
ProductListRoute().push(context);
},
leading: Icon(Icons.inventory),
title: Text(
'Inventaire',
style: AppTheme.of(context).bodyLarge,
),
),
Spacer(),
SafeArea(
child: ListTile(
onTap: () async {
await ref.read(loginPageModelProvider.notifier).logOut();
await UserStruct(id: '1').deleteLocalStorage();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
SplashRoute().go(context);
});
},
leading: Icon(Icons.logout),
title: Text(
'Se deconnecter',
style: AppTheme.of(context).bodyLarge,
),
),
),
],
),
),
),
drawer: DrawerComponent(isOperationExpanded: true),
backgroundColor: AppTheme.of(context).primaryBackground,
appBar: AppBar(
title: Text('Barcode Scanner', style: AppTheme.of(context).titleLarge),