adding multilingual support

This commit is contained in:
Azmat-7860
2026-10-03 15:04:48 +05:30
parent 3785ea1e45
commit 0d7785b242
51 changed files with 3007 additions and 250 deletions
+19 -17
View File
@@ -9,6 +9,7 @@ import 'package:base_project/utils/managers/user_manager.dart';
import 'package:provider/provider.dart';
import 'package:base_project/view_model/system_params/system_params_view_model.dart';
import 'package:flutter/material.dart';
import '../../l10n/app_localizations.dart';
class HomeView extends StatefulWidget {
const HomeView({super.key});
@@ -32,54 +33,54 @@ class _HomeViewState extends State<HomeView> with TickerProviderStateMixin {
// Dashboard stats (replace with real API data)
List<Map<String, dynamic>> _dashboardStats = [];
final List<Map<String, dynamic>> _quickActions = [
List<Map<String, dynamic>> _quickActions(BuildContext context) => [
{
'label': 'Profile',
'label': AppLocalizations.of(context)!.profile,
'icon': Icons.person,
'onTap': () {},
'backgroundColor': null, // Use theme default
},
{
'label': 'Settings',
'label': AppLocalizations.of(context)!.settings,
'icon': Icons.settings,
'onTap': () {},
'backgroundColor': null,
},
{
'label': 'Security',
'label': AppLocalizations.of(context)!.security,
'icon': Icons.security,
'onTap': () {},
'backgroundColor': null,
},
{
'label': 'Reports',
'label': AppLocalizations.of(context)!.reports,
'icon': Icons.analytics,
'onTap': () {},
'backgroundColor': null,
},
];
final List<DrawerItem> _drawerItems = [
List<DrawerItem> _drawerItems(BuildContext context) => [
DrawerItem(
icon: Icons.person,
title: 'Profile',
subtitle: 'Manage your account',
title: AppLocalizations.of(context)!.profile,
subtitle: AppLocalizations.of(context)!.manageAccount,
onTap: (context) {
Navigator.pushNamed(context, RouteNames.profileView);
},
),
DrawerItem(
icon: Icons.system_security_update,
title: 'System Parameters',
subtitle: 'Configure system settings',
title: AppLocalizations.of(context)!.systemParameters,
subtitle: AppLocalizations.of(context)!.configureSystemSettings,
onTap: (context) {
Navigator.pushNamed(context, RouteNames.systemParamsView);
},
),
DrawerItem(
icon: Icons.password,
title: 'Change Password',
subtitle: 'Update your password',
title: AppLocalizations.of(context)!.changePassword,
subtitle: AppLocalizations.of(context)!.updateYourPassword,
onTap: (context) {
Navigator.pushNamed(context, RouteNames.changePasswordView);
},
@@ -226,7 +227,7 @@ class _HomeViewState extends State<HomeView> with TickerProviderStateMixin {
return Scaffold(
backgroundColor: colorScheme.background,
appBar: ModernAppBar(
title: 'Dashboard',
title: AppLocalizations.of(context)!.dashboard,
centerTitle: false,
showLogoInTitle: true,
logoImage: _getDashboardLogoImage(colorScheme),
@@ -237,7 +238,7 @@ class _HomeViewState extends State<HomeView> with TickerProviderStateMixin {
Navigator.pushNamed(context, RouteNames.profileView);
},
),
drawer: ModernDrawer(items: _drawerItems),
drawer: ModernDrawer(items: _drawerItems(context)),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
@@ -339,7 +340,8 @@ class _HomeViewState extends State<HomeView> with TickerProviderStateMixin {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Welcome back, ${userName ?? 'User'}! 👋',
AppLocalizations.of(context)!
.helloUser(userName ?? AppLocalizations.of(context)!.user),
style: theme.textTheme.headlineMedium?.copyWith(
color: colorScheme.onBackground,
fontWeight: FontWeight.w700,
@@ -468,9 +470,9 @@ class _HomeViewState extends State<HomeView> with TickerProviderStateMixin {
mainAxisSpacing: UIConstants.spacing16,
childAspectRatio: 1.0,
),
itemCount: _quickActions.length,
itemCount: _quickActions(context).length,
itemBuilder: (context, index) {
final action = _quickActions[index];
final action = _quickActions(context)[index];
return QuickActionButton(
label: action['label'],
icon: action['icon'],
@@ -1,5 +1,6 @@
import 'package:base_project/core/constants/ui_constants.dart';
import 'package:base_project/core/providers/dynamic_theme_provider.dart';
import 'package:base_project/l10n/app_localizations.dart';
import 'package:base_project/shared/widgets/app_bar/modern_app_bar.dart';
import 'package:base_project/shared/widgets/inputs/modern_text_field.dart';
import 'package:base_project/shared/widgets/buttons/modern_button.dart';
@@ -160,33 +161,37 @@ class _AccountUpdateViewState extends State<AccountUpdateView>
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ModernTextField(
label: 'Company Name',
hint: 'Enter company name',
label: AppLocalizations.of(context)!.accCompanyName,
hint: AppLocalizations.of(context)!.accCompanyHint,
controller: _companyName,
prefixIcon: const Icon(Icons.business),
validator: (v) =>
(v == null || v.isEmpty) ? 'Required' : null,
(v == null || v.isEmpty)
? AppLocalizations.of(context)!.requiredVal
: null,
),
SizedBox(height: UIConstants.spacing20),
ModernTextField(
label: 'Workspace',
hint: 'Enter workspace',
label: AppLocalizations.of(context)!.accWorkspace,
hint: AppLocalizations.of(context)!.accWorkspaceHint,
controller: _workspace,
prefixIcon: const Icon(Icons.apartment_outlined),
validator: (v) =>
(v == null || v.isEmpty) ? 'Required' : null,
(v == null || v.isEmpty)
? AppLocalizations.of(context)!.requiredVal
: null,
),
SizedBox(height: UIConstants.spacing20),
ModernTextField(
label: 'GST Number',
hint: 'Enter GST number',
label: AppLocalizations.of(context)!.accGst,
hint: AppLocalizations.of(context)!.accGstHint,
controller: _gstNumber,
prefixIcon: const Icon(Icons.confirmation_number_outlined),
),
SizedBox(height: UIConstants.spacing20),
ModernTextField(
label: 'Mobile',
hint: 'Enter mobile number',
label: AppLocalizations.of(context)!.accMobile,
hint: AppLocalizations.of(context)!.accMobileHint,
controller: _mobile,
keyboardType: TextInputType.phone,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
@@ -195,23 +200,23 @@ class _AccountUpdateViewState extends State<AccountUpdateView>
SizedBox(height: UIConstants.spacing20),
AbsorbPointer(
child: ModernTextField(
label: 'Email (read-only)',
hint: 'Email',
label: AppLocalizations.of(context)!.accEmailReadonly,
hint: AppLocalizations.of(context)!.email,
controller: _email,
prefixIcon: const Icon(Icons.email_outlined),
),
),
SizedBox(height: UIConstants.spacing20),
ModernTextField(
label: 'PAN Card',
hint: 'Enter PAN',
label: AppLocalizations.of(context)!.accPan,
hint: AppLocalizations.of(context)!.accPanHint,
controller: _pancard,
prefixIcon: const Icon(Icons.badge_outlined),
),
SizedBox(height: UIConstants.spacing20),
ModernTextField(
label: 'Working',
hint: 'Working status',
label: AppLocalizations.of(context)!.accWorking,
hint: AppLocalizations.of(context)!.accWorkingHint,
controller: _working,
prefixIcon: const Icon(Icons.work_outline),
),
@@ -223,7 +228,7 @@ class _AccountUpdateViewState extends State<AccountUpdateView>
onChanged: (v) => setState(() => _active = v),
),
const SizedBox(width: 8),
const Text('Active')
Text(AppLocalizations.of(context)!.nActive)
],
),
SizedBox(
@@ -234,7 +239,7 @@ class _AccountUpdateViewState extends State<AccountUpdateView>
desktop: UIConstants.spacing48,
)),
ModernButton(
text: 'Update Account',
text: AppLocalizations.of(context)!.accountUpdate,
type: ModernButtonType.primary,
size: ModernButtonSize.large,
isLoading: vm.isUpdating,
@@ -1,5 +1,6 @@
import 'package:base_project/commans/widgets/custom_textform_field.dart';
import 'package:base_project/commans/widgets/custome_elevated_button.dart';
import 'package:base_project/l10n/app_localizations.dart';
import 'package:base_project/resources/app_colors.dart';
import 'package:base_project/utils/managers/user_manager.dart';
import 'package:base_project/utils/validator/text_feild_validator.dart';
@@ -372,7 +373,7 @@ class _ChangePasswordState extends State<ChangePassword>
Consumer<ProfileViewModel>(
builder: (context, provider, _) {
return ModernButton(
text: 'Change Password',
text: AppLocalizations.of(context)!.changePassword,
type: ModernButtonType.primary,
size: ModernButtonSize.large,
isLoading: provider.isUpdating,
@@ -1,5 +1,6 @@
import 'package:base_project/commans/widgets/custom_textform_field.dart';
import 'package:base_project/commans/widgets/custome_elevated_button.dart';
import 'package:base_project/l10n/app_localizations.dart';
import 'package:base_project/model/user/user_profile.dart';
import 'package:base_project/resources/app_colors.dart';
import 'package:base_project/view_model/profile/profile_view_model.dart';
@@ -396,7 +397,7 @@ class _EditProfileState extends State<EditProfile>
Consumer<ProfileViewModel>(
builder: (context, provider, _) {
return ModernButton(
text: 'Save Changes',
text: AppLocalizations.of(context)!.saveChanges,
type: ModernButtonType.primary,
size: ModernButtonSize.large,
isLoading: provider.isUpdating,
@@ -6,6 +6,7 @@ import 'package:base_project/utils/managers/user_manager.dart';
import 'package:base_project/view/dashboard/profile/edit_profile.dart';
import 'package:base_project/view_model/profile/profile_view_model.dart';
import 'package:flutter/material.dart';
import '../../../l10n/app_localizations.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
import 'package:base_project/core/providers/dynamic_theme_provider.dart';
@@ -77,7 +78,7 @@ class _ProfileViewState extends State<ProfileView>
return Scaffold(
appBar: ModernAppBar(
title: 'Profile',
title: AppLocalizations.of(context)!.profile,
automaticallyImplyLeading: true,
leading: IconButton(
icon: Icon(Icons.arrow_back),
@@ -393,7 +394,7 @@ class _ProfileViewState extends State<ProfileView>
context,
colorScheme: colorScheme,
icon: Icons.edit_outlined,
title: 'Edit Profile',
title: AppLocalizations.of(context)!.editProfile,
subtitle: 'Update your personal information',
onTap: () {
Navigator.push(
@@ -411,7 +412,7 @@ class _ProfileViewState extends State<ProfileView>
context,
colorScheme: colorScheme,
icon: Icons.manage_accounts_outlined,
title: 'Account Update',
title: AppLocalizations.of(context)!.accountUpdate,
subtitle: 'Update company/workspace details',
onTap: () {
Navigator.push(
@@ -427,7 +428,7 @@ class _ProfileViewState extends State<ProfileView>
context,
colorScheme: colorScheme,
icon: Icons.lock_outline,
title: 'Change Password',
title: AppLocalizations.of(context)!.changePassword,
subtitle: 'Update your account security',
onTap: () {
Navigator.pushNamed(context, RouteNames.changePasswordView);
@@ -438,7 +439,7 @@ class _ProfileViewState extends State<ProfileView>
context,
colorScheme: colorScheme,
icon: Icons.logout,
title: 'Logout',
title: AppLocalizations.of(context)!.logout,
subtitle: 'Sign out of your account',
iconColor: colorScheme.error,
onTap: () => _showLogoutDialog(context, colorScheme),
@@ -541,10 +542,10 @@ class _ProfileViewState extends State<ProfileView>
size: UIConstants.iconSizeMedium,
),
const SizedBox(width: UIConstants.spacing12),
const Text("Confirm Logout"),
Text(AppLocalizations.of(context)!.confirmLogout),
],
),
content: const Text("Are you sure you want to log out?"),
content: Text(AppLocalizations.of(context)!.confirmLogoutBody),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
@@ -563,7 +564,7 @@ class _ProfileViewState extends State<ProfileView>
backgroundColor: colorScheme.error,
foregroundColor: colorScheme.onError,
),
child: const Text("Log Out"),
child: Text(AppLocalizations.of(context)!.logoutAction),
),
],
);