💄 Optimized notification snack bar
This commit is contained in:
@ -12,7 +12,6 @@ import 'package:island/pods/userinfo.dart';
|
||||
import 'package:island/pods/websocket.dart';
|
||||
import 'package:island/route.dart';
|
||||
import 'package:island/services/responsive.dart';
|
||||
import 'package:island/widgets/app_notification.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
@ -26,24 +25,31 @@ class WindowScaffold extends HookConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// Add window resize listener for desktop platforms
|
||||
useEffect(() {
|
||||
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
if (!kIsWeb &&
|
||||
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
void saveWindowSize() {
|
||||
final size = appWindow.size;
|
||||
final settingsNotifier = ref.read(appSettingsNotifierProvider.notifier);
|
||||
final settingsNotifier = ref.read(
|
||||
appSettingsNotifierProvider.notifier,
|
||||
);
|
||||
settingsNotifier.setWindowSize(size);
|
||||
}
|
||||
|
||||
|
||||
// Save window size when app is about to close
|
||||
WidgetsBinding.instance.addObserver(_WindowSizeObserver(saveWindowSize));
|
||||
|
||||
WidgetsBinding.instance.addObserver(
|
||||
_WindowSizeObserver(saveWindowSize),
|
||||
);
|
||||
|
||||
return () {
|
||||
// Cleanup observer when widget is disposed
|
||||
WidgetsBinding.instance.removeObserver(_WindowSizeObserver(saveWindowSize));
|
||||
WidgetsBinding.instance.removeObserver(
|
||||
_WindowSizeObserver(saveWindowSize),
|
||||
);
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}, []);
|
||||
|
||||
|
||||
if (!kIsWeb &&
|
||||
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
@ -106,7 +112,6 @@ class WindowScaffold extends HookConsumerWidget {
|
||||
],
|
||||
),
|
||||
_WebSocketIndicator(),
|
||||
AppNotificationToast(),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -114,39 +119,37 @@ class WindowScaffold extends HookConsumerWidget {
|
||||
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned.fill(child: child),
|
||||
_WebSocketIndicator(),
|
||||
AppNotificationToast(),
|
||||
],
|
||||
children: [Positioned.fill(child: child), _WebSocketIndicator()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _WindowSizeObserver extends WidgetsBindingObserver {
|
||||
final VoidCallback onSaveWindowSize;
|
||||
|
||||
|
||||
_WindowSizeObserver(this.onSaveWindowSize);
|
||||
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
super.didChangeAppLifecycleState(state);
|
||||
|
||||
|
||||
// Save window size when app is paused, detached, or hidden
|
||||
if (state == AppLifecycleState.paused ||
|
||||
if (state == AppLifecycleState.paused ||
|
||||
state == AppLifecycleState.detached ||
|
||||
state == AppLifecycleState.hidden) {
|
||||
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
if (!kIsWeb &&
|
||||
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
onSaveWindowSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is _WindowSizeObserver && other.onSaveWindowSize == onSaveWindowSize;
|
||||
return other is _WindowSizeObserver &&
|
||||
other.onSaveWindowSize == onSaveWindowSize;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => onSaveWindowSize.hashCode;
|
||||
}
|
||||
|
Reference in New Issue
Block a user