Compare commits

..

No commits in common. '01a35adebc5f48f5df7d759f49b9d19e6544f74a' and 'a472fa773ccf5dd7387ab62ca896e0175b8b4523' have entirely different histories.

@ -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 {
// For iOS, try MiFare first // Fallback to Iso15693 for iOS
final mifare = MiFareIos.from(tag); final iso15693 = Iso15693Ios.from(tag);
if (mifare != null) { if (iso15693 != null) {
identifier = mifare.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = iso15693.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,18 +138,22 @@ class _NfcLayoutState extends State<NfcLayout> {
Widget scanNfc() { Widget scanNfc() {
return Container( return Container(
color: AppColor.background(context), color: AppColor.background(context),
key: const ValueKey(1), key: ValueKey(1),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
Text( Text(
"Ready To Scan", "Ready To Scan",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24, color: AppColor.headingTextColor(context)), style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 24,
color:AppColor.headingTextColor(context)
),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
Image.asset( Image.asset(
@ -192,7 +196,7 @@ class _NfcLayoutState extends State<NfcLayout> {
child: const Text("CANCEL"), child: const Text("CANCEL"),
), ),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
], ],
@ -207,14 +211,18 @@ class _NfcLayoutState extends State<NfcLayout> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
Text( Text(
"Successfully Scanned", "Successfully Scanned",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24, color: AppColor.headingTextColor(context)), style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 24,
color:AppColor.headingTextColor(context)
),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
Image.asset( Image.asset(
@ -224,16 +232,16 @@ class _NfcLayoutState extends State<NfcLayout> {
width: double.infinity, width: double.infinity,
color: AppColor.iconColor(context), color: AppColor.iconColor(context),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
const Text( Text(
"Approach an NFC Tag", "Approach an NFC Tag",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
), ),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
ButtonTheme( ButtonTheme(
@ -251,13 +259,10 @@ class _NfcLayoutState extends State<NfcLayout> {
// }, // },
onPressed: null, onPressed: null,
// elevation: 0, // elevation: 0,
child: Text( child: Text("DONE",style: TextStyle(color: context.isDark?AppColor.primary10:null),),
"DONE",
style: TextStyle(color: context.isDark ? AppColor.primary10 : null),
),
), ),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
], ],

@ -20,21 +20,6 @@ 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 {
@ -59,100 +44,61 @@ 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...");
try { static void getCurrentLocation(Function(Position position, bool isMocked) callback, Function errorCallBack, BuildContext context) {
final position = await Geolocator.getCurrentPosition( Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
desiredAccuracy: LocationAccuracy.high, bool isMocked = position.isMocked;
timeLimit: const Duration(seconds: 10), callback(position, isMocked);
); }).catchError((err) {
debugPrint("✅ Location: ${position.latitude}, ${position.longitude}"); errorCallBack();
});
callback(position, position.isMocked); // return;
} catch (e) { // Permission.location.isGranted.then((isGranted) {
debugPrint("❌ Primary location failed: $e"); // if (!isGranted) {
try { // Permission.location.request().then((granted) {
final lastPosition = await Geolocator.getLastKnownPosition(); // print("granted:$granted");
if (lastPosition != null) { // if (granted == PermissionStatus.granted) {
debugPrint("⚠️ Using last known location"); // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
callback(lastPosition, lastPosition.isMocked); // bool isMocked = position.isMocked;
return; // callback(position, isMocked);
} // }).catchError((err) {
} catch (fallbackError) { // print("getCurrentPositionError:$err");
debugPrint("❌ Fallback failed: $fallbackError"); // errorCallBack();
} // });
String message = "Unable to determine your location"; // } else {
final error = e.toString().toLowerCase(); // errorCallBack();
if (error.contains("timeout")) { // }
message = "Location request timed out. Please try again."; // });
} else if (error.contains("denied")) { // } else {
message = "Location permission denied."; // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
} else if (error.contains("disabled")) { // bool isMocked = position.isMocked;
message = "Location services are disabled."; // callback(position, isMocked);
} // }).catchError((err) {
errorCallBack(message); // 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);
} }
// 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,33 +114,20 @@ 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 color: isEnabled ?context.isDark ? AppColor.neutral60 : Colors.white : AppColor.background(context),
? 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( icon.toSvgAsset(color: isEnabled ?context.isDark ? AppColor.neutral30 : AppColor.neutral50 : Colors.grey.withOpacity(0.5)),
color: isEnabled title.heading5(context).custom(color: isEnabled ?context.isDark ? AppColor.neutral30 : AppColor.neutral50 : Colors.grey.withOpacity(0.5)),
? 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(
@ -349,128 +336,50 @@ class SwipeGeneralUtils {
} }
} }
Future<void> handleSwipe({ void handleSwipe({required SwipeTypeEnum swipeType, required bool isEnable, required BuildContext context}) async {
required SwipeTypeEnum swipeType, if (Platform.isAndroid && !(await isGoogleServicesAvailable())) {
required bool isEnable, checkHuaweiLocationPermission(attendanceType: swipeType, context: context);
required BuildContext context, } else {
}) async { LocationUtilities.isEnabled((bool isEnabled) {
try { if (isEnabled) {
if (Platform.isAndroid && !(await isGoogleServicesAvailable())) { LocationUtilities.havePermission((bool permission) {
checkHuaweiLocationPermission( if (permission) {
attendanceType: swipeType, showLoading(context);
context: context, LocationUtilities.getCurrentLocation(
); (Position position, bool isMocked) {
return; if (isMocked) {
} hideLoading(context);
// Check if location is enabled markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context);
final isEnabled = await LocationUtilities.isEnabledAsync(); } else {
if (!isEnabled) { hideLoading(context);
showInfoDialog( handleSwipeOperation(swipeType: swipeType, lat: position.latitude, long: position.longitude, context: context);
message: "You need to enable location services to mark attendance", }
onTap: () async => await Geolocator.openLocationSettings(), },
); () {
return; hideLoading(context);
} confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
},
// Check permission context,
final hasPermission = await LocationUtilities.havePermissionAsync(); );
if (!hasPermission) { } else {
showInfoDialog( showInfoDialog(
message: "You need to give location permission to mark attendance", message: "You need to give location permission to mark attendance",
onTap: () async => await Geolocator.openAppSettings(), onTap: () async {
); await Geolocator.openAppSettings();
return; });
} }
});
// Show loader } else {
showLoading(context); showInfoDialog(
message: "You need to enable location services to mark attendance",
// Get location onTap: () async {
await LocationUtilities.getCurrentLocation( await Geolocator.openLocationSettings();
(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,
@ -525,15 +434,16 @@ 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 + MediaQuery.of(context).padding.bottom, bottom: MediaQuery.of(context).viewInsets.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,
@ -559,45 +469,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 {
// For iOS, try MiFare first // Fallback to Iso15693 for iOS
final mifare = MiFareIos.from(tag); final iso15693 = Iso15693Ios.from(tag);
if (mifare != null) { if (iso15693 != null) {
identifier = mifare.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); identifier = iso15693.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,85 +44,90 @@ class _UpdateUserContactInfoBottomSheetState extends State<UpdateUserContactInfo
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Padding(
crossAxisAlignment: CrossAxisAlignment.start, padding: EdgeInsets.only(
mainAxisSize: MainAxisSize.min, bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom,
children: [ ),
AppTextFormField( child: Column(
labelText: "Email", crossAxisAlignment: CrossAxisAlignment.start,
backgroundColor: AppColor.fieldBgColor(context), mainAxisSize: MainAxisSize.min,
initialValue: widget.uEmail, children: [
textAlign: TextAlign.center, AppTextFormField(
hintText: "email@example.com", labelText: "Email",
labelStyle: AppTextStyles.textFieldLabelStyle, backgroundColor: AppColor.fieldBgColor(context),
hintStyle: AppTextStyles.textFieldLabelStyle, initialValue: widget.uEmail,
textInputType: TextInputType.emailAddress, textAlign: TextAlign.center,
showShadow: false, hintText: "email@example.com",
onChange: (value) { labelStyle: AppTextStyles.textFieldLabelStyle,
email = value; hintStyle: AppTextStyles.textFieldLabelStyle,
}, textInputType: TextInputType.emailAddress,
style: Theme.of(context).textTheme.titleMedium, showShadow: false,
), onChange: (value) {
12.height, email = value;
AppTextFormField( },
labelText: "Phone Number", style: Theme.of(context).textTheme.titleMedium,
backgroundColor: AppColor.fieldBgColor(context), ),
initialValue: widget.uPhoneNo, 12.height,
textAlign: TextAlign.center, AppTextFormField(
hintText: "05xxxxxxxx", labelText: "Phone Number",
labelStyle: AppTextStyles.textFieldLabelStyle, backgroundColor: AppColor.fieldBgColor(context),
hintStyle: AppTextStyles.textFieldLabelStyle, initialValue: widget.uPhoneNo,
textInputType: TextInputType.phone, textAlign: TextAlign.center,
showShadow: false, hintText: "05xxxxxxxx",
onChange: (value) { labelStyle: AppTextStyles.textFieldLabelStyle,
phoneNo = value; hintStyle: AppTextStyles.textFieldLabelStyle,
}, textInputType: TextInputType.phone,
style: Theme.of(context).textTheme.titleMedium, showShadow: false,
), onChange: (value) {
12.height, phoneNo = value;
AppTextFormField( },
labelText: "Extension No", style: Theme.of(context).textTheme.titleMedium,
backgroundColor: AppColor.fieldBgColor(context), ),
initialValue: widget.uExtensionNo, 12.height,
textAlign: TextAlign.center, AppTextFormField(
hintText: "1234", labelText: "Extension No",
labelStyle: AppTextStyles.textFieldLabelStyle, backgroundColor: AppColor.fieldBgColor(context),
hintStyle: AppTextStyles.textFieldLabelStyle, initialValue: widget.uExtensionNo,
textInputType: const TextInputType.numberWithOptions(decimal: true), textAlign: TextAlign.center,
showShadow: false, hintText: "1234",
onChange: (value) { labelStyle: AppTextStyles.textFieldLabelStyle,
extensionNo = value; hintStyle: AppTextStyles.textFieldLabelStyle,
}, textInputType: const TextInputType.numberWithOptions(decimal: true),
style: Theme.of(context).textTheme.titleMedium, showShadow: false,
), onChange: (value) {
12.height, extensionNo = value;
AppFilledButton( },
label: "Update", style: Theme.of(context).textTheme.titleMedium,
buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50, ),
onPressed: () async { 12.height,
FocusManager.instance.primaryFocus!.unfocus(); AppFilledButton(
if (email.isEmpty || !Validator.isEmail(email)) { label: "Update",
"Please enter valid email".showToast; buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50,
return; onPressed: () async {
} FocusManager.instance.primaryFocus!.unfocus();
if (phoneNo.isEmpty || phoneNo.length != 10) { if (email.isEmpty || !Validator.isEmail(email)) {
"Please enter valid phone number".showToast; "Please enter valid email".showToast;
return; return;
} }
if (extensionNo.isEmpty) { if (phoneNo.isEmpty || phoneNo.length != 10) {
"Please enter extension".showToast; "Please enter valid phone number".showToast;
return; return;
} }
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); if (extensionNo.isEmpty) {
bool status = await context.userProvider.updateContactInfo(widget.userID, email, phoneNo, extensionNo); "Please enter extension".showToast;
Navigator.pop(context); return;
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);
widget.onUpdate(email, phoneNo, extensionNo); if (status) {
} Navigator.pop(context);
}, widget.onUpdate(email, phoneNo, extensionNo);
), }
], },
),
],
),
); );
} }
} }

Loading…
Cancel
Save