Code Formatted
This commit is contained in:
@@ -17,7 +17,11 @@ class ProfileScreen extends StatefulWidget {
|
||||
final String mobileNumber;
|
||||
final String customerNo;
|
||||
final String customerName;
|
||||
const ProfileScreen({super.key, required this.mobileNumber, required this.customerNo, required this.customerName});
|
||||
const ProfileScreen(
|
||||
{super.key,
|
||||
required this.mobileNumber,
|
||||
required this.customerNo,
|
||||
required this.customerName});
|
||||
|
||||
@override
|
||||
State<ProfileScreen> createState() => _ProfileScreenState();
|
||||
@@ -306,283 +310,283 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
// );
|
||||
// }
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
final theme = Theme.of(context);
|
||||
final isDarkMode = theme.brightness == Brightness.dark;
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
final theme = Theme.of(context);
|
||||
final isDarkMode = theme.brightness == Brightness.dark;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(loc.profile),
|
||||
elevation: 0,
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
children: [
|
||||
// ===== Profile Header =====
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
// Avatar
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: theme.colorScheme.surface,
|
||||
image: const DecorationImage(
|
||||
image: AssetImage('assets/images/logo.png'),
|
||||
fit: BoxFit.cover,
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(loc.profile),
|
||||
elevation: 0,
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
children: [
|
||||
// ===== Profile Header =====
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
// Avatar
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: theme.colorScheme.surface,
|
||||
image: const DecorationImage(
|
||||
image: AssetImage('assets/images/logo.png'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Name + mobile
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
// If you want to show the user's name instead, replace below.
|
||||
widget.customerName,
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
const SizedBox(width: 12),
|
||||
// Name + mobile
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
// If you want to show the user's name instead, replace below.
|
||||
widget.customerName,
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
widget.customerNo,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color:
|
||||
theme.colorScheme.onSurface.withOpacity(0.7),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
widget.customerNo,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface
|
||||
.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Edit/Profile button (optional)
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
// TODO: Navigate to edit profile if required
|
||||
},
|
||||
icon: const Icon(Icons.edit, size: 18),
|
||||
label: const Text("Edit"),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// ===== Section: Settings =====
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
"Settings",
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.settings,
|
||||
title: loc.preferences,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const PreferenceScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.security,
|
||||
title: loc.securitySettings,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SecuritySettingsScreen(
|
||||
mobileNumber: widget.mobileNumber,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.currency_rupee,
|
||||
title: loc.dailylimit,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DailyLimitScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Card(
|
||||
child: SwitchListTile(
|
||||
title: Text(loc.enableFingerprintLogin),
|
||||
value: _isBiometricEnabled,
|
||||
onChanged: (bool value) {
|
||||
_handleBiometricToggle(value);
|
||||
},
|
||||
secondary: const Icon(Icons.fingerprint),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
const Divider(height: 24),
|
||||
|
||||
// ===== Section: Security & App =====
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
loc.appVersion,
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Fingerprint toggle inside a styled container
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.smartphone),
|
||||
title: Text(loc.appVersion),
|
||||
trailing: FutureBuilder<String>(
|
||||
future: _getAppVersion(),
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<String> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text(loc.error);
|
||||
} else {
|
||||
return Text(
|
||||
snapshot.data ?? "N/A",
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
const Divider(height: 24),
|
||||
|
||||
// ===== Section: Actions =====
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
"Exit",
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.exit_to_app,
|
||||
title: loc.logout,
|
||||
trailChevron: false, // action tile, no chevron
|
||||
onTap: () async {
|
||||
final shouldExit = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(loc.logout),
|
||||
content: Text(loc.logoutCheck),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(loc.no),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(loc.yes),
|
||||
// Edit/Profile button (optional)
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
// TODO: Navigate to edit profile if required
|
||||
},
|
||||
icon: const Icon(Icons.edit, size: 18),
|
||||
label: const Text("Edit"),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
),
|
||||
),
|
||||
|
||||
if (shouldExit == true) {
|
||||
if (Platform.isAndroid) {
|
||||
SystemNavigator.pop();
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// ===== Section: Settings =====
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
"Settings",
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.settings,
|
||||
title: loc.preferences,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const PreferenceScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.security,
|
||||
title: loc.securitySettings,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SecuritySettingsScreen(
|
||||
mobileNumber: widget.mobileNumber,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.currency_rupee,
|
||||
title: loc.dailylimit,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DailyLimitScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Card(
|
||||
child: SwitchListTile(
|
||||
title: Text(loc.enableFingerprintLogin),
|
||||
value: _isBiometricEnabled,
|
||||
onChanged: (bool value) {
|
||||
_handleBiometricToggle(value);
|
||||
},
|
||||
secondary: const Icon(Icons.fingerprint),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
const Divider(height: 24),
|
||||
|
||||
// ===== Section: Security & App =====
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
loc.appVersion,
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Fingerprint toggle inside a styled container
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.smartphone),
|
||||
title: Text(loc.appVersion),
|
||||
trailing: FutureBuilder<String>(
|
||||
future: _getAppVersion(),
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<String> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text(loc.error);
|
||||
} else {
|
||||
return Text(
|
||||
snapshot.data ?? "N/A",
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
const Divider(height: 24),
|
||||
|
||||
// ===== Section: Actions =====
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
"Exit",
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.exit_to_app,
|
||||
title: loc.logout,
|
||||
trailChevron: false, // action tile, no chevron
|
||||
onTap: () async {
|
||||
final shouldExit = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(loc.logout),
|
||||
content: Text(loc.logoutCheck),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(loc.no),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(loc.yes),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (shouldExit == true) {
|
||||
if (Platform.isAndroid) {
|
||||
SystemNavigator.pop();
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
},
|
||||
),
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.logout,
|
||||
title: loc.deregister,
|
||||
trailChevron: false,
|
||||
onTap: () async {
|
||||
final shouldLogout = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => const LogoutDialog(),
|
||||
);
|
||||
},
|
||||
),
|
||||
_SectionTile(
|
||||
leadingIcon: Icons.logout,
|
||||
title: loc.deregister,
|
||||
trailChevron: false,
|
||||
onTap: () async {
|
||||
final shouldLogout = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => const LogoutDialog(),
|
||||
);
|
||||
|
||||
if (shouldLogout == true) {
|
||||
await _handleLogout(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (shouldLogout == true) {
|
||||
await _handleLogout(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
|
||||
// ===== Watermark (kept subtle, no theme change) =====
|
||||
IgnorePointer(
|
||||
child: Positioned.fill(
|
||||
child: Center(
|
||||
child: Opacity(
|
||||
opacity: 0.06,
|
||||
child: ClipOval(
|
||||
child: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
filterQuality: FilterQuality.medium,
|
||||
// ===== Watermark (kept subtle, no theme change) =====
|
||||
IgnorePointer(
|
||||
child: Positioned.fill(
|
||||
child: Center(
|
||||
child: Opacity(
|
||||
opacity: 0.06,
|
||||
child: ClipOval(
|
||||
child: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SectionTile extends StatelessWidget {
|
||||
@@ -611,8 +615,7 @@ class _SectionTile extends StatelessWidget {
|
||||
? Icon(Icons.chevron_right, color: theme.colorScheme.onSurface)
|
||||
: null,
|
||||
onTap: onTap,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user