From b7d08e858cf5ed452998fcc4b136b988c78d20ce Mon Sep 17 00:00:00 2001 From: snehalathad Date: Mon, 8 Apr 2024 17:30:54 +0530 Subject: [PATCH] feat:offline sync , other changes and extension fixes --- assets/images/newconfigdata.json | 2 +- ios/Podfile.lock | 6 +- ios/Runner/Base.lproj/Main.storyboard | 13 +- ios/Runner/Info.plist | 3 + lib/main.dart | 73 +++--- lib/model/interaction_config_data.dart | 2 +- lib/model/interaction_data.dart | 1 - lib/model/save_interaction.dart | 1 - lib/openid/openid_screen.dart | 3 +- lib/repository/hive_repository.dart | 1 - lib/utils/constants.dart | 2 +- lib/utils/fileupload.dart | 2 +- lib/utils/mockapi.dart | 25 +- lib/utils/repository.dart | 13 + lib/utils/util.dart | 34 +++ lib/viewmodel/configprovider.dart | 53 ++-- lib/viewmodel/interactionprovider.dart | 38 +-- lib/viewmodel/loginprovider.dart | 1 - lib/viewmodel/viewinteractionprovider.dart | 33 ++- lib/views/home_screen.dart | 36 ++- .../edit_interaction_screen.dart | 65 ++--- .../interaction_screen.dart | 88 ++++--- .../interactionlistscreen.dart | 49 ++-- .../interaction_module/view_forms_list.dart | 10 +- .../view_interaction_screen.dart | 45 ++-- lib/views/konectarpage.dart | 24 +- lib/views/login.dart | 17 +- lib/views/notification_screen.dart | 17 +- lib/views/notifications.dart | 51 ++-- lib/views/profile.dart | 94 +++---- lib/views/webview_example.dart | 1 - lib/widgets/custombutton.dart | 1 - lib/widgets/customrangeslider.dart | 22 +- lib/widgets/customwidgets.dart | 15 ++ lib/widgets/interatciontextfield.dart | 2 +- macos/Flutter/GeneratedPluginRegistrant.swift | 2 +- macos/Podfile.lock | 2 +- macos/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- pubspec.lock | 232 ++++++++++++------ pubspec.yaml | 2 +- test/widget_test.dart | 1 - 42 files changed, 644 insertions(+), 442 deletions(-) create mode 100644 lib/utils/repository.dart create mode 100644 lib/widgets/customwidgets.dart diff --git a/assets/images/newconfigdata.json b/assets/images/newconfigdata.json index 0f84124..b76abe1 100644 --- a/assets/images/newconfigdata.json +++ b/assets/images/newconfigdata.json @@ -359,7 +359,7 @@ "id": "otherpostal_14", "depid": "", "widget": "text", - "input": "Hubli", + "input": "number", "validation": { "isRequired": true diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e617c0e..8f3924b 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -120,13 +120,13 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: asset_webview: 6ea3e602c34e111b4d808f8c09b8d31fbe5c27e4 - connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e + connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - flutter_inappwebview: 50b55a88f5dddadc9e741a7caf72f378116e2156 + flutter_inappwebview: 0fd654db805825eae42bd8ee7c428890cdaf7ff1 image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7 @@ -140,4 +140,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 108feb553cebadca4bc232556afce4dd4c21da4c -COCOAPODS: 1.12.1 +COCOAPODS: 1.14.3 diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard index f3c2851..fd0a013 100644 --- a/ios/Runner/Base.lproj/Main.storyboard +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -1,8 +1,10 @@ - - + + + - + + @@ -14,13 +16,14 @@ - + - + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 0e21ab3..88cdbcb 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -64,5 +64,8 @@ UIFileSharingEnabled + FLTEnableImpeller + + diff --git a/lib/main.dart b/lib/main.dart index 788a21e..ef40df2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,14 +1,10 @@ import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:pwa_ios/model/interaction_config_data.dart'; import 'package:pwa_ios/model/interaction_data.dart'; @@ -29,7 +25,6 @@ import 'package:pwa_ios/views/home_screen.dart'; import 'package:pwa_ios/views/konectarpage.dart'; import 'package:pwa_ios/views/login.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:openid_client/openid_client.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; @@ -92,9 +87,8 @@ Future main() async { Hive.registerAdapter(MultipleSectionListAdapter()); Hive.registerAdapter(SaveAdapter()); Hive.registerAdapter(SaveInteractionFormJsonAdapter()); - // await Hive.openBox('InteractionDataBox'); - // await Hive.openBox("UserDataBox"); - //await Hive.openBox('InteractionConfigDataBox'); + await Hive.openBox('InteractionDataBox'); + await Hive.openBox("UserDataBox"); await Hive.openBox('InteractionConfigDataBox'); // final ConfigDataProvider configDataProvider = ConfigDataProvider(); @@ -109,11 +103,10 @@ Future main() async { // print(json.toString()); // await MockApiCall().postFormData(json).then((value) async { // await configDataProvider.initConfigUIData().then((value) { - // // activateTimer(); + activateTimer(); // }); // }); - await configDataProvider.initConfigUIData(); - // activateTimer(); + // await configDataProvider.initConfigUIData(); // await provider.initConfigUIData(); if (!kIsWeb && @@ -141,10 +134,13 @@ Future main() async { // credential = await authenticate(client, scopes: scopes); // userInfo = await credential!.getUserInfo(); //runApp(const MyApp()); - SharedPreferences.getInstance().then((instance) { + // activateTimer(); + SharedPreferences.getInstance().then((instance) async { //StorageService().sharedPreferencesInstance = instance; bool isloggedIn = instance.getBool('isloggedin') ?? false; - + if (!isloggedIn) { + await configDataProvider.initConfigUIData(); + } runApp( MultiProvider( providers: [ @@ -166,14 +162,14 @@ Future main() async { builder: (context, snapshot) { print("Data_is : $snapshot"); if (snapshot.connectionState == ConnectionState.waiting) { - return CircularProgressIndicator(); + return const CircularProgressIndicator(); } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { final isLoggedIn = snapshot.data ?? false; print("isLoggedIn_is : $isLoggedIn"); - return isLoggedIn ? HomeScreen() : LoginScreen(); + return isLoggedIn ? const HomeScreen() : const LoginScreen(); } }, ), //userInfo != null ? const Home() : OpenidScreen(credential: credential,), @@ -191,22 +187,37 @@ cancelTimer() { activateTimer() { mytimer = Timer.periodic(const Duration(minutes: 5), (timer) async { - //code to run on every 2 minutes 5 seconds - final ConfigDataProvider configDataProvider = ConfigDataProvider(); - final ViewInteractionProvider viewInteractionProvider = - ViewInteractionProvider(); - List savedList = - await viewInteractionProvider.getAllRecords(); + if (await InternetConnectionChecker().hasConnection) { + //code to run on every 2 minutes 5 seconds + print("timer started "); + final ConfigDataProvider configDataProvider = ConfigDataProvider(); + final InteractionProvider viewInteractionProvider = InteractionProvider(); + if (await checkRecordsAvailable()) { + String jsonstr = await formJsonForSync(); - SendSavedDataJson json = SendSavedDataJson(data: savedList); - print(json.toString()); - await MockApiCall().postFormData(json).then((value) async { - await configDataProvider.initConfigUIData().then((value) { - // activateTimer(); - }); - }); + await MockApiCall().postSavedData(jsonstr).then((value) async { + await deleteRecords(); + await configDataProvider.initConfigUIData().then((value) async { + await viewInteractionProvider.initConfigData().then((value) { + activateTimer(); + }); + + print("ended"); + }); + }); + } else { + await configDataProvider.initConfigUIData().then((value) async { + await viewInteractionProvider.initConfigData().then((value) { + activateTimer(); + }); + + print("ended"); + }); + } + } print("Interval called 2 mins"); }); + print("timer"); print(mytimer?.isActive); } @@ -272,10 +283,10 @@ class _HomeState extends State with WidgetsBindingObserver { // Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => MyApp())); Navigator.push( context, - MaterialPageRoute(builder: (context) => const MyApp()), + MaterialPageRoute(builder: (context) => const MyApp()) ); }, - child: Text('click'), + child: const Text('click'), ), ), ), @@ -284,7 +295,7 @@ class _HomeState extends State with WidgetsBindingObserver { @override void dispose() { - Hive.close(); + // Hive.close(); super.dispose(); } } diff --git a/lib/model/interaction_config_data.dart b/lib/model/interaction_config_data.dart index 15a2d3a..7280e54 100644 --- a/lib/model/interaction_config_data.dart +++ b/lib/model/interaction_config_data.dart @@ -19,7 +19,7 @@ class UIDataResponse { success: json["success"], message: json["message"], formFields: List.from( - json["form-fields"].map((x) => FormFieldData.fromJson(x))), + json["data"].map((x) => FormFieldData.fromJson(x))), ); Map toJson() => { diff --git a/lib/model/interaction_data.dart b/lib/model/interaction_data.dart index bd8d32f..723e488 100644 --- a/lib/model/interaction_data.dart +++ b/lib/model/interaction_data.dart @@ -6,7 +6,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:pwa_ios/model/json_form_data.dart'; part 'interaction_data.g.dart'; // InteractionResultData welcomeFromJson(String str) => diff --git a/lib/model/save_interaction.dart b/lib/model/save_interaction.dart index e474c75..5603e99 100644 --- a/lib/model/save_interaction.dart +++ b/lib/model/save_interaction.dart @@ -6,7 +6,6 @@ import 'dart:convert'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:pwa_ios/model/interaction_data.dart'; -import 'package:pwa_ios/model/json_form_data.dart'; part 'save_interaction.g.dart'; SaveInteraction welcomeFromJson(String str) => diff --git a/lib/openid/openid_screen.dart b/lib/openid/openid_screen.dart index b1a3bf7..b2a3ccc 100644 --- a/lib/openid/openid_screen.dart +++ b/lib/openid/openid_screen.dart @@ -44,8 +44,9 @@ class _LoginPageState extends State { Future getClient() async { var uri = Uri.parse(keycloakUri); - if (!kIsWeb && Platform.isAndroid) + if (!kIsWeb && Platform.isAndroid) { uri = uri.replace(host: 'sso.konectar.io'); + } var clientId = 'appwildcard'; var issuer = await Issuer.discover(uri); diff --git a/lib/repository/hive_repository.dart b/lib/repository/hive_repository.dart index b708bf6..8e63115 100644 --- a/lib/repository/hive_repository.dart +++ b/lib/repository/hive_repository.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:pwa_ios/model/interaction_config_data.dart'; -import 'package:pwa_ios/model/save_interaction.dart'; class HiveDataRepository extends ChangeNotifier { Box _hiveBox; // Use the correct type for your Hive box diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 24e71a9..6ff2505 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -15,7 +15,7 @@ final kPwaHost = kPwaUri.host; final notificationUri = WebUri('https://cardio-staging.konectar.io/notifications/'); -final String publicKey = +const String publicKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyZWYiOiIxZTIxMTkyZS1jYTkyLTRlNDktYjY5Zi0yM2YzZTdiOWY1ODAiLCJhbm9uX2tleSI6ImVkZTgzYjg3LTljNGUtNDcyYS04MGEzLTQxNGU1NjE1YWExMSIsImlhdCI6MTY5NTk5MDY2NiwiZXhwIjoxNzI3NTQ4MjY2LCJpc3MiOiJodHRwczovL2J1aWxkd2l0aHRoZXRhLmNvbSJ9.nFjrMCr2swrkN9-JTqZOqsSOdUgJpH0LiRBFBpe2ceA"; // Custom HTML Error Page. diff --git a/lib/utils/fileupload.dart b/lib/utils/fileupload.dart index e9cba4f..a76f734 100644 --- a/lib/utils/fileupload.dart +++ b/lib/utils/fileupload.dart @@ -6,7 +6,7 @@ import 'package:dio/dio.dart'; class FileUpload { Future uploadFileAndJsonData( {required File empFace, required String empCode}) async { - final url = 'My API URL'; + const url = 'My API URL'; try { var formData = FormData.fromMap({ "files": [ diff --git a/lib/utils/mockapi.dart b/lib/utils/mockapi.dart index 7e9c778..b9e7866 100644 --- a/lib/utils/mockapi.dart +++ b/lib/utils/mockapi.dart @@ -6,7 +6,6 @@ import 'package:dio/dio.dart'; import 'package:dio/io.dart'; import 'package:flutter/services.dart'; import 'package:http_mock_adapter/http_mock_adapter.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:pwa_ios/model/interaction_config_data.dart'; class MockApiCall { @@ -32,14 +31,13 @@ class MockApiCall { // ), // ); // Send a GET request to "https://example.com" using Dio - final response = - await dio.get('http://192.168.2.64/konectar-app/public/forms'); + final response = await dio.get('https://passvault.konectar.io/forms'); - UIDataResponse dataResponse = UIDataResponse.fromJson(response.data); + //UIDataResponse dataResponse = UIDataResponse.fromJson(response.data); // The response should contain the mock data we registered print("response"); print(response.data); - return dataResponse; + return response.data; } Future postConfigData(var jsonObj) async { @@ -119,9 +117,10 @@ class MockApiCall { print(response.data); // {messa } - Future postSavedData(var jsonObj, String filepath) async { + Future postSavedData(var jsonObj) async { // final dio = Dio(BaseOptions()); final dio = Dio(); + // ignore: deprecated_member_use (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { client.badCertificateCallback = @@ -153,9 +152,15 @@ class MockApiCall { // }); // Send a GET request to "https://example.com" using Dio - final response = await dio.get( - 'http://192.168.2.64/konectar-app/public/push_data', - data: jsonObj); + + // Or create `Dio` with a `BaseOptions` instance. + final options = Options( + sendTimeout: const Duration(seconds: 15), + receiveTimeout: const Duration(seconds: 15), + ); + + final response = await dio.get('https://passvault.konectar.io/push_data', + options: options, data: jsonObj); //UIDataResponse dataResponse = UIDataResponse.fromJson(response.data); // The response should contain the mock data we registered @@ -166,7 +171,7 @@ class MockApiCall { Future uploadFileAndJsonData(var jsonObj) async { // {required File empFace, required String empCode} - final url = 'http://192.168.2.64/konectar-app/public/push_data'; + const url = 'http://192.168.2.64/konectar-app/public/push_data'; try { var formData = FormData.fromMap({ "files": [ diff --git a/lib/utils/repository.dart b/lib/utils/repository.dart new file mode 100644 index 0000000..b42de3b --- /dev/null +++ b/lib/utils/repository.dart @@ -0,0 +1,13 @@ +import 'package:flutter/foundation.dart'; +import 'package:hive_flutter/hive_flutter.dart'; + +class HiveRepository extends ChangeNotifier { + static Future> openHive(String boxname) async { + var connectionBox = Hive.box(boxname); + if (!connectionBox.isOpen) { + connectionBox = await Hive.openBox(boxname); + } + + return connectionBox; + } +} diff --git a/lib/utils/util.dart b/lib/utils/util.dart index e2a48ca..eea7ecd 100644 --- a/lib/utils/util.dart +++ b/lib/utils/util.dart @@ -3,6 +3,10 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:hive_flutter/hive_flutter.dart'; +import 'package:pwa_ios/model/json_form_data.dart'; +import 'package:pwa_ios/model/save_interaction.dart'; +import 'package:pwa_ios/viewmodel/interactionprovider.dart'; +import 'package:pwa_ios/viewmodel/viewinteractionprovider.dart'; import 'package:shared_preferences/shared_preferences.dart'; Future isNetworkAvailable() async { @@ -44,6 +48,36 @@ bool get isTablet { return logicalShortestSide > 600; } +Future formJsonForSync() async { + final provider = ViewInteractionProvider(); + final prov = InteractionProvider(); + List senSavedList = []; + List savedList = await provider.getAllRecords(); + for (var obj in savedList) { + senSavedList.add(prov.formJson(obj)); + } + + SendSaveJson jsonData = SendSaveJson(savedList: senSavedList); + DataJson dataJson = DataJson(sendSaveJson: jsonData); + String jsonstr = saveFormJsonToJson(jsonData); + print(jsonstr); + return jsonstr; +} + +Future checkRecordsAvailable() async { + final provider = ViewInteractionProvider(); + List savedList = await provider.getAllRecords(); + return savedList.isNotEmpty; +} + +deleteRecords() async { + final provider = ViewInteractionProvider(); + List savedList = await provider.getAllRecords(); + for (var obj in savedList) { + provider.deleteRecord(obj); + } +} + Future getNextAutoIncrementValue() async { var counterBox = await Hive.openBox('counterBox'); if (!counterBox.containsKey('counter')) { diff --git a/lib/viewmodel/configprovider.dart b/lib/viewmodel/configprovider.dart index 8a8a541..6b4c091 100644 --- a/lib/viewmodel/configprovider.dart +++ b/lib/viewmodel/configprovider.dart @@ -1,46 +1,46 @@ -import 'dart:convert'; -import 'dart:ffi'; -import 'dart:io'; import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:pwa_ios/model/interaction_config_data.dart'; import 'package:pwa_ios/model/interaction_data.dart'; import 'package:pwa_ios/utils/mockapi.dart'; import 'package:pwa_ios/utils/util.dart'; -import 'package:permission_handler/permission_handler.dart'; -import 'package:file_picker/file_picker.dart'; +import 'package:internet_connection_checker/internet_connection_checker.dart'; class ConfigDataProvider extends ChangeNotifier { Future initConfigUIData() async { - // dynamic jsonResult = await MockApiCall().getConfigData(); List interactionConfigData = []; // interactionConfigData = await fetchInteactionConfigData(); //interactionConfigData = fetchInteactionUIConfigData(jsonResult); - interactionConfigData = await fetchLocalInteactionConfigData(); - var box = - await Hive.openBox('InteractionConfigDataBox'); - if (box.isEmpty) { - for (InteractionConfigData data in interactionConfigData) { - box.put(await getNextAutoIncrementValue(), data); - } - } else { - box.clear(); + if (await InternetConnectionChecker().hasConnection) { + interactionConfigData = await fetchLocalInteactionConfigData(); + var box = Hive.box('InteractionConfigDataBox'); - for (InteractionConfigData data in interactionConfigData) { - box.put(await getNextAutoIncrementValue(), data); + if (!box.isOpen) { + box = await Hive.openBox( + 'InteractionConfigDataBox'); + } + + if (box.isEmpty) { + for (InteractionConfigData data in interactionConfigData) { + box.put(await getNextAutoIncrementValue(), data); + } + } else { + box.clear(); + + for (InteractionConfigData data in interactionConfigData) { + box.put(await getNextAutoIncrementValue(), data); + } } } notifyListeners(); } Future> fetchLocalInteactionConfigData() async { - dynamic jsonResult = jsonDecode( - await rootBundle.loadString("assets/images/interactiondata.json")); - + // dynamic jsonResult = jsonDecode( + // await rootBundle.loadString("assets/images/interactiondata.json")); + dynamic jsonResult = await MockApiCall().getConfigData(); // dynamic jsonResultc2 = jsonDecode( // await rootBundle.loadString("assets/images/interactiondatac2.json")); // // for (var value in jsonResult) { @@ -50,14 +50,15 @@ class ConfigDataProvider extends ChangeNotifier { // dynamic jsonResult2 = jsonDecode( // await rootBundle.loadString("assets/images/interactionform.json")); - dynamic jsonResult2c2 = jsonDecode( - await rootBundle.loadString("assets/images/newconfigdata.json")); + // dynamic jsonResult2c2 = jsonDecode( + // await rootBundle.loadString("assets/images/newconfigdata.json")); List interactionConfigData = []; + // for (var value in jsonResult) { // InteractionResultData interactionConfig = // InteractionResultData.fromJson(jsonResult2); - ResponseData responseData = ResponseDataFromJson(jsonResult2c2); + ResponseData responseData = ResponseDataFromJson(jsonResult); for (InteractionResultData obj in responseData.data) { // InteractionResultData interactionConfigc2 = // InteractionResultData.fromJson(obj); @@ -68,7 +69,7 @@ class ConfigDataProvider extends ChangeNotifier { // widgets: interactionConfig, // id: "IN01", // name: "InteractionForm1")); - // interactionConfigData.add( + // inte ractionConfigData.add( InteractionConfigData(widgets: obj, id: obj.id, name: obj.name)); } return interactionConfigData; diff --git a/lib/viewmodel/interactionprovider.dart b/lib/viewmodel/interactionprovider.dart index 1bd40d1..9527bd7 100644 --- a/lib/viewmodel/interactionprovider.dart +++ b/lib/viewmodel/interactionprovider.dart @@ -1,12 +1,8 @@ import 'dart:convert'; -import 'dart:io'; -import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:provider/provider.dart'; import 'package:pwa_ios/model/interaction_config_data.dart'; import 'package:pwa_ios/model/interaction_data.dart'; @@ -15,7 +11,6 @@ import 'package:pwa_ios/model/json_form_data.dart'; import 'package:pwa_ios/model/location_model.dart'; import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/repository/hive_repository.dart'; -import 'package:pwa_ios/utils/mockapi.dart'; import '../utils/util.dart'; @@ -50,10 +45,16 @@ class InteractionProvider extends ChangeNotifier { initConfigData() async { _hiveprovider.openHiveBox(); intConfigDataList = _hiveprovider.getAllDataFromHive(); + notifyListeners(); } Future getRecords() async { - var box = await Hive.openBox('InteractionDataBox'); + var box = Hive.box('InteractionDataBox'); + + if (!box.isOpen) { + box = await Hive.openBox('InteractionDataBox'); + } + savedList = box.values.toList(); notifyListeners(); } @@ -64,7 +65,7 @@ class InteractionProvider extends ChangeNotifier { // intConfigDataList = _hiveprovider.getAllDataFromHive(); dynamic jsonResult = jsonDecode( await rootBundle.loadString("assets/images/interactiondata.json")); - + await initConfigData(); InteractionConfigData interactionConfigData = intConfigDataList[index]; intId = intConfigDataList[index].id; intName = intConfigDataList[index].name; @@ -165,6 +166,7 @@ class InteractionProvider extends ChangeNotifier { // } String getDataValue(String widgetId, String id) { + print("issue *************"); if (id != "") { List list = []; String value = ' '; @@ -345,9 +347,9 @@ class InteractionProvider extends ChangeNotifier { } else if (sectionItem.widget == InteractionWidget.CHECKBOX) { List list = sectionItem.inputList!; if (list.isNotEmpty) { - sectionItem.inputList!.forEach((element) { + for (var element in sectionItem.inputList!) { element.ischecked = false; - }); + } } // sectionItem.value = list[0].id; // sectionItem.selectedValue!.add(list[0].id); @@ -602,11 +604,15 @@ class InteractionProvider extends ChangeNotifier { form: form, intId: intId ?? "id", intName: intName ?? "name"); + var box = Hive.box('InteractionDataBox'); - final box = await Hive.openBox('InteractionDataBox'); + if (!box.isOpen) { + box = await Hive.openBox('InteractionDataBox'); + } await box.put(await getNextAutoIncrementValue(), data); - box.close(); + // box.close(); + await getRecords(); return generateId; // await MockApiCall().postFormData(data); // await prov.addOfflineData(data); @@ -641,10 +647,10 @@ class InteractionProvider extends ChangeNotifier { List sectionList, List multipleList) { List> list = []; List> listing = []; - List _secList = getModifiedList(sectionList); - List _multipleList = getModifiedList(multipleList); - list.add(_secList); - listing.add(_secList); + List secList = getModifiedList(sectionList); + List multipleList0 = getModifiedList(multipleList); + list.add(secList); + listing.add(secList); // List listing = []; if (multipleList.isNotEmpty) { final releaseDateMap = multipleList.groupBy((m) => m.gid); @@ -657,7 +663,7 @@ class InteractionProvider extends ChangeNotifier { for (var item in mulList) { listing.add(getModifiedList(item)); } - listing.add(_secList); + listing.add(secList); list = [...listing]; //}); diff --git a/lib/viewmodel/loginprovider.dart b/lib/viewmodel/loginprovider.dart index 708f247..5d93fee 100644 --- a/lib/viewmodel/loginprovider.dart +++ b/lib/viewmodel/loginprovider.dart @@ -1,6 +1,5 @@ import 'package:flutter/foundation.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/model/userdata_model.dart'; class LoginProvider extends ChangeNotifier { diff --git a/lib/viewmodel/viewinteractionprovider.dart b/lib/viewmodel/viewinteractionprovider.dart index 44109da..7078a06 100644 --- a/lib/viewmodel/viewinteractionprovider.dart +++ b/lib/viewmodel/viewinteractionprovider.dart @@ -1,12 +1,9 @@ import 'dart:convert'; -import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:provider/provider.dart'; import 'package:pwa_ios/model/interaction_config_data.dart'; import 'package:pwa_ios/model/interaction_data.dart'; @@ -15,10 +12,8 @@ import 'package:pwa_ios/model/json_form_data.dart'; import 'package:pwa_ios/model/location_model.dart'; import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/repository/hive_repository.dart'; -import 'package:pwa_ios/utils/mockapi.dart'; import 'package:pwa_ios/viewmodel/interactionprovider.dart'; -import '../utils/util.dart'; class ViewInteractionProvider extends ChangeNotifier { List interactionReponseList = []; @@ -366,8 +361,8 @@ class ViewInteractionProvider extends ChangeNotifier { int i = 0; for (var obj in interactionReponseList) { if (multiple && obj.multipleList != null) { - i = obj.multipleList! - .indexWhere((element) => element.id == sectionItem.id); + i = obj.multipleList!.indexWhere((element) => + element.id == sectionItem.id && element.gid == sectionItem.gid); if (i != -1) { obj.multipleList![i].value = value; obj.multipleList![i].tempselectedValue = []; @@ -390,7 +385,7 @@ class ViewInteractionProvider extends ChangeNotifier { Future disposeValues() async { print("dispose called"); - await _hiveprovider.closeHiveBox(); + // await _hiveprovider.closeHiveBox(); for (var obj in interactionReponseList) { obj.multipleList!.clear(); // for (var obj2 in obj.sectionList) { @@ -406,8 +401,8 @@ class ViewInteractionProvider extends ChangeNotifier { int i = 0; for (var obj in interactionReponseList) { if (multiple && obj.multipleList != null) { - i = obj.multipleList! - .indexWhere((element) => element.id == sectionItem.id); + i = obj.multipleList!.indexWhere((element) => + element.id == sectionItem.id && element.gid == sectionItem.gid); if (i != -1) { obj.multipleList![i].value = value; obj.multipleList![i].selectedValue!.add(value); @@ -428,8 +423,8 @@ class ViewInteractionProvider extends ChangeNotifier { int i = 0; for (var obj in interactionReponseList) { if (multiple && obj.multipleList != null) { - i = obj.multipleList! - .indexWhere((element) => element.id == sectionItem.id); + i = obj.multipleList!.indexWhere((element) => + element.id == sectionItem.id && element.gid == sectionItem.gid); if (i != -1) { obj.multipleList![i].value = value; obj.multipleList![i].tempselectedValue = []; @@ -571,8 +566,8 @@ class ViewInteractionProvider extends ChangeNotifier { int index2 = 0; for (var obj in interactionReponseList) { if (multiple && obj.multipleList != null) { - index2 = obj.multipleList! - .indexWhere((element) => element.id == sectionItem.id); + index2 = obj.multipleList!.indexWhere((element) => + element.id == sectionItem.id && element.gid == sectionItem.gid); if (index2 != -1) { obj.multipleList![index2].value = sectionItem.inputList![index].id; obj.multipleList![index2].selectedValue! @@ -727,16 +722,18 @@ class ViewInteractionProvider extends ChangeNotifier { intId: saveInteraction.intId, intName: saveInteraction.intName, ); + var box = Hive.box('InteractionDataBox'); - var box = await Hive.openBox('InteractionDataBox'); - // box.put(await getNextAutoIncrementValue(), data); + if (!box.isOpen) { + box = await Hive.openBox('InteractionDataBox'); + } int index = box.values.toList().indexWhere((element) => element.id == data.id); box.putAt(index, data); await getRecords(saveInteraction.form!); - box.close(); + // box.close(); // await MockApiCall().postFormData(data); } @@ -752,7 +749,7 @@ class ViewInteractionProvider extends ChangeNotifier { }); box.delete(deleteKey); await getRecords(saveInteraction.form!); - box.close(); + //box.close(); } List getModifiedList(List sectionList) { diff --git a/lib/views/home_screen.dart b/lib/views/home_screen.dart index fd23d2d..095ee25 100644 --- a/lib/views/home_screen.dart +++ b/lib/views/home_screen.dart @@ -1,15 +1,9 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:pwa_ios/utils/apicall.dart'; -import 'package:pwa_ios/main.dart'; -import 'package:pwa_ios/views/interaction_module/interaction_screen.dart'; import 'package:pwa_ios/views/interaction_module/interactionlistscreen.dart'; import 'package:pwa_ios/views/konectarpage.dart'; -import 'package:pwa_ios/views/notification_screen.dart'; import 'package:pwa_ios/views/notifications.dart'; import 'package:pwa_ios/views/profile.dart'; -import 'package:pwa_ios/views/webview_example.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @@ -47,14 +41,14 @@ class _HomeScreenState extends State { type: BottomNavigationBarType.fixed, currentIndex: _selectedIndex, //backgroundColor: Color.fromARGB(255, 35, 79, 150), - selectedItemColor: Color.fromARGB(255, 35, 79, 150), - unselectedItemColor: Color.fromARGB(255, 153, 153, 163), + selectedItemColor: const Color.fromARGB(255, 35, 79, 150), + unselectedItemColor: const Color.fromARGB(255, 153, 153, 163), iconSize: 40, onTap: _onItemTapped, elevation: 1, items: [ BottomNavigationBarItem( - icon: Container( + icon: SizedBox( width: 30, height: 30, child: Image.asset( @@ -62,15 +56,15 @@ class _HomeScreenState extends State { ), ), label: 'Konectar', - backgroundColor: Color.fromARGB(255, 168, 170, 173)), - // const BottomNavigationBarItem( - // icon: Icon( - // Icons.notifications, - // size: 30, - // ), - // label: 'Notifications', - // backgroundColor: Colors.blue, - // ), + backgroundColor: const Color.fromARGB(255, 168, 170, 173)), + const BottomNavigationBarItem( + icon: Icon( + Icons.notifications, + size: 30, + ), + label: 'frappe', + backgroundColor: Colors.blue, + ), const BottomNavigationBarItem( icon: Icon( Icons.edit_document, @@ -91,8 +85,10 @@ class _HomeScreenState extends State { body: _selectedIndex == 0 ? const MyApp() : _selectedIndex == 1 - ? const InteractionListScreen() - : const ProfileScreen(), + ? const NotificationsScreen() + : _selectedIndex == 2 + ? const InteractionListScreen() + : const ProfileScreen(), ); } } diff --git a/lib/views/interaction_module/edit_interaction_screen.dart b/lib/views/interaction_module/edit_interaction_screen.dart index c577483..eed6a6b 100644 --- a/lib/views/interaction_module/edit_interaction_screen.dart +++ b/lib/views/interaction_module/edit_interaction_screen.dart @@ -1,13 +1,13 @@ import 'dart:convert'; import 'dart:io'; -import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:dropdown_button2/dropdown_button2.dart'; +import 'package:pwa_ios/main.dart'; import 'package:pwa_ios/model/interaction_data.dart'; import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/utils/util.dart'; @@ -56,6 +56,9 @@ class _EditInteractionScreenState extends State { void initState() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { // initConfig(); + if (mytimer!.isActive) { + cancelTimer(); + } init(); }); @@ -95,7 +98,7 @@ class _EditInteractionScreenState extends State { //resizeToAvoidBottomInset: false, appBar: AppBar( title: Text( - '${widget.saveInteraction.id}', + widget.saveInteraction.id, style: TextStyle( fontSize: isTablet ? 22 : 14, color: Colors.white), ), @@ -335,7 +338,10 @@ class _EditInteractionScreenState extends State { }) { switch (widgetData) { case InteractionWidget.CHECKBOX: - return buildCheckbox(sectionItem, item.sectionName, provider, multiple); + return (sectionItem.inputList!.length >= 5) + ? customMultiselectDropdown( + sectionItem, provider, sectionItem.inputList!, multiple) + : buildCheckbox(sectionItem, item.sectionName, provider, multiple); case InteractionWidget.AUTOCOMPLETE: return customAutoCompletedropdown( @@ -345,7 +351,10 @@ class _EditInteractionScreenState extends State { return customMultiselectDropdown(sectionItem, provider, list, multiple); case InteractionWidget.RADIO: - return buildRadio(sectionItem, provider); + return (sectionItem.inputList!.length >= 5) + ? customdropdown( + sectionItem, provider, sectionItem.inputList!, multiple) + : buildRadio(sectionItem, provider); case InteractionWidget.LABEL: return Text(sectionItem.input!); @@ -416,8 +425,8 @@ class _EditInteractionScreenState extends State { maxchars: int.parse(sectionItem.chars ?? "0"), controller: sectionItem.controller!, labelText: sectionItem.name, - maxlines: 4, - minlines: 3, + // maxlines: 4, + // minlines: 3, onChanged: (val) { sectionItem.selectedValue = []; setState(() {}); @@ -434,7 +443,7 @@ class _EditInteractionScreenState extends State { controller: sectionItem.controller!, inputType: sectionItem.input == "number" ? TextInputType.number - : TextInputType.none, + : TextInputType.name, labelText: sectionItem.name, onChanged: (val) { sectionItem.selectedValue = []; @@ -459,8 +468,8 @@ class _EditInteractionScreenState extends State { border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), ), - labelStyle: TextStyle(fontSize: 16), - suffixIcon: Icon(Icons.calendar_today), //icon of text field + labelStyle: const TextStyle(fontSize: 16), + suffixIcon: const Icon(Icons.calendar_today), //icon of text field labelText: "Enter Date" //label text of field ), readOnly: true, //set it true, so that user will not able to edit text @@ -503,13 +512,13 @@ class _EditInteractionScreenState extends State { CustomButton( backgroundColor: Colors.green.shade900, onPressed: () async { - if (textFieldsValidation(provider).isEmpty) { - await provider.saveJsonObject(context, - widget.saveInteraction.intId, widget.saveInteraction); - showAlertDialog(context, widget.saveInteraction.id!); - } else { - _displaySnackBar(textFieldsValidation(provider)); - } + // if (textFieldsValidation(provider).isEmpty) { + await provider.saveJsonObject(context, + widget.saveInteraction.intId, widget.saveInteraction); + showAlertDialog(context, widget.saveInteraction.id); + // } else { + // _displaySnackBar(textFieldsValidation(provider)); + // } }, textColor: Colors.white, title: "Update", @@ -550,7 +559,7 @@ class _EditInteractionScreenState extends State { }); }, ), - Text('${value.name}'), + Text(value.name), ], ), ], @@ -578,7 +587,7 @@ class _EditInteractionScreenState extends State { //setState(() {}); }, ), - Text('${value.name}'), + Text(value.name), ], ), ], @@ -614,7 +623,7 @@ class _EditInteractionScreenState extends State { ), hint: Text( 'Select ${sectionItem.name}', - style: TextStyle(fontSize: 14), + style: const TextStyle(fontSize: 14), ), items: list .map((item) => DropdownMenuItem( @@ -910,8 +919,8 @@ class _EditInteractionScreenState extends State { int listIndex) { return Padding( padding: isTablet - ? EdgeInsets.only(left: 8.0) - : EdgeInsets.only(left: 12.0, right: 12.0), + ? const EdgeInsets.only(left: 8.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), child: GridView.count( physics: const NeverScrollableScrollPhysics(), crossAxisCount: context.responsive( @@ -1029,7 +1038,7 @@ class _EditInteractionScreenState extends State { const EdgeInsets.only(left: 3.0, top: 5), child: CustomButton( backgroundColor: - Color.fromARGB(255, 233, 75, 75), + const Color.fromARGB(255, 233, 75, 75), onPressed: () { provider.deleteMultipleRows( sectionItem.gid!, @@ -1085,7 +1094,7 @@ class _EditInteractionScreenState extends State { final snackBar = SnackBar( content: Text( msg, - style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), + style: const TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), )); ScaffoldMessenger.of(context).showSnackBar(snackBar); //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); @@ -1116,7 +1125,7 @@ class _EditInteractionScreenState extends State { print("see the converted directory path $convertedDirectoryPath"); - newPath = convertedDirectoryPath + "/konectar/files"; + newPath = "$convertedDirectoryPath/konectar/files"; print("new path :$newPath"); directory = Directory(newPath); if (!await directory.exists()) { @@ -1154,7 +1163,7 @@ class _EditInteractionScreenState extends State { // ViewInteractionProvider provider = // Provider.of(context, listen: false); Widget cancelButton = TextButton( - child: Text("Ok"), + child: const Text("Ok"), onPressed: () async { Navigator.of(context).pop(); Navigator.of(context).pop(); @@ -1185,7 +1194,7 @@ class _EditInteractionScreenState extends State { // ViewInteractionProvider provider = // Provider.of(context, listen: false); Widget cancelButton = TextButton( - child: Text("Upload"), + child: const Text("Upload"), onPressed: () async { Navigator.of(context).pop(); sectionItem.selectedValue = []; @@ -1195,7 +1204,7 @@ class _EditInteractionScreenState extends State { }, ); Widget okButton = TextButton( - child: Text("Cancel"), + child: const Text("Cancel"), onPressed: () async { Navigator.of(context).pop(); }, @@ -1205,7 +1214,7 @@ class _EditInteractionScreenState extends State { title: const Text(""), content: Text( "Following File(s) $files uploaded .Do you still want to upload files ?", - style: TextStyle(fontSize: 15), + style: const TextStyle(fontSize: 15), ), actions: [cancelButton, okButton], ); diff --git a/lib/views/interaction_module/interaction_screen.dart b/lib/views/interaction_module/interaction_screen.dart index d72300e..da58841 100644 --- a/lib/views/interaction_module/interaction_screen.dart +++ b/lib/views/interaction_module/interaction_screen.dart @@ -1,17 +1,15 @@ import 'dart:convert'; import 'dart:io'; -import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:dropdown_button2/dropdown_button2.dart'; +import 'package:pwa_ios/main.dart'; import 'package:pwa_ios/model/interaction_data.dart'; -import 'package:pwa_ios/utils/mockapi.dart'; import 'package:pwa_ios/utils/util.dart'; -import 'package:pwa_ios/viewmodel/configprovider.dart'; import 'package:pwa_ios/viewmodel/interactionprovider.dart'; import 'package:pwa_ios/widgets/custombutton.dart'; import 'package:pwa_ios/widgets/customrangeslider.dart'; @@ -41,6 +39,9 @@ class _InteractionScreenState extends State { @override void initState() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + if (mytimer!.isActive) { + cancelTimer(); + } init(); }); @@ -216,7 +217,10 @@ class _InteractionScreenState extends State { 'add' ? const SizedBox.shrink() : Text( - '${sectionItem.name}:*', + sectionItem.validation! + .isRequired + ? '${sectionItem.name}:*' + : '${sectionItem.name}:', style: TextStyle( color: Colors .orange.shade800, @@ -292,7 +296,10 @@ class _InteractionScreenState extends State { }) { switch (widgetData) { case InteractionWidget.CHECKBOX: - return buildCheckbox(sectionItem, item.sectionName, provider, multiple); + return (sectionItem.inputList!.length >= 5) + ? customMultiselectDropdown( + sectionItem, provider, sectionItem.inputList!, multiple) + : buildCheckbox(sectionItem, item.sectionName, provider, multiple); case InteractionWidget.AUTOCOMPLETE: return customAutoCompletedropdown( @@ -302,7 +309,10 @@ class _InteractionScreenState extends State { return customMultiselectDropdown(sectionItem, provider, list, multiple); case InteractionWidget.RADIO: - return buildRadio(sectionItem, provider); + return (sectionItem.inputList!.length >= 5) + ? customdropdown( + sectionItem, provider, sectionItem.inputList!, multiple) + : buildRadio(sectionItem, provider); case InteractionWidget.LABEL: return Text(sectionItem.input!); @@ -372,8 +382,8 @@ class _InteractionScreenState extends State { maxchars: int.parse(sectionItem.validation!.chars ?? "0"), controller: sectionItem.controller!, labelText: sectionItem.name, - maxlines: 4, - minlines: 3, + // maxlines: 8, + //minlines: 4, onChanged: (val) { sectionItem.selectedValue = []; setState(() {}); @@ -388,7 +398,7 @@ class _InteractionScreenState extends State { child: InteractionTextField( inputType: sectionItem.input == "number" ? TextInputType.number - : TextInputType.none, + : TextInputType.name, maxchars: int.parse(sectionItem.chars ?? "0"), controller: sectionItem.controller!, labelText: sectionItem.name, @@ -537,7 +547,7 @@ class _InteractionScreenState extends State { }); }, ), - Text('${value.name}'), + Text(value.name), ], ), ], @@ -565,7 +575,7 @@ class _InteractionScreenState extends State { //setState(() {}); }, ), - Text('${value.name}'), + Text(value.name), ], ), ], @@ -601,7 +611,7 @@ class _InteractionScreenState extends State { ), hint: Text( 'Select ${sectionItem.name}', - style: TextStyle(fontSize: 14), + style: const TextStyle(fontSize: 14), ), items: list .map((item) => DropdownMenuItem( @@ -666,6 +676,7 @@ class _InteractionScreenState extends State { // if (list.isEmpty) { // print("list is empty"); list = sectionItem.inputList!; + print("***Autocomplete list ${list[0].name}"); //} //InputClass selectedObj = list[0]; return SizedBox( @@ -899,8 +910,8 @@ class _InteractionScreenState extends State { int listIndex) { return Padding( padding: isTablet - ? EdgeInsets.only(left: 8.0) - : EdgeInsets.only(left: 12.0, right: 12.0), + ? const EdgeInsets.only(left: 8.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), child: GridView.count( physics: const NeverScrollableScrollPhysics(), crossAxisCount: context.responsive( @@ -980,7 +991,7 @@ class _InteractionScreenState extends State { ), Text( sectionItem.selectedValue!.isNotEmpty - ? sectionItem.selectedValue!.length > 0 + ? sectionItem.selectedValue!.isNotEmpty ? 'File uploaded' : "Files Uploaded" : 'No file uploaded', @@ -1013,7 +1024,7 @@ class _InteractionScreenState extends State { const EdgeInsets.only(left: 3.0, top: 5), child: CustomButton( backgroundColor: - Color.fromARGB(255, 233, 75, 75), + const Color.fromARGB(255, 233, 75, 75), onPressed: () { provider.deleteMultipleRows( sectionItem.gid!, @@ -1046,22 +1057,35 @@ class _InteractionScreenState extends State { ); } - String textFieldsValidation(InteractionProvider provider) { - if (provider.sectionList - .any((element) => element.controller!.text.isEmpty)) { + String fieldsValidation(InteractionProvider provider) { + List secList = provider.sectionList + .where((element) => element.validation!.isRequired = true) + .toList(); + if (secList.any((element) => element.selectedValue!.isEmpty)) { return 'Fields cannot be empty'; } - if (provider.textEditingControllerList.isNotEmpty) { - if (provider.validateTextFields()) { - return 'Fields cannot be empty'; - } - } + return ''; + } - if (provider.multipletextEditingControllerList.isNotEmpty) { - if (provider.validateMultipleRows()) { - return 'Fields cannot be empty'; - } - } + String textFieldsValidation(InteractionProvider provider) { + // if (provider.sectionList + // .any((element) => element.widget == InteractionWidget.TEXT)) { + // if (provider.sectionList + // .any((element) => element.controller!.text.isEmpty)) { + // return 'Fields cannot be empty'; + // } + // if (provider.textEditingControllerList.isNotEmpty) { + // if (provider.validateTextFields()) { + // return 'Fields cannot be empty'; + // } + // } + + // if (provider.multipletextEditingControllerList.isNotEmpty) { + // if (provider.validateMultipleRows()) { + // return 'Fields cannot be empty'; + // } + // } + // } return ''; } @@ -1070,7 +1094,7 @@ class _InteractionScreenState extends State { final snackBar = SnackBar( content: Text( msg, - style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), + style: const TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), )); ScaffoldMessenger.of(context).showSnackBar(snackBar); //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); @@ -1101,7 +1125,7 @@ class _InteractionScreenState extends State { print("see the converted directory path $convertedDirectoryPath"); - newPath = convertedDirectoryPath + "/konectar/files"; + newPath = "$convertedDirectoryPath/konectar/files"; print("new path :$newPath"); directory = Directory(newPath); if (!await directory.exists()) { @@ -1131,7 +1155,7 @@ class _InteractionScreenState extends State { // ViewInteractionProvider provider = // Provider.of(context, listen: false); Widget cancelButton = TextButton( - child: Text("Ok"), + child: const Text("Ok"), onPressed: () async { Navigator.of(context).pop(); Navigator.of(context).pop(); diff --git a/lib/views/interaction_module/interactionlistscreen.dart b/lib/views/interaction_module/interactionlistscreen.dart index 6a39666..60a0f58 100644 --- a/lib/views/interaction_module/interactionlistscreen.dart +++ b/lib/views/interaction_module/interactionlistscreen.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:pwa_ios/main.dart'; import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/utils/util.dart'; import 'package:pwa_ios/viewmodel/interactionprovider.dart'; -import 'package:pwa_ios/viewmodel/viewinteractionprovider.dart'; import 'package:pwa_ios/views/interaction_module/interaction_screen.dart'; import 'package:pwa_ios/views/interaction_module/view_forms_list.dart'; @@ -19,6 +19,9 @@ class _InteractionListScreenState extends State { @override void initState() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + if (!mytimer!.isActive) { + activateTimer(); + } init(); }); @@ -32,8 +35,9 @@ class _InteractionListScreenState extends State { setState(() {}); } - int getCount(String form, InteractionProvider provider) { - provider.getRecords(); + Future getCount(String form, InteractionProvider provider) async { + await provider.getRecords(); + return provider.savedList.where((element) => element.form == form).length; } @@ -63,7 +67,7 @@ class _InteractionListScreenState extends State { title: Row( children: [ Text( - 'Interaction-form${(index + 1).toString()}', + provider.intConfigDataList[index].name, ), const SizedBox( width: 20, @@ -76,8 +80,9 @@ class _InteractionListScreenState extends State { builder: (BuildContext context) => InteractionScreen( index: index, - form: - 'Interaction-form${(index + 1).toString()}', + form: provider + .intConfigDataList[index] + .name, ))); }, icon: const Icon( @@ -90,32 +95,38 @@ class _InteractionListScreenState extends State { ), trailing: provider.savedList.indexWhere((element) => element.form == - 'Interaction-form${(index + 1).toString()}') != + provider.intConfigDataList[index].name) != -1 ? InkWell( onTap: () { if (getCount( - 'Interaction-form${(index + 1).toString()}', + provider + .intConfigDataList[index].name, provider) != 0) { - List sendsavedList = provider - .savedList - .where((element) => - element.form == - 'Interaction-form${(index + 1).toString()}') - .toList(); + List sendsavedList = + provider + .savedList + .where((element) => + element.form == + provider + .intConfigDataList[index] + .name) + .toList(); Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => SavedFormListScreen( - formname: - 'Interaction-form${(index + 1).toString()}', + formname: provider + .intConfigDataList[ + index] + .name, ))); } }, child: Text( - "${getCount('Interaction-form${(index + 1).toString()}', provider).toString()} record(s) saved", + "${provider.savedList.where((element) => element.form == provider.intConfigDataList[index].name).length} record(s) saved", style: TextStyle( fontSize: isTablet ? 18.0 : 14, color: Colors.blue.shade900), @@ -129,8 +140,8 @@ class _InteractionListScreenState extends State { builder: (BuildContext context) => InteractionScreen( index: index, - form: - 'Interaction-form${(index + 1).toString()}', + form: provider + .intConfigDataList[index].name, ))); }, ), diff --git a/lib/views/interaction_module/view_forms_list.dart b/lib/views/interaction_module/view_forms_list.dart index 8c7aac2..6bf8619 100644 --- a/lib/views/interaction_module/view_forms_list.dart +++ b/lib/views/interaction_module/view_forms_list.dart @@ -2,10 +2,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/utils/util.dart'; -import 'package:pwa_ios/viewmodel/interactionprovider.dart'; import 'package:pwa_ios/viewmodel/viewinteractionprovider.dart'; import 'package:pwa_ios/views/interaction_module/edit_interaction_screen.dart'; -import 'package:pwa_ios/views/interaction_module/interaction_screen.dart'; import 'package:pwa_ios/views/interaction_module/view_interaction_screen.dart'; class SavedFormListScreen extends StatefulWidget { @@ -73,7 +71,7 @@ class _SavedFormListScreenState extends State { //style: TextStyle(fontStyle: FontStyle.italic), ), title: Text( - '${provider.savedList[index].id}', + provider.savedList[index].id, ), trailing: SizedBox( width: 150, @@ -155,7 +153,7 @@ class _SavedFormListScreenState extends State { ViewInteractionProvider provider = Provider.of(context, listen: false); Widget cancelButton = TextButton( - child: Text("YES"), + child: const Text("YES"), onPressed: () async { await provider.deleteRecord(saveInteraction).then((value) { _displaySnackBar("Deleted sucessfully!"); @@ -164,7 +162,7 @@ class _SavedFormListScreenState extends State { }, ); Widget continueButton = TextButton( - child: Text("NO"), + child: const Text("NO"), onPressed: () { Navigator.of(context).pop(); }, @@ -193,7 +191,7 @@ class _SavedFormListScreenState extends State { final snackBar = SnackBar( content: Text( msg, - style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), + style: const TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), )); ScaffoldMessenger.of(context).showSnackBar(snackBar); //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); diff --git a/lib/views/interaction_module/view_interaction_screen.dart b/lib/views/interaction_module/view_interaction_screen.dart index 1c7fcaf..be711f4 100644 --- a/lib/views/interaction_module/view_interaction_screen.dart +++ b/lib/views/interaction_module/view_interaction_screen.dart @@ -1,19 +1,11 @@ -import 'dart:convert'; -import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; -import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:pwa_ios/model/interaction_data.dart'; import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/utils/util.dart'; import 'package:pwa_ios/viewmodel/interactionprovider.dart'; import 'package:pwa_ios/widgets/custombutton.dart'; -import 'package:pwa_ios/widgets/customrangeslider.dart'; -import 'package:pwa_ios/widgets/interatciontextfield.dart'; -import 'package:file_picker/file_picker.dart'; import 'package:pwa_ios/widgets/responsive_ext.dart'; class ViewInteractionScreen extends StatefulWidget { @@ -62,7 +54,7 @@ class _ViewInteractionScreenState extends State { //resizeToAvoidBottomInset: false, appBar: AppBar( title: Text( - '${widget.saveInteraction.id}', + widget.saveInteraction.id, style: TextStyle( fontSize: isTablet ? 22 : 14, color: Colors.white), ), @@ -262,19 +254,24 @@ class _ViewInteractionScreenState extends State { }) { switch (widgetData) { case InteractionWidget.CHECKBOX: - return Text( - "${provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last)}"); + return (sectionItem.inputList!.length >= 5) + ? Text(sectionItem.selectedValue.toString()) + : Text( + provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last)); case InteractionWidget.AUTOCOMPLETE: return Text( - "${provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last)}"); + provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last)); case InteractionWidget.MULTISELECT: - return Text("${sectionItem.selectedValue.toString()}"); + return Text(sectionItem.selectedValue.toString()); case InteractionWidget.RADIO: - return Text( - "${provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last)}"); + return (sectionItem.inputList!.length >= 5) + ? Text( + sectionItem.selectedValue!.isNotEmpty ? provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last) : " ") + : Text( + provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last)); case InteractionWidget.LABEL: return Text(sectionItem.input!); @@ -285,17 +282,19 @@ class _ViewInteractionScreenState extends State { : " "); case InteractionWidget.TEXT: - return Text(sectionItem.selectedValue!.last); + return Text(sectionItem.selectedValue!.isNotEmpty + ? sectionItem.selectedValue!.last.toString() + : " "); case InteractionWidget.BUTTON: return sectionItem.input == "chooseFile" ? sectionItem.selectedValue!.isNotEmpty - ? Text("File Uploaded") - : Text(" ") - : Text(" "); + ? const Text("File Uploaded") + : const Text(" ") + : const Text(" "); default: return Text( - "${sectionItem.selectedValue!.isNotEmpty ? provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last) : " "}"); + sectionItem.selectedValue!.isNotEmpty ? provider.getDataValue(sectionItem.id, sectionItem.selectedValue!.last) : " "); } } @@ -355,8 +354,8 @@ class _ViewInteractionScreenState extends State { int listIndex) { return Padding( padding: isTablet - ? EdgeInsets.only(left: 22.0) - : EdgeInsets.only(left: 12.0, right: 12.0), + ? const EdgeInsets.only(left: 22.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), child: GridView.count( physics: const NeverScrollableScrollPhysics(), crossAxisCount: context.responsive( @@ -441,7 +440,7 @@ class _ViewInteractionScreenState extends State { final snackBar = SnackBar( content: Text( msg, - style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), + style: const TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), )); ScaffoldMessenger.of(context).showSnackBar(snackBar); //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); diff --git a/lib/views/konectarpage.dart b/lib/views/konectarpage.dart index 16ac23f..9054e27 100644 --- a/lib/views/konectarpage.dart +++ b/lib/views/konectarpage.dart @@ -1,24 +1,16 @@ import 'package:flutter/material.dart'; import 'dart:async'; import 'dart:collection'; -import 'dart:io'; import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; -import 'package:pwa_ios/utils/apicall.dart'; import 'package:pwa_ios/utils/constants.dart'; -import 'package:pwa_ios/views/home_screen.dart'; import 'package:pwa_ios/views/login.dart'; import 'package:pwa_ios/utils/util.dart'; -import 'package:pwa_ios/views/webview_example.dart'; import 'package:pwa_ios/widgets/webview_popup.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'dart:ui' as ui; import 'package:internet_connection_checker/internet_connection_checker.dart'; -import 'package:openid_client/openid_client.dart'; -import 'package:flutter_web_plugins/url_strategy.dart'; class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @@ -148,11 +140,11 @@ class _MyAppState extends State with WidgetsBindingObserver { children: [ Expanded( child: FutureBuilder( - future: isNetworkAvailable(), + future: InternetConnectionChecker().hasConnection, builder: (context, snapshot) { if (!snapshot.hasData) { print("no data******"); - return Text("No internet connectivity!"); + return const Text("No internet connectivity!"); } final bool networkAvailable = snapshot.data ?? false; @@ -182,10 +174,10 @@ class _MyAppState extends State with WidgetsBindingObserver { valueListenable: isLoading, builder: (context, value, child) { return isLoading.value - ? CircularProgressIndicator() + ? const CircularProgressIndicator() : Center( child: Container( - child: Text( + child: const Text( "No internet connectivity!"), ), ); @@ -341,7 +333,8 @@ class _MyAppState extends State with WidgetsBindingObserver { )); } - if (await isNetworkAvailable() && + if (await InternetConnectionChecker() + .hasConnection && !(await isPWAInstalled())) { // if network is available and this is the first timeß setPWAInstalled(); @@ -352,7 +345,8 @@ class _MyAppState extends State with WidgetsBindingObserver { final isForMainFrame = request.isForMainFrame ?? true; if (isForMainFrame && - !(await isNetworkAvailable())) { + !(await InternetConnectionChecker() + .hasConnection)) { if (!(await isPWAInstalled())) { await controller.loadData( data: kHTMLErrorPageNotInstalled); @@ -411,7 +405,7 @@ class _MyAppState extends State with WidgetsBindingObserver { ], ) : Container( - child: Text("No internet"), + child: const Text("No internet"), ); }, ), diff --git a/lib/views/login.dart b/lib/views/login.dart index ff94cb3..7562a93 100644 --- a/lib/views/login.dart +++ b/lib/views/login.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:pwa_ios/model/userdata_model.dart'; @@ -102,7 +101,7 @@ class _LoginScreenState extends State { width: isTablet ? 160 : 80, height: isTablet ? 160 : 80, child: CircleAvatar( - backgroundColor: Color.fromARGB(255, 126, 134, 147), + backgroundColor: const Color.fromARGB(255, 126, 134, 147), child: Icon( Icons.person, size: isTablet ? 120 : 60, @@ -134,10 +133,20 @@ class _LoginScreenState extends State { // Color.fromARGB(255, 214, 217, 223), // ], // )), - child: _buildform(), padding: EdgeInsets.symmetric( horizontal: 30, vertical: orientation == Orientation.portrait ? 20 : 0), + // decoration: const BoxDecoration( + // gradient: LinearGradient( + // begin: Alignment.topRight, + // end: Alignment.bottomLeft, + // colors: [ + // Color.fromARGB(255, 126, 134, 147), + // Color.fromARGB(255, 193, 198, 209), + // Color.fromARGB(255, 214, 217, 223), + // ], + // )), + child: _buildform(), ), ) ]; @@ -171,7 +180,7 @@ class _LoginScreenState extends State { ), CustomTextField( labelText: "Secret key", controller: secretKeyTextConrtroller), - SizedBox( + SizedBox( height: isTablet ? 40 : 20, ), CustomButton( diff --git a/lib/views/notification_screen.dart b/lib/views/notification_screen.dart index 3c0fb08..d4159dd 100644 --- a/lib/views/notification_screen.dart +++ b/lib/views/notification_screen.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class NotificationCustomScreen extends StatefulWidget { @@ -88,8 +87,8 @@ class _NotificationCustomScreenState extends State { return MaterialApp( home: Scaffold( appBar: AppBar( - title: Text('Notifications'), - backgroundColor: Color.fromARGB(255, 11, 60, 144), + title: const Text('Notifications'), + backgroundColor: const Color.fromARGB(255, 11, 60, 144), ), body: Padding( padding: const EdgeInsets.all(20.0), @@ -170,28 +169,28 @@ class _NotificationCustomScreenState extends State { padding: const EdgeInsets.all(8.0), child: Text( item['Start date']!, - style: TextStyle(fontSize: 18.0), + style: const TextStyle(fontSize: 18.0), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( item['End date']!, - style: TextStyle(fontSize: 18.0), + style: const TextStyle(fontSize: 18.0), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( item['notification']!, - style: TextStyle(fontSize: 18.0), + style: const TextStyle(fontSize: 18.0), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( item['createdby']!, - style: TextStyle(fontSize: 18.0), + style: const TextStyle(fontSize: 18.0), ), ), ]) @@ -201,7 +200,7 @@ class _NotificationCustomScreenState extends State { ), ), floatingActionButton: FloatingActionButton( - backgroundColor: Color.fromARGB(255, 11, 60, 144), + backgroundColor: const Color.fromARGB(255, 11, 60, 144), onPressed: () { setState(() { // Update the list of table data rows @@ -229,7 +228,7 @@ class _NotificationCustomScreenState extends State { ]; }); }, - child: Icon(Icons.refresh), + child: const Icon(Icons.refresh), ), ), ); diff --git a/lib/views/notifications.dart b/lib/views/notifications.dart index 3c8488e..00ceb27 100644 --- a/lib/views/notifications.dart +++ b/lib/views/notifications.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:pwa_ios/utils/apicall.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:theta/theta.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -210,29 +209,33 @@ class _NotificationsScreenState extends State return null; }, - initialUrlRequest: token.isNotEmpty - ? URLRequest( - url: WebUri( - "https://cardio-staging.konectar.io/notifications/"), - headers: { - "rows": "10", - "page": "1", - "sidx": "name", - "sord": "desc" - }, - method: "POST") - : URLRequest( - url: kPwaUri, - headers: { - "key": key, - "email": email, - "name": name, - "key": - "\$2a\$08\$XeBs/kLqAESRk/jWyNVsyeCjoOvxEmDT7/TK5xkLn23FJ/.5B5beK", - // // "email": "scheepu@tikamobile.com", - // // "name": "scheepu", - }, - method: "GET"), + initialUrlRequest: URLRequest( + url: WebUri("http://192.168.2.109:8001/forms/new"), + ), + + // token.isNotEmpty + // ? URLRequest( + // url: WebUri( + // "https://cardio-staging.konectar.io/notifications/"), + // headers: { + // "rows": "10", + // "page": "1", + // "sidx": "name", + // "sord": "desc" + // }, + // method: "POST") + // : URLRequest( + // url: kPwaUri, + // headers: { + // "key": key, + // "email": email, + // "name": name, + // "key": + // "\$2a\$08\$XeBs/kLqAESRk/jWyNVsyeCjoOvxEmDT7/TK5xkLn23FJ/.5B5beK", + // // // "email": "scheepu@tikamobile.com", + // // // "name": "scheepu", + // }, + // method: "GET"), //cachePolicy: cachePolicy), onReceivedServerTrustAuthRequest: diff --git a/lib/views/profile.dart b/lib/views/profile.dart index e97306e..6f4d79e 100644 --- a/lib/views/profile.dart +++ b/lib/views/profile.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:developer'; import 'dart:io'; import 'package:flutter/foundation.dart'; @@ -8,19 +7,12 @@ import 'package:flutter/services.dart'; import 'package:image_picker/image_picker.dart'; import 'package:provider/provider.dart'; import 'package:pwa_ios/main.dart'; -import 'package:pwa_ios/model/interaction_data.dart'; -import 'package:pwa_ios/model/json_form_data.dart'; -import 'package:pwa_ios/model/save_interaction.dart'; import 'package:pwa_ios/model/userdata_model.dart'; -import 'package:pwa_ios/utils/apicall.dart'; import 'package:pwa_ios/utils/mockapi.dart'; import 'package:pwa_ios/utils/sessionmanager.dart'; import 'package:pwa_ios/utils/util.dart'; import 'package:pwa_ios/viewmodel/configprovider.dart'; -import 'package:pwa_ios/viewmodel/interactionprovider.dart'; import 'package:pwa_ios/viewmodel/loginprovider.dart'; -import 'package:pwa_ios/viewmodel/viewinteractionprovider.dart'; -import 'package:pwa_ios/views/login.dart'; import 'package:pwa_ios/utils/validations.dart'; import 'package:pwa_ios/widgets/custombutton.dart'; import 'package:pwa_ios/widgets/customtextfield.dart'; @@ -202,44 +194,56 @@ class _ProfileScreenState extends State { CustomButton( backgroundColor: Colors.grey.shade300, onPressed: () async { - //cancelTimer(); - bool result = - await InternetConnectionChecker().hasConnection; - if (result == true) { + cancelTimer(); + + if (await InternetConnectionChecker().hasConnection) { showLoaderDialog(context); + final ConfigDataProvider configDataProvider = + ConfigDataProvider(); // ignore: use_build_context_synchronously - final provider = Provider.of( - context, - listen: false); - final prov = Provider.of(context, - listen: false); - List senSavedList = []; - List savedList = - await provider.getAllRecords(); - for (var obj in savedList) { - senSavedList.add(prov.formJson(obj)); - } + // final provider = Provider.of( + // context, + // listen: false); + // final prov = Provider.of(context, + // listen: false); + // List senSavedList = []; + // List savedList = + // await provider.getAllRecords(); + // for (var obj in savedList) { + // senSavedList.add(prov.formJson(obj)); + // } - SendSaveJson jsonData = - SendSaveJson(savedList: senSavedList); - DataJson dataJson = DataJson(sendSaveJson: jsonData); - String jsonstr = saveFormJsonToJson(jsonData); - print(jsonstr); - String jsonDataEncoded = - saveInteractionFormJsonToJson(dataJson); - print(jsonDataEncoded); + // SendSaveJson jsonData = + // SendSaveJson(savedList: senSavedList); + // DataJson dataJson = DataJson(sendSaveJson: jsonData); + // String jsonstr = saveFormJsonToJson(jsonData); + // print(jsonstr); + if (await checkRecordsAvailable()) { + String jsonstr = await formJsonForSync(); - var result = await MockApiCall().postSavedData( - jsonstr, - "/Users/aissel/Library/Developer/CoreSimulator/Devices/1E435121-7E65-45C6-9E0B-411C8B9915F5/data/Containers/Data/Application/4B7EDC75-F376-4A21-A1E4-2A621BCCBD13/Documents/konectar/files/Flutter Questionaire.pdf"); - if (result != null) { - Navigator.pop(context); - _displaySnackBar('Data synced sucessfully!'); + var result = + await MockApiCall().postSavedData(jsonstr); + + if (result != null) { + Navigator.pop(context); + + await deleteRecords(); + await configDataProvider + .initConfigUIData() + .then((value) {}); + + _displaySnackBar('Data synced sucessfully!'); + } else { + Navigator.pop(context); + _displaySnackBar('Something went wrong!'); + } } else { Navigator.pop(context); - _displaySnackBar('Something went wrong!'); + _displaySnackBar('No records to sync!'); } + } else { + _displaySnackBar('No Internet Connectivity!'); } }, textColor: Colors.black, @@ -273,7 +277,7 @@ class _ProfileScreenState extends State { const CircularProgressIndicator(), Container( margin: const EdgeInsets.only(left: 7), - child: Text("Syncing...")), + child: const Text("Syncing...")), ], ), ); @@ -476,7 +480,7 @@ class _ProfileScreenState extends State { showAlertDialog(BuildContext context) { // set up the buttons Widget cancelButton = TextButton( - child: Text("Gallery"), + child: const Text("Gallery"), onPressed: () async { await _getFromGallery(); setState(() {}); @@ -484,7 +488,7 @@ class _ProfileScreenState extends State { }, ); Widget continueButton = TextButton( - child: Text("Camera"), + child: const Text("Camera"), onPressed: () async { await _getFromCamera(); setState(() {}); @@ -494,8 +498,8 @@ class _ProfileScreenState extends State { // set up the AlertDialog AlertDialog alert = AlertDialog( - title: Text(""), - content: Text("Profile photo"), + title: const Text(""), + content: const Text("Profile photo"), actions: [ cancelButton, continueButton, @@ -514,7 +518,7 @@ class _ProfileScreenState extends State { showDeleteProfileAlertDialog(BuildContext context) { // set up the buttons Widget cancelButton = TextButton( - child: Text("YES"), + child: const Text("YES"), onPressed: () async { await provider.deleteUserData().then((value) async { await SessionManager().clearSession().then((value) { @@ -526,7 +530,7 @@ class _ProfileScreenState extends State { }, ); Widget continueButton = TextButton( - child: Text("NO"), + child: const Text("NO"), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/views/webview_example.dart b/lib/views/webview_example.dart index 899ac1b..f4bbd5e 100644 --- a/lib/views/webview_example.dart +++ b/lib/views/webview_example.dart @@ -1,6 +1,5 @@ import 'dart:collection'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; diff --git a/lib/widgets/custombutton.dart b/lib/widgets/custombutton.dart index 2ecd2ea..5915c67 100644 --- a/lib/widgets/custombutton.dart +++ b/lib/widgets/custombutton.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class CustomButton extends StatelessWidget { diff --git a/lib/widgets/customrangeslider.dart b/lib/widgets/customrangeslider.dart index 8f80c44..9e8bf96 100644 --- a/lib/widgets/customrangeslider.dart +++ b/lib/widgets/customrangeslider.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:pwa_ios/utils/util.dart'; @@ -19,17 +18,20 @@ class CustomRangeSlider extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - Slider( - activeColor: const Color(0xFF2b9af3), - onChanged: onChanged, - min: min ?? 10.0, - max: max ?? 80.0, - label: sliderPos.toInt().toString(), - divisions: 48, - value: sliderPos, + SizedBox( + height: isTablet ? 40 : 40, + child: Slider( + activeColor: const Color(0xFF2b9af3), + onChanged: onChanged, + min: min ?? 10.0, + max: max ?? 80.0, + label: sliderPos.toInt().toString(), + divisions: 48, + value: sliderPos, + ), ), SizedBox( - height: isTablet ? 2 : 1, + height: isTablet ? 1 : 1, ), Text( "Range: ${sliderPos.toInt()}", diff --git a/lib/widgets/customwidgets.dart b/lib/widgets/customwidgets.dart new file mode 100644 index 0000000..a4ae3e0 --- /dev/null +++ b/lib/widgets/customwidgets.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class customWidgets extends StatefulWidget { + const customWidgets({super.key}); + + @override + State createState() => _customWidgetsState(); +} + +class _customWidgetsState extends State { + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/widgets/interatciontextfield.dart b/lib/widgets/interatciontextfield.dart index 5d0689a..79710d1 100644 --- a/lib/widgets/interatciontextfield.dart +++ b/lib/widgets/interatciontextfield.dart @@ -37,7 +37,7 @@ class InteractionTextField extends StatelessWidget { onTap: () {}, maxLines: maxlines ?? 1, minLines: minlines, - keyboardType: inputType ?? TextInputType.none, + keyboardType: inputType ?? TextInputType.name, onChanged: (value) { onChanged(value); }, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 3c46cee..509608a 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,7 +8,7 @@ import Foundation import connectivity_plus import device_info_plus import file_selector_macos -import flutter_inappwebview +import flutter_inappwebview_macos import package_info_plus import path_provider_foundation import shared_preferences_foundation diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 470dce7..2486249 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -74,4 +74,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 -COCOAPODS: 1.12.1 +COCOAPODS: 1.14.3 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 0c6a299..ce7b93b 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -259,7 +259,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 7e098bb..51e94a0 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =3.2.0-194.0.dev <4.0.0" - flutter: ">=3.16.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/pubspec.yaml b/pubspec.yaml index c2ce60d..777b3b7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,7 +67,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.3 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/test/widget_test.dart b/test/widget_test.dart index 3381861..db84051 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -8,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:pwa_ios/main.dart'; import 'package:pwa_ios/views/konectarpage.dart'; void main() {