diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 8132310..a4e1203 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -6,13 +6,13 @@ PODS: - Flutter DEPENDENCIES: - - Flutter (from `.symlinks/flutter/ios-profile`) + - Flutter (from `.symlinks/flutter/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) EXTERNAL SOURCES: Flutter: - :path: ".symlinks/flutter/ios-profile" + :path: ".symlinks/flutter/ios" shared_preferences: :path: ".symlinks/plugins/shared_preferences/ios" url_launcher: diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a0f8e33..5b4844c 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -281,7 +281,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios-profile/Flutter.framework", + "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( diff --git a/lib/common/apifunctions/request_login_api.dart b/lib/common/apifunctions/request_login_api.dart index 27d3bdc..9cdc0ef 100644 --- a/lib/common/apifunctions/request_login_api.dart +++ b/lib/common/apifunctions/request_login_api.dart @@ -7,14 +7,14 @@ import 'package:local_spend/common/functions/save_current_login.dart'; import 'package:local_spend/common/functions/show_dialog_single_button.dart'; import 'package:local_spend/model/json/login_model.dart'; -Future _incorrectDialog(BuildContext context) async { +Future _incorrectDialog(BuildContext context, bool isLoginWrong) async { return showDialog( context: context, barrierDismissible: true, builder: (BuildContext context) { return AlertDialog( title: Text("Unable to Login"), - content: Text("Incorrect login details. Please try again."), + content: Text(isLoginWrong ? "Incorrect login details. Please try again." : "The server is having issues; sorry for the inconvenience. Please try again later."), actions: [ FlatButton( child: Text('OK'), @@ -40,30 +40,30 @@ Future requestLoginAPI( // debugPrint('$body'); - final response = await http.post( - url, - body: json.encode(body), - ); + try { + final response = await http.post( + url, + body: json.encode(body), + ); -// debugPrint(response.body); + if (response.statusCode == 200) { + final responseJson = json.decode(response.body); - if (response.statusCode == 200) { - final responseJson = json.decode(response.body); - var user = new LoginModel.fromJson(responseJson); + saveCurrentLogin(responseJson, body["email"]); + Navigator.of(context).pushReplacementNamed('/HomePage'); - saveCurrentLogin(responseJson, body["email"]); - Navigator.of(context).pushReplacementNamed('/HomePage'); + return LoginModel.fromJson(responseJson); + } else { + final responseJson = json.decode(response.body); - return LoginModel.fromJson(responseJson); - } else { -// debugPrint("Invalid, either credentials are wrong or server is down"); + saveCurrentLogin(responseJson, body["email"]); - final responseJson = json.decode(response.body); + _incorrectDialog(context, true); - saveCurrentLogin(responseJson, body["email"]); - - _incorrectDialog(context); - - return null; + return null; + } + } catch (_) { + _incorrectDialog(context, false); } } +