import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:kmobile/data/models/user.dart'; import '../../../l10n/app_localizations.dart'; class CustomerInfoScreen extends StatefulWidget { final User user; const CustomerInfoScreen({super.key, required this.user}); @override State createState() => _CustomerInfoScreenState(); } class _CustomerInfoScreenState extends State { late final User user = widget.user; String _maskPrimaryId(String? primaryId) { if (primaryId == null || primaryId.length <= 4) { return primaryId ?? 'N/A'; } final lastFour = primaryId.substring(primaryId.length - 4); return '*' * (primaryId.length - 4) + lastFour; } @override Widget build(BuildContext context) { final theme = Theme.of(context); return Scaffold( appBar: AppBar( title: Text( AppLocalizations.of(context) .customerInfo .replaceFirst(RegExp('\n'), ''), ), ), body: SafeArea( child: Stack( children: [ SingleChildScrollView( physics: const AlwaysScrollableScrollPhysics(), child: Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Card( elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), side: BorderSide( color: theme.colorScheme.outline.withOpacity(0.2), width: 1, ), ), child: Padding( padding: const EdgeInsets.all(16.0), child: Row( children: [ SizedBox( width: 56, height: 56, child: CircleAvatar( radius: 50, child: SvgPicture.asset( 'assets/images/avatar_male.svg', 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. user.name ?? '', style: theme.textTheme.titleLarge?.copyWith( fontWeight: FontWeight.w600, ), ), const SizedBox(height: 4), Text( user.cifNumber ?? '', style: theme.textTheme.bodyMedium?.copyWith( color: theme.colorScheme.onSurface .withOpacity(0.7), ), ), ], ), ), ], ), ), ), const SizedBox(height: 16), Card( elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), side: BorderSide( color: theme.colorScheme.outline.withOpacity(0.2), width: 1, ), ), child: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Personal Information', style: theme.textTheme.titleMedium?.copyWith( fontWeight: FontWeight.w600, ), ), const SizedBox(height: 16), InfoField( label: AppLocalizations.of(context).activeAccounts, value: user.activeAccounts?.toString() ?? 'N/A', ), InfoField( label: AppLocalizations.of(context).mobileNumber, value: user.mobileNo ?? 'N/A', ), InfoField( label: AppLocalizations.of(context).dateOfBirth, value: (user.dateOfBirth != null && user.dateOfBirth!.length == 8) ? '${user.dateOfBirth!.substring(0, 2)}-${user.dateOfBirth!.substring(2, 4)}-${user.dateOfBirth!.substring(4, 8)}' : 'N/A', ), // Replace with DOB if available InfoField( label: AppLocalizations.of(context).branchCode, value: user.branchId ?? 'N/A', ), InfoField( label: AppLocalizations.of(context).address, value: user.address ?? 'N/A', ), // Replace with Aadhar if available InfoField( label: AppLocalizations.of(context).primaryId, value: _maskPrimaryId(user.primaryId), ), ], ), ), ), ], ), ), ), IgnorePointer( child: Center( child: Opacity( opacity: 0.07, // Reduced opacity child: ClipOval( child: Image.asset( 'assets/images/logo.png', width: 200, // Adjust size as needed height: 200, // Adjust size as needed ), ), ), ), ), ], ), ) ); } } class InfoField extends StatelessWidget { final String label; final String value; const InfoField({super.key, required this.label, required this.value}); @override Widget build(BuildContext context) { final theme = Theme.of(context); return Container( width: double.infinity, margin: const EdgeInsets.symmetric(vertical: 8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: theme.textTheme.bodySmall?.copyWith( color: theme.colorScheme.onSurface.withOpacity(0.6), ), ), const SizedBox(height: 4), Text( value.isEmpty ? 'N/A' : value, style: theme.textTheme.titleMedium?.copyWith( fontWeight: FontWeight.w600, ), ), ], ), ); } }