diff --git a/packages/at_onboarding_flutter/example/ios/Podfile.lock b/packages/at_onboarding_flutter/example/ios/Podfile.lock index d3e09e904..4942f9069 100644 --- a/packages/at_onboarding_flutter/example/ios/Podfile.lock +++ b/packages/at_onboarding_flutter/example/ios/Podfile.lock @@ -72,7 +72,6 @@ PODS: - Flutter - webview_flutter_wkwebview (0.0.1): - Flutter - - FlutterMacOS DEPENDENCIES: - at_backupkey_flutter (from `.symlinks/plugins/at_backupkey_flutter/ios`) @@ -91,7 +90,7 @@ DEPENDENCIES: - share_plus (from `.symlinks/plugins/share_plus/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`) + - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) SPEC REPOS: trunk: @@ -135,7 +134,7 @@ EXTERNAL SOURCES: url_launcher_ios: :path: ".symlinks/plugins/url_launcher_ios/ios" webview_flutter_wkwebview: - :path: ".symlinks/plugins/webview_flutter_wkwebview/darwin" + :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: at_backupkey_flutter: 2fc3d01138175e41bce8b574387a47544c53e01b @@ -159,8 +158,8 @@ SPEC CHECKSUMS: shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe - webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4 + webview_flutter_wkwebview: 2a23822e9039b7b1bc52e5add778e5d89ad488d1 PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/packages/at_onboarding_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/at_onboarding_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift index 417197bd7..591d027b4 100644 --- a/packages/at_onboarding_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/at_onboarding_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -14,7 +14,6 @@ import path_provider_foundation import share_plus import shared_preferences_foundation import url_launcher_macos -import webview_flutter_wkwebview func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin")) @@ -26,5 +25,4 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) - FLTWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "FLTWebViewFlutterPlugin")) } diff --git a/packages/at_onboarding_flutter/example/macos/Podfile.lock b/packages/at_onboarding_flutter/example/macos/Podfile.lock index 0403151df..7a1345740 100644 --- a/packages/at_onboarding_flutter/example/macos/Podfile.lock +++ b/packages/at_onboarding_flutter/example/macos/Podfile.lock @@ -20,9 +20,6 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS - - webview_flutter_wkwebview (0.0.1): - - Flutter - - FlutterMacOS DEPENDENCIES: - at_file_saver (from `Flutter/ephemeral/.symlinks/plugins/at_file_saver/macos`) @@ -35,7 +32,6 @@ DEPENDENCIES: - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - - webview_flutter_wkwebview (from `Flutter/ephemeral/.symlinks/plugins/webview_flutter_wkwebview/darwin`) EXTERNAL SOURCES: at_file_saver: @@ -58,8 +54,6 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos - webview_flutter_wkwebview: - :path: Flutter/ephemeral/.symlinks/plugins/webview_flutter_wkwebview/darwin SPEC CHECKSUMS: at_file_saver: 1fc6ed722f17c7a20ce79cce168d1100fcad4b95 @@ -67,13 +61,12 @@ SPEC CHECKSUMS: device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c + package_info_plus: d2f71247aab4b6521434f887276093acc70d214c path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 - share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf + share_plus: a182a58e04e51647c0481aadabbc4de44b3a2bce shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 - webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4 PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/packages/at_onboarding_flutter/example/pubspec.yaml b/packages/at_onboarding_flutter/example/pubspec.yaml index c0f0336b2..19bcdfc31 100644 --- a/packages/at_onboarding_flutter/example/pubspec.yaml +++ b/packages/at_onboarding_flutter/example/pubspec.yaml @@ -46,8 +46,6 @@ dev_dependencies: flutter_lints: ^4.0.0 flutter_test: sdk: flutter - - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/at_onboarding_flutter/lib/at_onboarding.dart b/packages/at_onboarding_flutter/lib/at_onboarding.dart index 7ec312245..6dd052c7b 100644 --- a/packages/at_onboarding_flutter/lib/at_onboarding.dart +++ b/packages/at_onboarding_flutter/lib/at_onboarding.dart @@ -1,184 +1,5 @@ -import 'dart:io'; +library at_onboarding_legacy; -import 'package:at_onboarding_flutter/at_onboarding_result.dart'; -import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_activate_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_intro_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reset_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_start_screen.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_config.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_theme.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_app_constants.dart'; -import 'package:flutter/material.dart'; - -class AtOnboarding { - /// Using this function to get onboard atsing. - /// - /// @param context The build context. - /// @param config The config for the onboard - /// @param isSwitchingAtsign True - alway show UI for add new atsign. False - check onboard if existing atsing. Default is false - /// @param atsign The atsign name when change the primary atsign. - /// - /// Return [AtOnboardingResult] - static Future onboard({ - required BuildContext context, - required AtOnboardingConfig config, - bool isSwitchingAtsign = false, - String? atsign, - }) async { - AtOnboardingConstants.setApiKey(config.appAPIKey ?? - (AtOnboardingConstants.rootEnvironment.apikey ?? '')); - AtOnboardingConstants.rootDomain = - config.domain ?? AtOnboardingConstants.rootEnvironment.domain; - - /// Initial Setup - await _initialSetup(context); - - /// user sharing is not supported on Android, iOS and Linux. - if (Platform.isAndroid || Platform.isIOS || Platform.isLinux) { - config.showPopupSharedStorage = false; - } - - if (config.theme == null) { - final defaultConfig = config.copyWith( - theme: AtOnboardingTheme(), - ); - config = defaultConfig; - } - - if (!isSwitchingAtsign || (atsign ?? '').trim().isNotEmpty) { - if ((atsign ?? '').trim().isNotEmpty) { - await changePrimaryAtsign(atsign: atsign!); - } - - //Check if existing an atsign => return onboard success - // ignore: use_build_context_synchronously - AtOnboardingResult? result; - if (context.mounted) { - result = await showDialog( - context: context, - barrierDismissible: false, - builder: (_) => AtOnboardingStartScreen( - config: config, - ), - ); - } - - if (result is AtOnboardingResult) { - return result; - } - - return AtOnboardingResult.cancelled(); - } - - if (context.mounted) { - final result = await Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) { - return AtOnboardingIntroScreen( - config: config, - ); - }, - ), - ); - - if (result is AtOnboardingResult) { - //Update primary atsign after onboard success - if (result.status == AtOnboardingResultStatus.success && - result.atsign != null) { - await changePrimaryAtsign(atsign: result.atsign!); - } - return result; - } - } - - return AtOnboardingResult.cancelled(); - } - - static Future activateAccount({ - required BuildContext context, - required AtOnboardingConfig config, - }) async { - /// Initial Setup - await _initialSetup(context); - - if (context.mounted) { - final result = await Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) { - return AtOnboardingActivateScreen( - hideReferences: false, - config: config, - ); - }, - ), - ); - - if (result is AtOnboardingResult) { - return result; - } - } - - return AtOnboardingResult.cancelled(); - } - - static Future changePrimaryAtsign({required String atsign}) async { - return await OnboardingService.getInstance() - .changePrimaryAtsign(atsign: atsign); - } - - static Future reset({ - required BuildContext context, - required AtOnboardingConfig config, - }) async { - /// Initial Setup - await _initialSetup(context); - - if (context.mounted) { - final result = await Navigator.push(context, - MaterialPageRoute(builder: (BuildContext context) { - return AtOnboardingResetScreen(config: config); - })); - - if (result is AtOnboardingResetResult) { - return result; - } - } - - return AtOnboardingResetResult.cancelled; - } - - Future enableUsingSharedStorage() async { - if (Platform.isAndroid || Platform.isIOS || Platform.isLinux) { - throw UnsupportedError('user sharing not supported'); - } - - final result = - await OnboardingService.getInstance().enableUsingSharedStorage(); - return result; - } - - Future disableUsingSharedStorage() async { - if (Platform.isAndroid || Platform.isIOS || Platform.isLinux) { - throw UnsupportedError('user sharing not supported'); - } - - final result = - await OnboardingService.getInstance().disableUsingSharedStorage(); - return result; - } - - static Future _initialSetup(BuildContext context) async { - /// Configure Localization - const AppLocalizationDelegate _delegate = AppLocalizationDelegate(); - final currentLocal = Localizations.localeOf(context); - if (_delegate.isSupported(currentLocal)) { - _delegate.load(currentLocal); - } else { - _delegate.load(const Locale.fromSubtags(languageCode: 'en')); - } - } -} +@Deprecated( + "This is a legacy export and will be removed in a future version: use at_onboarding_flutter.dart instead") +export 'src/at_onboarding.dart'; diff --git a/packages/at_onboarding_flutter/lib/at_onboarding_flutter.dart b/packages/at_onboarding_flutter/lib/at_onboarding_flutter.dart index ca5e7ff79..157fb3ab5 100644 --- a/packages/at_onboarding_flutter/lib/at_onboarding_flutter.dart +++ b/packages/at_onboarding_flutter/lib/at_onboarding_flutter.dart @@ -1,10 +1,15 @@ library at_onboarding_flutter; -export './utils/at_onboarding_app_constants.dart' show RootEnvironment; +// Re-export some important external dependencies export 'package:at_backupkey_flutter/at_backupkey_flutter.dart'; -export './at_onboarding.dart'; -export 'services/at_onboarding_config.dart'; -export 'at_onboarding_result.dart'; export 'package:at_client_mobile/at_client_mobile.dart'; + +// Core package requirements +export 'src/at_onboarding.dart'; +export 'src/at_onboarding_result.dart'; +export 'src/utils/at_onboarding_app_constants.dart' show RootEnvironment; +export 'src/services/at_onboarding_config.dart'; + +// Additional customizations export './localizations/generated/l10n.dart'; -export './services/at_onboarding_theme.dart'; +export 'src/services/at_onboarding_theme.dart'; diff --git a/packages/at_onboarding_flutter/lib/at_onboarding_result.dart b/packages/at_onboarding_flutter/lib/at_onboarding_result.dart index f5f17d2b4..754389409 100644 --- a/packages/at_onboarding_flutter/lib/at_onboarding_result.dart +++ b/packages/at_onboarding_flutter/lib/at_onboarding_result.dart @@ -1,73 +1,5 @@ -/// The status of onboard's result -/// -/// Values include: success, error, cancel -/// -enum AtOnboardingResultStatus { - success, //Authenticate success - error, //Authenticate error - cancel, //User canceled -} +library at_onboarding_result_legacy; -enum AtOnboardingResetResult { - cancelled, - success, -} - -/// The result returned after onboard -class AtOnboardingResult { - /// Status of result - AtOnboardingResultStatus status; - - /// The message returned when onboard failed - String? message; - - /// The error code returned when onboard failed - String? errorCode; - - /// The atSign returned when onboard successfully - String? atsign; - - AtOnboardingResult._({ - required this.status, - this.message, - this.errorCode, - this.atsign, - }); - - /// Create instance with success status - /// - /// [atsign] The name of atSign - /// - factory AtOnboardingResult.success({ - required String atsign, - }) { - return AtOnboardingResult._( - status: AtOnboardingResultStatus.success, - atsign: atsign, - ); - } - - /// Create instance with error status - /// - /// [message] The message returned when onboard failed - /// - /// [errorCode] The error code returned when onboard failed - /// - factory AtOnboardingResult.error({ - String? message, - String? errorCode, - }) { - return AtOnboardingResult._( - status: AtOnboardingResultStatus.error, - message: message, - errorCode: errorCode, - ); - } - - /// Create instance with cancel status - factory AtOnboardingResult.cancelled() { - return AtOnboardingResult._( - status: AtOnboardingResultStatus.cancel, - ); - } -} +@Deprecated( + "This is a legacy export and will be removed in a future version: use at_onboarding_flutter.dart instead") +export 'src/at_onboarding_result.dart'; diff --git a/packages/at_onboarding_flutter/lib/at_onboarding_screens.dart b/packages/at_onboarding_flutter/lib/at_onboarding_screens.dart new file mode 100644 index 000000000..8664fc752 --- /dev/null +++ b/packages/at_onboarding_flutter/lib/at_onboarding_screens.dart @@ -0,0 +1,16 @@ +library at_onboarding_screens; + +export "src/screen/at_onboarding_accounts_screen.dart"; +export "src/screen/at_onboarding_activate_screen.dart"; +export "src/screen/at_onboarding_backup_screen.dart"; +export "src/screen/at_onboarding_generate_screen.dart"; +export "src/screen/at_onboarding_home_screen.dart"; +export "src/screen/at_onboarding_input_atsign_screen.dart"; +export "src/screen/at_onboarding_intro_screen.dart"; +export "src/screen/at_onboarding_otp_screen.dart"; +export "src/screen/at_onboarding_pair_screen.dart"; +export "src/screen/at_onboarding_qrcode_screen.dart"; +export "src/screen/at_onboarding_reference_screen.dart"; +export "src/screen/at_onboarding_reset_screen.dart"; +export "src/screen/at_onboarding_start_screen.dart"; +export "src/screen/at_onboarding_webview_screen.dart"; diff --git a/packages/at_onboarding_flutter/lib/at_onboarding_services.dart b/packages/at_onboarding_flutter/lib/at_onboarding_services.dart new file mode 100644 index 000000000..642146d2a --- /dev/null +++ b/packages/at_onboarding_flutter/lib/at_onboarding_services.dart @@ -0,0 +1,11 @@ +library at_onboarding_services; + +export 'src/services/at_keys_file_upload_service.dart'; +export 'src/services/at_onboarding_backup_service.dart'; +export 'src/services/at_onboarding_config.dart'; +export 'src/services/at_onboarding_theme.dart'; +export 'src/services/at_onboarding_tutorial_service.dart'; +export 'src/services/backend_service.dart'; +export 'src/services/free_atsign_service.dart'; +export 'src/services/onboarding_service.dart'; +export 'src/services/sdk_service.dart'; diff --git a/packages/at_onboarding_flutter/lib/at_onboarding_widgets.dart b/packages/at_onboarding_flutter/lib/at_onboarding_widgets.dart new file mode 100644 index 000000000..67e50bf71 --- /dev/null +++ b/packages/at_onboarding_flutter/lib/at_onboarding_widgets.dart @@ -0,0 +1,4 @@ +library at_onboarding_widgets; + +export 'src/widgets/at_onboarding_button.dart'; +export 'src/widgets/at_onboarding_dialog.dart'; diff --git a/packages/at_onboarding_flutter/lib/src/at_onboarding.dart b/packages/at_onboarding_flutter/lib/src/at_onboarding.dart new file mode 100644 index 000000000..a72de533c --- /dev/null +++ b/packages/at_onboarding_flutter/lib/src/at_onboarding.dart @@ -0,0 +1,184 @@ +import 'dart:io'; + +import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; +import 'package:at_onboarding_flutter/src/at_onboarding_result.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_activate_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_intro_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reset_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_start_screen.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_config.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_theme.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_app_constants.dart'; +import 'package:flutter/material.dart'; + +class AtOnboarding { + /// Using this function to get onboard atsing. + /// + /// @param context The build context. + /// @param config The config for the onboard + /// @param isSwitchingAtsign True - alway show UI for add new atsign. False - check onboard if existing atsing. Default is false + /// @param atsign The atsign name when change the primary atsign. + /// + /// Return [AtOnboardingResult] + static Future onboard({ + required BuildContext context, + required AtOnboardingConfig config, + bool isSwitchingAtsign = false, + String? atsign, + }) async { + AtOnboardingConstants.setApiKey(config.appAPIKey ?? + (AtOnboardingConstants.rootEnvironment.apikey ?? '')); + AtOnboardingConstants.rootDomain = + config.domain ?? AtOnboardingConstants.rootEnvironment.domain; + + /// Initial Setup + await _initialSetup(context); + + /// user sharing is not supported on Android, iOS and Linux. + if (Platform.isAndroid || Platform.isIOS || Platform.isLinux) { + config.showPopupSharedStorage = false; + } + + if (config.theme == null) { + final defaultConfig = config.copyWith( + theme: AtOnboardingTheme(), + ); + config = defaultConfig; + } + + if (!isSwitchingAtsign || (atsign ?? '').trim().isNotEmpty) { + if ((atsign ?? '').trim().isNotEmpty) { + await changePrimaryAtsign(atsign: atsign!); + } + + //Check if existing an atsign => return onboard success + // ignore: use_build_context_synchronously + AtOnboardingResult? result; + if (context.mounted) { + result = await showDialog( + context: context, + barrierDismissible: false, + builder: (_) => AtOnboardingStartScreen( + config: config, + ), + ); + } + + if (result is AtOnboardingResult) { + return result; + } + + return AtOnboardingResult.cancelled(); + } + + if (context.mounted) { + final result = await Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) { + return AtOnboardingIntroScreen( + config: config, + ); + }, + ), + ); + + if (result is AtOnboardingResult) { + //Update primary atsign after onboard success + if (result.status == AtOnboardingResultStatus.success && + result.atsign != null) { + await changePrimaryAtsign(atsign: result.atsign!); + } + return result; + } + } + + return AtOnboardingResult.cancelled(); + } + + static Future activateAccount({ + required BuildContext context, + required AtOnboardingConfig config, + }) async { + /// Initial Setup + await _initialSetup(context); + + if (context.mounted) { + final result = await Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) { + return AtOnboardingActivateScreen( + hideReferences: false, + config: config, + ); + }, + ), + ); + + if (result is AtOnboardingResult) { + return result; + } + } + + return AtOnboardingResult.cancelled(); + } + + static Future changePrimaryAtsign({required String atsign}) async { + return await OnboardingService.getInstance() + .changePrimaryAtsign(atsign: atsign); + } + + static Future reset({ + required BuildContext context, + required AtOnboardingConfig config, + }) async { + /// Initial Setup + await _initialSetup(context); + + if (context.mounted) { + final result = await Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) { + return AtOnboardingResetScreen(config: config); + })); + + if (result is AtOnboardingResetResult) { + return result; + } + } + + return AtOnboardingResetResult.cancelled; + } + + Future enableUsingSharedStorage() async { + if (Platform.isAndroid || Platform.isIOS || Platform.isLinux) { + throw UnsupportedError('user sharing not supported'); + } + + final result = + await OnboardingService.getInstance().enableUsingSharedStorage(); + return result; + } + + Future disableUsingSharedStorage() async { + if (Platform.isAndroid || Platform.isIOS || Platform.isLinux) { + throw UnsupportedError('user sharing not supported'); + } + + final result = + await OnboardingService.getInstance().disableUsingSharedStorage(); + return result; + } + + static Future _initialSetup(BuildContext context) async { + /// Configure Localization + const AppLocalizationDelegate _delegate = AppLocalizationDelegate(); + final currentLocal = Localizations.localeOf(context); + if (_delegate.isSupported(currentLocal)) { + _delegate.load(currentLocal); + } else { + _delegate.load(const Locale.fromSubtags(languageCode: 'en')); + } + } +} diff --git a/packages/at_onboarding_flutter/lib/src/at_onboarding_result.dart b/packages/at_onboarding_flutter/lib/src/at_onboarding_result.dart new file mode 100644 index 000000000..f5f17d2b4 --- /dev/null +++ b/packages/at_onboarding_flutter/lib/src/at_onboarding_result.dart @@ -0,0 +1,73 @@ +/// The status of onboard's result +/// +/// Values include: success, error, cancel +/// +enum AtOnboardingResultStatus { + success, //Authenticate success + error, //Authenticate error + cancel, //User canceled +} + +enum AtOnboardingResetResult { + cancelled, + success, +} + +/// The result returned after onboard +class AtOnboardingResult { + /// Status of result + AtOnboardingResultStatus status; + + /// The message returned when onboard failed + String? message; + + /// The error code returned when onboard failed + String? errorCode; + + /// The atSign returned when onboard successfully + String? atsign; + + AtOnboardingResult._({ + required this.status, + this.message, + this.errorCode, + this.atsign, + }); + + /// Create instance with success status + /// + /// [atsign] The name of atSign + /// + factory AtOnboardingResult.success({ + required String atsign, + }) { + return AtOnboardingResult._( + status: AtOnboardingResultStatus.success, + atsign: atsign, + ); + } + + /// Create instance with error status + /// + /// [message] The message returned when onboard failed + /// + /// [errorCode] The error code returned when onboard failed + /// + factory AtOnboardingResult.error({ + String? message, + String? errorCode, + }) { + return AtOnboardingResult._( + status: AtOnboardingResultStatus.error, + message: message, + errorCode: errorCode, + ); + } + + /// Create instance with cancel status + factory AtOnboardingResult.cancelled() { + return AtOnboardingResult._( + status: AtOnboardingResultStatus.cancel, + ); + } +} diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_accounts_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_accounts_screen.dart similarity index 81% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_accounts_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_accounts_screen.dart index 62a4d92b4..ff1591fa9 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_accounts_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_accounts_screen.dart @@ -1,7 +1,8 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; + import 'package:flutter/material.dart'; /// This screen shows the list of atSign already available for the given email @@ -27,10 +28,12 @@ class AtOnboardingAccountsScreen extends StatefulWidget { }) : super(key: key); @override - State createState() => _AtOnboardingAccountsScreenState(); + State createState() => + _AtOnboardingAccountsScreenState(); } -class _AtOnboardingAccountsScreenState extends State { +class _AtOnboardingAccountsScreenState + extends State { List pairedAtsignsList = []; Object? lastSelectedIndex; late int greyStartIndex; @@ -70,7 +73,9 @@ class _AtOnboardingAccountsScreenState extends State ? Center( child: Column( children: [ - CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(theme.primaryColor)), + CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + theme.primaryColor)), Text( AtOnboardingLocalizations.current.loading_atSigns, style: const TextStyle( @@ -84,7 +89,8 @@ class _AtOnboardingAccountsScreenState extends State : Column( children: [ Text( - widget.message ?? AtOnboardingLocalizations.current.title_select_atSign, + widget.message ?? + AtOnboardingLocalizations.current.title_select_atSign, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: AtOnboardingDimens.fontNormal, @@ -104,7 +110,9 @@ class _AtOnboardingAccountsScreenState extends State }, value: 'new', activeColor: theme.primaryColor, - title: Text('@${widget.newAtsign}', style: const TextStyle(fontWeight: FontWeight.bold)), + title: Text('@${widget.newAtsign}', + style: + const TextStyle(fontWeight: FontWeight.bold)), ) ], const Divider(thickness: 0.8), @@ -113,7 +121,8 @@ class _AtOnboardingAccountsScreenState extends State itemCount: widget.atsigns.length, itemBuilder: (BuildContext context, int index) { String currentItem = '@${widget.atsigns[index]}'; - bool isExist = pairedAtsignsList.contains(currentItem); + bool isExist = + pairedAtsignsList.contains(currentItem); return Padding( padding: const EdgeInsets.symmetric(vertical: 2.0), child: RadioListTile( @@ -126,7 +135,8 @@ class _AtOnboardingAccountsScreenState extends State lastSelectedIndex = value; }); _showAlert( - widget.atsigns[int.parse(lastSelectedIndex.toString())], + widget.atsigns[int.parse( + lastSelectedIndex.toString())], context, ); }, @@ -163,11 +173,15 @@ class _AtOnboardingAccountsScreenState extends State style: theme.textTheme.bodyLarge, children: [ TextSpan( - text: AtOnboardingLocalizations.current.title_pair_atSign_prev, + text: + AtOnboardingLocalizations.current.title_pair_atSign_prev, ), - TextSpan(text: ' $atsign ', style: const TextStyle(fontWeight: FontWeight.bold)), TextSpan( - text: AtOnboardingLocalizations.current.title_pair_atSign_next, + text: ' $atsign ', + style: const TextStyle(fontWeight: FontWeight.bold)), + TextSpan( + text: + AtOnboardingLocalizations.current.title_pair_atSign_next, ) ], ), diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_activate_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_activate_screen.dart similarity index 89% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_activate_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_activate_screen.dart index eb7cad86b..c12e8f0bc 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_activate_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_activate_screen.dart @@ -2,19 +2,19 @@ import 'dart:convert'; import 'dart:io'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_onboarding_flutter/at_onboarding_result.dart'; +import 'package:at_onboarding_flutter/src/at_onboarding_result.dart'; import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_backup_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_otp_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_config.dart'; -import 'package:at_onboarding_flutter/services/free_atsign_service.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_error_util.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_response_status.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_backup_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_otp_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_config.dart'; +import 'package:at_onboarding_flutter/src/services/free_atsign_service.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_error_util.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_response_status.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:at_server_status/at_server_status.dart'; import 'package:at_sync_ui_flutter/at_sync_material.dart'; import 'package:flutter/material.dart'; @@ -103,7 +103,8 @@ class _AtOnboardingActivateScreenState ), const SizedBox(height: 10), Text( - AtOnboardingLocalizations.current.msg_wait_fetching_atSign, + AtOnboardingLocalizations + .current.msg_wait_fetching_atSign, ), ], ), @@ -146,7 +147,7 @@ class _AtOnboardingActivateScreenState data = jsonDecode(data); AtOnboardingOTPResult? result; - if(context.mounted) { + if (context.mounted) { result = await AtOnboardingOTPScreen.push( context: context, atSign: atsign ?? (widget.atSign ?? ''), diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_backup_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_backup_screen.dart similarity index 91% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_backup_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_backup_screen.dart index 3d17d0257..51c298faa 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_backup_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_backup_screen.dart @@ -1,12 +1,12 @@ import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_backup_service.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_app_constants.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_backup_service.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_app_constants.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; import 'package:flutter/material.dart'; /// This screen is for backing up an atKey during onboarding diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_generate_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_generate_screen.dart similarity index 94% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_generate_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_generate_screen.dart index a3cf1a1f5..0e7d65f82 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_generate_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_generate_screen.dart @@ -2,19 +2,19 @@ import 'dart:convert'; import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_backup_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_home_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_pair_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_tutorial_service.dart'; -import 'package:at_onboarding_flutter/services/free_atsign_service.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_error_util.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_response_status.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_backup_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_home_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_pair_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_tutorial_service.dart'; +import 'package:at_onboarding_flutter/src/services/free_atsign_service.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_error_util.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_response_status.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:at_sync_ui_flutter/at_sync_material.dart'; import 'package:at_utils/at_logger.dart'; import 'package:flutter/material.dart'; diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_home_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_home_screen.dart similarity index 61% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_home_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_home_screen.dart index 593407dec..e0f563891 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_home_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_home_screen.dart @@ -1,33 +1,28 @@ -import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; -import 'package:archive/archive.dart'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_onboarding_flutter/at_onboarding_result.dart'; +import 'package:at_onboarding_flutter/src/at_onboarding_result.dart'; import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_activate_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_backup_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_generate_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_input_atsign_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_config.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_tutorial_service.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_app_constants.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_error_util.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_response_status.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_activate_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_backup_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_generate_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_input_atsign_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_config.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_tutorial_service.dart'; +import 'package:at_onboarding_flutter/src/services/at_keys_file_upload_service.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_error_util.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_response_status.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:at_server_status/at_server_status.dart'; import 'package:at_sync_ui_flutter/at_sync_material.dart'; import 'package:at_utils/at_logger.dart'; -import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:image/image.dart' as img; -import 'package:path_provider/path_provider.dart' as path_provider; import 'package:permission_handler/permission_handler.dart'; import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -55,13 +50,13 @@ class AtOnboardingHomeScreen extends StatefulWidget { final bool isFromIntroScreen; const AtOnboardingHomeScreen({ - Key? key, + super.key, required this.config, this.getAtSign = false, this.hideReferences = false, this.hideQrScan = false, this.isFromIntroScreen = false, - }) : super(key: key); + }); @override State createState() => _AtOnboardingHomeScreenState(); @@ -78,12 +73,13 @@ class _AtOnboardingHomeScreenState extends State { bool loading = false; bool permissionGrated = false; - bool _isContinue = true; String? _pairingAtsign; ServerStatus? atSignStatus; - final String _incorrectKeyFile = AtOnboardingLocalizations.current.msg_cannot_fetch_keys_from_chosen_file; - final String _failedFileProcessing = AtOnboardingLocalizations.current.error_processing_files; + final String _incorrectKeyFile = + AtOnboardingLocalizations.current.msg_cannot_fetch_keys_from_chosen_file; + final String _failedFileProcessing = + AtOnboardingLocalizations.current.error_processing_files; late AtSyncDialog _inprogressDialog; @@ -96,6 +92,8 @@ class _AtOnboardingHomeScreenState extends State { GlobalKey keyActivateAtSign = GlobalKey(); GlobalKey keyCreateAnAtSign = GlobalKey(); + late AtKeysFileUploadService filePicker; + Future askPermissions(Permission type) async { if (type == Permission.camera) { await Permission.camera.request(); @@ -142,7 +140,8 @@ class _AtOnboardingHomeScreenState extends State { // width: _dialogWidth, decoration: BoxDecoration( color: theme.primaryColor.withOpacity(0.1), - borderRadius: BorderRadius.circular(AtOnboardingDimens.borderRadius)), + borderRadius: + BorderRadius.circular(AtOnboardingDimens.borderRadius)), padding: const EdgeInsets.all(AtOnboardingDimens.paddingNormal), margin: const EdgeInsets.all(AtOnboardingDimens.paddingNormal), constraints: const BoxConstraints( @@ -165,9 +164,7 @@ class _AtOnboardingHomeScreenState extends State { key: keyUploadAtSign, height: 48, borderRadius: 24, - onPressed: (Platform.isMacOS || Platform.isLinux || Platform.isWindows) - ? _uploadKeyFileForDesktop - : _uploadKeyFile, + onPressed: _uploadKeyFile, isLoading: loading, child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -206,8 +203,10 @@ class _AtOnboardingHomeScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - AtOnboardingLocalizations.current.btn_activate_atSign, - style: const TextStyle(fontSize: AtOnboardingDimens.fontLarge), + AtOnboardingLocalizations + .current.btn_activate_atSign, + style: const TextStyle( + fontSize: AtOnboardingDimens.fontLarge), ), const Icon(Icons.arrow_right_alt_rounded) ], @@ -228,7 +227,9 @@ class _AtOnboardingHomeScreenState extends State { required String secret, }) { String cramSecret = secret.split(':').last; - String atsign = atSign.startsWith('@') ? atSign : '@$atSign'; + String atsign = atSign.startsWith('@') + ? atSign + : '@$atSign'; _processSharedSecret(atsign, cramSecret); }, config: widget.config, @@ -291,8 +292,8 @@ class _AtOnboardingHomeScreenState extends State { String decodeQrCode(String imagepath) { var image = img.decodePng(File(imagepath).readAsBytesSync())!; - LuminanceSource source = RGBLuminanceSource( - image.width, image.height, image.getBytes(order: img.ChannelOrder.abgr).buffer.asInt32List()); + LuminanceSource source = RGBLuminanceSource(image.width, image.height, + image.getBytes(order: img.ChannelOrder.abgr).buffer.asInt32List()); var bitmap = BinaryBitmap(HybridBinarizer(source)); var reader = QRCodeReader(); @@ -303,6 +304,7 @@ class _AtOnboardingHomeScreenState extends State { @override void initState() { _inprogressDialog = AtSyncDialog(context: context); + filePicker = AtKeysFileUploadService(config: widget.config); checkPermissions(); super.initState(); _init(); @@ -350,7 +352,8 @@ class _AtOnboardingHomeScreenState extends State { child: Text( (Platform.isAndroid || Platform.isIOS) ? AtOnboardingLocalizations.current.tutorial_scan_QRCode - : AtOnboardingLocalizations.current.tutorial_upload_image_QRCode, + : AtOnboardingLocalizations + .current.tutorial_upload_image_QRCode, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w500, @@ -378,7 +381,8 @@ class _AtOnboardingHomeScreenState extends State { builder: (context, controller) { return Center( child: Text( - AtOnboardingLocalizations.current.tutorial_activate_your_atSign, + AtOnboardingLocalizations + .current.tutorial_activate_your_atSign, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w500, @@ -425,7 +429,8 @@ class _AtOnboardingHomeScreenState extends State { } Future showErrorDialog(String? errorMessage) async { - return AtOnboardingDialog.showError(context: context, message: errorMessage ?? ''); + return AtOnboardingDialog.showError( + context: context, message: errorMessage ?? ''); } bool skipTutorial() { @@ -437,13 +442,15 @@ class _AtOnboardingHomeScreenState extends State { if (widget.config.tutorialDisplay == AtOnboardingTutorialDisplay.always) { await Future.delayed(const Duration(milliseconds: 300)); _showTutorial(); - } else if (widget.config.tutorialDisplay == AtOnboardingTutorialDisplay.never) { + } else if (widget.config.tutorialDisplay == + AtOnboardingTutorialDisplay.never) { return; } else { final result = await AtOnboardingTutorialService.checkShowTutorial(); if (!result) { await Future.delayed(const Duration(milliseconds: 300)); - final result = await AtOnboardingTutorialService.hasShowTutorialSignIn(); + final result = + await AtOnboardingTutorialService.hasShowTutorialSignIn(); if (!result) { _showTutorial(); } @@ -451,19 +458,6 @@ class _AtOnboardingHomeScreenState extends State { } } - Future _desktopKeyPicker() async { - try { - FilePickerResult? result = await FilePicker.platform.pickFiles( - type: FileType.custom, - allowedExtensions: ['atKeys', 'atkeys'], - ); - return result?.files.single.path; - } catch (e) { - _logger.severe('Error with desktop atKeys file picker: $e'); - return null; - } - } - void _endTutorial() async { var tutorialInfo = await AtOnboardingTutorialService.getTutorialInfo(); tutorialInfo ??= AtTutorialServiceInfo(); @@ -477,69 +471,8 @@ class _AtOnboardingHomeScreenState extends State { await _checkShowTutorial(); } - Future _processAESKey(String? atsign, String? aesKey, String contents) async { - dynamic authResponse; - assert(aesKey != null || aesKey != ''); - assert(atsign != null || atsign != ''); - assert(contents != ''); - _inprogressDialog.show( - message: AtOnboardingLocalizations.current.processing, - ); - await Future.delayed(const Duration(milliseconds: 400)); - try { - bool isExist = await _onboardingService.isExistingAtsign(atsign); - if (isExist) { - _inprogressDialog.close(); - await showErrorDialog(AtOnboardingErrorToString().pairedAtsign(atsign)); - return; - } - - _onboardingService.setAtClientPreference = widget.config.atClientPreference; - - authResponse = await _onboardingService.authenticate( - atsign, - jsonData: contents, - decryptKey: aesKey, - ); - _inprogressDialog.close(); - if (authResponse == AtOnboardingResponseStatus.authSuccess) { - //Don't show backup key for case user upload backup key - // await AtOnboardingBackupScreen.push(context: context); - if (!mounted) return; - Navigator.pop(context, AtOnboardingResult.success(atsign: atsign!)); - } else if (authResponse == AtOnboardingResponseStatus.serverNotReached) { - await _showAlertDialog( - AtOnboardingLocalizations.current.msg_atSign_unreachable, - ); - } else if (authResponse == AtOnboardingResponseStatus.authFailed) { - await _showAlertDialog( - AtOnboardingLocalizations.current.error_authenticated_failed, - ); - } else { - await showErrorDialog( - AtOnboardingLocalizations.current.msg_response_time_out, - ); - } - } catch (e) { - _inprogressDialog.close(); - if (e == AtOnboardingResponseStatus.serverNotReached && _isContinue) { - await _processAESKey(atsign, aesKey, contents); - } else if (e == AtOnboardingResponseStatus.authFailed) { - _logger.severe('Error in authenticateWithAESKey'); - await showErrorDialog( - AtOnboardingLocalizations.current.msg_auth_failed, - ); - } else if (e == AtOnboardingResponseStatus.timeOut) { - await showErrorDialog( - AtOnboardingLocalizations.current.msg_response_time_out, - ); - } else { - _logger.warning(e); - } - } - } - - Future _processSharedSecret(String atsign, String secret) async { + Future _processSharedSecret(String atsign, String secret, + {bool retry = true}) async { dynamic authResponse; try { _inprogressDialog.show( @@ -549,16 +482,19 @@ class _AtOnboardingHomeScreenState extends State { bool isExist = await _onboardingService.isExistingAtsign(atsign); if (isExist) { _inprogressDialog.close(); - await _showAlertDialog(AtOnboardingErrorToString().pairedAtsign(atsign)); + await _showAlertDialog( + AtOnboardingErrorToString().pairedAtsign(atsign)); return; } //Delay for waiting for ServerStatus change to teapot when activating an atsign await Future.delayed(const Duration(seconds: 10)); - _onboardingService.setAtClientPreference = widget.config.atClientPreference; + _onboardingService.setAtClientPreference = + widget.config.atClientPreference; - authResponse = await _onboardingService.authenticate(atsign, cramSecret: secret, status: widget.onboardStatus); + authResponse = await _onboardingService.authenticate(atsign, + cramSecret: secret, status: widget.onboardStatus); int round = 1; atSignStatus = await _onboardingService.checkAtSignServerStatus(atsign); @@ -615,8 +551,8 @@ class _AtOnboardingHomeScreenState extends State { e, title: AtOnboardingLocalizations.current.msg_auth_failed, ); - } else if (e == AtOnboardingResponseStatus.serverNotReached && _isContinue) { - await _processSharedSecret(atsign, secret); + } else if (e == AtOnboardingResponseStatus.serverNotReached && retry) { + await _processSharedSecret(atsign, secret, retry: false); } else if (e == AtOnboardingResponseStatus.timeOut) { await _showAlertDialog( e, @@ -670,8 +606,10 @@ class _AtOnboardingHomeScreenState extends State { } Future _showAlertDialog(dynamic errorMessage, {String? title}) async { - String? messageString = AtOnboardingErrorToString().getErrorMessage(errorMessage); - return AtOnboardingDialog.showError(context: context, title: title, message: messageString); + String? messageString = + AtOnboardingErrorToString().getErrorMessage(errorMessage); + return AtOnboardingDialog.showError( + context: context, title: title, message: messageString); } void _showReferenceWebview() { @@ -710,174 +648,81 @@ class _AtOnboardingHomeScreenState extends State { )..show(context: context); } - Future _uploadKeyFile() async { - try { - if (!permissionGrated) { - await checkPermissions(); - } - _isContinue = true; - String? fileContents, aesKey, atsign; - FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.any); - if ((result?.files ?? []).isEmpty) { - //User cancelled => do nothing - return; - } + void setLoading(bool loading) { + if (this.loading != loading) { setState(() { - loading = true; + this.loading = loading; }); - for (PlatformFile pickedFile in result?.files ?? []) { - String? path = pickedFile.path; - if (path == null) { - throw const FileSystemException( - 'FilePicker.pickFiles returned a null path', - ); - } - File selectedFile = File(path); - int length = selectedFile.lengthSync(); - if (length < 10) { - await showErrorDialog(_incorrectKeyFile); - return; - } - - if (pickedFile.extension == 'zip') { - Uint8List bytes = selectedFile.readAsBytesSync(); - Archive archive = ZipDecoder().decodeBytes(bytes); - for (ArchiveFile file in archive) { - if (file.name.contains('atKeys')) { - fileContents = String.fromCharCodes(file.content); - } else if (aesKey == null && atsign == null && file.name.contains('_private_key.png')) { - List bytes = file.content as List; - String path = (await path_provider.getTemporaryDirectory()).path; - File file1 = await File('${path}test').create(); - file1.writeAsBytesSync(bytes); - String result = decodeQrCode(file1.path); - List params = result.replaceAll('"', '').split(':'); - atsign = params[0]; - aesKey = params[1]; - await File('${path}test').delete(); - //read scan QRcode and extract atsign,aeskey - } - } - } else if (pickedFile.name.contains('atKeys')) { - fileContents = File(path.toString()).readAsStringSync(); - } else if (aesKey == null && atsign == null && pickedFile.name.contains('_private_key.png')) { - //read scan QRcode and extract atsign,aeskey - var result = decodeQrCode(path); - - List params = result.split(':'); - atsign = params[0]; - aesKey = params[1]; - } else { - Uint8List result1 = selectedFile.readAsBytesSync(); - fileContents = String.fromCharCodes(result1); - bool result = _validatePickedFileContents(fileContents); - _logger.finer('result after extracting data is......$result'); - if (!result) { - await showErrorDialog(_incorrectKeyFile); - setState(() { - loading = false; - }); - return; - } - } - } - if (aesKey == null && atsign == null && fileContents != null) { - List keyData = fileContents.split(',"@'); - List params = keyData[1].toString().substring(0, keyData[1].length - 2).split('":"'); - atsign = "@${params[0]}"; - Map keyMap = jsonDecode(fileContents); - aesKey = keyMap[AtOnboardingConstants.atSelfEncryptionKey]; - } - if (fileContents == null || (aesKey == null && atsign == null)) { - await showErrorDialog(_incorrectKeyFile); - setState(() { - loading = false; - }); - return; - } else if (OnboardingService.getInstance().formatAtSign(atsign) != _pairingAtsign && _pairingAtsign != null) { - await showErrorDialog(AtOnboardingErrorToString().atsignMismatch(_pairingAtsign)); - setState(() { - loading = false; - }); - return; - } - setState(() { - loading = false; - }); - await _processAESKey(atsign, aesKey, fileContents); - } catch (error) { - setState(() { - loading = false; - }); - _logger.severe('Uploading backup zip file throws $error'); - await showErrorDialog(_failedFileProcessing); } } - Future _uploadKeyFileForDesktop() async { - try { - _isContinue = true; - String? fileContents, aesKey, atsign; - setState(() { - loading = true; - }); - - String? path = await _desktopKeyPicker(); - if (path == null) { - setState(() { - loading = false; - }); - return; - } - - File selectedFile = File(path); - int length = selectedFile.lengthSync(); - if (length < 10) { - await showErrorDialog(_incorrectKeyFile); - return; - } - - fileContents = File(path).readAsStringSync(); - // ignore: unnecessary_null_comparison - if (aesKey == null && atsign == null && fileContents.isNotEmpty) { - List keyData = fileContents.split(',"@'); - List params = keyData[1].toString().substring(0, keyData[1].length - 2).split('":"'); - atsign = "@${params[0]}"; - Map keyMap = jsonDecode(fileContents); - aesKey = keyMap[AtOnboardingConstants.atSelfEncryptionKey]; - } - if (fileContents.isEmpty || (aesKey == null && atsign == null)) { - await showErrorDialog(_incorrectKeyFile); - setState(() { - loading = false; - }); - return; - } else if (OnboardingService.getInstance().formatAtSign(atsign) != _pairingAtsign && _pairingAtsign != null) { - await showErrorDialog(AtOnboardingErrorToString().atsignMismatch(_pairingAtsign)); - setState(() { - loading = false; - }); - return; + Future _uploadKeyFile() async { + await checkPermissions(); + Stream statusStream = + filePicker.uploadKeyFile(_pairingAtsign); + statusStream.listen((status) async { + switch (status) { + case FilePickingInProgress(): + setLoading(true); + break; + case FilePickingDone(): + setLoading(false); + break; + case FilePickingCanceled(): + setLoading(false); + break; + case ErrorIncorrectKeyFile(): + await showErrorDialog(_incorrectKeyFile); + break; + case ErrorAtSignMismatch(): + await showErrorDialog( + AtOnboardingErrorToString().atsignMismatch(_pairingAtsign)); + break; + case ErrorFailedFileProcessing(): + await showErrorDialog(_failedFileProcessing); + break; + case ProcessingAesKeyInProgress(): + _inprogressDialog.show( + message: AtOnboardingLocalizations.current.processing, + ); + break; + // Non constant status, so use _ for pattern match + case ErrorPairedAtsign _: + _inprogressDialog.close(); + await showErrorDialog( + AtOnboardingErrorToString().pairedAtsign(status.atSign)); + break; + case ProcessingAesKeyDone(): + _inprogressDialog.close(); + break; + case ErrorAtServerUnreachable(): + await _showAlertDialog( + AtOnboardingLocalizations.current.msg_atSign_unreachable, + ); + break; + case ErrorAuthFailed(): + await _showAlertDialog( + AtOnboardingLocalizations.current.error_authenticated_failed, + ); + break; + case ErrorAuthTimeout(): + await showErrorDialog( + AtOnboardingLocalizations.current.msg_response_time_out, + ); + break; + // Non constant status, so use _ for pattern match + case FileUploadAuthSuccess _: + //Don't show backup key for case user upload backup key + // await AtOnboardingBackupScreen.push(context: context); + if (!mounted) return; + Navigator.pop( + context, AtOnboardingResult.success(atsign: status.atSign!)); } + }, onDone: () { setState(() { - loading = false; - }); - await _processAESKey(atsign, aesKey, fileContents); - } catch (error) { - setState(() { - loading = false; + // Just in case + setLoading(false); }); - _logger.severe('Uploading backup zip file throws $error'); - await showErrorDialog(_failedFileProcessing); - } - } - - bool _validatePickedFileContents(String fileContents) { - bool result = fileContents.contains(BackupKeyConstants.PKAM_PRIVATE_KEY_FROM_KEY_FILE) && - fileContents.contains(BackupKeyConstants.PKAM_PUBLIC_KEY_FROM_KEY_FILE) && - fileContents.contains(BackupKeyConstants.ENCRYPTION_PRIVATE_KEY_FROM_FILE) && - fileContents.contains(BackupKeyConstants.ENCRYPTION_PUBLIC_KEY_FROM_FILE) && - fileContents.contains(BackupKeyConstants.SELF_ENCRYPTION_KEY_FROM_FILE); - return result; + }); } } diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_input_atsign_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_input_atsign_screen.dart similarity index 94% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_input_atsign_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_input_atsign_screen.dart index e31c9409b..96daae5e6 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_input_atsign_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_input_atsign_screen.dart @@ -1,10 +1,10 @@ import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_intro_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_intro_screen.dart similarity index 91% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_intro_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_intro_screen.dart index b51ac35a1..e917f6bf1 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_intro_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_intro_screen.dart @@ -1,12 +1,12 @@ import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_generate_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_home_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_generate_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_home_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_otp_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_otp_screen.dart similarity index 96% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_otp_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_otp_screen.dart index 270664561..bc8efc508 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_otp_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_otp_screen.dart @@ -2,14 +2,14 @@ import 'dart:convert'; import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_accounts_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/services/free_atsign_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_input_formatter.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_accounts_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/services/free_atsign_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_input_formatter.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_pair_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_pair_screen.dart similarity index 95% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_pair_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_pair_screen.dart index 4e117f7a6..9daeb38a4 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_pair_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_pair_screen.dart @@ -2,13 +2,13 @@ import 'dart:convert'; import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_otp_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/services/free_atsign_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_strings.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_otp_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/services/free_atsign_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_strings.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -102,7 +102,8 @@ class _AtOnboardingPairScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - AtOnboardingLocalizations.current.enter_your_email_address, + AtOnboardingLocalizations + .current.enter_your_email_address, style: const TextStyle( fontSize: AtOnboardingDimens.fontLarge, fontWeight: FontWeight.bold, diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_qrcode_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_qrcode_screen.dart similarity index 98% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_qrcode_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_qrcode_screen.dart index a3361e720..0dce998ba 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_qrcode_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_qrcode_screen.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:at_sync_ui_flutter/at_sync_material.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_reference_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_reference_screen.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_reference_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_reference_screen.dart diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_reset_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_reset_screen.dart similarity index 84% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_reset_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_reset_screen.dart index 94a9dbd16..d5f6c191a 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_reset_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_reset_screen.dart @@ -1,11 +1,11 @@ -import 'package:at_onboarding_flutter/at_onboarding_result.dart'; +import 'package:at_onboarding_flutter/src/at_onboarding_result.dart'; import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_config.dart'; -import 'package:at_onboarding_flutter/services/sdk_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_error_util.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_config.dart'; +import 'package:at_onboarding_flutter/src/services/sdk_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_error_util.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:flutter/material.dart'; /// The screen is used for resetting the paired atSign @@ -19,7 +19,8 @@ class AtOnboardingResetScreen extends StatefulWidget { }) : super(key: key); @override - State createState() => _AtOnboardingResetScreenState(); + State createState() => + _AtOnboardingResetScreenState(); } class _AtOnboardingResetScreenState extends State { @@ -83,7 +84,9 @@ class _AtOnboardingResetScreenState extends State { ), ), Expanded( - child: atsignsList.isEmpty ? _buildEmptyWidget() : _buildAtSignsWidget(theme), + child: atsignsList.isEmpty + ? _buildEmptyWidget() + : _buildAtSignsWidget(theme), ), ], ), @@ -113,7 +116,8 @@ class _AtOnboardingResetScreenState extends State { onChanged: (bool? value) { isSelectAll = value!; if (atsignMap.isNotEmpty) { - atsignMap.updateAll((String? key, bool? value1) => value1 = value); + atsignMap + .updateAll((String? key, bool? value1) => value1 = value); } setState(() {}); }, @@ -176,7 +180,8 @@ class _AtOnboardingResetScreenState extends State { padding: EdgeInsets.only( left: AtOnboardingDimens.paddingNormal, right: AtOnboardingDimens.paddingNormal, - bottom: AtOnboardingDimens.paddingNormal + MediaQuery.of(context).padding.bottom, + bottom: AtOnboardingDimens.paddingNormal + + MediaQuery.of(context).padding.bottom, ), constraints: const BoxConstraints( maxWidth: 400, @@ -219,7 +224,9 @@ class _AtOnboardingResetScreenState extends State { } Future showErrorDialog(dynamic errorMessage, {String? title}) async { - String? messageString = AtOnboardingErrorToString().getErrorMessage(errorMessage); - return AtOnboardingDialog.showError(context: context, message: messageString); + String? messageString = + AtOnboardingErrorToString().getErrorMessage(errorMessage); + return AtOnboardingDialog.showError( + context: context, message: messageString); } } diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_start_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_start_screen.dart similarity index 80% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_start_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_start_screen.dart index 2a920f17d..0a88a73f9 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_start_screen.dart +++ b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_start_screen.dart @@ -1,16 +1,16 @@ import 'dart:io'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_onboarding_flutter/at_onboarding.dart'; -import 'package:at_onboarding_flutter/at_onboarding_result.dart'; +import 'package:at_onboarding_flutter/src/at_onboarding.dart'; +import 'package:at_onboarding_flutter/src/at_onboarding_result.dart'; import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_intro_screen.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_config.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_dimens.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_error_util.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_intro_screen.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_config.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_dimens.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_error_util.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:at_sync_ui_flutter/at_sync_material.dart'; import 'package:flutter/material.dart'; @@ -25,7 +25,8 @@ class AtOnboardingStartScreen extends StatefulWidget { }) : super(key: key); @override - State createState() => _AtOnboardingStartScreenState(); + State createState() => + _AtOnboardingStartScreenState(); } class _AtOnboardingStartScreenState extends State { @@ -39,7 +40,8 @@ class _AtOnboardingStartScreenState extends State { void _init() async { // This feature will reopen in future - final isUsingSharedStorage = await _onboardingService.isUsingSharedStorage(); + final isUsingSharedStorage = + await _onboardingService.isUsingSharedStorage(); final showPopupShareStorage = widget.config.showPopupSharedStorage; if (isUsingSharedStorage == null && @@ -49,7 +51,8 @@ class _AtOnboardingStartScreenState extends State { final result = await askUserUseSharedStorage(); await _onboardingService.initialSetup(usingSharedStorage: result); } else { - await _onboardingService.initialSetup(usingSharedStorage: isUsingSharedStorage ?? false); + await _onboardingService.initialSetup( + usingSharedStorage: isUsingSharedStorage ?? false); } _onboardingService.setAtClientPreference = widget.config.atClientPreference; try { @@ -66,7 +69,8 @@ class _AtOnboardingStartScreenState extends State { } catch (e, stacktrace) { debugPrint("AtOnboardingInitScreen: error - $e"); debugPrint(stacktrace.toString()); - if (e == OnboardingStatus.ATSIGN_NOT_FOUND || e == OnboardingStatus.PRIVATE_KEY_NOT_FOUND) { + if (e == OnboardingStatus.ATSIGN_NOT_FOUND || + e == OnboardingStatus.PRIVATE_KEY_NOT_FOUND) { if (!mounted) return; final result = await Navigator.push( context, @@ -122,7 +126,8 @@ class _AtOnboardingStartScreenState extends State { padding: const EdgeInsets.all(AtOnboardingDimens.paddingNormal), decoration: BoxDecoration( color: theme.scaffoldBackgroundColor, - borderRadius: BorderRadius.circular(AtOnboardingDimens.dialogBorderRadius), + borderRadius: BorderRadius.circular( + AtOnboardingDimens.dialogBorderRadius), ), child: Row( mainAxisSize: MainAxisSize.min, diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_webview_screen.dart b/packages/at_onboarding_flutter/lib/src/screen/at_onboarding_webview_screen.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/screen/at_onboarding_webview_screen.dart rename to packages/at_onboarding_flutter/lib/src/screen/at_onboarding_webview_screen.dart diff --git a/packages/at_onboarding_flutter/lib/src/services/at_keys_file_upload_service.dart b/packages/at_onboarding_flutter/lib/src/services/at_keys_file_upload_service.dart new file mode 100644 index 000000000..96d0a1163 --- /dev/null +++ b/packages/at_onboarding_flutter/lib/src/services/at_keys_file_upload_service.dart @@ -0,0 +1,222 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; +import 'package:at_onboarding_flutter/at_onboarding_services.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_app_constants.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_response_status.dart'; +import 'package:at_utils/at_logger.dart'; +import 'package:file_picker/file_picker.dart'; + +class AtKeysFileUploadService { + final AtSignLogger _logger = AtSignLogger('At Onboarding'); + final OnboardingService _onboardingService = OnboardingService.getInstance(); + final AtOnboardingConfig _config; + AtKeysFileUploadService({required AtOnboardingConfig config}) + : _config = config; + + bool get isMobile => Platform.isIOS || Platform.isAndroid; + Future pickFile() async { + try { + FilePickerResult? result = isMobile + ? await FilePicker.platform.pickFiles( + type: FileType.any, + ) + : await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['atKeys', 'atkeys'], + ); + + return result?.files.single.path; + } catch (e) { + _logger.severe('Error with desktop atKeys file picker: $e'); + return null; + } + } + + Stream uploadKeyFile(String? pairingAtsign) { + final StreamController streamController = + StreamController(); + _uploadKeyFileForDesktop(streamController, pairingAtsign); + return streamController.stream; + } + + Future _uploadKeyFileForDesktop( + StreamController streamController, + String? pairingAtsign) async { + try { + String? fileContents, aesKey, atsign; + streamController.add(const FilePickingInProgress()); + + String? path = await pickFile(); + if (path == null) { + streamController.add(const FilePickingCanceled()); + return; + } + + File selectedFile = File(path); + int length = selectedFile.lengthSync(); + if (length < 10) { + streamController.add(const ErrorIncorrectKeyFile()); + return; + } + + fileContents = File(path).readAsStringSync(); + if (!_validatePickedFileContents(fileContents)) { + streamController.add(const ErrorIncorrectKeyFile()); + return; + } + if (fileContents.isNotEmpty) { + List keyData = fileContents.split(',"@'); + List params = keyData[1] + .toString() + .substring(0, keyData[1].length - 2) + .split('":"'); + atsign = "@${params[0]}"; + Map keyMap = jsonDecode(fileContents); + aesKey = keyMap[AtOnboardingConstants.atSelfEncryptionKey]; + } + if (fileContents.isEmpty || (aesKey == null && atsign == null)) { + streamController.add(const ErrorIncorrectKeyFile()); + return; + } else if (OnboardingService.getInstance().formatAtSign(atsign) != + pairingAtsign && + pairingAtsign != null) { + streamController.add(const ErrorAtSignMismatch()); + return; + } + + streamController.add(const FilePickingDone()); + await _processAESKey(atsign, aesKey, fileContents, streamController); + } catch (error) { + _logger.severe('Uploading backup zip file throws $error'); + streamController.add(const ErrorFailedFileProcessing()); + } + } + + Future _processAESKey(String? atsign, String? aesKey, String contents, + StreamController? controller, + {bool retry = true}) async { + dynamic authResponse; + assert(aesKey != null || aesKey != ''); + assert(atsign != null || atsign != ''); + assert(contents != ''); + controller?.add(const ProcessingAesKeyInProgress()); + await Future.delayed(const Duration(milliseconds: 400)); + try { + bool isExist = await _onboardingService.isExistingAtsign(atsign); + if (isExist) { + controller?.add(const ProcessingAesKeyDone()); + controller?.add(ErrorPairedAtsign(atsign)); + return; + } + + _onboardingService.setAtClientPreference = _config.atClientPreference; + + authResponse = await _onboardingService.authenticate( + atsign, + jsonData: contents, + decryptKey: aesKey, + ); + controller?.add(const ProcessingAesKeyDone()); + if (authResponse == AtOnboardingResponseStatus.authSuccess) { + controller?.add(FileUploadAuthSuccess(atsign)); + } else if (authResponse == AtOnboardingResponseStatus.serverNotReached) { + controller?.add(const ErrorAtServerUnreachable()); + } else if (authResponse == AtOnboardingResponseStatus.authFailed) { + controller?.add(const ErrorAuthFailed()); + } else {} + } catch (e) { + controller?.add(const ProcessingAesKeyDone()); + if (e == AtOnboardingResponseStatus.serverNotReached && retry) { + await _processAESKey(atsign, aesKey, contents, controller, + retry: false); + } else if (e == AtOnboardingResponseStatus.authFailed) { + _logger.severe('Error in authenticateWithAESKey'); + controller?.add(const ErrorAuthFailed()); + } else if (e == AtOnboardingResponseStatus.timeOut) { + controller?.add(const ErrorAuthTimeout()); + } else { + _logger.warning(e); + } + } + } + + bool _validatePickedFileContents(String fileContents) { + bool result = fileContents + .contains(BackupKeyConstants.PKAM_PRIVATE_KEY_FROM_KEY_FILE) && + fileContents + .contains(BackupKeyConstants.PKAM_PUBLIC_KEY_FROM_KEY_FILE) && + fileContents + .contains(BackupKeyConstants.ENCRYPTION_PRIVATE_KEY_FROM_FILE) && + fileContents + .contains(BackupKeyConstants.ENCRYPTION_PUBLIC_KEY_FROM_FILE) && + fileContents.contains(BackupKeyConstants.SELF_ENCRYPTION_KEY_FROM_FILE); + return result; + } +} + +sealed class FileUploadStatus { + const FileUploadStatus(); +} + +// Errors + +class ErrorIncorrectKeyFile extends FileUploadStatus { + const ErrorIncorrectKeyFile(); +} + +class ErrorAtSignMismatch extends FileUploadStatus { + const ErrorAtSignMismatch(); +} + +class ErrorFailedFileProcessing extends FileUploadStatus { + const ErrorFailedFileProcessing(); +} + +class ErrorAtServerUnreachable extends FileUploadStatus { + const ErrorAtServerUnreachable(); +} + +class ErrorAuthFailed extends FileUploadStatus { + const ErrorAuthFailed(); +} + +class ErrorAuthTimeout extends FileUploadStatus { + const ErrorAuthTimeout(); +} + +class ErrorPairedAtsign extends FileUploadStatus { + final String? atSign; + ErrorPairedAtsign(this.atSign); +} + +// File Picking + +class FilePickingInProgress extends FileUploadStatus { + const FilePickingInProgress(); +} + +class FilePickingDone extends FileUploadStatus { + const FilePickingDone(); +} + +class FilePickingCanceled extends FileUploadStatus { + const FilePickingCanceled(); +} + +// Processing AesKey + +class ProcessingAesKeyInProgress extends FileUploadStatus { + const ProcessingAesKeyInProgress(); +} + +class ProcessingAesKeyDone extends FileUploadStatus { + const ProcessingAesKeyDone(); +} + +class FileUploadAuthSuccess extends FileUploadStatus { + final String? atSign; + FileUploadAuthSuccess(this.atSign); +} diff --git a/packages/at_onboarding_flutter/lib/services/at_onboarding_backup_service.dart b/packages/at_onboarding_flutter/lib/src/services/at_onboarding_backup_service.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/services/at_onboarding_backup_service.dart rename to packages/at_onboarding_flutter/lib/src/services/at_onboarding_backup_service.dart diff --git a/packages/at_onboarding_flutter/lib/services/at_onboarding_config.dart b/packages/at_onboarding_flutter/lib/src/services/at_onboarding_config.dart similarity index 91% rename from packages/at_onboarding_flutter/lib/services/at_onboarding_config.dart rename to packages/at_onboarding_flutter/lib/src/services/at_onboarding_config.dart index d504ffea4..dec7a694b 100644 --- a/packages/at_onboarding_flutter/lib/services/at_onboarding_config.dart +++ b/packages/at_onboarding_flutter/lib/src/services/at_onboarding_config.dart @@ -1,6 +1,6 @@ -import 'package:at_onboarding_flutter/services/at_onboarding_theme.dart'; -import 'package:at_onboarding_flutter/services/at_onboarding_tutorial_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_app_constants.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_theme.dart'; +import 'package:at_onboarding_flutter/src/services/at_onboarding_tutorial_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_app_constants.dart'; import 'package:flutter/material.dart'; import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_utils/at_logger.dart'; diff --git a/packages/at_onboarding_flutter/lib/services/at_onboarding_theme.dart b/packages/at_onboarding_flutter/lib/src/services/at_onboarding_theme.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/services/at_onboarding_theme.dart rename to packages/at_onboarding_flutter/lib/src/services/at_onboarding_theme.dart diff --git a/packages/at_onboarding_flutter/lib/services/at_onboarding_tutorial_service.dart b/packages/at_onboarding_flutter/lib/src/services/at_onboarding_tutorial_service.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/services/at_onboarding_tutorial_service.dart rename to packages/at_onboarding_flutter/lib/src/services/at_onboarding_tutorial_service.dart diff --git a/packages/at_onboarding_flutter/lib/services/backend_service.dart b/packages/at_onboarding_flutter/lib/src/services/backend_service.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/services/backend_service.dart rename to packages/at_onboarding_flutter/lib/src/services/backend_service.dart diff --git a/packages/at_onboarding_flutter/lib/services/free_atsign_service.dart b/packages/at_onboarding_flutter/lib/src/services/free_atsign_service.dart similarity index 97% rename from packages/at_onboarding_flutter/lib/services/free_atsign_service.dart rename to packages/at_onboarding_flutter/lib/src/services/free_atsign_service.dart index 5213c549a..557503951 100644 --- a/packages/at_onboarding_flutter/lib/services/free_atsign_service.dart +++ b/packages/at_onboarding_flutter/lib/src/services/free_atsign_service.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:at_onboarding_flutter/utils/at_onboarding_app_constants.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_app_constants.dart'; import 'package:http/io_client.dart'; import 'package:http/http.dart'; diff --git a/packages/at_onboarding_flutter/lib/services/onboarding_service.dart b/packages/at_onboarding_flutter/lib/src/services/onboarding_service.dart similarity index 98% rename from packages/at_onboarding_flutter/lib/services/onboarding_service.dart rename to packages/at_onboarding_flutter/lib/src/services/onboarding_service.dart index 10e1e8296..e56096c49 100644 --- a/packages/at_onboarding_flutter/lib/services/onboarding_service.dart +++ b/packages/at_onboarding_flutter/lib/src/services/onboarding_service.dart @@ -3,8 +3,8 @@ import 'dart:convert'; import 'package:at_auth/at_auth.dart'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_app_constants.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_response_status.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_app_constants.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_response_status.dart'; import 'package:at_server_status/at_server_status.dart'; import 'package:at_utils/at_logger.dart'; import 'package:flutter/material.dart'; diff --git a/packages/at_onboarding_flutter/lib/services/sdk_service.dart b/packages/at_onboarding_flutter/lib/src/services/sdk_service.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/services/sdk_service.dart rename to packages/at_onboarding_flutter/lib/src/services/sdk_service.dart diff --git a/packages/at_onboarding_flutter/lib/utils/at_onboarding_app_constants.dart b/packages/at_onboarding_flutter/lib/src/utils/at_onboarding_app_constants.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/utils/at_onboarding_app_constants.dart rename to packages/at_onboarding_flutter/lib/src/utils/at_onboarding_app_constants.dart diff --git a/packages/at_onboarding_flutter/lib/utils/at_onboarding_dimens.dart b/packages/at_onboarding_flutter/lib/src/utils/at_onboarding_dimens.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/utils/at_onboarding_dimens.dart rename to packages/at_onboarding_flutter/lib/src/utils/at_onboarding_dimens.dart diff --git a/packages/at_onboarding_flutter/lib/utils/at_onboarding_error_util.dart b/packages/at_onboarding_flutter/lib/src/utils/at_onboarding_error_util.dart similarity index 93% rename from packages/at_onboarding_flutter/lib/utils/at_onboarding_error_util.dart rename to packages/at_onboarding_flutter/lib/src/utils/at_onboarding_error_util.dart index be74a03c7..c420e6a54 100644 --- a/packages/at_onboarding_flutter/lib/utils/at_onboarding_error_util.dart +++ b/packages/at_onboarding_flutter/lib/src/utils/at_onboarding_error_util.dart @@ -1,8 +1,8 @@ import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_app_constants.dart'; -import 'package:at_onboarding_flutter/utils/at_onboarding_response_status.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_app_constants.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_response_status.dart'; import 'package:at_server_status/at_server_status.dart'; class AtOnboardingErrorToString { diff --git a/packages/at_onboarding_flutter/lib/utils/at_onboarding_input_formatter.dart b/packages/at_onboarding_flutter/lib/src/utils/at_onboarding_input_formatter.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/utils/at_onboarding_input_formatter.dart rename to packages/at_onboarding_flutter/lib/src/utils/at_onboarding_input_formatter.dart diff --git a/packages/at_onboarding_flutter/lib/utils/at_onboarding_response_status.dart b/packages/at_onboarding_flutter/lib/src/utils/at_onboarding_response_status.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/utils/at_onboarding_response_status.dart rename to packages/at_onboarding_flutter/lib/src/utils/at_onboarding_response_status.dart diff --git a/packages/at_onboarding_flutter/lib/utils/at_onboarding_strings.dart b/packages/at_onboarding_flutter/lib/src/utils/at_onboarding_strings.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/utils/at_onboarding_strings.dart rename to packages/at_onboarding_flutter/lib/src/utils/at_onboarding_strings.dart diff --git a/packages/at_onboarding_flutter/lib/widgets/at_onboarding_button.dart b/packages/at_onboarding_flutter/lib/src/widgets/at_onboarding_button.dart similarity index 100% rename from packages/at_onboarding_flutter/lib/widgets/at_onboarding_button.dart rename to packages/at_onboarding_flutter/lib/src/widgets/at_onboarding_button.dart diff --git a/packages/at_onboarding_flutter/lib/widgets/at_onboarding_dialog.dart b/packages/at_onboarding_flutter/lib/src/widgets/at_onboarding_dialog.dart similarity index 96% rename from packages/at_onboarding_flutter/lib/widgets/at_onboarding_dialog.dart rename to packages/at_onboarding_flutter/lib/src/widgets/at_onboarding_dialog.dart index a57a981c7..bd6da2d32 100644 --- a/packages/at_onboarding_flutter/lib/widgets/at_onboarding_dialog.dart +++ b/packages/at_onboarding_flutter/lib/src/widgets/at_onboarding_dialog.dart @@ -1,5 +1,5 @@ import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; +import '../widgets/at_onboarding_button.dart'; import 'package:flutter/material.dart'; class AtOnboardingDialog extends StatefulWidget { diff --git a/packages/at_onboarding_flutter/pubspec.yaml b/packages/at_onboarding_flutter/pubspec.yaml index 064680e9c..d6a94b442 100644 --- a/packages/at_onboarding_flutter/pubspec.yaml +++ b/packages/at_onboarding_flutter/pubspec.yaml @@ -9,7 +9,7 @@ issue_tracker: https://github.com/atsign-foundation/at_widgets/issues documentation: https://docs.atsign.com/ environment: - sdk: ">=2.12.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" flutter: ">=1.20.0" dependencies: diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_accounts_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_accounts_screen_test.dart index b293d988f..3b65bc20b 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_accounts_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_accounts_screen_test.dart @@ -1,6 +1,6 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_accounts_screen.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_accounts_screen.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_activate_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_activate_screen_test.dart index 05b5ab963..705711920 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_activate_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_activate_screen_test.dart @@ -1,6 +1,6 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_activate_screen.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_activate_screen.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; import 'package:at_server_status/at_server_status.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_backup_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_backup_screen_test.dart index 6a5f1200a..f455d096d 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_backup_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_backup_screen_test.dart @@ -1,6 +1,6 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_backup_screen.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_backup_screen.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_generate_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_generate_screen_test.dart index 2abeec287..5105c9d57 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_generate_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_generate_screen_test.dart @@ -1,5 +1,5 @@ -import 'package:at_onboarding_flutter/screen/at_onboarding_generate_screen.dart'; -import 'package:at_onboarding_flutter/services/free_atsign_service.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_generate_screen.dart'; +import 'package:at_onboarding_flutter/src/services/free_atsign_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_input_atsign_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_input_atsign_screen_test.dart index 2a02fa947..d939dc534 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_input_atsign_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_input_atsign_screen_test.dart @@ -1,9 +1,9 @@ import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_input_atsign_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_input_atsign_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_otp_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_otp_screen_test.dart index 14f70f5ca..72b2ae545 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_otp_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_otp_screen_test.dart @@ -1,5 +1,5 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_otp_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_otp_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_pair_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_pair_screen_test.dart index c6e8ac8dd..ec38bf468 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_pair_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_pair_screen_test.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_pair_screen.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_pair_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_qrcode_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_qrcode_screen_test.dart index 9cca0fd88..1eaa10cb7 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_qrcode_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_qrcode_screen_test.dart @@ -1,5 +1,5 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_qrcode_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_qrcode_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_reference_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_reference_screen_test.dart index 84f37552c..f9c88755d 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_reference_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_reference_screen_test.dart @@ -1,5 +1,5 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reference_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reference_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_reset_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_reset_screen_test.dart index 54170b225..e586ea675 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_reset_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_reset_screen_test.dart @@ -1,5 +1,5 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_reset_screen.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_reset_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/at_onboarding_flutter/test/screens/at_onboarding_start_screen_test.dart b/packages/at_onboarding_flutter/test/screens/at_onboarding_start_screen_test.dart index 097f9c380..540371ca2 100644 --- a/packages/at_onboarding_flutter/test/screens/at_onboarding_start_screen_test.dart +++ b/packages/at_onboarding_flutter/test/screens/at_onboarding_start_screen_test.dart @@ -1,7 +1,7 @@ import 'package:at_auth/at_auth.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/screen/at_onboarding_start_screen.dart'; -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/screen/at_onboarding_start_screen.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; @@ -15,7 +15,8 @@ class MockOnboardingService extends Mock implements OnboardingService { } @override - Future onboard({String? cramSecret, AtOnboardingRequest? atOnboardingRequest}) { + Future onboard( + {String? cramSecret, AtOnboardingRequest? atOnboardingRequest}) { throw OnboardingStatus.ACTIVATE; } } diff --git a/packages/at_onboarding_flutter/test/services/onboarding_service_test.dart b/packages/at_onboarding_flutter/test/services/onboarding_service_test.dart index ff34dd0a8..5185e1d07 100644 --- a/packages/at_onboarding_flutter/test/services/onboarding_service_test.dart +++ b/packages/at_onboarding_flutter/test/services/onboarding_service_test.dart @@ -1,4 +1,4 @@ -import 'package:at_onboarding_flutter/services/onboarding_service.dart'; +import 'package:at_onboarding_flutter/src/services/onboarding_service.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/at_onboarding_flutter/test/services/sdk_service_test.dart b/packages/at_onboarding_flutter/test/services/sdk_service_test.dart index 8666ea592..1f838ee77 100644 --- a/packages/at_onboarding_flutter/test/services/sdk_service_test.dart +++ b/packages/at_onboarding_flutter/test/services/sdk_service_test.dart @@ -1,4 +1,4 @@ -import 'package:at_onboarding_flutter/services/sdk_service.dart'; +import 'package:at_onboarding_flutter/src/services/sdk_service.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/at_onboarding_flutter/test/utils/at_onboarding_error_util_test.dart b/packages/at_onboarding_flutter/test/utils/at_onboarding_error_util_test.dart index 9e59c2235..45d2a871b 100644 --- a/packages/at_onboarding_flutter/test/utils/at_onboarding_error_util_test.dart +++ b/packages/at_onboarding_flutter/test/utils/at_onboarding_error_util_test.dart @@ -1,4 +1,4 @@ -import 'package:at_onboarding_flutter/utils/at_onboarding_error_util.dart'; +import 'package:at_onboarding_flutter/src/utils/at_onboarding_error_util.dart'; import 'package:flutter_test/flutter_test.dart'; main() { diff --git a/packages/at_onboarding_flutter/test/widgets/at_onboarding_button_test.dart b/packages/at_onboarding_flutter/test/widgets/at_onboarding_button_test.dart index 8e5127b31..5ba9399e0 100644 --- a/packages/at_onboarding_flutter/test/widgets/at_onboarding_button_test.dart +++ b/packages/at_onboarding_flutter/test/widgets/at_onboarding_button_test.dart @@ -1,4 +1,4 @@ -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; import 'package:at_sync_ui_flutter/at_sync_material.dart'; import '../test_material_app.dart'; diff --git a/packages/at_onboarding_flutter/test/widgets/at_onboarding_dialog_test.dart b/packages/at_onboarding_flutter/test/widgets/at_onboarding_dialog_test.dart index b6039c927..f116f5fb2 100644 --- a/packages/at_onboarding_flutter/test/widgets/at_onboarding_dialog_test.dart +++ b/packages/at_onboarding_flutter/test/widgets/at_onboarding_dialog_test.dart @@ -1,6 +1,6 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; -import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_button.dart'; +import 'package:at_onboarding_flutter/src/widgets/at_onboarding_dialog.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart';