Skip to content

Commit

Permalink
feat(neon_framework): Implement syncing
Browse files Browse the repository at this point in the history
Signed-off-by: jld3103 <[email protected]>
  • Loading branch information
provokateurin committed Feb 22, 2024
1 parent dfd0724 commit e9523a3
Show file tree
Hide file tree
Showing 35 changed files with 1,187 additions and 16 deletions.
7 changes: 7 additions & 0 deletions packages/app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
synchronize:
dependency: "direct overridden"
description:
path: "../synchronize"
relative: true
source: path
version: "1.0.0"
synchronized:
dependency: transitive
description:
Expand Down
4 changes: 3 additions & 1 deletion packages/app/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon_dashboard,neon_files,neon_framework,neon_lints,neon_news,neon_notes,neon_notifications,nextcloud,sort_box,package_info_plus
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon_dashboard,neon_files,neon_framework,neon_lints,neon_news,neon_notes,neon_notifications,nextcloud,sort_box,synchronize,package_info_plus
dependency_overrides:
dynamite_runtime:
path: ../dynamite/dynamite_runtime
Expand All @@ -22,6 +22,8 @@ dependency_overrides:
path: ../nextcloud
sort_box:
path: ../sort_box
synchronize:
path: ../synchronize
package_info_plus:
git:
url: https://github.com/fluttercommunity/plus_plugins
Expand Down
4 changes: 3 additions & 1 deletion packages/neon/neon_dashboard/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,package_info_plus
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,synchronize,package_info_plus
dependency_overrides:
dynamite_runtime:
path: ../../dynamite/dynamite_runtime
Expand All @@ -10,6 +10,8 @@ dependency_overrides:
path: ../../nextcloud
sort_box:
path: ../../sort_box
synchronize:
path: ../../synchronize
package_info_plus:
git:
url: https://github.com/fluttercommunity/plus_plugins
Expand Down
4 changes: 3 additions & 1 deletion packages/neon/neon_files/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon_framework,neon_lints,nextcloud,sort_box,package_info_plus
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon_framework,neon_lints,nextcloud,sort_box,synchronize,package_info_plus
dependency_overrides:
dynamite_runtime:
path: ../../dynamite/dynamite_runtime
Expand All @@ -12,6 +12,8 @@ dependency_overrides:
path: ../../nextcloud
sort_box:
path: ../../sort_box
synchronize:
path: ../../synchronize
package_info_plus:
git:
url: https://github.com/fluttercommunity/plus_plugins
Expand Down
4 changes: 3 additions & 1 deletion packages/neon/neon_news/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,package_info_plus
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,synchronize,package_info_plus
dependency_overrides:
dynamite_runtime:
path: ../../dynamite/dynamite_runtime
Expand All @@ -10,6 +10,8 @@ dependency_overrides:
path: ../../nextcloud
sort_box:
path: ../../sort_box
synchronize:
path: ../../synchronize
package_info_plus:
git:
url: https://github.com/fluttercommunity/plus_plugins
Expand Down
4 changes: 3 additions & 1 deletion packages/neon/neon_notes/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,package_info_plus
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,synchronize,package_info_plus
dependency_overrides:
dynamite_runtime:
path: ../../dynamite/dynamite_runtime
Expand All @@ -10,6 +10,8 @@ dependency_overrides:
path: ../../nextcloud
sort_box:
path: ../../sort_box
synchronize:
path: ../../synchronize
package_info_plus:
git:
url: https://github.com/fluttercommunity/plus_plugins
Expand Down
4 changes: 3 additions & 1 deletion packages/neon/neon_notifications/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,package_info_plus
# melos_managed_dependency_overrides: dynamite_runtime,neon_framework,neon_lints,nextcloud,sort_box,synchronize,package_info_plus
dependency_overrides:
dynamite_runtime:
path: ../../dynamite/dynamite_runtime
Expand All @@ -10,6 +10,8 @@ dependency_overrides:
path: ../../nextcloud
sort_box:
path: ../../sort_box
synchronize:
path: ../../synchronize
package_info_plus:
git:
url: https://github.com/fluttercommunity/plus_plugins
Expand Down
42 changes: 41 additions & 1 deletion packages/neon_framework/lib/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
"actionContinue": "Continue",
"actionCancel": "Cancel",
"actionDone": "Done",
"actionPrevious": "Previous",
"actionNext": "Next",
"actionFinish": "Finish",
"firstLaunchGoToSettingsToEnablePushNotifications": "Go to the settings to enable push notifications",
"nextPushSupported": "NextPush is supported!",
"nextPushSupportedText": "NextPush is a FOSS way of receiving push notifications using the UnifiedPush protocol via a Nextcloud instance.\nYou can install NextPush from the F-Droid app store.",
Expand Down Expand Up @@ -248,5 +251,42 @@
"userStatusClearAtThisWeek": "This week",
"userStatusActionClear": "Clear status",
"userStatusStatusMessage": "Status message",
"userStatusOnlineStatus": "Online status"
"userStatusOnlineStatus": "Online status",
"sync": "Synchronization",
"syncOptionsNoSynchronizations": "No {type} synchronizations",
"@syncOptionsNoSynchronizations": {
"placeholders": {
"type": {
"type": "String"
}
}
},
"syncOptionsAdd": "Add {type} synchronization",
"@syncOptionsAdd": {
"placeholders": {
"type": {
"type": "String"
}
}
},
"syncOptionsRemove": "Remove synchronization",
"syncOptionsSyncNow": "Synchronize now",
"syncOptionsStatusUnknown": "Unknown synchronization status",
"syncOptionsStatusIncomplete": "Not completely synchronized",
"syncOptionsStatusComplete": "Completely synchronized",
"syncOptionsRemoveConfirmation": "Do you want to remove the synchronization?",
"syncOptionsAutomaticSync": "Sync automatically",
"syncResolveConflictsLocal": "Local",
"syncResolveConflictsRemote": "Remote",
"syncResolveConflictsTitle": "Found {count} conflicts for syncing {name}",
"@syncResolveConflictsTitle": {
"placeholders": {
"count": {
"type": "int"
},
"name": {
"type": "String"
}
}
}
}
96 changes: 96 additions & 0 deletions packages/neon_framework/lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,24 @@ abstract class NeonLocalizations {
/// **'Done'**
String get actionDone;

/// No description provided for @actionPrevious.
///
/// In en, this message translates to:
/// **'Previous'**
String get actionPrevious;

/// No description provided for @actionNext.
///
/// In en, this message translates to:
/// **'Next'**
String get actionNext;

/// No description provided for @actionFinish.
///
/// In en, this message translates to:
/// **'Finish'**
String get actionFinish;

/// No description provided for @firstLaunchGoToSettingsToEnablePushNotifications.
///
/// In en, this message translates to:
Expand Down Expand Up @@ -844,6 +862,84 @@ abstract class NeonLocalizations {
/// In en, this message translates to:
/// **'Online status'**
String get userStatusOnlineStatus;

/// No description provided for @sync.
///
/// In en, this message translates to:
/// **'Synchronization'**
String get sync;

/// No description provided for @syncOptionsNoSynchronizations.
///
/// In en, this message translates to:
/// **'No {type} synchronizations'**
String syncOptionsNoSynchronizations(String type);

/// No description provided for @syncOptionsAdd.
///
/// In en, this message translates to:
/// **'Add {type} synchronization'**
String syncOptionsAdd(String type);

/// No description provided for @syncOptionsRemove.
///
/// In en, this message translates to:
/// **'Remove synchronization'**
String get syncOptionsRemove;

/// No description provided for @syncOptionsSyncNow.
///
/// In en, this message translates to:
/// **'Synchronize now'**
String get syncOptionsSyncNow;

/// No description provided for @syncOptionsStatusUnknown.
///
/// In en, this message translates to:
/// **'Unknown synchronization status'**
String get syncOptionsStatusUnknown;

/// No description provided for @syncOptionsStatusIncomplete.
///
/// In en, this message translates to:
/// **'Not completely synchronized'**
String get syncOptionsStatusIncomplete;

/// No description provided for @syncOptionsStatusComplete.
///
/// In en, this message translates to:
/// **'Completely synchronized'**
String get syncOptionsStatusComplete;

/// No description provided for @syncOptionsRemoveConfirmation.
///
/// In en, this message translates to:
/// **'Do you want to remove the synchronization?'**
String get syncOptionsRemoveConfirmation;

/// No description provided for @syncOptionsAutomaticSync.
///
/// In en, this message translates to:
/// **'Sync automatically'**
String get syncOptionsAutomaticSync;

/// No description provided for @syncResolveConflictsLocal.
///
/// In en, this message translates to:
/// **'Local'**
String get syncResolveConflictsLocal;

/// No description provided for @syncResolveConflictsRemote.
///
/// In en, this message translates to:
/// **'Remote'**
String get syncResolveConflictsRemote;

/// No description provided for @syncResolveConflictsTitle.
///
/// In en, this message translates to:
/// **'Found {count} conflicts for syncing {name}'**
String syncResolveConflictsTitle(int count, String name);
}

class _NeonLocalizationsDelegate extends LocalizationsDelegate<NeonLocalizations> {
Expand Down
54 changes: 54 additions & 0 deletions packages/neon_framework/lib/l10n/localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ class NeonLocalizationsEn extends NeonLocalizations {
@override
String get actionDone => 'Done';

@override
String get actionPrevious => 'Previous';

@override
String get actionNext => 'Next';

@override
String get actionFinish => 'Finish';

@override
String get firstLaunchGoToSettingsToEnablePushNotifications => 'Go to the settings to enable push notifications';

Expand Down Expand Up @@ -460,4 +469,49 @@ class NeonLocalizationsEn extends NeonLocalizations {

@override
String get userStatusOnlineStatus => 'Online status';

@override
String get sync => 'Synchronization';

@override
String syncOptionsNoSynchronizations(String type) {
return 'No $type synchronizations';
}

@override
String syncOptionsAdd(String type) {
return 'Add $type synchronization';
}

@override
String get syncOptionsRemove => 'Remove synchronization';

@override
String get syncOptionsSyncNow => 'Synchronize now';

@override
String get syncOptionsStatusUnknown => 'Unknown synchronization status';

@override
String get syncOptionsStatusIncomplete => 'Not completely synchronized';

@override
String get syncOptionsStatusComplete => 'Completely synchronized';

@override
String get syncOptionsRemoveConfirmation => 'Do you want to remove the synchronization?';

@override
String get syncOptionsAutomaticSync => 'Sync automatically';

@override
String get syncResolveConflictsLocal => 'Local';

@override
String get syncResolveConflictsRemote => 'Remote';

@override
String syncResolveConflictsTitle(int count, String name) {
return 'Found $count conflicts for syncing $name';
}
}
6 changes: 6 additions & 0 deletions packages/neon_framework/lib/neon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:neon_framework/src/blocs/accounts.dart';
import 'package:neon_framework/src/blocs/first_launch.dart';
import 'package:neon_framework/src/blocs/next_push.dart';
import 'package:neon_framework/src/blocs/push_notifications.dart';
import 'package:neon_framework/src/blocs/sync.dart';
import 'package:neon_framework/src/models/account.dart';
import 'package:neon_framework/src/models/app_implementation.dart';
import 'package:neon_framework/src/models/disposable.dart';
Expand Down Expand Up @@ -65,6 +66,10 @@ Future<void> runNeon({
globalOptions,
disabled: nextPushDisabled,
);
final syncBloc = SyncBloc(
accountsBloc,
appImplementations,
);

runApp(
MultiProvider(
Expand All @@ -73,6 +78,7 @@ Future<void> runNeon({
NeonProvider<AccountsBloc>.value(value: accountsBloc),
NeonProvider<FirstLaunchBloc>.value(value: firstLaunchBloc),
NeonProvider<NextPushBloc>.value(value: nextPushBloc),
NeonProvider<SyncBloc>.value(value: syncBloc),
Provider<BuiltSet<AppImplementation>>(
create: (_) => appImplementations,
dispose: (_, appImplementations) => appImplementations.disposeAll(),
Expand Down
9 changes: 9 additions & 0 deletions packages/neon_framework/lib/src/blocs/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ abstract class AppsBloc implements InteractiveBloc {
/// If no bloc exists yet a new one will be instantiated and cached in [AppImplementation.blocsCache].
T getAppBloc<T extends Bloc>(AppImplementation<T, dynamic> appImplementation);

/// Returns the active [Bloc] for the given [appId].
///
/// If no bloc exists yet a new one will be instantiated and cached in [AppImplementation.blocsCache].
/// See [getAppBloc] for getting the [Bloc] by the [AppImplementation].
T getAppBlocByID<T extends Bloc>(String appId);

/// Returns the active [Bloc] for every registered [AppImplementation] wrapped in a Provider.
List<Provider<Bloc>> get appBlocProviders;
}
Expand Down Expand Up @@ -284,6 +290,9 @@ class _AppsBloc extends InteractiveBloc implements AppsBloc {
@override
T getAppBloc<T extends Bloc>(AppImplementation<T, dynamic> appImplementation) => appImplementation.getBloc(account);

@override
T getAppBlocByID<T extends Bloc>(String appId) => allAppImplementations.find(appId).getBloc(account) as T;

@override
List<Provider<Bloc>> get appBlocProviders =>
allAppImplementations.map((appImplementation) => appImplementation.blocProvider).toList();
Expand Down
Loading

0 comments on commit e9523a3

Please sign in to comment.