Skip to content

Commit

Permalink
Merge pull request #604 from atsign-foundation/feature/enable-user-sh…
Browse files Browse the repository at this point in the history
…aring

Feature/enable user sharing
  • Loading branch information
sachins-geekyants authored Apr 27, 2023
2 parents 7981c9c + 6489447 commit 8a8770a
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 19 deletions.
39 changes: 37 additions & 2 deletions packages/at_onboarding_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class _MyAppState extends State<MyApp> {
theme: AtOnboardingTheme(
primaryColor: null,
),
showPopupSharedStorage: true,
),
);
switch (result.status) {
Expand Down Expand Up @@ -166,6 +167,8 @@ class HomeScreen extends StatefulWidget {
}

class _HomeScreenState extends State<HomeScreen> {
static final KeyChainManager _keyChainManager = KeyChainManager.getInstance();

@override
Widget build(BuildContext context) {
/// Get the AtClientManager instance
Expand Down Expand Up @@ -195,11 +198,43 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column(
children: [
const Text(
'Successfully onboarded and navigated to FirstAppScreen'),
'Successfully onboarded and navigated to FirstAppScreen',
),

/// Use the AtClientManager instance to get the current atsign
Text(
'Current atSign: ${atClientManager.atClient.getCurrentAtSign()}'),
'Current atSign: ${atClientManager.atClient.getCurrentAtSign()}',
),
const SizedBox(
height: 30,
),
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ElevatedButton(
onPressed: () async {
_keyChainManager.enableUsingSharedStorage();
},
child: const Text('Enable share'),
),
const SizedBox(width: 24),
ElevatedButton(
onPressed: () async {
_keyChainManager.disableUsingSharedStorage();
},
child: const Text('Disable share'),
),
],
),
const SizedBox(
height: 30,
),
ElevatedButton(
onPressed: () async {
_keyChainManager.deleteAllData();
},
child: const Text('Delete all data'),
),
],
),
),
Expand Down
2 changes: 2 additions & 0 deletions packages/at_onboarding_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ dependencies:
at_backupkey_flutter: ^4.0.8

dependency_overrides:
path: 1.8.3
at_onboarding_flutter:
path: ../
at_client_mobile: ^3.2.9
# When depending on this package from a real application you should use in the dependencies section here we have used in dev_dependencies section:
# at_onboarding_flutter: ^x.y.z
# See https://dart.dev/tools/pub/dependencies#version-constraints
Expand Down
12 changes: 12 additions & 0 deletions packages/at_onboarding_flutter/lib/at_onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,16 @@ class AtOnboarding {
return AtOnboardingResetResult.cancelled;
}
}

Future<bool> enableUsingSharedStorage() async {
final result =
await OnboardingService.getInstance().enableUsingSharedStorage();
return result;
}

