wrap swb open from file in platform check

This commit is contained in:
julian 2022-09-05 17:31:24 -06:00
parent 825356179a
commit c366e4a9c5

View file

@ -344,11 +344,13 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
_prefs = ref.read(prefsChangeNotifierProvider);
_wallets = ref.read(walletsChangeNotifierProvider);
if (Platform.isAndroid) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
// fetch open file if it exists
await getOpenFile();
if (ref.read(openedFromSWBFileStringStateProvider.state).state != null) {
if (ref.read(openedFromSWBFileStringStateProvider.state).state !=
null) {
// waiting for loading to complete before going straight to restore if the app was opened via file
await loadingCompleter.future;
@ -358,6 +360,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
}
// ref.read(shouldShowLockscreenOnResumeStateProvider.state).state = false;
});
}
super.initState();
}
@ -378,6 +381,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
case AppLifecycleState.paused:
break;
case AppLifecycleState.resumed:
if (Platform.isAndroid) {
// fetch open file if it exists
await getOpenFile();
// go straight to restore if the app was resumed via file
@ -387,6 +391,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
ref.read(openedFromSWBFileStringStateProvider.state).state!);
ref.read(openedFromSWBFileStringStateProvider.state).state = null;
}
}
// if (ref.read(hasAuthenticatedOnStartStateProvider.state).state &&
// ref.read(shouldShowLockscreenOnResumeStateProvider.state).state) {
// final now = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000;
@ -419,6 +424,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
}
}
/// should only be called on android currently
Future<void> getOpenFile() async {
// update provider with new file content state
ref.read(openedFromSWBFileStringStateProvider.state).state =
@ -432,6 +438,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
level: LogLevel.Info);
}
/// should only be called on android currently
Future<void> resetOpenPath() async {
await platform.invokeMethod("resetOpenPath");
}