mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: store
This commit is contained in:
@@ -45,7 +45,7 @@ class _FullScreenPageState extends State<FullScreenPage> with AfterLayoutMixin {
|
||||
void initState() {
|
||||
super.initState();
|
||||
switchStatusBar(hide: true);
|
||||
_rotateQuarter = _setting.fullScreenRotateQuarter.fetch()!;
|
||||
_rotateQuarter = _setting.fullScreenRotateQuarter.fetch();
|
||||
_timer = Timer.periodic(const Duration(minutes: 1), (_) {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
@@ -362,7 +362,7 @@ class _FullScreenPageState extends State<FullScreenPage> with AfterLayoutMixin {
|
||||
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
if (_setting.autoCheckAppUpdate.fetch()!) {
|
||||
if (_setting.autoCheckAppUpdate.fetch()) {
|
||||
doUpdate(context);
|
||||
}
|
||||
await GetIt.I.allReady();
|
||||
|
||||
@@ -54,7 +54,7 @@ class _HomePageState extends State<HomePage>
|
||||
super.initState();
|
||||
switchStatusBar(hide: false);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_selectIndex.value = _setting.launchPage.fetch()!;
|
||||
_selectIndex.value = _setting.launchPage.fetch();
|
||||
// avoid index out of range
|
||||
if (_selectIndex.value >= AppTab.values.length || _selectIndex.value < 0) {
|
||||
_selectIndex.value = 0;
|
||||
@@ -90,7 +90,7 @@ class _HomePageState extends State<HomePage>
|
||||
break;
|
||||
case AppLifecycleState.paused:
|
||||
// Keep running in background on Android device
|
||||
if (isAndroid && _setting.bgRun.fetch()!) {
|
||||
if (isAndroid && _setting.bgRun.fetch()) {
|
||||
if (_app.moveBg) {
|
||||
bgRunChannel.invokeMethod('sendToBackground');
|
||||
}
|
||||
@@ -366,7 +366,7 @@ class _HomePageState extends State<HomePage>
|
||||
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
if (_setting.autoCheckAppUpdate.fetch()!) {
|
||||
if (_setting.autoCheckAppUpdate.fetch()) {
|
||||
doUpdate(context);
|
||||
}
|
||||
updateHomeWidget();
|
||||
@@ -379,7 +379,7 @@ class _HomePageState extends State<HomePage>
|
||||
}
|
||||
|
||||
void updateHomeWidget() {
|
||||
if (_setting.autoUpdateHomeWidget.fetch()!) {
|
||||
if (_setting.autoUpdateHomeWidget.fetch()) {
|
||||
homeWidgetChannel.invokeMethod('update');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_cardsOrder.addAll(_setting.detailCardOrder.fetch()!);
|
||||
_cardsOrder.addAll(_setting.detailCardOrder.fetch());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -80,7 +80,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildMainPage(Server si) {
|
||||
final buildFuncs = !_setting.moveOutServerTabFuncBtns.fetch()!;
|
||||
final buildFuncs = !_setting.moveOutServerTabFuncBtns.fetch();
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: Text(si.spi.name, style: textSize18),
|
||||
@@ -299,7 +299,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
Widget _buildDiskView(ServerStatus ss) {
|
||||
final disk = ss.disk;
|
||||
disk.removeWhere((e) {
|
||||
for (final ingorePath in _setting.diskIgnorePath.fetch()!) {
|
||||
for (final ingorePath in _setting.diskIgnorePath.fetch()) {
|
||||
if (e.path.startsWith(ingorePath)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -238,7 +238,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
),
|
||||
),
|
||||
height13,
|
||||
if (_settingStore.moveOutServerTabFuncBtns.fetch()!)
|
||||
if (_settingStore.moveOutServerTabFuncBtns.fetch())
|
||||
SizedBox(
|
||||
height: 27,
|
||||
child: ServerFuncBtns(spi: spi, s: _s),
|
||||
@@ -446,7 +446,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
if (cs != ServerState.finished) {
|
||||
return 23.0;
|
||||
}
|
||||
if (_settingStore.moveOutServerTabFuncBtns.fetch()!) {
|
||||
if (_settingStore.moveOutServerTabFuncBtns.fetch()) {
|
||||
return 132;
|
||||
}
|
||||
return 107;
|
||||
|
||||
@@ -77,7 +77,12 @@ class _SettingPageState extends State<SettingPage> {
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_s = S.of(context)!;
|
||||
_localeCode.value = _setting.locale.fetch() ?? _s.localeName;
|
||||
final localeSettingVal = _setting.locale.fetch();
|
||||
if (localeSettingVal.isEmpty) {
|
||||
_localeCode.value = _s.localeName;
|
||||
} else {
|
||||
_localeCode.value = localeSettingVal;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -85,18 +90,18 @@ class _SettingPageState extends State<SettingPage> {
|
||||
super.initState();
|
||||
_serverProvider = locator<ServerProvider>();
|
||||
_setting = locator<SettingStore>();
|
||||
_launchPageIdx.value = _setting.launchPage.fetch()!;
|
||||
_nightMode.value = _setting.themeMode.fetch()!;
|
||||
_updateInterval.value = _setting.serverStatusUpdateInterval.fetch()!;
|
||||
_maxRetryCount.value = _setting.maxRetryCount.fetch()!;
|
||||
_selectedColorValue.value = _setting.primaryColor.fetch()!;
|
||||
_termFontSize.value = _setting.termFontSize.fetch()!;
|
||||
_editorFontSize.value = _setting.editorFontSize.fetch()!;
|
||||
_editorTheme.value = _setting.editorTheme.fetch()!;
|
||||
_editorDarkTheme.value = _setting.editorDarkTheme.fetch()!;
|
||||
_keyboardType.value = _setting.keyboardType.fetch()!;
|
||||
_rotateQuarter.value = _setting.fullScreenRotateQuarter.fetch()!;
|
||||
_netViewType.value = _setting.netViewType.fetch()!;
|
||||
_launchPageIdx.value = _setting.launchPage.fetch();
|
||||
_nightMode.value = _setting.themeMode.fetch();
|
||||
_updateInterval.value = _setting.serverStatusUpdateInterval.fetch();
|
||||
_maxRetryCount.value = _setting.maxRetryCount.fetch();
|
||||
_selectedColorValue.value = _setting.primaryColor.fetch();
|
||||
_termFontSize.value = _setting.termFontSize.fetch();
|
||||
_editorFontSize.value = _setting.editorFontSize.fetch();
|
||||
_editorTheme.value = _setting.editorTheme.fetch();
|
||||
_editorDarkTheme.value = _setting.editorDarkTheme.fetch();
|
||||
_keyboardType.value = _setting.keyboardType.fetch();
|
||||
_rotateQuarter.value = _setting.fullScreenRotateQuarter.fetch();
|
||||
_netViewType.value = _setting.netViewType.fetch();
|
||||
SharedPreferences.getInstance().then((value) => _sp = value);
|
||||
}
|
||||
|
||||
@@ -563,7 +568,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
}
|
||||
|
||||
Widget _buildDiskIgnorePath() {
|
||||
final paths = _setting.diskIgnorePath.fetch()!;
|
||||
final paths = _setting.diskIgnorePath.fetch();
|
||||
return ListTile(
|
||||
title: Text(_s.diskIgnorePath),
|
||||
trailing: Text(_s.edit, style: textSize15),
|
||||
@@ -987,7 +992,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
|
||||
void _showFontSizeDialog(
|
||||
ValueNotifier<double> notifier,
|
||||
StoreProperty property,
|
||||
StorePropertyBase<double> property,
|
||||
) {
|
||||
final ctrller = TextEditingController(text: notifier.value.toString());
|
||||
void onSave() {
|
||||
|
||||
@@ -30,7 +30,7 @@ class _ServerDetailOrderPageState extends State<ServerDetailOrderPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_cardsOrder.addAll(_store.detailCardOrder.fetch()!);
|
||||
_cardsOrder.addAll(_store.detailCardOrder.fetch());
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -39,7 +39,7 @@ class _SSHVirtKeySettingPageState extends State<SSHVirtKeySettingPage> {
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
final keys_ = _setting.sshVirtKeys.fetchRaw()!;
|
||||
final keys_ = _setting.sshVirtKeys.fetch();
|
||||
final keys = <VirtKey>[];
|
||||
for (final key in keys_) {
|
||||
keys.add(key);
|
||||
|
||||
@@ -61,10 +61,10 @@ class _SSHPageState extends State<SSHPage> {
|
||||
final fontFamilly = getFileName(_setting.fontPath.fetch());
|
||||
final textStyle = TextStyle(
|
||||
fontFamily: fontFamilly,
|
||||
fontSize: _setting.termFontSize.fetch()!,
|
||||
fontSize: _setting.termFontSize.fetch(),
|
||||
);
|
||||
_terminalStyle = TerminalStyle.fromTextStyle(textStyle);
|
||||
_keyboardType = TextInputType.values[_setting.keyboardType.fetch()!];
|
||||
_keyboardType = TextInputType.values[_setting.keyboardType.fetch()];
|
||||
_initTerminal();
|
||||
_initVirtKeys();
|
||||
}
|
||||
@@ -299,7 +299,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
}
|
||||
|
||||
void _initVirtKeys() {
|
||||
final virtKeys = List<VirtKey>.from(_setting.sshVirtKeys.fetchRaw());
|
||||
final virtKeys = List<VirtKey>.from(_setting.sshVirtKeys.fetch());
|
||||
|
||||
for (int len = 0; len < virtKeys.length; len += 7) {
|
||||
if (len + 7 > virtKeys.length) {
|
||||
|
||||
@@ -430,7 +430,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
void _delete(BuildContext context, SftpName file) {
|
||||
context.pop();
|
||||
final isDir = file.attr.isDirectory;
|
||||
final useRmrf = _setting.sftpRmrfDir.fetch()!;
|
||||
final useRmrf = _setting.sftpRmrfDir.fetch();
|
||||
final dirText = (isDir && !useRmrf) ? '\n${_s.sureDirEmpty}' : '';
|
||||
final text = '${_s.sureDelete(file.filename)}$dirText';
|
||||
final child = Text(text);
|
||||
|
||||
Reference in New Issue
Block a user