mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
feat: general wake lock (#347)
This commit is contained in:
@@ -33,6 +33,7 @@ import 'package:toolbox/view/widget/appbar.dart';
|
||||
import 'package:toolbox/view/widget/cardx.dart';
|
||||
import 'package:toolbox/view/widget/markdown.dart';
|
||||
import 'package:toolbox/view/widget/val_builder.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
|
||||
part 'appbar.dart';
|
||||
|
||||
@@ -68,6 +69,9 @@ class _HomePageState extends State<HomePage>
|
||||
_selectIndex.value = 0;
|
||||
}
|
||||
_pageController = PageController(initialPage: _selectIndex.value);
|
||||
if (Stores.setting.generalWakeLock.fetch()) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -82,6 +86,7 @@ class _HomePageState extends State<HomePage>
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
Pros.server.closeServer();
|
||||
_pageController.dispose();
|
||||
WakelockPlus.disable();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -176,7 +176,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Widget _buildSSH() {
|
||||
return Column(
|
||||
children: [
|
||||
_buildWakeLock(),
|
||||
_buildSSHWakeLock(),
|
||||
_buildTermTheme(),
|
||||
_buildFont(),
|
||||
_buildTermFontSize(),
|
||||
@@ -1076,6 +1076,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
leading: const Icon(MingCute.more_3_fill),
|
||||
title: Text(l10n.more),
|
||||
children: [
|
||||
_buildWakeLock(),
|
||||
if (isAndroid || isIOS) _buildCollectUsage(),
|
||||
_buildCollapseUI(),
|
||||
_buildCupertinoRoute(),
|
||||
@@ -1136,7 +1137,15 @@ class _SettingPageState extends State<SettingPage> {
|
||||
return ListTile(
|
||||
leading: const Icon(MingCute.lock_fill),
|
||||
title: Text(l10n.wakeLock),
|
||||
trailing: StoreSwitch(prop: _setting.wakeLock),
|
||||
trailing: StoreSwitch(prop: _setting.generalWakeLock),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSSHWakeLock() {
|
||||
return ListTile(
|
||||
leading: const Icon(MingCute.lock_fill),
|
||||
title: Text(l10n.wakeLock),
|
||||
trailing: StoreSwitch(prop: _setting.sshWakeLock),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
_showHelp();
|
||||
await _initTerminal();
|
||||
|
||||
if (Stores.setting.wakeLock.fetch()) WakelockPlus.enable();
|
||||
if (Stores.setting.sshWakeLock.fetch()) WakelockPlus.enable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
_virtKeyLongPressTimer?.cancel();
|
||||
_terminalController.dispose();
|
||||
_discontinuityTimer?.cancel();
|
||||
WakelockPlus.disable();
|
||||
if (!Stores.setting.generalWakeLock.fetch()) WakelockPlus.disable();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user