location and bottomsheet keyboard bug fixes

main_production_upgrade_ios
WaseemAbbasi22 10 hours ago
parent 445e7cf091
commit 123738e333

@ -66,59 +66,59 @@ class _NfcLayoutState extends State<NfcLayout> {
NfcManager.instance.startSession( NfcManager.instance.startSession(
onDiscovered: (NfcTag tag) async { onDiscovered: (NfcTag tag) async {
String? identifier; String? identifier;
try { try {
if (Platform.isAndroid) { if (Platform.isAndroid) {
// Try NfcA first (most common) // Try NfcA first (most common)
final nfcA = NfcAAndroid.from(tag); final nfcA = NfcAAndroid.from(tag);
if (nfcA != null) { if (nfcA != null) {
identifier = nfcA.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = nfcA.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
} else { } else {
// Fallback to NfcB // Fallback to NfcB
final nfcB = NfcBAndroid.from(tag); final nfcB = NfcBAndroid.from(tag);
if (nfcB != null) { if (nfcB != null) {
identifier = nfcB.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = nfcB.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
}
} }
}
} else {
// For iOS, try MiFare first
final mifare = MiFareIos.from(tag);
if (mifare != null) {
identifier = mifare.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
} else { } else {
// Fallback to Iso15693 for iOS // For iOS, try MiFare first
final iso15693 = Iso15693Ios.from(tag); final mifare = MiFareIos.from(tag);
if (iso15693 != null) { if (mifare != null) {
identifier = iso15693.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = mifare.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
} else {
// Fallback to Iso15693 for iOS
final iso15693 = Iso15693Ios.from(tag);
if (iso15693 != null) {
identifier = iso15693.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
}
} }
} }
} catch (e) {
print('Error reading NFC tag: $e');
} }
} catch (e) {
print('Error reading NFC tag: $e');
}
nfcId = identifier; nfcId = identifier;
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_reading = true; _reading = true;
mainWidget = doneNfc(); // mainWidget = doneNfc();
}); });
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
try { try {
await NfcManager.instance.stopSession(); await NfcManager.instance.stopSession();
} catch (e) { } catch (e) {
print('Error stopping session: $e'); print('Error stopping session: $e');
} }
if (mounted) { if (mounted) {
Navigator.pop(context); Navigator.pop(context);
widget.onNcfScan!(nfcId!); widget.onNcfScan!(nfcId!);
} }
}); });
}, },
pollingOptions: {NfcPollingOption.iso14443}, pollingOptions: {NfcPollingOption.iso14443},
).catchError((err) { ).catchError((err) {
print('NFC session error: $err'); print('NFC session error: $err');
@ -138,22 +138,18 @@ class _NfcLayoutState extends State<NfcLayout> {
Widget scanNfc() { Widget scanNfc() {
return Container( return Container(
color: AppColor.background(context), color: AppColor.background(context),
key: ValueKey(1), key: const ValueKey(1),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Text( Text(
"Ready To Scan", "Ready To Scan",
style: TextStyle( style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24, color: AppColor.headingTextColor(context)),
fontWeight: FontWeight.bold,
fontSize: 24,
color:AppColor.headingTextColor(context)
),
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Image.asset( Image.asset(
@ -196,7 +192,7 @@ class _NfcLayoutState extends State<NfcLayout> {
child: const Text("CANCEL"), child: const Text("CANCEL"),
), ),
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
], ],
@ -211,18 +207,14 @@ class _NfcLayoutState extends State<NfcLayout> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Text( Text(
"Successfully Scanned", "Successfully Scanned",
style: TextStyle( style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24, color: AppColor.headingTextColor(context)),
fontWeight: FontWeight.bold,
fontSize: 24,
color:AppColor.headingTextColor(context)
),
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Image.asset( Image.asset(
@ -232,16 +224,16 @@ class _NfcLayoutState extends State<NfcLayout> {
width: double.infinity, width: double.infinity,
color: AppColor.iconColor(context), color: AppColor.iconColor(context),
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Text( const Text(
"Approach an NFC Tag", "Approach an NFC Tag",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
), ),
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
ButtonTheme( ButtonTheme(
@ -259,10 +251,13 @@ class _NfcLayoutState extends State<NfcLayout> {
// }, // },
onPressed: null, onPressed: null,
// elevation: 0, // elevation: 0,
child: Text("DONE",style: TextStyle(color: context.isDark?AppColor.primary10:null),), child: Text(
"DONE",
style: TextStyle(color: context.isDark ? AppColor.primary10 : null),
),
), ),
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
], ],

@ -20,6 +20,21 @@ class LocationUtilities {
Geolocator.isLocationServiceEnabled().then((value) => callback(value)); Geolocator.isLocationServiceEnabled().then((value) => callback(value));
} }
static Future<bool> isEnabledAsync() async {
return await Geolocator.isLocationServiceEnabled();
}
static Future<bool> havePermissionAsync() async {
LocationPermission permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
}
return permission == LocationPermission.always ||
permission == LocationPermission.whileInUse;
}
static bool _listeningSettingChange = true; static bool _listeningSettingChange = true;
static void listenGPS({bool change = true, Function(bool)? onChange}) async { static void listenGPS({bool change = true, Function(bool)? onChange}) async {
@ -44,61 +59,100 @@ class LocationUtilities {
completion(isGranted); completion(isGranted);
}); });
} }
static Future<void> getCurrentLocation(
Function(Position position, bool isMocked) callback,
Function(String error) errorCallBack,
BuildContext context,
) async {
debugPrint("📍 Fetching current location...");
static void getCurrentLocation(Function(Position position, bool isMocked) callback, Function errorCallBack, BuildContext context) { try {
Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { final position = await Geolocator.getCurrentPosition(
bool isMocked = position.isMocked; desiredAccuracy: LocationAccuracy.high,
callback(position, isMocked); timeLimit: const Duration(seconds: 10),
}).catchError((err) { );
errorCallBack(); debugPrint("✅ Location: ${position.latitude}, ${position.longitude}");
});
// return; callback(position, position.isMocked);
// Permission.location.isGranted.then((isGranted) { } catch (e) {
// if (!isGranted) { debugPrint("❌ Primary location failed: $e");
// Permission.location.request().then((granted) { try {
// print("granted:$granted"); final lastPosition = await Geolocator.getLastKnownPosition();
// if (granted == PermissionStatus.granted) { if (lastPosition != null) {
// Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { debugPrint("⚠️ Using last known location");
// bool isMocked = position.isMocked; callback(lastPosition, lastPosition.isMocked);
// callback(position, isMocked); return;
// }).catchError((err) { }
// print("getCurrentPositionError:$err"); } catch (fallbackError) {
// errorCallBack(); debugPrint("❌ Fallback failed: $fallbackError");
// }); }
// } else { String message = "Unable to determine your location";
// errorCallBack(); final error = e.toString().toLowerCase();
// } if (error.contains("timeout")) {
// }); message = "Location request timed out. Please try again.";
// } else { } else if (error.contains("denied")) {
// Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { message = "Location permission denied.";
// bool isMocked = position.isMocked; } else if (error.contains("disabled")) {
// callback(position, isMocked); message = "Location services are disabled.";
// }).catchError((err) { }
// print("getCurrentPositionError:$err"); errorCallBack(message);
// errorCallBack(); }
// });
// }
// });
//
// // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// // bool isMocked = position.isMocked;
// // callback(position, isMocked);
// // }).catchError((err) {
// // print("getCurrentPositionError:$err");
// // errorCallBack();
// // });
//
// // locationFun((granted) {
// // if (granted) {
// // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) {
// // done(value);
// // }).catchError((err) {
// // print("getCurrentPositionError:$err");
// // errorCallBack();
// // });
// // } else {
// // // AppPermissions
// // }
// // }, context);
} }
// static void getCurrentLocation(Function(Position position, bool isMocked) callback, Function errorCallBack, BuildContext context) {
// Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// bool isMocked = position.isMocked;
// callback(position, isMocked);
// }).catchError((err) {
// errorCallBack();
// });
// // return;
// // Permission.location.isGranted.then((isGranted) {
// // if (!isGranted) {
// // Permission.location.request().then((granted) {
// // print("granted:$granted");
// // if (granted == PermissionStatus.granted) {
// // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// // bool isMocked = position.isMocked;
// // callback(position, isMocked);
// // }).catchError((err) {
// // print("getCurrentPositionError:$err");
// // errorCallBack();
// // });
// // } else {
// // errorCallBack();
// // }
// // });
// // } else {
// // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// // bool isMocked = position.isMocked;
// // callback(position, isMocked);
// // }).catchError((err) {
// // print("getCurrentPositionError:$err");
// // errorCallBack();
// // });
// // }
// // });
// //
// // // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// // // bool isMocked = position.isMocked;
// // // callback(position, isMocked);
// // // }).catchError((err) {
// // // print("getCurrentPositionError:$err");
// // // errorCallBack();
// // // });
// //
// // // locationFun((granted) {
// // // if (granted) {
// // // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) {
// // // done(value);
// // // }).catchError((err) {
// // // print("getCurrentPositionError:$err");
// // // errorCallBack();
// // // });
// // // } else {
// // // // AppPermissions
// // // }
// // // }, context);
// }
} }

@ -40,7 +40,7 @@ class SwipeGeneralUtils {
static bool get isLoading => _isLoadingVisible; static bool get isLoading => _isLoadingVisible;
void markFakeAttendance(dynamic sourceName, String lat, String long, @required BuildContext context) async { void markFakeAttendance(dynamic sourceName, String lat, String long, {required BuildContext context}) async {
showLoading(context); showLoading(context);
try { try {
hideLoading(navigatorKey.currentState!.overlay!.context); hideLoading(navigatorKey.currentState!.overlay!.context);
@ -114,20 +114,33 @@ class SwipeGeneralUtils {
} }
Widget attendanceTypeCard(String title, String icon, bool isEnabled, VoidCallback onPress, BuildContext context) { Widget attendanceTypeCard(String title, String icon, bool isEnabled, VoidCallback onPress, BuildContext context) {
return Container( return Container(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isEnabled ?context.isDark ? AppColor.neutral60 : Colors.white : AppColor.background(context), color: isEnabled
? context.isDark
? AppColor.neutral60
: Colors.white
: AppColor.background(context),
borderRadius: BorderRadius.circular(18), borderRadius: BorderRadius.circular(18),
border: Border.all(color:context.isDark ? AppColor.neutral60 : Colors.white70 , width: 2), border: Border.all(color: context.isDark ? AppColor.neutral60 : Colors.white70, width: 2),
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
icon.toSvgAsset(color: isEnabled ?context.isDark ? AppColor.neutral30 : AppColor.neutral50 : Colors.grey.withOpacity(0.5)), icon.toSvgAsset(
title.heading5(context).custom(color: isEnabled ?context.isDark ? AppColor.neutral30 : AppColor.neutral50 : Colors.grey.withOpacity(0.5)), color: isEnabled
? context.isDark
? AppColor.neutral30
: AppColor.neutral50
: Colors.grey.withOpacity(0.5)),
title.heading5(context).custom(
color: isEnabled
? context.isDark
? AppColor.neutral30
: AppColor.neutral50
: Colors.grey.withOpacity(0.5)),
], ],
), ),
).onPress( ).onPress(
@ -336,50 +349,128 @@ class SwipeGeneralUtils {
} }
} }
void handleSwipe({required SwipeTypeEnum swipeType, required bool isEnable, required BuildContext context}) async { Future<void> handleSwipe({
if (Platform.isAndroid && !(await isGoogleServicesAvailable())) { required SwipeTypeEnum swipeType,
checkHuaweiLocationPermission(attendanceType: swipeType, context: context); required bool isEnable,
} else { required BuildContext context,
LocationUtilities.isEnabled((bool isEnabled) { }) async {
if (isEnabled) { try {
LocationUtilities.havePermission((bool permission) { if (Platform.isAndroid && !(await isGoogleServicesAvailable())) {
if (permission) { checkHuaweiLocationPermission(
showLoading(context); attendanceType: swipeType,
LocationUtilities.getCurrentLocation( context: context,
(Position position, bool isMocked) { );
if (isMocked) { return;
hideLoading(context); }
markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context); // Check if location is enabled
} else { final isEnabled = await LocationUtilities.isEnabledAsync();
hideLoading(context); if (!isEnabled) {
handleSwipeOperation(swipeType: swipeType, lat: position.latitude, long: position.longitude, context: context); showInfoDialog(
} message: "You need to enable location services to mark attendance",
}, onTap: () async => await Geolocator.openLocationSettings(),
() { );
hideLoading(context); return;
confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working."); }
},
context, // Check permission
); final hasPermission = await LocationUtilities.havePermissionAsync();
} else { if (!hasPermission) {
showInfoDialog( showInfoDialog(
message: "You need to give location permission to mark attendance", message: "You need to give location permission to mark attendance",
onTap: () async { onTap: () async => await Geolocator.openAppSettings(),
await Geolocator.openAppSettings(); );
}); return;
} }
});
} else { // Show loader
showInfoDialog( showLoading(context);
message: "You need to enable location services to mark attendance",
onTap: () async { // Get location
await Geolocator.openLocationSettings(); await LocationUtilities.getCurrentLocation(
}); (Position position, bool isMocked) {
} hideLoading(context);
});
if (isMocked) {
markFakeAttendance(
swipeType.name,
position.latitude.toString(),
position.longitude.toString(),
context: context,
);
} else {
handleSwipeOperation(
swipeType: swipeType,
lat: position.latitude,
long: position.longitude,
context: context,
);
}
},
(String error) {
hideLoading(context);
confirmDialog(
context,
error.isNotEmpty ? error : "Unable to determine your location. Please try again.",
);
},
context,
);
} catch (e) {
hideLoading(context);
confirmDialog(
context,
"Something went wrong. Please try again.",
);
debugPrint("❌ handleSwipe error: $e");
} }
} }
//older code..
// void handleSwipe({required SwipeTypeEnum swipeType, required bool isEnable, required BuildContext context}) async {
// if (Platform.isAndroid && !(await isGoogleServicesAvailable())) {
// checkHuaweiLocationPermission(attendanceType: swipeType, context: context);
// } else {
// LocationUtilities.isEnabled((bool isEnabled) {
// if (isEnabled) {
// LocationUtilities.havePermission((bool permission) {
// if (permission) {
// showLoading(context);
// LocationUtilities.getCurrentLocation(
// (Position position, bool isMocked) {
// if (isMocked) {
// hideLoading(context);
// markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context);
// } else {
// hideLoading(context);
// handleSwipeOperation(swipeType: swipeType, lat: position.latitude, long: position.longitude, context: context);
// }
// },
// () {
// hideLoading(context);
// confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
// },
// context,
// );
// } else {
// showInfoDialog(
// message: "You need to give location permission to mark attendance",
// onTap: () async {
// await Geolocator.openAppSettings();
// });
// }
// });
// } else {
// showInfoDialog(
// message: "You need to enable location services to mark attendance",
// onTap: () async {
// await Geolocator.openLocationSettings();
// });
// }
// });
// }
// }
void showInfoDialog({required String message, VoidCallback? onTap}) { void showInfoDialog({required String message, VoidCallback? onTap}) {
showDialog( showDialog(
context: navigatorKey.currentState!.overlay!.context, context: navigatorKey.currentState!.overlay!.context,
@ -434,16 +525,15 @@ class SwipeGeneralUtils {
), ),
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
clipBehavior: Clip.antiAliasWithSaveLayer, clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (BuildContext context) =>Padding( builder: (BuildContext context) => Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom + bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom,
MediaQuery.of(context).padding.bottom,
), ),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
context.translation.markAttendance.heading4(context).custom(color:context.isDark?AppColor.white50: AppColor.white936), context.translation.markAttendance.heading4(context).custom(color: context.isDark ? AppColor.white50 : AppColor.white936),
8.height, 8.height,
context.translation.selectMethodToMarkAttendance.bodyText2(context).custom(color: AppColor.neutral120), context.translation.selectMethodToMarkAttendance.bodyText2(context).custom(color: AppColor.neutral120),
12.height, 12.height,
@ -469,45 +559,45 @@ class SwipeGeneralUtils {
NfcManager.instance.startSession( NfcManager.instance.startSession(
onDiscovered: (NfcTag tag) async { onDiscovered: (NfcTag tag) async {
String identifier = ''; String identifier = '';
try { try {
if (Platform.isAndroid) { if (Platform.isAndroid) {
// Try NfcA first (most common) // Try NfcA first (most common)
final nfcA = NfcAAndroid.from(tag); final nfcA = NfcAAndroid.from(tag);
if (nfcA != null) { if (nfcA != null) {
identifier = nfcA.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = nfcA.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
} else { } else {
// Fallback to NfcB // Fallback to NfcB
final nfcB = NfcBAndroid.from(tag); final nfcB = NfcBAndroid.from(tag);
if (nfcB != null) { if (nfcB != null) {
identifier = nfcB.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = nfcB.tag.id.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
}
} }
}
} else {
// For iOS, try MiFare first
final mifare = MiFareIos.from(tag);
if (mifare != null) {
identifier = mifare.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
} else { } else {
// Fallback to Iso15693 for iOS // For iOS, try MiFare first
final iso15693 = Iso15693Ios.from(tag); final mifare = MiFareIos.from(tag);
if (iso15693 != null) { if (mifare != null) {
identifier = iso15693.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = mifare.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
} else {
// Fallback to Iso15693 for iOS
final iso15693 = Iso15693Ios.from(tag);
if (iso15693 != null) {
identifier = iso15693.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
}
} }
} }
} catch (e) {
print('Error reading NFC: $e');
} }
} catch (e) {
print('Error reading NFC: $e');
}
try { try {
await NfcManager.instance.stopSession(); await NfcManager.instance.stopSession();
} catch (e) { } catch (e) {
print('Error stopping NFC session: $e'); print('Error stopping NFC session: $e');
} }
onRead!(identifier); onRead!(identifier);
}, },
pollingOptions: {NfcPollingOption.iso14443}, pollingOptions: {NfcPollingOption.iso14443},
).catchError((err) { ).catchError((err) {
print('NFC session error: $err'); print('NFC session error: $err');

@ -44,90 +44,85 @@ class _UpdateUserContactInfoBottomSheetState extends State<UpdateUserContactInfo
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Column(
padding: EdgeInsets.only( crossAxisAlignment: CrossAxisAlignment.start,
bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom, mainAxisSize: MainAxisSize.min,
), children: [
child: Column( AppTextFormField(
crossAxisAlignment: CrossAxisAlignment.start, labelText: "Email",
mainAxisSize: MainAxisSize.min, backgroundColor: AppColor.fieldBgColor(context),
children: [ initialValue: widget.uEmail,
AppTextFormField( textAlign: TextAlign.center,
labelText: "Email", hintText: "email@example.com",
backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle,
initialValue: widget.uEmail, hintStyle: AppTextStyles.textFieldLabelStyle,
textAlign: TextAlign.center, textInputType: TextInputType.emailAddress,
hintText: "email@example.com", showShadow: false,
labelStyle: AppTextStyles.textFieldLabelStyle, onChange: (value) {
hintStyle: AppTextStyles.textFieldLabelStyle, email = value;
textInputType: TextInputType.emailAddress, },
showShadow: false, style: Theme.of(context).textTheme.titleMedium,
onChange: (value) { ),
email = value; 12.height,
}, AppTextFormField(
style: Theme.of(context).textTheme.titleMedium, labelText: "Phone Number",
), backgroundColor: AppColor.fieldBgColor(context),
12.height, initialValue: widget.uPhoneNo,
AppTextFormField( textAlign: TextAlign.center,
labelText: "Phone Number", hintText: "05xxxxxxxx",
backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle,
initialValue: widget.uPhoneNo, hintStyle: AppTextStyles.textFieldLabelStyle,
textAlign: TextAlign.center, textInputType: TextInputType.phone,
hintText: "05xxxxxxxx", showShadow: false,
labelStyle: AppTextStyles.textFieldLabelStyle, onChange: (value) {
hintStyle: AppTextStyles.textFieldLabelStyle, phoneNo = value;
textInputType: TextInputType.phone, },
showShadow: false, style: Theme.of(context).textTheme.titleMedium,
onChange: (value) { ),
phoneNo = value; 12.height,
}, AppTextFormField(
style: Theme.of(context).textTheme.titleMedium, labelText: "Extension No",
), backgroundColor: AppColor.fieldBgColor(context),
12.height, initialValue: widget.uExtensionNo,
AppTextFormField( textAlign: TextAlign.center,
labelText: "Extension No", hintText: "1234",
backgroundColor: AppColor.fieldBgColor(context), labelStyle: AppTextStyles.textFieldLabelStyle,
initialValue: widget.uExtensionNo, hintStyle: AppTextStyles.textFieldLabelStyle,
textAlign: TextAlign.center, textInputType: const TextInputType.numberWithOptions(decimal: true),
hintText: "1234", showShadow: false,
labelStyle: AppTextStyles.textFieldLabelStyle, onChange: (value) {
hintStyle: AppTextStyles.textFieldLabelStyle, extensionNo = value;
textInputType: const TextInputType.numberWithOptions(decimal: true), },
showShadow: false, style: Theme.of(context).textTheme.titleMedium,
onChange: (value) { ),
extensionNo = value; 12.height,
}, AppFilledButton(
style: Theme.of(context).textTheme.titleMedium, label: "Update",
), buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50,
12.height, onPressed: () async {
AppFilledButton( FocusManager.instance.primaryFocus!.unfocus();
label: "Update", if (email.isEmpty || !Validator.isEmail(email)) {
buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50, "Please enter valid email".showToast;
onPressed: () async { return;
FocusManager.instance.primaryFocus!.unfocus(); }
if (email.isEmpty || !Validator.isEmail(email)) { if (phoneNo.isEmpty || phoneNo.length != 10) {
"Please enter valid email".showToast; "Please enter valid phone number".showToast;
return; return;
} }
if (phoneNo.isEmpty || phoneNo.length != 10) { if (extensionNo.isEmpty) {
"Please enter valid phone number".showToast; "Please enter extension".showToast;
return; return;
} }
if (extensionNo.isEmpty) { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
"Please enter extension".showToast; bool status = await context.userProvider.updateContactInfo(widget.userID, email, phoneNo, extensionNo);
return; Navigator.pop(context);
} if (status) {
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
bool status = await context.userProvider.updateContactInfo(widget.userID, email, phoneNo, extensionNo);
Navigator.pop(context); Navigator.pop(context);
if (status) { widget.onUpdate(email, phoneNo, extensionNo);
Navigator.pop(context); }
widget.onUpdate(email, phoneNo, extensionNo); },
} ),
}, ],
),
],
),
); );
} }
} }

Loading…
Cancel
Save