Skip to content

Commit 84db2bf

Browse files
authored
Merge pull request #1178 from cypherstack/more-bug-fixes
More bug fixes
2 parents f7b79fe + d13acd6 commit 84db2bf

9 files changed

Lines changed: 255 additions & 204 deletions

File tree

lib/main.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void main(List<String> args) async {
217217
await CampfireMigration.init();
218218
}
219219

220-
if (kDebugMode) {
220+
if (kDebugMode && !Platform.isIOS) {
221221
unawaited(
222222
MwebdService.instance
223223
.logsStream(CryptoCurrencyNetwork.main)
@@ -344,7 +344,6 @@ class MaterialAppWithTheme extends ConsumerStatefulWidget {
344344
class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
345345
with WidgetsBindingObserver {
346346
static const platform = MethodChannel("STACK_WALLET_RESTORE");
347-
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
348347

349348
// late final Wallets _wallets;
350349
// late final Prefs _prefs;
@@ -659,10 +658,10 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
659658
Future<void> goToRestoreSWB(String encrypted) async {
660659
if (!ref.read(prefsChangeNotifierProvider).hasPin) {
661660
await Navigator.of(
662-
navigatorKey.currentContext!,
661+
ref.read(pNavKey).currentContext!,
663662
).pushNamed(CreatePinView.routeName, arguments: true).then((value) {
664663
if (value is! bool || value == false) {
665-
Navigator.of(navigatorKey.currentContext!).pushNamed(
664+
Navigator.of(ref.read(pNavKey).currentContext!).pushNamed(
666665
RestoreFromEncryptedStringView.routeName,
667666
arguments: encrypted,
668667
);
@@ -671,7 +670,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
671670
} else {
672671
unawaited(
673672
Navigator.push(
674-
navigatorKey.currentContext!,
673+
ref.read(pNavKey).currentContext!,
675674
RouteGenerator.getRoute(
676675
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
677676
builder:
@@ -711,7 +710,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
711710

712711
return MaterialApp(
713712
key: GlobalKey(),
714-
navigatorKey: navigatorKey,
713+
navigatorKey: ref.read(pNavKey),
715714
title: AppConfig.appName,
716715
onGenerateRoute: RouteGenerator.generateRoute,
717716
theme: ThemeData(

lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ class _VerifyRecoveryPhraseViewState
9595
super.initState();
9696
}
9797

98-
@override
99-
dispose() {
100-
super.dispose();
101-
}
102-
10398
Future<bool> _verifyMnemonicPassphrase() async {
10499
final result = await showDialog<String?>(
105100
context: context,
@@ -391,12 +386,15 @@ class _VerifyRecoveryPhraseViewState
391386
).pushNamedAndRemoveUntil(HomeView.routeName, (route) => false),
392387
);
393388
if (_coin is Ethereum) {
394-
unawaited(
395-
Navigator.of(context).pushNamed(
396-
EditWalletTokensView.routeName,
397-
arguments: widget.wallet.walletId,
398-
),
399-
);
389+
WidgetsBinding.instance.addPostFrameCallback((_) {
390+
ref
391+
.read(pNavKey)
392+
.currentState
393+
?.pushNamed(
394+
EditWalletTokensView.routeName,
395+
arguments: widget.wallet.walletId,
396+
);
397+
});
400398
}
401399
}
402400
}

lib/pages/wallets_view/wallets_overview.dart

Lines changed: 104 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import '../../app_config.dart';
1717
import '../../models/add_wallet_list_entity/sub_classes/coin_entity.dart';
1818
import '../../models/isar/models/ethereum/eth_contract.dart';
1919
import '../../pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart';
20-
import '../../providers/db/main_db_provider.dart';
2120
import '../../providers/providers.dart';
2221
import '../../services/event_bus/events/wallet_added_event.dart';
2322
import '../../services/event_bus/global_event_bus.dart';
@@ -28,6 +27,7 @@ import '../../utilities/text_styles.dart';
2827
import '../../utilities/util.dart';
2928
import '../../wallets/crypto_currency/crypto_currency.dart';
3029
import '../../wallets/isar/models/wallet_info.dart';
30+
import '../../wallets/isar/providers/all_wallets_info_provider.dart';
3131
import '../../wallets/isar/providers/wallet_info_provider.dart';
3232
import '../../wallets/wallet/wallet.dart';
3333
import '../../widgets/background.dart';
@@ -73,13 +73,14 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
7373

7474
List<WalletListItemData> _filter(String searchTerm) {
7575
// clean out deleted wallets
76-
final existingWalletIds = ref
77-
.read(mainDBProvider)
78-
.isar
79-
.walletInfo
80-
.where()
81-
.walletIdProperty()
82-
.findAllSync();
76+
final existingWalletIds =
77+
ref
78+
.read(mainDBProvider)
79+
.isar
80+
.walletInfo
81+
.where()
82+
.walletIdProperty()
83+
.findAllSync();
8384
wallets.removeWhere((k, v) => !existingWalletIds.contains(k));
8485

8586
if (searchTerm.isEmpty) {
@@ -127,25 +128,22 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
127128
}
128129

129130
void updateWallets() {
130-
final walletsData =
131-
ref.read(mainDBProvider).isar.walletInfo.where().findAllSync();
131+
final walletsData = ref.read(pAllWalletsInfo);
132+
132133
walletsData.removeWhere((e) => e.coin != widget.coin);
133134

134135
if (widget.coin is Ethereum) {
135136
for (final data in walletsData) {
136137
final List<EthContract> contracts = [];
137-
final contractAddresses =
138-
ref.read(pWalletTokenAddresses(data.walletId));
138+
final contractAddresses = ref.read(
139+
pWalletTokenAddresses(data.walletId),
140+
);
139141

140142
// fetch each contract
141143
for (final contractAddress in contractAddresses) {
142144
final contract = ref
143-
.read(
144-
mainDBProvider,
145-
)
146-
.getEthContractSync(
147-
contractAddress,
148-
);
145+
.read(mainDBProvider)
146+
.getEthContractSync(contractAddress);
149147

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

156154
// add tuple to list
157155
wallets[data.walletId] = (
158-
wallet: ref.read(pWallets).getWallet(
159-
data.walletId,
160-
),
156+
wallet: ref.read(pWallets).getWallet(data.walletId),
161157
contracts: contracts,
162158
);
163159
}
@@ -167,9 +163,7 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
167163
// desktop single coin apps may cause issues so lets just ignore the error and move on
168164
try {
169165
wallets[data.walletId] = (
170-
wallet: ref.read(pWallets).getWallet(
171-
data.walletId,
172-
),
166+
wallet: ref.read(pWallets).getWallet(data.walletId),
173167
contracts: [],
174168
);
175169
} catch (_) {
@@ -211,46 +205,45 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
211205
Widget build(BuildContext context) {
212206
return ConditionalParent(
213207
condition: !isDesktop && !AppConfig.isSingleCoinApp,
214-
builder: (child) => Background(
215-
child: Scaffold(
216-
backgroundColor:
217-
Theme.of(context).extension<StackColors>()!.background,
218-
appBar: AppBar(
219-
leading: const AppBarBackButton(),
220-
title: Text(
221-
"${widget.coin.prettyName} (${widget.coin.ticker}) wallets",
222-
style: STextStyles.navBarTitle(context),
223-
),
224-
actions: [
225-
AspectRatio(
226-
aspectRatio: 1,
227-
child: AppBarIconButton(
228-
icon: SvgPicture.asset(
229-
Assets.svg.plus,
230-
width: 18,
231-
height: 18,
232-
color: Theme.of(context)
233-
.extension<StackColors>()!
234-
.topNavIconPrimary,
235-
),
236-
onPressed: () {
237-
Navigator.of(context).pushNamed(
238-
CreateOrRestoreWalletView.routeName,
239-
arguments: CoinEntity(widget.coin),
240-
);
241-
},
208+
builder:
209+
(child) => Background(
210+
child: Scaffold(
211+
backgroundColor:
212+
Theme.of(context).extension<StackColors>()!.background,
213+
appBar: AppBar(
214+
leading: const AppBarBackButton(),
215+
title: Text(
216+
"${widget.coin.prettyName} (${widget.coin.ticker}) wallets",
217+
style: STextStyles.navBarTitle(context),
242218
),
219+
actions: [
220+
AspectRatio(
221+
aspectRatio: 1,
222+
child: AppBarIconButton(
223+
icon: SvgPicture.asset(
224+
Assets.svg.plus,
225+
width: 18,
226+
height: 18,
227+
color:
228+
Theme.of(
229+
context,
230+
).extension<StackColors>()!.topNavIconPrimary,
231+
),
232+
onPressed: () {
233+
Navigator.of(context).pushNamed(
234+
CreateOrRestoreWalletView.routeName,
235+
arguments: CoinEntity(widget.coin),
236+
);
237+
},
238+
),
239+
),
240+
],
241+
),
242+
body: SafeArea(
243+
child: Padding(padding: const EdgeInsets.all(16), child: child),
243244
),
244-
],
245-
),
246-
body: SafeArea(
247-
child: Padding(
248-
padding: const EdgeInsets.all(16),
249-
child: child,
250245
),
251246
),
252-
),
253-
),
254247
child: Column(
255248
children: [
256249
ClipRRect(
@@ -267,14 +260,16 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
267260
_searchString = value;
268261
});
269262
},
270-
style: isDesktop
271-
? STextStyles.desktopTextExtraSmall(context).copyWith(
272-
color: Theme.of(context)
273-
.extension<StackColors>()!
274-
.textFieldActiveText,
275-
height: 1.8,
276-
)
277-
: STextStyles.field(context),
263+
style:
264+
isDesktop
265+
? STextStyles.desktopTextExtraSmall(context).copyWith(
266+
color:
267+
Theme.of(
268+
context,
269+
).extension<StackColors>()!.textFieldActiveText,
270+
height: 1.8,
271+
)
272+
: STextStyles.field(context),
278273
decoration: standardInputDecoration(
279274
"Search...",
280275
searchFieldFocusNode,
@@ -292,32 +287,31 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
292287
height: isDesktop ? 20 : 16,
293288
),
294289
),
295-
suffixIcon: _searchController.text.isNotEmpty
296-
? Padding(
297-
padding: const EdgeInsets.only(right: 0),
298-
child: UnconstrainedBox(
299-
child: Row(
300-
children: [
301-
TextFieldIconButton(
302-
child: const XIcon(),
303-
onTap: () async {
304-
setState(() {
305-
_searchController.text = "";
306-
_searchString = "";
307-
});
308-
},
309-
),
310-
],
290+
suffixIcon:
291+
_searchController.text.isNotEmpty
292+
? Padding(
293+
padding: const EdgeInsets.only(right: 0),
294+
child: UnconstrainedBox(
295+
child: Row(
296+
children: [
297+
TextFieldIconButton(
298+
child: const XIcon(),
299+
onTap: () async {
300+
setState(() {
301+
_searchController.text = "";
302+
_searchString = "";
303+
});
304+
},
305+
),
306+
],
307+
),
311308
),
312-
),
313-
)
314-
: null,
309+
)
310+
: null,
315311
),
316312
),
317313
),
318-
const SizedBox(
319-
height: 16,
320-
),
314+
const SizedBox(height: 16),
321315
Expanded(
322316
child: Builder(
323317
builder: (context) {
@@ -346,33 +340,34 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
346340
return ConditionalParent(
347341
key: Key(wallet.walletId),
348342
condition: isDesktop,
349-
builder: (child) => RoundedWhiteContainer(
350-
padding: const EdgeInsets.symmetric(
351-
vertical: 14,
352-
horizontal: 20,
353-
),
354-
borderColor: Theme.of(context)
355-
.extension<StackColors>()!
356-
.backgroundAppBar,
357-
child: child,
358-
),
343+
builder:
344+
(child) => RoundedWhiteContainer(
345+
padding: const EdgeInsets.symmetric(
346+
vertical: 14,
347+
horizontal: 20,
348+
),
349+
borderColor:
350+
Theme.of(
351+
context,
352+
).extension<StackColors>()!.backgroundAppBar,
353+
child: child,
354+
),
359355
child: SimpleWalletCard(
360356
walletId: wallet.walletId,
361-
popPrevious: widget
362-
.overrideSimpleWalletCardPopPreviousValueWith ==
363-
null
364-
? isDesktop
365-
: widget
366-
.overrideSimpleWalletCardPopPreviousValueWith!,
357+
popPrevious:
358+
widget.overrideSimpleWalletCardPopPreviousValueWith ==
359+
null
360+
? isDesktop
361+
: widget
362+
.overrideSimpleWalletCardPopPreviousValueWith!,
367363
desktopNavigatorState:
368364
isDesktop ? widget.navigatorState : null,
369365
),
370366
);
371367
}
372368
},
373-
separatorBuilder: (_, __) => SizedBox(
374-
height: isDesktop ? 10 : 8,
375-
),
369+
separatorBuilder:
370+
(_, __) => SizedBox(height: isDesktop ? 10 : 8),
376371
itemCount: data.length,
377372
);
378373
},
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import 'package:flutter/widgets.dart';
2+
import 'package:flutter_riverpod/flutter_riverpod.dart';
3+
4+
final pNavKey = Provider((_) => GlobalKey<NavigatorState>());

0 commit comments

Comments
 (0)