huawei swipe fixes

main_design2.1
WaseemAbbasi22 1 year ago
parent 8600867322
commit 97fefd8423

@ -57,6 +57,7 @@ class ApiManager {
Future<http.Response> post(
String url, {
Map<String, String> headers,
bool showToast = true,
@required Map<String, dynamic> body,
}) async {
headers ??= {};
@ -80,12 +81,15 @@ class ApiManager {
if (response.statusCode == 401) {
showLoginDialog();
} else {
if (jsonDecode(response.body) is Map<String, dynamic>) {
final message = jsonDecode(response.body)["message"];
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
if(showToast){
if (jsonDecode(response.body) is Map<String, dynamic>) {
final message = jsonDecode(response.body)["message"];
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
}
}
}
}
} catch (ex) {}

@ -193,7 +193,7 @@ class UserProvider extends ChangeNotifier {
notifyListeners();
Response response;
try {
response = await ApiManager.instance.post(URLs.swipeUrl, body: model.toJson());
response = await ApiManager.instance.post(URLs.swipeUrl, body: model.toJson(),showToast: false);
swipeResponse = SwipeModel.fromJson(json.decode(response.body));
if (response.statusCode >= 200 && response.statusCode < 300) {
isUserConfirmSwipe = true;

@ -157,7 +157,7 @@ class SwipeGeneralUtils {
(Location location) async {
hideLoading(context);
await locationService.removeLocationUpdates(requestCode);
handleSwipeOperation(swipeType: attendanceType, context: context);
handleSwipeOperation(swipeType: attendanceType, context: context,lat:location.latitude ,long:location.longitude );
requestCode = 0;
},
);
@ -234,13 +234,13 @@ class SwipeGeneralUtils {
// }
}
void handleSwipeOperation({@required SwipeTypeEnum swipeType, double lat, double lang, BuildContext context}) {
void handleSwipeOperation({@required SwipeTypeEnum swipeType, double lat, double long, BuildContext context}) {
switch (swipeType) {
case SwipeTypeEnum.NFC:
handleNfcAttendance(latitude: lat, longitude: lang, context: context);
handleNfcAttendance(latitude: lat, longitude: long, context: context);
return;
case SwipeTypeEnum.QR:
performQrCodeAttendance(latitude: lat, longitude: lang, context: context);
performQrCodeAttendance(latitude: lat, longitude: long, context: context);
return;
case SwipeTypeEnum.Wifi:
//TODO need to implement.
@ -333,6 +333,7 @@ class SwipeGeneralUtils {
final swipeResponse = await userProvider.makeSwipe(model: swipeModel);
if (swipeResponse.isSuccess) {
hideLoading(context);
Navigator.pushNamed(context, SwipeSuccessView.routeName);
@ -361,7 +362,7 @@ class SwipeGeneralUtils {
markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context);
} else {
hideLoading(context);
handleSwipeOperation(swipeType: swipeType, lat: position.latitude, lang: position.longitude, context: context);
handleSwipeOperation(swipeType: swipeType, lat: position.latitude, long: position.longitude, context: context);
}
},
() {

Loading…
Cancel
Save