|
|
@ -44,7 +44,6 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
final _appRegex = RegExp(r'^app_([a-z]+)$', multiLine: true); |
|
|
|
final _appRegex = RegExp(r'^app_([a-z]+)$', multiLine: true); |
|
|
|
final _navigatorKey = GlobalKey<NavigatorState>(); |
|
|
|
final _navigatorKey = GlobalKey<NavigatorState>(); |
|
|
|
late final Iterable<AppImplementation> _appImplementations; |
|
|
|
late final Iterable<AppImplementation> _appImplementations; |
|
|
|
late final NeonPlatform _platform; |
|
|
|
|
|
|
|
late final GlobalOptions _globalOptions; |
|
|
|
late final GlobalOptions _globalOptions; |
|
|
|
late final AccountsBloc _accountsBloc; |
|
|
|
late final AccountsBloc _accountsBloc; |
|
|
|
late final _routerDelegate = AppRouter( |
|
|
|
late final _routerDelegate = AppRouter( |
|
|
@ -59,15 +58,14 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
super.initState(); |
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
|
|
_appImplementations = Provider.of<Iterable<AppImplementation>>(context, listen: false); |
|
|
|
_appImplementations = Provider.of<Iterable<AppImplementation>>(context, listen: false); |
|
|
|
_platform = Provider.of<NeonPlatform>(context, listen: false); |
|
|
|
|
|
|
|
_globalOptions = Provider.of<GlobalOptions>(context, listen: false); |
|
|
|
_globalOptions = Provider.of<GlobalOptions>(context, listen: false); |
|
|
|
_accountsBloc = Provider.of<AccountsBloc>(context, listen: false); |
|
|
|
_accountsBloc = Provider.of<AccountsBloc>(context, listen: false); |
|
|
|
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
if (_platform.canUseSystemTray) { |
|
|
|
if (NeonPlatform.instance.canUseSystemTray) { |
|
|
|
tray.trayManager.addListener(this); |
|
|
|
tray.trayManager.addListener(this); |
|
|
|
} |
|
|
|
} |
|
|
|
if (_platform.canUseWindowManager) { |
|
|
|
if (NeonPlatform.instance.canUseWindowManager) { |
|
|
|
windowManager.addListener(this); |
|
|
|
windowManager.addListener(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -77,7 +75,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
if (!mounted) { |
|
|
|
if (!mounted) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (_platform.canUseQuickActions) { |
|
|
|
if (NeonPlatform.instance.canUseQuickActions) { |
|
|
|
const quickActions = QuickActions(); |
|
|
|
const quickActions = QuickActions(); |
|
|
|
await quickActions.setShortcutItems( |
|
|
|
await quickActions.setShortcutItems( |
|
|
|
_appImplementations |
|
|
|
_appImplementations |
|
|
@ -93,7 +91,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
await quickActions.initialize(_handleShortcut); |
|
|
|
await quickActions.initialize(_handleShortcut); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_platform.canUseWindowManager) { |
|
|
|
if (NeonPlatform.instance.canUseWindowManager) { |
|
|
|
await windowManager.setPreventClose(true); |
|
|
|
await windowManager.setPreventClose(true); |
|
|
|
|
|
|
|
|
|
|
|
if (_globalOptions.startupMinimized.value) { |
|
|
|
if (_globalOptions.startupMinimized.value) { |
|
|
@ -101,7 +99,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_platform.canUseSystemTray) { |
|
|
|
if (NeonPlatform.instance.canUseSystemTray) { |
|
|
|
_globalOptions.systemTrayEnabled.addListener(() async { |
|
|
|
_globalOptions.systemTrayEnabled.addListener(() async { |
|
|
|
if (_globalOptions.systemTrayEnabled.value) { |
|
|
|
if (_globalOptions.systemTrayEnabled.value) { |
|
|
|
// TODO: This works on Linux, but maybe not on macOS or Windows |
|
|
|
// TODO: This works on Linux, but maybe not on macOS or Windows |
|
|
@ -136,7 +134,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_platform.canUsePushNotifications) { |
|
|
|
if (NeonPlatform.instance.canUsePushNotifications) { |
|
|
|
final localNotificationsPlugin = await PushUtils.initLocalNotifications(); |
|
|
|
final localNotificationsPlugin = await PushUtils.initLocalNotifications(); |
|
|
|
Global.onPushNotificationReceived = (final accountID) async { |
|
|
|
Global.onPushNotificationReceived = (final accountID) async { |
|
|
|
final account = _accountsBloc.accounts.value.tryFind(accountID); |
|
|
|
final account = _accountsBloc.accounts.value.tryFind(accountID); |
|
|
@ -213,7 +211,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
|
|
|
|
|
|
|
|
Future _handleShortcut(final String shortcutType) async { |
|
|
|
Future _handleShortcut(final String shortcutType) async { |
|
|
|
if (shortcutType == 'show_hide') { |
|
|
|
if (shortcutType == 'show_hide') { |
|
|
|
if (_platform.canUseWindowManager) { |
|
|
|
if (NeonPlatform.instance.canUseWindowManager) { |
|
|
|
if (await windowManager.isVisible()) { |
|
|
|
if (await windowManager.isVisible()) { |
|
|
|
await _saveAndMinimizeWindow(); |
|
|
|
await _saveAndMinimizeWindow(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -249,7 +247,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Future _showAndRestoreWindow() async { |
|
|
|
Future _showAndRestoreWindow() async { |
|
|
|
if (!_platform.canUseWindowManager) { |
|
|
|
if (!NeonPlatform.instance.canUseWindowManager) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -264,10 +262,10 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra |
|
|
|
@override |
|
|
|
@override |
|
|
|
void dispose() { |
|
|
|
void dispose() { |
|
|
|
WidgetsBinding.instance.removeObserver(this); |
|
|
|
WidgetsBinding.instance.removeObserver(this); |
|
|
|
if (_platform.canUseSystemTray) { |
|
|
|
if (NeonPlatform.instance.canUseSystemTray) { |
|
|
|
tray.trayManager.removeListener(this); |
|
|
|
tray.trayManager.removeListener(this); |
|
|
|
} |
|
|
|
} |
|
|
|
if (_platform.canUseWindowManager) { |
|
|
|
if (NeonPlatform.instance.canUseWindowManager) { |
|
|
|
windowManager.removeListener(this); |
|
|
|
windowManager.removeListener(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|