Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 5 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void main(List<String> args) async {
await CampfireMigration.init();
}

if (kDebugMode) {
if (kDebugMode && !Platform.isIOS) {
unawaited(
MwebdService.instance
.logsStream(CryptoCurrencyNetwork.main)
Expand Down Expand Up @@ -344,7 +344,6 @@ class MaterialAppWithTheme extends ConsumerStatefulWidget {
class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
with WidgetsBindingObserver {
static const platform = MethodChannel("STACK_WALLET_RESTORE");
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

// late final Wallets _wallets;
// late final Prefs _prefs;
Expand Down Expand Up @@ -659,10 +658,10 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
Future<void> goToRestoreSWB(String encrypted) async {
if (!ref.read(prefsChangeNotifierProvider).hasPin) {
await Navigator.of(
navigatorKey.currentContext!,
ref.read(pNavKey).currentContext!,
).pushNamed(CreatePinView.routeName, arguments: true).then((value) {
if (value is! bool || value == false) {
Navigator.of(navigatorKey.currentContext!).pushNamed(
Navigator.of(ref.read(pNavKey).currentContext!).pushNamed(
RestoreFromEncryptedStringView.routeName,
arguments: encrypted,
);
Expand All @@ -671,7 +670,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
} else {
unawaited(
Navigator.push(
navigatorKey.currentContext!,
ref.read(pNavKey).currentContext!,
RouteGenerator.getRoute(
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
builder:
Expand Down Expand Up @@ -711,7 +710,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>

return MaterialApp(
key: GlobalKey(),
navigatorKey: navigatorKey,
navigatorKey: ref.read(pNavKey),
title: AppConfig.appName,
onGenerateRoute: RouteGenerator.generateRoute,
theme: ThemeData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ class _VerifyRecoveryPhraseViewState
super.initState();
}

@override
dispose() {
super.dispose();
}

Future<bool> _verifyMnemonicPassphrase() async {
final result = await showDialog<String?>(
context: context,
Expand Down Expand Up @@ -391,12 +386,15 @@ class _VerifyRecoveryPhraseViewState
).pushNamedAndRemoveUntil(HomeView.routeName, (route) => false),
);
if (_coin is Ethereum) {
unawaited(
Navigator.of(context).pushNamed(
EditWalletTokensView.routeName,
arguments: widget.wallet.walletId,
),
);
WidgetsBinding.instance.addPostFrameCallback((_) {
ref
.read(pNavKey)
.currentState
?.pushNamed(
EditWalletTokensView.routeName,
arguments: widget.wallet.walletId,
);
});
}
}
}
Expand Down
213 changes: 104 additions & 109 deletions lib/pages/wallets_view/wallets_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import '../../app_config.dart';
import '../../models/add_wallet_list_entity/sub_classes/coin_entity.dart';
import '../../models/isar/models/ethereum/eth_contract.dart';
import '../../pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart';
import '../../providers/db/main_db_provider.dart';
import '../../providers/providers.dart';
import '../../services/event_bus/events/wallet_added_event.dart';
import '../../services/event_bus/global_event_bus.dart';
Expand All @@ -28,6 +27,7 @@ import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
import '../../wallets/isar/models/wallet_info.dart';
import '../../wallets/isar/providers/all_wallets_info_provider.dart';
import '../../wallets/isar/providers/wallet_info_provider.dart';
import '../../wallets/wallet/wallet.dart';
import '../../widgets/background.dart';
Expand Down Expand Up @@ -73,13 +73,14 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {

List<WalletListItemData> _filter(String searchTerm) {
// clean out deleted wallets
final existingWalletIds = ref
.read(mainDBProvider)
.isar
.walletInfo
.where()
.walletIdProperty()
.findAllSync();
final existingWalletIds =
ref
.read(mainDBProvider)
.isar
.walletInfo
.where()
.walletIdProperty()
.findAllSync();
wallets.removeWhere((k, v) => !existingWalletIds.contains(k));

if (searchTerm.isEmpty) {
Expand Down Expand Up @@ -127,25 +128,22 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
}

void updateWallets() {
final walletsData =
ref.read(mainDBProvider).isar.walletInfo.where().findAllSync();
final walletsData = ref.read(pAllWalletsInfo);

walletsData.removeWhere((e) => e.coin != widget.coin);

if (widget.coin is Ethereum) {
for (final data in walletsData) {
final List<EthContract> contracts = [];
final contractAddresses =
ref.read(pWalletTokenAddresses(data.walletId));
final contractAddresses = ref.read(
pWalletTokenAddresses(data.walletId),
);

// fetch each contract
for (final contractAddress in contractAddresses) {
final contract = ref
.read(
mainDBProvider,
)
.getEthContractSync(
contractAddress,
);
.read(mainDBProvider)
.getEthContractSync(contractAddress);

// add it to list if it exists in DB
if (contract != null) {
Expand All @@ -155,9 +153,7 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {

// add tuple to list
wallets[data.walletId] = (
wallet: ref.read(pWallets).getWallet(
data.walletId,
),
wallet: ref.read(pWallets).getWallet(data.walletId),
contracts: contracts,
);
}
Expand All @@ -167,9 +163,7 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
// desktop single coin apps may cause issues so lets just ignore the error and move on
try {
wallets[data.walletId] = (
wallet: ref.read(pWallets).getWallet(
data.walletId,
),
wallet: ref.read(pWallets).getWallet(data.walletId),
contracts: [],
);
} catch (_) {
Expand Down Expand Up @@ -211,46 +205,45 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
Widget build(BuildContext context) {
return ConditionalParent(
condition: !isDesktop && !AppConfig.isSingleCoinApp,
builder: (child) => Background(
child: Scaffold(
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: const AppBarBackButton(),
title: Text(
"${widget.coin.prettyName} (${widget.coin.ticker}) wallets",
style: STextStyles.navBarTitle(context),
),
actions: [
AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
icon: SvgPicture.asset(
Assets.svg.plus,
width: 18,
height: 18,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
),
onPressed: () {
Navigator.of(context).pushNamed(
CreateOrRestoreWalletView.routeName,
arguments: CoinEntity(widget.coin),
);
},
builder:
(child) => Background(
child: Scaffold(
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: const AppBarBackButton(),
title: Text(
"${widget.coin.prettyName} (${widget.coin.ticker}) wallets",
style: STextStyles.navBarTitle(context),
),
actions: [
AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
icon: SvgPicture.asset(
Assets.svg.plus,
width: 18,
height: 18,
color:
Theme.of(
context,
).extension<StackColors>()!.topNavIconPrimary,
),
onPressed: () {
Navigator.of(context).pushNamed(
CreateOrRestoreWalletView.routeName,
arguments: CoinEntity(widget.coin),
);
},
),
),
],
),
body: SafeArea(
child: Padding(padding: const EdgeInsets.all(16), child: child),
),
],
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: child,
),
),
),
),
child: Column(
children: [
ClipRRect(
Expand All @@ -267,14 +260,16 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
_searchString = value;
});
},
style: isDesktop
? STextStyles.desktopTextExtraSmall(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
height: 1.8,
)
: STextStyles.field(context),
style:
isDesktop
? STextStyles.desktopTextExtraSmall(context).copyWith(
color:
Theme.of(
context,
).extension<StackColors>()!.textFieldActiveText,
height: 1.8,
)
: STextStyles.field(context),
decoration: standardInputDecoration(
"Search...",
searchFieldFocusNode,
Expand All @@ -292,32 +287,31 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
height: isDesktop ? 20 : 16,
),
),
suffixIcon: _searchController.text.isNotEmpty
? Padding(
padding: const EdgeInsets.only(right: 0),
child: UnconstrainedBox(
child: Row(
children: [
TextFieldIconButton(
child: const XIcon(),
onTap: () async {
setState(() {
_searchController.text = "";
_searchString = "";
});
},
),
],
suffixIcon:
_searchController.text.isNotEmpty
? Padding(
padding: const EdgeInsets.only(right: 0),
child: UnconstrainedBox(
child: Row(
children: [
TextFieldIconButton(
child: const XIcon(),
onTap: () async {
setState(() {
_searchController.text = "";
_searchString = "";
});
},
),
],
),
),
),
)
: null,
)
: null,
),
),
),
const SizedBox(
height: 16,
),
const SizedBox(height: 16),
Expanded(
child: Builder(
builder: (context) {
Expand Down Expand Up @@ -346,33 +340,34 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
return ConditionalParent(
key: Key(wallet.walletId),
condition: isDesktop,
builder: (child) => RoundedWhiteContainer(
padding: const EdgeInsets.symmetric(
vertical: 14,
horizontal: 20,
),
borderColor: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
child: child,
),
builder:
(child) => RoundedWhiteContainer(
padding: const EdgeInsets.symmetric(
vertical: 14,
horizontal: 20,
),
borderColor:
Theme.of(
context,
).extension<StackColors>()!.backgroundAppBar,
child: child,
),
child: SimpleWalletCard(
walletId: wallet.walletId,
popPrevious: widget
.overrideSimpleWalletCardPopPreviousValueWith ==
null
? isDesktop
: widget
.overrideSimpleWalletCardPopPreviousValueWith!,
popPrevious:
widget.overrideSimpleWalletCardPopPreviousValueWith ==
null
? isDesktop
: widget
.overrideSimpleWalletCardPopPreviousValueWith!,
desktopNavigatorState:
isDesktop ? widget.navigatorState : null,
),
);
}
},
separatorBuilder: (_, __) => SizedBox(
height: isDesktop ? 10 : 8,
),
separatorBuilder:
(_, __) => SizedBox(height: isDesktop ? 10 : 8),
itemCount: data.length,
);
},
Expand Down
4 changes: 4 additions & 0 deletions lib/providers/global/global_nav_key_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final pNavKey = Provider((_) => GlobalKey<NavigatorState>());
Loading
Loading