mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
manually restart app
This commit is contained in:
10
lib/app.dart
10
lib/app.dart
@@ -19,15 +19,11 @@ class MyApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
setTransparentNavigationBar(context);
|
||||
final fontName = getFileName(_setting.fontPath.fetch());
|
||||
return ValueListenableBuilder<int>(
|
||||
valueListenable: _setting.primaryColor.listenable(),
|
||||
builder: (_, colorValue, __) {
|
||||
primaryColor = Color(colorValue);
|
||||
primaryColor = Color(_setting.primaryColor.fetch()!);
|
||||
|
||||
final textStyle = TextStyle(color: primaryColor);
|
||||
final materialColor = primaryColor.materialStateColor;
|
||||
final materialColorAlpha =
|
||||
primaryColor.withOpacity(0.7).materialStateColor;
|
||||
final materialColorAlpha = primaryColor.withOpacity(0.7).materialStateColor;
|
||||
final fabTheme =
|
||||
FloatingActionButtonThemeData(backgroundColor: primaryColor);
|
||||
final switchTheme = SwitchThemeData(
|
||||
@@ -83,7 +79,5 @@ class MyApp extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,5 +34,5 @@ class SettingStore extends PersistentStore {
|
||||
StoreProperty<int> get themeMode => property('themeMode', defaultValue: 0);
|
||||
|
||||
/// Font file path
|
||||
StoreProperty<String> get fontPath => property('fontPath2');
|
||||
StoreProperty<String> get fontPath => property('fontPath');
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_serverProvider.closeServer();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -445,8 +445,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
await GetIt.I.allReady();
|
||||
if (_serverProvider.servers.isEmpty) {
|
||||
await _serverProvider.loadLocalData();
|
||||
await _serverProvider.refreshData();
|
||||
}
|
||||
_serverProvider.startAutoRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
icon: const Icon(Icons.save),
|
||||
onPressed: (() {
|
||||
_setting.primaryColor.put(_selectedColorValue);
|
||||
setState(() {});
|
||||
_showRestartSnackbar();
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -459,18 +459,13 @@ class _SettingPageState extends State<SettingPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () async => pickFontFile(),
|
||||
onPressed: () async => _pickFontFile(),
|
||||
child: Text(_s.pickFile),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => setState(() {
|
||||
_setting.fontPath.delete();
|
||||
showSnackBarWithAction(
|
||||
context,
|
||||
'${_s.success}\n${_s.needRestart}',
|
||||
_s.restart,
|
||||
() => rebuildAll(context),
|
||||
);
|
||||
_showRestartSnackbar();
|
||||
}),
|
||||
child: Text(_s.clear),
|
||||
)
|
||||
@@ -480,7 +475,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> pickFontFile() async {
|
||||
Future<void> _pickFontFile() async {
|
||||
final path = await pickOneFile();
|
||||
if (path != null) {
|
||||
final fontDir_ = await fontDir;
|
||||
@@ -489,14 +484,18 @@ class _SettingPageState extends State<SettingPage> {
|
||||
await fontFile.copy(newPath);
|
||||
_setting.fontPath.put(newPath);
|
||||
setState(() {});
|
||||
_showRestartSnackbar();
|
||||
return;
|
||||
}
|
||||
showSnackBar(context, Text(_s.failed));
|
||||
}
|
||||
|
||||
void _showRestartSnackbar() {
|
||||
showSnackBarWithAction(
|
||||
context,
|
||||
'${_s.success}\n${_s.needRestart}',
|
||||
_s.restart,
|
||||
() => rebuildAll(context),
|
||||
);
|
||||
return;
|
||||
}
|
||||
showSnackBar(context, Text(_s.failed));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user