2024-09-02 13:20:30 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2024-08-29 17:56:21 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-09-02 13:20:30 +00:00
|
|
|
import 'package:get/get.dart';
|
2024-08-29 17:56:21 +00:00
|
|
|
import 'package:rhythm_box/platform.dart';
|
2024-09-02 13:20:30 +00:00
|
|
|
import 'package:rhythm_box/providers/error_notifier.dart';
|
2024-08-30 11:53:53 +00:00
|
|
|
import 'package:window_manager/window_manager.dart';
|
2024-08-29 17:56:21 +00:00
|
|
|
|
2024-09-02 13:20:30 +00:00
|
|
|
class SystemShell extends StatefulWidget {
|
2024-08-29 17:56:21 +00:00
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
const SystemShell({super.key, required this.child});
|
|
|
|
|
2024-09-02 13:20:30 +00:00
|
|
|
@override
|
|
|
|
State<SystemShell> createState() => _SystemShellState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SystemShellState extends State<SystemShell> {
|
|
|
|
late final ErrorNotifier _errorNotifier = Get.find();
|
|
|
|
|
|
|
|
StreamSubscription? _subscription;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_subscription = _errorNotifier.showing.listen((value) {
|
|
|
|
if (value == null) {
|
|
|
|
ScaffoldMessenger.of(context).clearMaterialBanners();
|
|
|
|
} else {
|
|
|
|
ScaffoldMessenger.of(context).showMaterialBanner(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_subscription?.cancel();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2024-08-29 17:56:21 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-08-30 13:53:40 +00:00
|
|
|
if (PlatformInfo.isMacOS) {
|
2024-08-30 11:53:53 +00:00
|
|
|
return DragToMoveArea(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
height: 28,
|
|
|
|
color: Theme.of(context).colorScheme.surface,
|
|
|
|
),
|
|
|
|
const Divider(
|
|
|
|
thickness: 0.3,
|
|
|
|
height: 0.3,
|
|
|
|
),
|
2024-09-02 13:20:30 +00:00
|
|
|
Expanded(child: widget.child),
|
2024-08-30 11:53:53 +00:00
|
|
|
],
|
|
|
|
),
|
2024-08-29 17:56:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-09-02 13:20:30 +00:00
|
|
|
return widget.child;
|
2024-08-29 17:56:21 +00:00
|
|
|
}
|
|
|
|
}
|