diff --git a/lib/core/chan.dart b/lib/core/chan.dart index 16f09ab1..1a424079 100644 --- a/lib/core/chan.dart +++ b/lib/core/chan.dart @@ -1,6 +1,5 @@ import 'package:flutter/services.dart'; import 'package:server_box/data/res/misc.dart'; -import 'package:server_box/data/res/store.dart'; abstract final class MethodChans { static const _channel = MethodChannel('${Miscs.pkgName}/main_chan'); @@ -9,14 +8,16 @@ abstract final class MethodChans { _channel.invokeMethod('sendToBackground'); } + /// Issue #662 static void startService() { - if (Stores.setting.fgService.fetch() != true) return; - _channel.invokeMethod('startService'); + // if (Stores.setting.fgService.fetch() != true) return; + // _channel.invokeMethod('startService'); } + /// Issue #662 static void stopService() { - if (Stores.setting.fgService.fetch() != true) return; - _channel.invokeMethod('stopService'); + // if (Stores.setting.fgService.fetch() != true) return; + // _channel.invokeMethod('stopService'); } static void updateHomeWidget() async { diff --git a/lib/view/page/editor.dart b/lib/view/page/editor.dart index 924de024..be6b7be9 100644 --- a/lib/view/page/editor.dart +++ b/lib/view/page/editor.dart @@ -80,36 +80,7 @@ class _EditorPageState extends State { @override void initState() { super.initState(); - - /// Higher priority than [path] - if (Stores.setting.editorHighlight.fetch()) { - _langCode = - widget.args?.langCode ?? Highlights.getCode(widget.args?.path); - } - _controller = CodeController( - language: Highlights.all[_langCode], - ); - - if (_langCode == null) { - _setupCtrl(); - } else { - Future.delayed(const Duration(milliseconds: 377)).then( - (value) async => await _setupCtrl(), - ); - } - } - - Future _setupCtrl() async { - final path = widget.args?.path; - final text = widget.args?.text; - if (path != null) { - final code = await Computer.shared.startNoParam( - () => File(path).readAsString(), - ); - _controller.text = code; - } else if (text != null) { - _controller.text = text; - } + _init(); } @override @@ -206,3 +177,37 @@ class _EditorPageState extends State { )); } } + +extension on _EditorPageState { + Future _init() async { + /// Higher priority than [path] + if (Stores.setting.editorHighlight.fetch()) { + _langCode = + widget.args?.langCode ?? Highlights.getCode(widget.args?.path); + } + _controller = CodeController( + language: Highlights.all[_langCode], + ); + + if (_langCode == null) { + _setupCtrl(); + } else { + Future.delayed(const Duration(milliseconds: 377)).then( + (value) async => await _setupCtrl(), + ); + } + } + + Future _setupCtrl() async { + final path = widget.args?.path; + final text = widget.args?.text; + if (path != null) { + final code = await Computer.shared.startNoParam( + () => File(path).readAsString(), + ); + _controller.text = code; + } else if (text != null) { + _controller.text = text; + } + } +} diff --git a/lib/view/page/setting/platform/android.dart b/lib/view/page/setting/platform/android.dart index b264fdca..1f898973 100644 --- a/lib/view/page/setting/platform/android.dart +++ b/lib/view/page/setting/platform/android.dart @@ -21,7 +21,7 @@ class _AndroidSettingsPageState extends State { body: ListView( padding: const EdgeInsets.symmetric(horizontal: 17), children: [ - _buildFgService(), + // _buildFgService(), _buildBgRun(), _buildAndroidWidgetSharedPreference(), if (BioAuth.isPlatformSupported) @@ -31,6 +31,13 @@ class _AndroidSettingsPageState extends State { ); } + // Widget _buildFgService() { + // return ListTile( + // title: TipText(l10n.fgService, l10n.fgServiceTip), + // trailing: StoreSwitch(prop: Stores.setting.fgService), + // ); + // } + Widget _buildBgRun() { return ListTile( title: TipText(l10n.bgRun, l10n.bgRunTip), @@ -116,11 +123,4 @@ class _AndroidSettingsPageState extends State { // }, // ); // } - - Widget _buildFgService() { - return ListTile( - title: TipText(l10n.fgService, l10n.fgServiceTip), - trailing: StoreSwitch(prop: Stores.setting.fgService), - ); - } }