Skip to content

Commit

Permalink
Merge pull request #689 from atsign-foundation/hamdaan-improve-pubsco…
Browse files Browse the repository at this point in the history
…re-atonboarding

fix: improve pub score of at_onboarding_flutter
  • Loading branch information
XavierChanth authored Jun 27, 2023
2 parents 92730f5 + 18b78cf commit 283536d
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 69 deletions.
3 changes: 1 addition & 2 deletions packages/at_onboarding_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _MyAppState extends State<MyApp> {
AtClientPreference? atClientPreference;

bool isChangeLanguage = false;
var _currentLocale = Locale('en', '');
var _currentLocale = const Locale('en', '');

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -169,7 +169,6 @@ class _MyAppState extends State<MyApp> {
DropdownButton(
onChanged: (value) {
setState(() {
print(value);
value == 'en'
? _currentLocale = const Locale('en')
: _currentLocale = const Locale('fr');
Expand Down
4 changes: 2 additions & 2 deletions packages/at_onboarding_flutter/example/lib/switch_atsign.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ class _AtSignBottomSheetState extends State<AtSignBottomSheet> {
),
),
isLoading
? Center(
? const Center(
child: Column(
children: const [
children: [
Text(
'Switching atsign...',
style: TextStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import Foundation

import at_file_saver
import biometric_storage
import device_info_plus
import file_selector_macos
import package_info_plus
import path_provider_macos
import path_provider_foundation
import share_plus_macos
import shared_preferences_foundation
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
BiometricStorageMacOSPlugin.register(with: registry.registrar(forPlugin: "BiometricStorageMacOSPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
Expand Down
1 change: 1 addition & 0 deletions packages/at_onboarding_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependency_overrides:
at_onboarding_flutter:
path: ../
at_client_mobile: ^3.2.9
intl: ^0.18.0
# 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
71 changes: 40 additions & 31 deletions packages/at_onboarding_flutter/lib/at_onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ class AtOnboarding {

if (result is AtOnboardingResult) {
return result;
} else {
return AtOnboardingResult.cancelled();
}
} else {
}

return AtOnboardingResult.cancelled();
}

if (context.mounted){
final result = await Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -78,7 +80,7 @@ class AtOnboarding {
);
},
),
);
);

if (result is AtOnboardingResult) {
//Update primary atsign after onboard success
Expand All @@ -87,10 +89,10 @@ class AtOnboarding {
await changePrimaryAtsign(atsign: result.atsign!);
}
return result;
} else {
return AtOnboardingResult.cancelled();
}
}
}

return AtOnboardingResult.cancelled();
}

static Future<AtOnboardingResult> activateAccount({
Expand All @@ -99,22 +101,26 @@ class AtOnboarding {
}) async {
/// Initial Setup
await _initialSetup(context);
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) {
return AtOnboardingActivateScreen(
hideReferences: false,
config: config,
);
},
),
);
if (result is AtOnboardingResult) {
return result;
} else {
return AtOnboardingResult.cancelled();

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<bool> changePrimaryAtsign({required String atsign}) async {
Expand All @@ -129,15 +135,18 @@ class AtOnboarding {
/// Initial Setup
await _initialSetup(context);

final result = await Navigator.push(context,
MaterialPageRoute(builder: (BuildContext context) {
return AtOnboardingResetScreen(config: config);
}));
if (result is AtOnboardingResetResult) {
return result;
} else {
return AtOnboardingResetResult.cancelled;
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<bool> enableUsingSharedStorage() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ class _AtOnboardingAccountsScreenState
children: <Widget>[
Text(
widget.message ??
AtOnboardingLocalizations.current
.title_select_atSign,
AtOnboardingLocalizations.current.title_select_atSign,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: AtOnboardingDimens.fontNormal,
Expand Down Expand Up @@ -168,18 +167,18 @@ class _AtOnboardingAccountsScreenState
child: AlertDialog(
content: RichText(
text: TextSpan(
style: theme.textTheme.bodyText1,
style: theme.textTheme.bodyLarge,
children: <InlineSpan>[
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:
AtOnboardingLocalizations.current.title_pair_atSign_next,
)
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class _AtOnboardingActivateScreenState
child: Scaffold(
appBar: AppBar(
title: Text(
AtOnboardingLocalizations.current
.title_setting_up_your_atSign,
AtOnboardingLocalizations.current.title_setting_up_your_atSign,
),
actions: [
IconButton(
Expand All @@ -97,8 +96,7 @@ class _AtOnboardingActivateScreenState
),
const SizedBox(height: 10),
Text(
AtOnboardingLocalizations.current
.msg_wait_fetching_atSign,
AtOnboardingLocalizations.current.msg_wait_fetching_atSign,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,7 @@ class _AtOnboardingGenerateScreenState
message: AtOnboardingLocalizations.current.processing,
);
await Future.delayed(const Duration(milliseconds: 400));
bool isExist =
await _onboardingService.isExistingAtsign(verifiedAtSign);
bool isExist = await _onboardingService.isExistingAtsign(verifiedAtSign);

if (isExist) {
_inprogressDialog.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class _AtOnboardingOTPScreenState extends State<AtOnboardingOTPScreen> {
children: <TextSpan>[
TextSpan(
text: AtOnboardingLocalizations.current.note,
style: theme.textTheme.bodyText2?.copyWith(
style: theme.textTheme.bodyMedium?.copyWith(
fontSize: AtOnboardingDimens.fontSmall,
height: 1.5,
fontWeight: FontWeight.bold,
Expand All @@ -207,7 +207,7 @@ class _AtOnboardingOTPScreenState extends State<AtOnboardingOTPScreen> {
TextSpan(
text: AtOnboardingLocalizations
.current.note_otp_content,
style: theme.textTheme.bodyText2?.copyWith(
style: theme.textTheme.bodyMedium?.copyWith(
fontSize: AtOnboardingDimens.fontSmall,
height: 1.5,
),
Expand Down Expand Up @@ -620,4 +620,4 @@ class _AtOnboardingOTPScreenState extends State<AtOnboardingOTPScreen> {
},
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class _AtOnboardingPairScreenState extends State<AtOnboardingPairScreen> {
if (status) {
_showOTPScreen();
} else {
if (!mounted) return;
AtOnboardingDialog.showError(
context: context,
message: AtOnboardingLocalizations.current.error_please_enter_email,
Expand Down Expand Up @@ -249,6 +250,7 @@ class _AtOnboardingPairScreenState extends State<AtOnboardingPairScreen> {
if (errorMessage.contains('maximum number of free atSigns')) {
await showlimitDialog();
} else {
if (!mounted) return status;
AtOnboardingDialog.showError(context: context, message: errorMessage);
}
}
Expand Down Expand Up @@ -346,8 +348,10 @@ class _AtOnboardingPairScreenState extends State<AtOnboardingPairScreen> {
data = response.body;
data = jsonDecode(data);
String errorMessage = data['message'];
if (!mounted) return;
AtOnboardingDialog.showError(context: context, message: errorMessage);
}
if (!mounted) return;
final result2 = await AtOnboardingOTPScreen.push(
context: context,
atSign: result.atSign,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class _AtOnboardingQRCodeScreenState extends State<AtOnboardingQRCodeScreen> {
);
} else {
await _controller?.pauseCamera();
if (!mounted) return;
await AtOnboardingDialog.showError(
context: context,
message: AtOnboardingLocalizations.current.invalid_QR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class _AtOnboardingStartScreenState extends State<AtOnboardingStartScreen> {
if (!mounted) return;
Navigator.pop(context, result);
} else if (e == OnboardingStatus.ACTIVATE) {
if (!mounted) return;
final result = await AtOnboarding.activateAccount(
context: context,
config: widget.config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AtOnboardingBackupService {
AtOnboardingBackupService._();

static final AtOnboardingBackupService _instance =
AtOnboardingBackupService._();
AtOnboardingBackupService._();

static AtOnboardingBackupService get instance => _instance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import 'package:shared_preferences/shared_preferences.dart';
const int _tutorialVersion = 2;

enum AtOnboardingTutorialDisplay {
normal, /// show once
always, /// always show tutorial when opening app
never, /// never show tutorial when opening app
normal,

/// show once
always,

/// always show tutorial when opening app
never,

/// never show tutorial when opening app
}

class AtTutorialServiceInfo {
Expand All @@ -29,10 +37,10 @@ class AtTutorialServiceInfo {
}

Map<String, dynamic> toJson() => {
"versionInfo": versionInfo,
"hasShowSignInPage": hasShowSignInPage,
"hasShowSignUpPage": hasShowSignUpPage,
};
"versionInfo": versionInfo,
"hasShowSignInPage": hasShowSignInPage,
"hasShowSignUpPage": hasShowSignUpPage,
};
}

class AtOnboardingTutorialService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ class AtOnboardingStrings {
static const String atsignHintText = 'alice';
static const String _basepath = 'assets/images';
static const String backupZip = '$_basepath/backup_key.png';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ class _AtOnboardingDialogState extends State<AtOnboardingDialog> {
actions: widget.actions,
);
}
}
}
4 changes: 2 additions & 2 deletions packages/at_onboarding_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ dependencies:
at_utils: ^3.0.12
at_sync_ui_flutter: ^1.0.1

dependency_overrides:
package_info_plus: ^3.0.0


dev_dependencies:
flutter_test:
Expand All @@ -55,6 +54,7 @@ dev_dependencies:
mocktail: ^0.3.0



# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void main() {
onboardingDataTest = OnboardingDataTest();
});

// ignore: unused_element
Widget _defaultApp({
ThemeData? theme,
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void main() {
onboardingDataTest = OnboardingDataTest();
});

// ignore: unused_element
Widget _defaultApp({
ThemeData? theme,
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void main() {

group("test formatAtSign Func", () {
test("formatAtSign don't @", () {

final result = onboardingService.formatAtSign(
"@${onboardingDataTest.atSignTest}",
);
Expand Down
Loading

0 comments on commit 283536d

Please sign in to comment.