diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml
index 35a11152d..0d45fc254 100644
--- a/.github/workflows/dart.yml
+++ b/.github/workflows/dart.yml
@@ -1,8 +1,3 @@
-# This workflow uses actions that are not certified by GitHub.
-# They are provided by a third-party and are governed by
-# separate terms of service, privacy policy, and support
-# documentation.
-
name: Run analysis and tests
on:
@@ -22,7 +17,13 @@ jobs:
- name: Flutter action
uses: subosito/flutter-action@v2.8.0
with:
- flutter-version: "3.16.5"
+ flutter-version: "3.22.1"
+
+ - name: Clean previous builds
+ run: flutter clean
+
+ - name: Install dependencies
+ run: flutter pub get
- name: Generate models
run: ./tools/install_bricks.sh
diff --git a/apps/health_campaign_field_worker_app/android/app/build.gradle b/apps/health_campaign_field_worker_app/android/app/build.gradle
index 7ed3cf689..4ec7c839d 100644
--- a/apps/health_campaign_field_worker_app/android/app/build.gradle
+++ b/apps/health_campaign_field_worker_app/android/app/build.gradle
@@ -1,3 +1,11 @@
+plugins {
+ id 'com.android.application'
+ id 'kotlin-android'
+ id 'dev.flutter.flutter-gradle-plugin'
+ id 'com.google.gms.google-services'
+ id 'com.google.firebase.crashlytics'
+}
+
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
@@ -6,11 +14,6 @@ if (localPropertiesFile.exists()) {
}
}
-def flutterRoot = localProperties.getProperty('flutter.sdk')
-if (flutterRoot == null) {
- throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
-}
-
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
@@ -21,12 +24,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
-apply plugin: 'com.android.application'
-// START: FlutterFire Configuration
-apply plugin: 'com.google.gms.google-services'
-// END: FlutterFire Configuration
-apply plugin: 'kotlin-android'
-apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 34
@@ -67,8 +64,4 @@ android {
flutter {
source '../..'
-}
-
-dependencies {
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
-}
+}
\ No newline at end of file
diff --git a/apps/health_campaign_field_worker_app/android/app/src/main/AndroidManifest.xml b/apps/health_campaign_field_worker_app/android/app/src/main/AndroidManifest.xml
index 8599cae8b..14af9d02b 100644
--- a/apps/health_campaign_field_worker_app/android/app/src/main/AndroidManifest.xml
+++ b/apps/health_campaign_field_worker_app/android/app/src/main/AndroidManifest.xml
@@ -3,6 +3,9 @@
+
+
+
@@ -64,9 +67,10 @@
-
-
+
properties.load(reader) }
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
-def flutterSdkPath = properties.getProperty("flutter.sdk")
-assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
-apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
+plugins {
+ id "dev.flutter.flutter-plugin-loader" version "1.0.0"
+ id "com.android.application" version "7.3.0" apply false
+ id "org.jetbrains.kotlin.android" version "1.8.22" apply false
+ id "com.google.gms.google-services" version "4.4.0" apply false
+ id "com.google.firebase.crashlytics" version "2.9.9" apply false
+}
+
+include ":app"
\ No newline at end of file
diff --git a/apps/health_campaign_field_worker_app/build.yaml b/apps/health_campaign_field_worker_app/build.yaml
index 27c12a092..c0579ceef 100644
--- a/apps/health_campaign_field_worker_app/build.yaml
+++ b/apps/health_campaign_field_worker_app/build.yaml
@@ -7,4 +7,7 @@ targets:
- lib/pages/**.dart
auto_route_generator:auto_router_generator:
generate_for:
- - lib/router/**router.dart
\ No newline at end of file
+ - lib/router/**router.dart
+ super_annotations:
+ options:
+ targets: [ sync ]
\ No newline at end of file
diff --git a/apps/health_campaign_field_worker_app/lib/app.dart b/apps/health_campaign_field_worker_app/lib/app.dart
index 531d0295c..1f071314f 100644
--- a/apps/health_campaign_field_worker_app/lib/app.dart
+++ b/apps/health_campaign_field_worker_app/lib/app.dart
@@ -19,6 +19,8 @@ import 'package:registration_delivery/models/entities/household.dart';
import 'package:registration_delivery/models/entities/household_member.dart';
import 'package:registration_delivery/models/entities/project_beneficiary.dart';
import 'package:registration_delivery/models/entities/task.dart';
+import 'package:sync_service/data/sync_service.dart';
+import 'package:sync_service/data/sync_service_annotation.dart';
import 'blocs/app_initialization/app_initialization.dart';
import 'blocs/auth/auth.dart';
diff --git a/apps/health_campaign_field_worker_app/lib/blocs/project/project.dart b/apps/health_campaign_field_worker_app/lib/blocs/project/project.dart
index 3be8eec58..07347633e 100644
--- a/apps/health_campaign_field_worker_app/lib/blocs/project/project.dart
+++ b/apps/health_campaign_field_worker_app/lib/blocs/project/project.dart
@@ -161,8 +161,8 @@ class ProjectBloc extends Bloc {
title: 'ProjectBloc',
);
- final isOnline = connectivityResult == ConnectivityResult.wifi ||
- connectivityResult == ConnectivityResult.mobile;
+ final isOnline = connectivityResult.firstOrNull == ConnectivityResult.wifi ||
+ connectivityResult.firstOrNull == ConnectivityResult.mobile;
final selectedProject = await localSecureStore.selectedProject;
final isProjectSetUpComplete = await localSecureStore
.isProjectSetUpComplete(selectedProject?.id ?? "noProjectId");
diff --git a/apps/health_campaign_field_worker_app/lib/blocs/projects_beneficiary_downsync/project_beneficiaries_downsync.dart b/apps/health_campaign_field_worker_app/lib/blocs/projects_beneficiary_downsync/project_beneficiaries_downsync.dart
index a443250b1..61c278aeb 100644
--- a/apps/health_campaign_field_worker_app/lib/blocs/projects_beneficiary_downsync/project_beneficiaries_downsync.dart
+++ b/apps/health_campaign_field_worker_app/lib/blocs/projects_beneficiary_downsync/project_beneficiaries_downsync.dart
@@ -2,14 +2,14 @@
import 'dart:async';
import 'package:digit_data_model/data_model.dart';
-import 'package:disk_space/disk_space.dart';
+import 'package:disk_space_update/disk_space_update.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:registration_delivery/registration_delivery.dart';
+import 'package:sync_service/sync_service_lib.dart';
import '../../data/local_store/no_sql/schema/app_configuration.dart';
import '../../data/local_store/secure_store/secure_store.dart';
-import '../../data/network_manager.dart';
import '../../data/repositories/remote/bandwidth_check.dart';
import '../../models/downsync/downsync.dart';
import '../../utils/background_service.dart';
@@ -27,7 +27,6 @@ class BeneficiaryDownSyncBloc
downSyncRemoteRepository;
final LocalRepository
downSyncLocalRepository;
- final NetworkManager networkManager;
final BandwidthCheckRepository bandwidthCheckRepository;
final LocalRepository
householdLocalRepository;
@@ -39,12 +38,11 @@ class BeneficiaryDownSyncBloc
final LocalRepository
sideEffectLocalRepository;
final LocalRepository
- referralLocalRepository;
+ referralLocalRepository;
BeneficiaryDownSyncBloc({
required this.individualLocalRepository,
required this.downSyncRemoteRepository,
required this.downSyncLocalRepository,
- required this.networkManager,
required this.bandwidthCheckRepository,
required this.householdLocalRepository,
required this.householdMemberLocalRepository,
@@ -203,7 +201,9 @@ class BeneficiaryDownSyncBloc
);
// check if the API response is there or it failed
if (downSyncResults.isNotEmpty) {
- await networkManager.writeToEntityDB(downSyncResults, [
+ await SyncServiceSingleton()
+ .entityMapper
+ ?.writeToEntityDB(downSyncResults, [
individualLocalRepository,
householdLocalRepository,
householdMemberLocalRepository,
diff --git a/apps/health_campaign_field_worker_app/lib/data/data_manager.dart b/apps/health_campaign_field_worker_app/lib/data/data_manager.dart
deleted file mode 100644
index 7d649d73e..000000000
--- a/apps/health_campaign_field_worker_app/lib/data/data_manager.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-import 'dart:async';
-
-import 'package:digit_data_model/data_model.dart';
-
-class DataManager {
- final RemoteRepository remoteRepository;
- final LocalRepository localRepository;
- final PersistenceConfiguration configuration;
-
- const DataManager({
- required this.localRepository,
- required this.remoteRepository,
- required this.configuration,
- });
-
- DataRepository _getRepository(PersistenceConfiguration configuration) {
- switch (configuration) {
- case PersistenceConfiguration.offline:
- return localRepository;
- case PersistenceConfiguration.online:
- return remoteRepository;
- }
- }
-
- FutureOr> search(R query) =>
- _getRepository(configuration).search(query);
-
- FutureOr create(D entity) =>
- _getRepository(configuration).create(entity);
-
- FutureOr update(D entity) =>
- _getRepository(configuration).update(entity);
-}
-
-enum PersistenceConfiguration { offline, online }
diff --git a/apps/health_campaign_field_worker_app/lib/data/network_manager.dart b/apps/health_campaign_field_worker_app/lib/data/network_manager.dart
index 744577530..34125ce56 100644
--- a/apps/health_campaign_field_worker_app/lib/data/network_manager.dart
+++ b/apps/health_campaign_field_worker_app/lib/data/network_manager.dart
@@ -1,18 +1,6 @@
-import 'dart:async';
-import 'dart:convert';
-
import 'package:digit_data_model/data_model.dart';
import 'package:flutter/cupertino.dart';
-import 'package:flutter/foundation.dart';
-import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:provider/provider.dart';
-import 'package:registration_delivery/registration_delivery.dart';
-
-import '../models/bandwidth/bandwidth_model.dart';
-import 'local_store/secure_store/secure_store.dart';
-import 'repositories/sync/remote_type.dart';
-import 'repositories/sync/sync_down.dart';
-import 'repositories/sync/sync_up.dart';
class NetworkManager {
final NetworkManagerConfiguration configuration;
@@ -30,194 +18,6 @@ class NetworkManager {
return context.read>();
}
}
-
-/* This function will read the params and get the records which are not synced
- and pushes to the sync-up and sync-down methods */
-
- FutureOr performSync({
- required List localRepositories,
- required List remoteRepositories,
- required BandwidthModel bandwidthModel,
- ServiceInstance? service,
- }) async {
- if (configuration.persistenceConfig ==
- PersistenceConfiguration.onlineOnly) {
- throw Exception('Sync up is not valid for online only configuration');
- }
- bool isSyncCompleted = false;
-
- final futuresSyncDown = await Future.wait(
- localRepositories
- .map((e) => e.getItemsToBeSyncedDown(bandwidthModel.userId)),
- );
- final pendingSyncDownEntries = futuresSyncDown.expand((e) => e).toList();
-
- final futuresSyncUp = await Future.wait(
- localRepositories
- .map((e) => e.getItemsToBeSyncedUp(bandwidthModel.userId)),
- );
- final pendingSyncUpEntries = futuresSyncUp.expand((e) => e).toList();
-
- SyncError? syncError;
-
-// Perform the sync Down Operation
-
- try {
- await PerformSyncDown.syncDown(
- bandwidthModel: bandwidthModel,
- localRepositories: localRepositories.toSet().toList(),
- remoteRepositories: remoteRepositories.toSet().toList(),
- configuration: configuration,
- );
- } catch (e) {
- syncError = SyncDownError(e);
- service?.stopSelf();
- }
-
-// Perform the sync up Operation
-
- try {
- await PerformSyncUp.syncUp(
- bandwidthModel: bandwidthModel,
- localRepositories: localRepositories.toSet().toList(),
- remoteRepositories: remoteRepositories.toSet().toList(),
- );
- } catch (e) {
- if (kDebugMode) {
- print('Sync Up Error: $e');
- }
- syncError ??= SyncUpError(e);
- service?.stopSelf();
- }
-
- if (syncError != null) throw syncError;
-
- // Recursive function which will call the Perfom Sync
-
- if (pendingSyncUpEntries.isNotEmpty || pendingSyncDownEntries.isNotEmpty) {
- await Future.delayed(const Duration(seconds: 3));
- isSyncCompleted = await performSync(
- bandwidthModel: bandwidthModel,
- localRepositories: localRepositories,
- remoteRepositories: remoteRepositories,
- );
- } else if (pendingSyncUpEntries.isEmpty && pendingSyncDownEntries.isEmpty) {
- await LocalSecureStore.instance.setManualSyncTrigger(false);
- isSyncCompleted = true;
- }
-
- return isSyncCompleted;
- }
-
-
- FutureOr writeToEntityDB(
- Map response,
- List localRepositories,
- ) async {
- try {
- for (int i = 0; i <= response.keys.length - 1; i++) {
- if (response.keys.elementAt(i) != 'DownsyncCriteria') {
- final local = RepositoryType.getLocalForType(
- DataModels.getDataModelForEntityName(response.keys.elementAt(i)),
- localRepositories,
- );
- final List entityResponse =
- response[response.keys.elementAt(i)] ?? [];
-
- final entityList =
- entityResponse.whereType