mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 15:54:35 +01:00
@@ -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 {
|
||||
|
||||
@@ -80,36 +80,7 @@ class _EditorPageState extends State<EditorPage> {
|
||||
@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<void> _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<EditorPage> {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
extension on _EditorPageState {
|
||||
Future<void> _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<void> _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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
children: [
|
||||
_buildFgService(),
|
||||
// _buildFgService(),
|
||||
_buildBgRun(),
|
||||
_buildAndroidWidgetSharedPreference(),
|
||||
if (BioAuth.isPlatformSupported)
|
||||
@@ -31,6 +31,13 @@ class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
// 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<AndroidSettingsPage> {
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget _buildFgService() {
|
||||
return ListTile(
|
||||
title: TipText(l10n.fgService, l10n.fgServiceTip),
|
||||
trailing: StoreSwitch(prop: Stores.setting.fgService),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user