Skip to content
Open
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
7 changes: 6 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import 'utilities/desktop_startup_and_reset.dart';
import 'utilities/enums/backup_frequency_type.dart';
import 'utilities/flutter_secure_storage_interface.dart';
import 'utilities/logger.dart';
import 'utilities/native_library_check.dart';
import 'utilities/prefs.dart';
import 'utilities/stack_file_system.dart';
import 'utilities/util.dart';
Expand Down Expand Up @@ -100,7 +101,7 @@ void main(List<String> args) async {
StackFileSystem.setDesktopOverrideDir(args.last);
}

final loadCoinlibFuture = loadCoinlib();
final loadCoinlibFuture = loadCoinlibOrRecordFailure(loadCoinlib);

GoogleFonts.config.allowRuntimeFetching = false;
if (Platform.isIOS) {
Expand Down Expand Up @@ -303,6 +304,10 @@ void main(List<String> args) async {

await loadCoinlibFuture;

// Before any wallet loads, so a quarantined library is reported once on
// the home screen instead of surfacing as wallets that fail to open.
checkNativeLibrariesOnStartup();

await MainDB.instance.initMainDB();
ThemeService.instance.init(MainDB.instance);

Expand Down
125 changes: 63 additions & 62 deletions lib/pages/home_view/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import '../../widgets/animated_widgets/rotate_icon.dart';
import '../../widgets/app_icon.dart';
import '../../widgets/background.dart';
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
import '../../widgets/onetime_popups/native_library_warning_dialog.dart';
import '../../widgets/small_tor_icon.dart';
import '../../widgets/stack_dialog.dart';
import '../buy_view/buy_view.dart';
Expand Down Expand Up @@ -243,6 +244,10 @@ class _HomeViewState extends ConsumerState<HomeView> {
// showOneTimeTorHasBeenAddedDialogIfRequired(context);
// });

WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(showNativeLibraryWarningIfRequired(context));
});

_idleMonitor?.attach();

ref.read(prefsChangeNotifierProvider).addListener(_prefsTimeoutListener);
Expand Down Expand Up @@ -306,9 +311,9 @@ class _HomeViewState extends ConsumerState<HomeView> {
key: _key,
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Theme.of(
context,
).extension<StackColors>()!.backgroundAppBar,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
title: Row(
children: [
GestureDetector(
Expand Down Expand Up @@ -343,11 +348,10 @@ class _HomeViewState extends ConsumerState<HomeView> {
key: const Key("walletsViewAlertsButton"),
size: 36,
shadows: const [],
color: Theme.of(
context,
).extension<StackColors>()!.backgroundAppBar,
icon:
ref.watch(pAnyGlobalUnreadNotifications)
color: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
icon: ref.watch(pAnyGlobalUnreadNotifications)
? SvgPicture.file(
File(
ref.watch(
Expand All @@ -358,60 +362,58 @@ class _HomeViewState extends ConsumerState<HomeView> {
),
width: 20,
height: 20,
color:
ref.watch(pAnyGlobalUnreadNotifications)
color: ref.watch(pAnyGlobalUnreadNotifications)
? null
: Theme.of(
context,
).extension<StackColors>()!.topNavIconPrimary,
: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
)
: SvgPicture.asset(
Assets.svg.bell,
width: 20,
height: 20,
color:
ref.watch(pAnyGlobalUnreadNotifications)
color: ref.watch(pAnyGlobalUnreadNotifications)
? null
: Theme.of(
context,
).extension<StackColors>()!.topNavIconPrimary,
: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
),
onPressed: () {
// reset unread state
ref.refresh(unreadNotificationsStateProvider);

Navigator.of(
context,
).pushNamed(NotificationsView.routeName).then((_) {
final Set<int> unreadNotificationIds = ref
.read(unreadNotificationsStateProvider.state)
.state;
if (unreadNotificationIds.isEmpty) return;

final List<Future<void>> futures = [];
for (
int i = 0;
i < unreadNotificationIds.length - 1;
i++
) {
futures.add(
ref
.read(notificationsProvider)
.markAsRead(
unreadNotificationIds.elementAt(i),
false,
),
);
}

// wait for multiple to update if any
Future.wait(futures).then((_) {
// only notify listeners once
ref
.read(notificationsProvider)
.markAsRead(unreadNotificationIds.last, true);
});
});
Navigator.of(context)
.pushNamed(NotificationsView.routeName)
.then((_) {
final Set<int> unreadNotificationIds = ref
.read(unreadNotificationsStateProvider.state)
.state;
if (unreadNotificationIds.isEmpty) return;

final List<Future<void>> futures = [];
for (
int i = 0;
i < unreadNotificationIds.length - 1;
i++
) {
futures.add(
ref
.read(notificationsProvider)
.markAsRead(
unreadNotificationIds.elementAt(i),
false,
),
);
}

// wait for multiple to update if any
Future.wait(futures).then((_) {
// only notify listeners once
ref
.read(notificationsProvider)
.markAsRead(unreadNotificationIds.last, true);
});
});
},
),
),
Expand All @@ -425,23 +427,22 @@ class _HomeViewState extends ConsumerState<HomeView> {
key: const Key("walletsViewSettingsButton"),
size: 36,
shadows: const [],
color: Theme.of(
context,
).extension<StackColors>()!.backgroundAppBar,
color: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
icon: SvgPicture.asset(
Assets.svg.gear,
color: Theme.of(
context,
).extension<StackColors>()!.topNavIconPrimary,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
width: 20,
height: 20,
),
onPressed: () {
//todo: check if print needed
// debugPrint("main view settings tapped");
Navigator.of(
context,
).pushNamed(GlobalSettingsView.routeName);
Navigator.of(context)
.pushNamed(GlobalSettingsView.routeName);
},
),
),
Expand All @@ -455,9 +456,9 @@ class _HomeViewState extends ConsumerState<HomeView> {
ref.watch(prefsChangeNotifierProvider).enableExchange)
Container(
decoration: BoxDecoration(
color: Theme.of(
context,
).extension<StackColors>()!.backgroundAppBar,
color: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
boxShadow:
Theme.of(context)
.extension<StackColors>()!
Expand Down
10 changes: 7 additions & 3 deletions lib/pages_desktop_specific/desktop_home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import '../utilities/enums/backup_frequency_type.dart';
import '../utilities/idle_monitor.dart';
import '../utilities/prefs.dart';
import '../widgets/background.dart';
import '../widgets/onetime_popups/native_library_warning_dialog.dart';
import 'address_book_view/desktop_address_book.dart';
import 'desktop_buy/desktop_buy_view.dart';
import 'desktop_exchange/desktop_exchange_view.dart';
Expand Down Expand Up @@ -108,6 +109,10 @@ class _DesktopHomeViewState extends ConsumerState<DesktopHomeView> {
// showOneTimeTorHasBeenAddedDialogIfRequired(context);
// });

WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(showNativeLibraryWarningIfRequired(context));
});

super.initState();
}

Expand Down Expand Up @@ -171,9 +176,8 @@ class _DesktopHomeViewState extends ConsumerState<DesktopHomeView> {
if (ref.read(prevDesktopMenuItemProvider.state).state ==
DesktopMenuItemId.myStack &&
ref.read(prevDesktopMenuItemProvider.state).state == newKey) {
Navigator.of(
myStackViewNavKey.currentContext!,
).popUntil(ModalRoute.withName(MyStackView.routeName));
Navigator.of(myStackViewNavKey.currentContext!)
.popUntil(ModalRoute.withName(MyStackView.routeName));
if (ref.read(currentWalletIdProvider.state).state != null) {
final wallet = ref
.read(pWallets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import '../../widgets/desktop/desktop_dialog.dart';
import '../../widgets/desktop/desktop_scaffold.dart';
import '../../widgets/desktop/primary_button.dart';
import '../../widgets/loading_indicator.dart';
import '../../widgets/onetime_popups/native_library_warning_dialog.dart';
import '../../widgets/stack_text_field.dart';
import 'create_password_view.dart';

Expand Down Expand Up @@ -95,9 +96,9 @@ class _ForgottenPassphraseRestoreFromSWBState
child: Text(
"Decrypting ${AppConfig.prefix} backup file",
style: STextStyles.pageTitleH2(context).copyWith(
color: Theme.of(
context,
).extension<StackColors>()!.textWhite,
color: Theme.of(context)
.extension<StackColors>()!
.textWhite,
),
),
),
Expand Down Expand Up @@ -188,6 +189,13 @@ class _ForgottenPassphraseRestoreFromSWBState

passwordFocusNode = FocusNode();

// On a fresh install this screen comes before any home view, and a
// restore with a library missing would fail its cryptonote wallets
// with no explanation.
WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(showNativeLibraryWarningIfRequired(context));
});

super.initState();
}

Expand All @@ -214,9 +222,8 @@ class _ForgottenPassphraseRestoreFromSWBState
ref.refresh(storageCryptoHandlerProvider);
await DB.instance.init();
if (mounted) {
Navigator.of(
context,
).popUntil(ModalRoute.withName(CreatePasswordView.routeName));
Navigator.of(context)
.popUntil(ModalRoute.withName(CreatePasswordView.routeName));
Navigator.of(context).pop();
}
},
Expand All @@ -241,9 +248,9 @@ class _ForgottenPassphraseRestoreFromSWBState
"Use your ${AppConfig.prefix} backup file to restore your wallets, address book, and wallet preferences.",
textAlign: TextAlign.center,
style: STextStyles.desktopTextSmall(context).copyWith(
color: Theme.of(
context,
).extension<StackColors>()!.textSubtitle1,
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
),
),
const SizedBox(height: 40),
Expand Down Expand Up @@ -283,9 +290,9 @@ class _ForgottenPassphraseRestoreFromSWBState
const SizedBox(width: 24),
SvgPicture.asset(
Assets.svg.folder,
color: Theme.of(
context,
).extension<StackColors>()!.textDark3,
color: Theme.of(context)
.extension<StackColors>()!
.textDark3,
width: 24,
height: 24,
),
Expand Down Expand Up @@ -323,9 +330,8 @@ class _ForgottenPassphraseRestoreFromSWBState
key: const Key("restoreFromFilePasswordFieldKey"),
focusNode: passwordFocusNode,
controller: passwordController,
style: STextStyles.desktopTextMedium(
context,
).copyWith(height: 2),
style: STextStyles.desktopTextMedium(context)
.copyWith(height: 2),
obscureText: hidePassword,
enableSuggestions: false,
autocorrect: false,
Expand Down Expand Up @@ -356,9 +362,9 @@ class _ForgottenPassphraseRestoreFromSWBState
hidePassword
? Assets.svg.eye
: Assets.svg.eyeSlash,
color: Theme.of(
context,
).extension<StackColors>()!.textDark3,
color: Theme.of(context)
.extension<StackColors>()!
.textDark3,
width: 24,
height: 24,
),
Expand Down
Loading
Loading