Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new flow create account #616

Merged
merged 10 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -615,5 +615,6 @@
"selectedTokensBeImportedInfo": "Only the tokens you’ve selected will appear in your wallet. You can always hide tokens later by searching for them.",
"backWord": "Back",
"selectAll": "Select all",
"hideAll": "Hide all"
"hideAll": "Hide all",
"selectSeed": "Select seed"
}
3 changes: 2 additions & 1 deletion assets/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -615,5 +615,6 @@
"selectedTokensBeImportedInfo": "Only the tokens you’ve selected will appear in your wallet. You can always hide tokens later by searching for them.",
"backWord": "Back",
"selectAll": "Select all",
"hideAll": "Hide all"
"hideAll": "Hide all",
"selectSeed": "Select seed"
}
10 changes: 9 additions & 1 deletion lib/app/router/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ enum AppRoute {
'walletCancelUnstaking', // all data in query
),
walletAddAccount(
'walletAddAccount',
'walletAddAccount',
),
walletSelectSeed(
'',
'walletSelectSeed',
),
walletNewAccount(
'',
'walletAddAccount', // all data in query
'walletNewAccount', // all data in query
),

/// Browser section
Expand Down
29 changes: 22 additions & 7 deletions lib/app/router/routs/wallet/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import 'package:app/feature/add_seed/add_seed_enable_biometry/view/add_seed_enab
import 'package:app/feature/network/network.dart';
import 'package:app/feature/no_internet/no_internet_screen.dart';
import 'package:app/feature/splash/splash_screen.dart';
import 'package:app/feature/wallet/add_account/add_account.dart';
import 'package:app/feature/wallet/new_account/add_account.dart';
import 'package:app/feature/wallet/new_account/add_account_page.dart';
import 'package:app/feature/wallet/new_account/select_seed/select_seed_page.dart';
import 'package:app/feature/wallet/wallet.dart';
import 'package:app/feature/wallet/widgets/account_asset_tab/select_new_asset/select_new_asset.dart';
import 'package:go_router/go_router.dart';
import 'package:nekoton_repository/nekoton_repository.dart';

const selectNewAssetAddressPathParam = 'selectNewAssetAddress';
const walletSelectSeedPathParam = 'walletSelectSeedSeeds';
const tonWalletDetailsAddressPathParam = 'tonWalletDetailsAddress';
const tokenWalletDetailsOwnerAddressPathParam = 'tonWalletDetailsOwnerAddress';
const tokenWalletDetailsContractAddressPathParam =
Expand Down Expand Up @@ -104,12 +107,24 @@ StatefulShellBranch get walletBranch {
),
GoRoute(
path: AppRoute.walletAddAccount.path,
builder: (_, state) => AddAccountPage(
publicKey:
state.uri.queryParameters[walletCreatePublicKeyQueryParam]!,
password:
state.uri.queryParameters[walletCreatePasswordQueryParam]!,
),
builder: (_, state) => const AddAccountPage(),
routes: [
GoRoute(
path: AppRoute.walletSelectSeed.path,
builder: (_, state) => const SelectSeedPage(),
routes: [
GoRoute(
path: AppRoute.walletNewAccount.path,
builder: (_, state) => NewAccountPage(
publicKey: state.uri
.queryParameters[walletCreatePublicKeyQueryParam]!,
password: state
.uri.queryParameters[walletCreatePasswordQueryParam]!,
),
),
],
),
],
),
addSeedNamedRoute,
tonWalletDetailsRoute,
Expand Down
3 changes: 1 addition & 2 deletions lib/app/service/storage_service/secure_storage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class SecureStorageService extends AbstractStorageService {
}

