diff --git a/README.md b/README.md index 25af64cad145c631e7b124b8810d195ce5995141..7cef7673274fbb17de83613703c6fa1b993a6ce1 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,9 @@ samples, guidance on mobile development, and a full API reference. ## Configuration Details -* Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git -* Framework • revision 5f105a6ca7 (6 days ago) • 2022-02-01 14:15:42 -0800 -* Engine • revision 776efd2034 -* Tools • Dart 2.16.0 • DevTools 2.9.2 +* Flutter 2.10.3 • channel stable • https://github.com/flutter/flutter.git +* Framework • revision 7e9793dee1 (2 weeks ago) • 2022-03-02 11:23:12 -0600 +* Engine • revision bd539267b4 +* Tools • Dart 2.16.1 • DevTools 2.9.2 + diff --git a/android/build.gradle b/android/build.gradle index 94d72e4b887df493da4493223ca52560f1e18e54..86178971ef3bca38c4fc15129d9a9249fc5397d2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,7 +8,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.google.gms:google-services:4.3.4' + classpath 'com.google.gms:google-services:4.3.10' } } diff --git a/lib/constants/app_constants.dart b/lib/constants/app_constants.dart index e583bbd6fb57f0f50ea25ba0f9e98968f8b7bc50..6da8d2cdc4670e0bd1b28ad54d148584658c475d 100644 --- a/lib/constants/app_constants.dart +++ b/lib/constants/app_constants.dart @@ -25,6 +25,7 @@ class InspectionStatus { static const String inspectionPending = 'PENDING'; static const String returned = 'RETURNED'; static const String approved = 'APPROVED'; + static const String rejected = 'REJECTED'; } class FieldValue { diff --git a/lib/constants/color_constants.dart b/lib/constants/color_constants.dart index 8415a1e95b7458625207e0d557a8757d8e7604d1..ddcec33194b64a532bdb81a2d3ac702344d70842 100644 --- a/lib/constants/color_constants.dart +++ b/lib/constants/color_constants.dart @@ -12,4 +12,8 @@ class AppColors { static const black40 = Color.fromRGBO(0, 0, 0, 0.40); static const black60 = Color.fromRGBO(0, 0, 0, 0.60); static const black87 = Color.fromRGBO(0, 0, 0, 0.87); + static const returned = Color.fromARGB(209, 57, 36, 1); + static const sentForIns = Color.fromARGB(233, 158, 56, 1); + static const insCompleted = Color.fromRGBO(29, 137, 35, 1); + static const leadInsCompleted = Color.fromRGBO(29, 137, 35, 1); } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 102ddc8f29c8af76ed0350896738fd578053a569..d6391bbe63a68056577ff2b42241f24a9b208dc8 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -53,6 +53,7 @@ "acceptTermsAndConditions": "Please accept terms and conditions", "dataSynchoronized": "Data synchoronized", "dataSynchoronizedText": "Data has been synchoronized", - "formNotAvailable": "Form not available" - + "formNotAvailable": "Form not available", + "failedToGetUniqueIdentifier": "Failed to get Unique Identifier", + "invalidResponse": "Invalid response recieved from the server" } \ No newline at end of file diff --git a/lib/pages/application_details_page.dart b/lib/pages/application_details_page.dart index 9cc244167ab4d2c396edf0441e2514edb4a26829..e973baecd4cb1ea44fae465639dc965b27ea92a2 100644 --- a/lib/pages/application_details_page.dart +++ b/lib/pages/application_details_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'package:smf_mobile/constants/app_constants.dart'; +import 'package:smf_mobile/constants/app_urls.dart'; import 'package:smf_mobile/constants/color_constants.dart'; import 'package:smf_mobile/models/application_model.dart'; import 'package:smf_mobile/models/form_model.dart'; @@ -122,22 +123,25 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage> } Future<dynamic> _getFormDetails() async { - _formData = await Provider.of<FormRespository>(context, listen: false) - .getFormDetails(widget.application.formId); - _errorMessage = - Provider.of<FormRespository>(context, listen: false).errorMessage; - if (_errorMessage != '') { - Helper.toastMessage(_errorMessage); - } else { - for (int i = 0; i < _formData.fields.length; i++) { - if (_formData.fields[i]['fieldType'] != FieldType.heading) { - _fieldTypes[_formData.fields[i]['name']] = - _formData.fields[i]['fieldType']; - _fieldOptions[_formData.fields[i]['name']] = - _formData.fields[i]['values']; - } + try { + _formData = await Provider.of<FormRespository>(context, listen: false) + .getFormDetails(widget.application.formId); + } catch (_) { + if (mounted) { + Helper.toastMessage(AppLocalizations.of(context)!.formNotAvailable); + Navigator.popAndPushNamed(context, AppUrl.homePage); + } + } + + for (int i = 0; i < _formData.fields.length; i++) { + if (_formData.fields[i]['fieldType'] != FieldType.heading) { + _fieldTypes[_formData.fields[i]['name']] = + _formData.fields[i]['fieldType']; + _fieldOptions[_formData.fields[i]['name']] = + _formData.fields[i]['values']; } } + // print(_fieldTypes); return _fieldTypes; } @@ -296,7 +300,7 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage> _errorMessage = Provider.of<ApplicationRespository>(context, listen: false) .errorMessage; - Helper.toastMessage(_errorMessage); + Helper.toastMessage(AppLocalizations.of(context)!.invalidResponse); } } catch (err) { throw Exception(err); diff --git a/lib/pages/inspection_summary.dart b/lib/pages/inspection_summary.dart index d08836f6d202de01e5ad73486f645aaafa7e5850..2343f0258a818555caaa221e6cbff2cc1534311b 100644 --- a/lib/pages/inspection_summary.dart +++ b/lib/pages/inspection_summary.dart @@ -146,6 +146,7 @@ class _InspectionSummaryPageState extends State<InspectionSummaryPage> { final responseCode = await Provider.of<ApplicationRespository>(context, listen: false) .submitInspection(isInternetConnected, data); + // print(responseCode.toString()); if (responseCode == 200) { Navigator.of(context).pushReplacement(MaterialPageRoute( builder: (context) => const InspectionCompletedPage())); @@ -153,7 +154,7 @@ class _InspectionSummaryPageState extends State<InspectionSummaryPage> { _errorMessage = Provider.of<ApplicationRespository>(context, listen: false) .errorMessage; - Helper.toastMessage(_errorMessage); + Helper.toastMessage(AppLocalizations.of(context)!.invalidResponse); } } catch (err) { throw Exception(err); diff --git a/lib/pages/login_email_page.dart b/lib/pages/login_email_page.dart index d7691547c80a3c48fe8fd66f0cb525821c3e5378..17c2d7c997448f9ce90fd787f8eea2302708c031 100644 --- a/lib/pages/login_email_page.dart +++ b/lib/pages/login_email_page.dart @@ -68,7 +68,7 @@ class _LoginEmailPageState extends State<LoginEmailPage> { try { identifier = await UniqueIdentifier.serial; } on PlatformException { - identifier = 'Failed to get Unique Identifier'; + identifier = AppLocalizations.of(context)!.failedToGetUniqueIdentifier; } if (!mounted) return; diff --git a/lib/repositories/form_repository.dart b/lib/repositories/form_repository.dart index 6727d3e33e0035cdcde8b00a3141c87c8506b88f..bcd60d2f5cd6faf0fe87e1e3de9436983c59ea55 100644 --- a/lib/repositories/form_repository.dart +++ b/lib/repositories/form_repository.dart @@ -61,22 +61,17 @@ class FormRespository with ChangeNotifier { var rawData = await OfflineModel.getForms(username); Map formData = json.decode(rawData['form_data']); List forms = formData['responseData']; - // print('formId: $formId'); for (var form in forms) { - // print(form['id']); if (form['id'] == formId) { - // print(form.toString()); formDetails = form; } } if (formDetails['id'] == null) { - Helper.toastMessage('Form not available'); + return; } } catch (_) { return _; } - // print(formId); - // print(formDetails); if (formDetails.isNotEmpty) { _formData = FormData.fromJson(formDetails); } diff --git a/lib/util/helper.dart b/lib/util/helper.dart index dc161fae39377eb725d54ac9388a57b89f7368a9..3e4da36b10e6b27c21ff575165ca079a9fac77a7 100644 --- a/lib/util/helper.dart +++ b/lib/util/helper.dart @@ -8,6 +8,7 @@ import 'package:jwt_decoder/jwt_decoder.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:smf_mobile/constants/app_constants.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:smf_mobile/constants/color_constants.dart'; const _storage = FlutterSecureStorage(); @@ -129,4 +130,26 @@ class Helper { } return _isConnectionSuccessful; } + + static Color getColorByStatus(String inspectionStatus, String actualStatus) { + Color color; + switch (actualStatus) { + case InspectionStatus.sentForInspection: + if (inspectionStatus == InspectionStatus.leadInspectorCompleted) { + color = AppColors.insCompleted; + } else { + color = AppColors.sentForIns; + } + break; + case InspectionStatus.returned: + color = AppColors.returned; + break; + case InspectionStatus.rejected: + color = AppColors.returned; + break; + default: + color = AppColors.insCompleted; + } + return color; + } } diff --git a/lib/widgets/application_card.dart b/lib/widgets/application_card.dart index 26534f72f8b5a99f639c976e574270df2c585608..b5e34ef5930693f5d32faed1970d330106639673 100644 --- a/lib/widgets/application_card.dart +++ b/lib/widgets/application_card.dart @@ -115,7 +115,9 @@ class _ApplicationCardState extends State<ApplicationCard> { widget.application.inspectionStatus, widget.application.status)), style: GoogleFonts.lato( - color: AppColors.black60, + color: Helper.getColorByStatus( + widget.application.inspectionStatus, + widget.application.status), fontSize: 14.0, letterSpacing: 0.12, fontWeight: FontWeight.w700, diff --git a/lib/widgets/lead_inspector_dialog.dart b/lib/widgets/lead_inspector_dialog.dart index 0bec891adf4d7e77e7f725a7a33a609d4469fb4c..0f7ad6971eb3a72713892d279a74d9f1a4f341eb 100644 --- a/lib/widgets/lead_inspector_dialog.dart +++ b/lib/widgets/lead_inspector_dialog.dart @@ -67,7 +67,7 @@ class _LeadInspectorDialogState extends State<LeadInspectorDialog> { Helper.toastMessage('Please enter reason'); return; } - if (_inspectionValue == '') { + if (_inspectionValue == '' && widget.fieldType != FieldType.file) { Helper.toastMessage('Please enter actual value'); return; } diff --git a/lib/widgets/questions/text_question.dart b/lib/widgets/questions/text_question.dart index 4cc30086a5acbee241f56832d80c2d1f3c1bad04..10aae7ef36365927968e70e521564b34a638fd44 100644 --- a/lib/widgets/questions/text_question.dart +++ b/lib/widgets/questions/text_question.dart @@ -50,6 +50,10 @@ class _TextQuestionState extends State<TextQuestion> { SystemChannels.textInput.invokeMethod('TextInput.hide'); // return; }, + onChanged: (text) { + widget.parentAction(_textController.text.toString()); + // SystemChannels.textInput.invokeMethod('TextInput.hide'); + }, controller: _textController, style: GoogleFonts.lato(fontSize: 14.0), textInputAction: TextInputAction.done, diff --git a/pubspec.lock b/pubspec.lock index 16fd0f5cf060966515d8fbf24935ea691783fb7a..1e10ec0db7a43659f067c773ae4b3ddf4a7d1058 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -175,35 +175,35 @@ packages: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.2.4" + version: "4.2.5" firebase_core_web: dependency: transitive description: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "1.5.4" + version: "1.6.1" firebase_messaging: dependency: "direct main" description: name: firebase_messaging url: "https://pub.dartlang.org" source: hosted - version: "11.2.6" + version: "11.2.11" firebase_messaging_platform_interface: dependency: transitive description: name: firebase_messaging_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.1.6" + version: "3.2.1" firebase_messaging_web: dependency: transitive description: name: firebase_messaging_web url: "https://pub.dartlang.org" source: hosted - version: "2.2.7" + version: "2.2.9" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index cbe066e9d1b6e3f6b7d42315c207279ae3a662cf..6bf454c66bc81188c6a1524dc0f2643af84cf4de 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,7 +44,7 @@ dependencies: fluttertoast: ^8.0.8 jwt_decoder: ^2.0.1 intl: ^0.17.0 - firebase_messaging: ^11.0.0 + firebase_messaging: ^11.2.11 firebase_core: ^1.12.0 flutter_local_notifications: ^9.3.2 unique_identifier: ^0.2.2