mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: auto switch status bar
This commit is contained in:
@@ -11,7 +11,6 @@ import '../../data/model/server/snippet.dart';
|
||||
import '../../data/provider/snippet.dart';
|
||||
import '../../locator.dart';
|
||||
import '../../view/page/snippet/edit.dart';
|
||||
import '../../view/widget/card_dialog.dart';
|
||||
import '../../view/widget/picker.dart';
|
||||
import '../persistant_store.dart';
|
||||
import '../route.dart';
|
||||
@@ -54,18 +53,16 @@ Future<T?> showRoundDialog<T>({
|
||||
Widget? child,
|
||||
List<Widget>? actions,
|
||||
Widget? title,
|
||||
EdgeInsets? padding,
|
||||
bool barrierDismiss = true,
|
||||
}) async {
|
||||
return await showDialog<T>(
|
||||
context: context,
|
||||
barrierDismissible: barrierDismiss,
|
||||
builder: (_) {
|
||||
return CardDialog(
|
||||
return AlertDialog(
|
||||
title: title,
|
||||
content: child,
|
||||
actions: actions,
|
||||
padding: padding,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -168,7 +165,12 @@ void showSnippetDialog(
|
||||
);
|
||||
}
|
||||
|
||||
void hideStatusBar() {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,
|
||||
void switchStatusBar({required bool hide}) {
|
||||
if (hide) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,
|
||||
overlays: []);
|
||||
} else {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge,
|
||||
overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class _FullScreenPageState extends State<FullScreenPage> with AfterLayoutMixin {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
hideStatusBar();
|
||||
switchStatusBar(hide: true);
|
||||
_timer = Timer.periodic(const Duration(minutes: 1), (_) {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
|
||||
@@ -50,6 +50,7 @@ class _HomePageState extends State<HomePage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
switchStatusBar(hide: false);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_selectIndex.value = _setting.launchPage.fetch()!;
|
||||
// avoid index out of range
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CardDialog extends StatelessWidget {
|
||||
const CardDialog(
|
||||
{Key? key, this.title, this.content, this.actions, this.padding})
|
||||
: super(key: key);
|
||||
|
||||
final Widget? content;
|
||||
final List<Widget>? actions;
|
||||
final Widget? title;
|
||||
final EdgeInsets? padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: padding,
|
||||
actionsPadding: const EdgeInsets.all(7),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0)),
|
||||
),
|
||||
title: title,
|
||||
content: content,
|
||||
actions: actions,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user