Future<bool> disableUsingSharedStorage() async {
final result =
await OnboardingService.getInstance().disableUsingSharedStorage();
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ class _AtOnboardingStartScreenState extends State<AtOnboardingStartScreen> {
}

void _init() async {
await _onboardingService.initialSetup(usingSharedStorage: false);
// This feature will reopen in future
// final isUsingSharedStorage = await onboardingService.isUsingSharedStorage();
// if (isUsingSharedStorage == null) {
// //No defind yet
// final result = await askUserUseSharedStorage();
// await onboardingService.initialSetup(usingSharedStorage: result);
// } else {
// await onboardingService.initialSetup(
// usingSharedStorage: isUsingSharedStorage);
// }
final isUsingSharedStorage = await _onboardingService.isUsingSharedStorage();
final showPopupShareStorage = widget.config.showPopupSharedStorage;

if (isUsingSharedStorage == null && showPopupShareStorage) {
//No defind yet
final result = await askUserUseSharedStorage();
await _onboardingService.initialSetup(usingSharedStorage: result);
} else {
await _onboardingService.initialSetup(
usingSharedStorage: isUsingSharedStorage ?? false);
}
_onboardingService.setAtClientPreference = widget.config.atClientPreference;
try {
final result = await _onboardingService.onboard();
Expand Down Expand Up @@ -139,9 +140,10 @@ class _AtOnboardingStartScreenState extends State<AtOnboardingStartScreen> {
builder: (BuildContext context) {
return AtOnboardingDialog(
title:
'Do you want to share this onboarded atsign with other apps on atPlatform?',
'Share this atSign with all your atPlatform apps?',
message:
'This would save you the process to onboard this atsign on other apps again.',
'You will not be required to re-upload your atKeys when you use this atSign with other atPlatform apps on this device.',
subMessage: '*For this to work, sharing must also be switched on in the other apps',
actions: [
AtOnboardingSecondaryButton(
child: const Text('No'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AtOnboardingConfig {
/// API Key is required when you set [rootEnvironment] to production.
final RootEnvironment rootEnvironment;
final AtSignLogger logger = AtSignLogger('At Onboarding Flutter');
final bool showPopupSharedStorage;

final AtOnboardingTheme? theme;

Expand All @@ -57,6 +58,7 @@ class AtOnboardingConfig {
this.hideQrScan = false,
this.tutorialDisplay = AtOnboardingTutorialDisplay.normal,
this.theme,
this.showPopupSharedStorage = false,
});

AtOnboardingConfig copyWith({
Expand All @@ -68,6 +70,7 @@ class AtOnboardingConfig {
AtOnboardingTutorialDisplay? tutorialDisplay,
String? appAPIKey,
RootEnvironment? rootEnvironment,
bool? showPopupSharedStorage,
}) {
return AtOnboardingConfig(
hideReferences: hideReferences ?? this.hideReferences,
Expand All @@ -78,6 +81,8 @@ class AtOnboardingConfig {
tutorialDisplay: tutorialDisplay ?? this.tutorialDisplay,
appAPIKey: appAPIKey ?? this.appAPIKey,
rootEnvironment: rootEnvironment ?? this.rootEnvironment,
showPopupSharedStorage:
showPopupSharedStorage ?? this.showPopupSharedStorage,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,14 @@ class OnboardingService {
// ignore: deprecated_member_use
_getClientServiceForAtsign(atSign)!.atClientManager.syncService.sync();
}
}

Future<bool> enableUsingSharedStorage() async {
final result = await keyChainManager.enableUsingSharedStorage();
return result;
}

Future<bool> disableUsingSharedStorage() async {
final result = await keyChainManager.disableUsingSharedStorage();
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ class AtOnboardingDialog extends StatefulWidget {

final String title;
final String message;
final String? subMessage;
final List<Widget> actions;

const AtOnboardingDialog({
Key? key,
required this.title,
required this.message,
required this.actions,
this.subMessage,
}) : super(key: key);

@override
Expand All @@ -53,8 +55,25 @@ class _AtOnboardingDialogState extends State<AtOnboardingDialog> {
Widget build(BuildContext context) {
return AlertDialog(
title: Text(widget.title),
content: Text(widget.message),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.message),
Visibility(
visible: (widget.subMessage ?? '').isNotEmpty,
child: const SizedBox(height: 8),
),
Text(
widget.subMessage ?? '',
style: const TextStyle(
fontSize: 13,
fontStyle: FontStyle.italic,
),
)
],
),
actions: widget.actions,
);
}
}
}
3 changes: 3 additions & 0 deletions packages/at_onboarding_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ dependencies:
at_utils: ^3.0.12
at_sync_ui_flutter: ^1.0.1

dependency_overrides:
path: 1.8.3

dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
8 changes: 7 additions & 1 deletion packages/at_sync_ui_flutter/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ PODS:
- Flutter (1.0.0)
- flutter_keychain (0.0.1):
- Flutter
- flutter_qr_reader (0.0.1):
- Flutter
- MTBBarcodeScanner (5.0.11)
- package_info_plus (0.4.5):
- Flutter
Expand Down Expand Up @@ -73,6 +75,7 @@ DEPENDENCIES:
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_keychain (from `.symlinks/plugins/flutter_keychain/ios`)
- flutter_qr_reader (from `.symlinks/plugins/flutter_qr_reader/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
Expand Down Expand Up @@ -104,6 +107,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_keychain:
:path: ".symlinks/plugins/flutter_keychain/ios"
flutter_qr_reader:
:path: ".symlinks/plugins/flutter_qr_reader/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_ios:
Expand All @@ -129,6 +134,7 @@ SPEC CHECKSUMS:
file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_keychain: 01aabf894ffe8b01adfda1d9df21c210c1b4b452
flutter_qr_reader: d930dde3b2cfe2b3d0bb7d66e5ff3e514300a5e5
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
Expand All @@ -140,6 +146,6 @@ SPEC CHECKSUMS:
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d

COCOAPODS: 1.11.3
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>

0 comments on commit 8a8770a

Please sign in to comment.