mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-20 15:15:15 +01:00
@@ -11,6 +11,7 @@ import 'package:server_box/data/res/provider.dart';
|
||||
import 'package:server_box/data/res/rebuild.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:server_box/data/res/url.dart';
|
||||
import 'package:server_box/view/page/setting/platform/platform_pub.dart';
|
||||
|
||||
import '../../../core/route.dart';
|
||||
import '../../../data/model/app/net_view.dart';
|
||||
@@ -1071,6 +1072,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildCollapseUI(),
|
||||
_buildCupertinoRoute(),
|
||||
if (isDesktop) _buildHideTitleBar(),
|
||||
if (isDesktop) PlatformPublicSettings.buildSaveWindowSize(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
abstract final class PlatformPublicSettings {
|
||||
static Widget buildBioAuth() {
|
||||
@@ -45,4 +46,48 @@ abstract final class PlatformPublicSettings {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static Widget buildSaveWindowSize() {
|
||||
final isBusy = false.vn;
|
||||
// Only show [FadeIn] when previous state is busy.
|
||||
var lastIsBusy = false;
|
||||
final prop = Stores.setting.windowSize;
|
||||
|
||||
return ListTile(
|
||||
title: Text(l10n.rememberWindowSize),
|
||||
/// Copied from `fl_build/view/store_switch`
|
||||
trailing: ValBuilder(
|
||||
listenable: isBusy,
|
||||
builder: (busy) {
|
||||
return ValBuilder(
|
||||
listenable: prop.listenable(),
|
||||
builder: (value) {
|
||||
if (busy) {
|
||||
lastIsBusy = true;
|
||||
return UIs.centerSizedLoadingSmall.paddingOnly(right: 17);
|
||||
}
|
||||
|
||||
final switcher = Switch(
|
||||
value: value.isNotEmpty,
|
||||
onChanged: (value) async {
|
||||
isBusy.value = true;
|
||||
final size = await windowManager.getSize();
|
||||
isBusy.value = false;
|
||||
prop.put(size.toIntStr());
|
||||
},
|
||||
);
|
||||
|
||||
if (lastIsBusy) {
|
||||
final ret = FadeIn(child: switcher);
|
||||
lastIsBusy = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return switcher;
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user