class StorageKey {
factory StorageKey.userWithNewWallet() =>
StorageKey._('userWithNewWallet');
factory StorageKey.userWithNewWallet() => StorageKey._('userWithNewWallet');

factory StorageKey.showingNewTokensLabel(String masterKey) =>
StorageKey._('showingNewTokensLabel', masterKey);
Expand Down
5 changes: 0 additions & 5 deletions lib/feature/wallet/add_account/add_account.dart

This file was deleted.

4 changes: 4 additions & 0 deletions lib/feature/wallet/new_account/add_account.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export 'add_account_confirm/add_new_account_confirm_sheet.dart';
export 'add_account_result/add_account_result_sheet.dart';
export 'new_account_page.dart';
export 'new_account_type/new_account_type_widget.dart';
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
import 'package:app/feature/wallet/add_account/add_account_confirm/add_new_account_confirm_sheet.dart';
import 'package:app/app/router/app_route.dart';
import 'package:app/generated/generated.dart';
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:nekoton_repository/nekoton_repository.dart';
import 'package:ui_components_lib/ui_components_lib.dart';
import 'package:ui_components_lib/v2/ui_components_lib_v2.dart';

/// This is a helper method to display AddNewAccountSheet.
Future<void> showAddNewAccountSheet({
required BuildContext context,
required PublicKey publicKey,
}) {
return showCommonBottomSheet(
context: context,
title: LocaleKeys.addNewAccount.tr(),
centerTitle: true,
body: (_, __) => AddNewAccountSheet(
publicKey: publicKey,
),
);
}

class AddNewAccountSheet extends StatelessWidget {
const AddNewAccountSheet({
required this.publicKey,
super.key,
});

final PublicKey publicKey;
class AddAccountView extends StatelessWidget {
const AddAccountView({super.key});

@override
Widget build(BuildContext context) {
final theme = context.themeStyleV2;

return PrimaryCard(
color: theme.colors.background2,
borderRadius: BorderRadius.circular(DimensRadiusV2.radius16),
Expand All @@ -43,7 +21,11 @@ class AddNewAccountSheet extends StatelessWidget {
separator: const CommonDivider(),
children: [
GestureDetector(
onTap: () => _addLocal(context),
onTap: () {
context.goFurther(
AppRoute.walletSelectSeed.path,
);
},
behavior: HitTestBehavior.translucent,
child: SizedBox(
height: DimensSizeV2.d64,
Expand Down Expand Up @@ -108,12 +90,4 @@ class AddNewAccountSheet extends StatelessWidget {
),
);
}

void _addLocal(BuildContext context) {
Navigator.of(context).pop();
showAddAccountConfirmSheet(
context: context,
publicKey: publicKey,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:app/feature/wallet/add_account/add_account_confirm/add_account_confirm_wm.dart';
import 'package:app/feature/wallet/wallet.dart';
import 'package:app/feature/wallet/new_account/add_account_confirm/add_account_confirm_wm.dart';
import 'package:app/generated/generated.dart';
import 'package:elementary/elementary.dart';
import 'package:elementary_helper/elementary_helper.dart';
Expand All @@ -13,22 +12,44 @@ class AddAccountConfirmWidget
extends ElementaryWidget<AddAccountConfirmWidgetModel> {
const AddAccountConfirmWidget({
required this.publicKey,
required this.seedName,
Key? key,
WidgetModelFactory wmFactory = defaultAddAccountConfirmWidgetModelFactory,
}) : super(wmFactory, key: key);

final PublicKey publicKey;
final String seedName;

@override
Widget build(AddAccountConfirmWidgetModel wm) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (wm.account != null)
AccountInfo(
account: wm.account!,
color: wm.theme.colors.background2,
Container(
padding: const EdgeInsets.symmetric(vertical: DimensSizeV2.d24),
decoration: BoxDecoration(
color: wm.theme.colors.background3,
borderRadius: BorderRadius.circular(DimensRadiusV2.radius16),
),
child: Row(
children: [
const SizedBox(width: DimensSizeV2.d16),
Icon(
LucideIcons.lockKeyhole,
color: wm.theme.colors.content0,
size: DimensSizeV2.d20,
),
const SizedBox(width: DimensSizeV2.d12),
Flexible(
child: Text(
seedName,
style: wm.theme.textStyles.labelMedium,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
const SizedBox(height: DimensSizeV2.d16),
SecureTextField(
textEditingController: wm.controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:app/app/router/router.dart';
import 'package:app/core/error_handler_factory.dart';
import 'package:app/core/wm/custom_wm.dart';
import 'package:app/di/di.dart';
import 'package:app/feature/wallet/add_account/add_account_confirm/add_account_confirm_model.dart';
import 'package:app/feature/wallet/add_account/add_account_confirm/add_account_confirm_widget.dart';
import 'package:app/feature/wallet/new_account/add_account_confirm/add_account_confirm_model.dart';
import 'package:app/feature/wallet/new_account/add_account_confirm/add_account_confirm_widget.dart';
import 'package:elementary_helper/elementary_helper.dart';
import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';
Expand Down Expand Up @@ -74,7 +74,7 @@ class AddAccountConfirmWidgetModel
} else if (contextSafe != null) {
Navigator.of(contextSafe!).pop();
contextSafe!.goFurther(
AppRoute.walletAddAccount.pathWithData(
AppRoute.walletNewAccount.pathWithData(
queryParameters: {
walletCreatePublicKeyQueryParam: widget.publicKey.publicKey,
walletCreatePasswordQueryParam: password,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:app/feature/wallet/add_account/add_account_confirm/add_account_confirm_widget.dart';
import 'package:app/feature/wallet/new_account/add_account_confirm/add_account_confirm_widget.dart';
import 'package:app/generated/generated.dart';
import 'package:flutter/material.dart';
import 'package:nekoton_repository/nekoton_repository.dart';
Expand All @@ -8,13 +8,15 @@ import 'package:ui_components_lib/ui_components_lib.dart';
Future<void> showAddAccountConfirmSheet({
required BuildContext context,
required PublicKey publicKey,
required String seedName,
}) {
return showCommonBottomSheet(
context: context,
title: LocaleKeys.confirmAction.tr(),
centerTitle: true,
body: (_, scrollController) => AddAccountConfirmWidget(
publicKey: publicKey,
seedName: seedName,
),
);
}
23 changes: 23 additions & 0 deletions lib/feature/wallet/new_account/add_account_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:app/feature/wallet/new_account/add_account/add_account_view.dart';
import 'package:app/generated/generated.dart';
import 'package:flutter/material.dart';
import 'package:ui_components_lib/ui_components_lib.dart';

class AddAccountPage extends StatelessWidget {
const AddAccountPage({
super.key,
});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: DefaultAppBar(
titleText: LocaleKeys.newAccount.tr(),
),
body: const Padding(
padding: EdgeInsets.symmetric(horizontal: DimensSize.d16),
child: AddAccountView(),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:app/feature/wallet/add_account/add_account_result/add_account_result_widget.dart';
import 'package:app/feature/wallet/new_account/add_account_result/add_account_result_widget.dart';
import 'package:flutter/material.dart';
import 'package:nekoton_repository/nekoton_repository.dart';
import 'package:ui_components_lib/ui_components_lib.dart';

Future<void> showAddAccountResultSheet({
Future<void> showNewAccountResultSheet({
required BuildContext context,
required Address address,
}) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:app/feature/wallet/add_account/add_account_result/add_account_result_wm.dart';
import 'package:app/feature/wallet/new_account/add_account_result/add_account_result_wm.dart';
import 'package:app/generated/generated.dart';
import 'package:elementary/elementary.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:app/core/error_handler_factory.dart';
import 'package:app/core/wm/custom_wm.dart';
import 'package:app/di/di.dart';
import 'package:app/feature/wallet/add_account/add_account_result/add_account_result_model.dart';
import 'package:app/feature/wallet/add_account/add_account_result/add_account_result_widget.dart';
import 'package:app/feature/wallet/new_account/add_account_result/add_account_result_model.dart';
import 'package:app/feature/wallet/new_account/add_account_result/add_account_result_widget.dart';
import 'package:app/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:ui_components_lib/v2/ui_components_lib_v2.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:app/feature/wallet/add_account/add_account.dart';
import 'package:app/feature/wallet/new_account/add_account.dart';
import 'package:app/generated/generated.dart';
import 'package:flutter/material.dart';
import 'package:nekoton_repository/nekoton_repository.dart';
import 'package:ui_components_lib/ui_components_lib.dart';

class AddAccountPage extends StatelessWidget {
const AddAccountPage({
class NewAccountPage extends StatelessWidget {
const NewAccountPage({
required this.publicKey,
required this.password,
super.key,
Expand All @@ -22,7 +22,7 @@ class AddAccountPage extends StatelessWidget {
),
body: Padding(
padding: const EdgeInsets.all(DimensSizeV2.d16),
child: AddAccountTypeWidget(
child: NewAccountTypeWidget(
publicKey: PublicKey(publicKey: publicKey),
password: password,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:flutter/material.dart';
import 'package:nekoton_repository/nekoton_repository.dart' hide Message;
import 'package:rxdart/rxdart.dart';

class AddAccountTypeModel extends ElementaryModel {
AddAccountTypeModel(
class NewAccountTypeModel extends ElementaryModel {
NewAccountTypeModel(
ErrorHandler errorHandler,
this._messengerService,
this._nekotonRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:app/feature/wallet/add_account/add_account_type/add_account_type_wm.dart';
import 'package:app/feature/wallet/new_account/new_account_type'
'/new_account_type_wm.dart';
import 'package:app/generated/generated.dart';
import 'package:app/utils/constants.dart';
import 'package:elementary/elementary.dart';
Expand All @@ -9,19 +10,19 @@ import 'package:nekoton_repository/nekoton_repository.dart';
import 'package:ui_components_lib/ui_components_lib.dart';
import 'package:ui_components_lib/v2/ui_components_lib_v2.dart';

class AddAccountTypeWidget extends ElementaryWidget<AddAccountTypeWidgetModel> {
const AddAccountTypeWidget({
class NewAccountTypeWidget extends ElementaryWidget<NewAccountTypeWidgetModel> {
const NewAccountTypeWidget({
required this.publicKey,
required this.password,
Key? key,
WidgetModelFactory wmFactory = defaultAddAccountTypeWidgetModelFactory,
WidgetModelFactory wmFactory = defaultNewAccountTypeWidgetModelFactory,
}) : super(wmFactory, key: key);

final PublicKey publicKey;
final String password;

@override
Widget build(AddAccountTypeWidgetModel wm) {
Widget build(NewAccountTypeWidgetModel wm) {
final theme = wm.theme;

return Column(
Expand Down
Loading
Loading