mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: input field suggestion
This commit is contained in:
36
lib/app.dart
36
lib/app.dart
@@ -23,7 +23,18 @@ class MyApp extends StatelessWidget {
|
||||
builder: (context, _) {
|
||||
if (!Stores.setting.useSystemPrimaryColor.fetch()) {
|
||||
UIs.colorSeed = Color(Stores.setting.primaryColor.fetch());
|
||||
return _buildApp(context);
|
||||
return _buildApp(
|
||||
context,
|
||||
light: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorSchemeSeed: UIs.colorSeed,
|
||||
),
|
||||
dark: ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.dark,
|
||||
colorSchemeSeed: UIs.colorSeed,
|
||||
),
|
||||
);
|
||||
}
|
||||
return DynamicColorBuilder(
|
||||
builder: (light, dark) {
|
||||
@@ -36,10 +47,10 @@ class MyApp extends StatelessWidget {
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: dark,
|
||||
);
|
||||
if (context.isDark && light != null) {
|
||||
UIs.primaryColor = light.primary;
|
||||
} else if (!context.isDark && dark != null) {
|
||||
if (context.isDark && dark != null) {
|
||||
UIs.primaryColor = dark.primary;
|
||||
} else if (!context.isDark && light != null) {
|
||||
UIs.primaryColor = light.primary;
|
||||
}
|
||||
return _buildApp(context, light: lightTheme, dark: darkTheme);
|
||||
},
|
||||
@@ -48,7 +59,8 @@ class MyApp extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildApp(BuildContext ctx, {ThemeData? light, ThemeData? dark}) {
|
||||
Widget _buildApp(BuildContext ctx,
|
||||
{required ThemeData light, required ThemeData dark}) {
|
||||
final tMode = Stores.setting.themeMode.fetch();
|
||||
// Issue #57
|
||||
final themeMode = switch (tMode) {
|
||||
@@ -58,16 +70,6 @@ class MyApp extends StatelessWidget {
|
||||
};
|
||||
final locale = Stores.setting.locale.fetch().toLocale;
|
||||
|
||||
light ??= ThemeData(
|
||||
useMaterial3: true,
|
||||
colorSchemeSeed: UIs.colorSeed,
|
||||
);
|
||||
dark ??= ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.dark,
|
||||
colorSchemeSeed: UIs.colorSeed,
|
||||
);
|
||||
|
||||
return MaterialApp(
|
||||
locale: locale,
|
||||
localizationsDelegates: const [
|
||||
@@ -78,8 +80,8 @@ class MyApp extends StatelessWidget {
|
||||
localeListResolutionCallback: LocaleUtil.resolve,
|
||||
title: BuildData.name,
|
||||
themeMode: themeMode,
|
||||
theme: light,
|
||||
darkTheme: tMode < 3 ? dark : dark.toAmoled,
|
||||
theme: light.fixWindowsFont,
|
||||
darkTheme: (tMode < 3 ? dark : dark.toAmoled).fixWindowsFont,
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
context.setLibL10n();
|
||||
|
||||
@@ -53,9 +53,7 @@ void _runInZone(void Function() body) {
|
||||
|
||||
runZonedGuarded(
|
||||
body,
|
||||
(obj, trace) {
|
||||
Loggers.root.warning(obj, null, trace);
|
||||
},
|
||||
(e, s) => print('[ZONE] $e\n$s'),
|
||||
zoneSpecification: zoneSpec,
|
||||
);
|
||||
}
|
||||
@@ -82,7 +80,6 @@ Future<void> _initApp() async {
|
||||
}
|
||||
|
||||
Future<void> _initData() async {
|
||||
// await SecureStore.init();
|
||||
await Hive.initFlutter();
|
||||
// Ordered by typeId
|
||||
Hive.registerAdapter(PrivateKeyInfoAdapter()); // 1
|
||||
@@ -94,7 +91,7 @@ Future<void> _initData() async {
|
||||
Hive.registerAdapter(ServerCustomAdapter()); // 7
|
||||
Hive.registerAdapter(WakeOnLanCfgAdapter()); // 8
|
||||
|
||||
await SharedPref.init(); // Call this before accessing any store
|
||||
await PrefStore.init(); // Call this before accessing any store
|
||||
|
||||
await Stores.setting.init();
|
||||
await Stores.server.init();
|
||||
|
||||
@@ -316,18 +316,21 @@ class BackupPage extends StatelessWidget {
|
||||
label: 'URL',
|
||||
hint: 'https://example.com/webdav/',
|
||||
controller: url,
|
||||
suggestion: false,
|
||||
onSubmitted: (p0) => FocusScope.of(context).requestFocus(nodeUser),
|
||||
),
|
||||
Input(
|
||||
label: l10n.user,
|
||||
controller: user,
|
||||
node: nodeUser,
|
||||
suggestion: false,
|
||||
onSubmitted: (p0) => FocusScope.of(context).requestFocus(nodePwd),
|
||||
),
|
||||
Input(
|
||||
label: l10n.pwd,
|
||||
controller: pwd,
|
||||
node: nodePwd,
|
||||
suggestion: false,
|
||||
onSubmitted: (_) => context.pop(true),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -338,18 +338,21 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
label: l10n.image,
|
||||
hint: 'xxx:1.1',
|
||||
controller: imageCtrl,
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
type: TextInputType.text,
|
||||
controller: nameCtrl,
|
||||
label: l10n.containerName,
|
||||
hint: 'xxx',
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
type: TextInputType.text,
|
||||
controller: argsCtrl,
|
||||
label: l10n.extraArgs,
|
||||
hint: '-p 2222:22 -v ~/.xxx/:/xxx',
|
||||
suggestion: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -425,6 +428,7 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
controller: ctrl,
|
||||
onSubmitted: _onSaveDockerHost,
|
||||
hint: 'unix:///run/user/1000/docker.sock',
|
||||
suggestion: false,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
|
||||
@@ -52,12 +52,14 @@ class _IPerfPageState extends State<IPerfPage> {
|
||||
controller: _hostCtrl,
|
||||
label: l10n.host,
|
||||
icon: Icons.computer,
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
controller: _portCtrl,
|
||||
label: l10n.port,
|
||||
type: TextInputType.number,
|
||||
icon: Icons.numbers,
|
||||
suggestion: false,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -59,6 +59,7 @@ class _PingPageState extends State<PingPage>
|
||||
controller: _textEditingController,
|
||||
hint: l10n.inputDomainHere,
|
||||
maxLines: 1,
|
||||
suggestion: false,
|
||||
onSubmitted: (_) => _doPing(),
|
||||
),
|
||||
actions: [
|
||||
|
||||
@@ -135,6 +135,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_keyNode),
|
||||
label: l10n.name,
|
||||
icon: Icons.info,
|
||||
suggestion: true,
|
||||
),
|
||||
Input(
|
||||
controller: _keyController,
|
||||
@@ -145,6 +146,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_pwdNode),
|
||||
label: l10n.privateKey,
|
||||
icon: Icons.vpn_key,
|
||||
suggestion: false,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
@@ -181,6 +183,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
obscureText: true,
|
||||
label: l10n.pwd,
|
||||
icon: Icons.password,
|
||||
suggestion: false,
|
||||
onSubmitted: (_) => _onTapSave(),
|
||||
),
|
||||
SizedBox(height: MediaQuery.of(context).size.height * 0.1),
|
||||
|
||||
@@ -51,8 +51,7 @@ class _ProcessPageState extends State<ProcessPage> {
|
||||
|
||||
Future<void> _refresh() async {
|
||||
if (mounted) {
|
||||
final result =
|
||||
await _client?.run(ShellFunc.process.exec).string;
|
||||
final result = await _client?.run(ShellFunc.process.exec).string;
|
||||
if (result == null || result.isEmpty) {
|
||||
context.showSnackBar(l10n.noResult);
|
||||
return;
|
||||
|
||||
@@ -196,6 +196,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: l10n.host,
|
||||
icon: BoxIcons.bx_server,
|
||||
hint: 'example.com',
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
controller: _portController,
|
||||
@@ -205,6 +206,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: l10n.port,
|
||||
icon: Bootstrap.number_123,
|
||||
hint: '22',
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
controller: _usernameController,
|
||||
@@ -214,6 +216,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: l10n.user,
|
||||
icon: Icons.account_box,
|
||||
hint: 'root',
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
controller: _altUrlController,
|
||||
@@ -222,6 +225,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: l10n.fallbackSshDest,
|
||||
icon: MingCute.link_line,
|
||||
hint: 'user@ip:port',
|
||||
suggestion: false,
|
||||
),
|
||||
TagEditor(
|
||||
tags: _tags,
|
||||
@@ -288,6 +292,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: l10n.pwd,
|
||||
icon: Icons.password,
|
||||
hint: l10n.pwd,
|
||||
suggestion: false,
|
||||
onSubmitted: (_) => _onSave(),
|
||||
));
|
||||
}
|
||||
@@ -354,6 +359,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
icon: Icons.image,
|
||||
label: 'URL',
|
||||
hint: 'https://example.com/logo.png',
|
||||
suggestion: false,
|
||||
),
|
||||
UIs.height7,
|
||||
..._buildPVEs(),
|
||||
@@ -368,6 +374,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: l10n.deviceName,
|
||||
icon: MingCute.low_temperature_line,
|
||||
hint: 'nvme-pci-0400',
|
||||
suggestion: false,
|
||||
),
|
||||
UIs.height7,
|
||||
..._buildWOLs(),
|
||||
@@ -396,6 +403,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
node: node,
|
||||
label: 'URL',
|
||||
hint: addr,
|
||||
suggestion: false,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -429,6 +437,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: 'JSON',
|
||||
icon: Icons.code,
|
||||
hint: '{${l10n.customCmdHint}}',
|
||||
suggestion: false,
|
||||
),
|
||||
ListTile(
|
||||
leading: const Padding(
|
||||
@@ -460,6 +469,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: 'MAC ${l10n.addr}',
|
||||
icon: Icons.computer,
|
||||
hint: '00:11:22:33:44:55',
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
controller: _wolIpCtrl,
|
||||
@@ -467,6 +477,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: 'IP ${l10n.addr}',
|
||||
icon: Icons.network_cell,
|
||||
hint: '192.168.1.x',
|
||||
suggestion: false,
|
||||
),
|
||||
Input(
|
||||
controller: _wolPwdCtrl,
|
||||
@@ -475,6 +486,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
label: l10n.pwd,
|
||||
icon: Icons.password,
|
||||
hint: l10n.pwd,
|
||||
suggestion: false,
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -620,17 +632,6 @@ class _ServerEditPageState extends State<ServerEditPage> {
|
||||
wolCfg: wol,
|
||||
);
|
||||
|
||||
// final tipShown = Stores.history.writeScriptTipShown;
|
||||
// if (!tipShown.fetch()) {
|
||||
// final ok = await context.showRoundDialog(
|
||||
// title: l10n.attention,
|
||||
// child: SimpleMarkdown(data: l10n.beforeConnect(Urls.thisRepo)),
|
||||
// actions: Btns.oks(onTap: () => context.pop(true)),
|
||||
// );
|
||||
// if (ok != true) return;
|
||||
// tipShown.put(true);
|
||||
// }
|
||||
|
||||
if (widget.spi == null) {
|
||||
Pros.server.addServer(spi);
|
||||
} else {
|
||||
|
||||
@@ -270,6 +270,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
controller: ctrl,
|
||||
hint: '#8b2252',
|
||||
icon: Icons.colorize,
|
||||
suggestion: false,
|
||||
),
|
||||
ColorPicker(
|
||||
color: Color(_setting.primaryColor.fetch()),
|
||||
@@ -784,6 +785,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
icon: Icons.format_size,
|
||||
controller: ctrl,
|
||||
onSubmitted: _onSaveTextScaler,
|
||||
suggestion: false,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -888,6 +890,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
autoFocus: true,
|
||||
type: TextInputType.number,
|
||||
icon: Icons.font_download,
|
||||
suggestion: false,
|
||||
onSubmitted: (_) => onSave(),
|
||||
),
|
||||
actions: [
|
||||
@@ -1151,6 +1154,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
hint: 'https://example.com/logo.png',
|
||||
icon: Icons.link,
|
||||
maxLines: 2,
|
||||
suggestion: false,
|
||||
onSubmitted: onSave,
|
||||
),
|
||||
ListTile(
|
||||
|
||||
@@ -114,6 +114,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
onSubmitted: (_) => FocusScope.of(context).requestFocus(_scriptNode),
|
||||
label: l10n.name,
|
||||
icon: Icons.info,
|
||||
suggestion: true,
|
||||
),
|
||||
Input(
|
||||
controller: _noteController,
|
||||
@@ -122,6 +123,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
type: TextInputType.multiline,
|
||||
label: l10n.note,
|
||||
icon: Icons.note,
|
||||
suggestion: true,
|
||||
),
|
||||
ValBuilder(
|
||||
listenable: _tags,
|
||||
@@ -146,6 +148,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
type: TextInputType.multiline,
|
||||
label: l10n.snippet,
|
||||
icon: Icons.code,
|
||||
suggestion: false,
|
||||
),
|
||||
_buildAutoRunOn(),
|
||||
_buildTip(),
|
||||
|
||||
@@ -329,6 +329,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
child: Input(
|
||||
autoFocus: true,
|
||||
controller: TextEditingController(text: fileName),
|
||||
suggestion: true,
|
||||
onSubmitted: (p0) {
|
||||
context.pop();
|
||||
final newPath = '${file.parent.path}/$p0';
|
||||
|
||||
@@ -267,6 +267,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
label: l10n.path,
|
||||
node: node,
|
||||
controller: controller,
|
||||
suggestion: true,
|
||||
onSubmitted: (value) => context.pop(value),
|
||||
);
|
||||
},
|
||||
@@ -617,6 +618,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
icon: Icons.folder,
|
||||
controller: textController,
|
||||
label: l10n.name,
|
||||
suggestion: true,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
),
|
||||
actions: [
|
||||
@@ -672,6 +674,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
icon: Icons.insert_drive_file,
|
||||
controller: textController,
|
||||
label: l10n.name,
|
||||
suggestion: true,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
),
|
||||
actions: [
|
||||
@@ -723,6 +726,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
icon: Icons.abc,
|
||||
controller: textController,
|
||||
label: l10n.name,
|
||||
suggestion: true,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
),
|
||||
actions: [
|
||||
|
||||
@@ -368,8 +368,8 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
path: "."
|
||||
ref: "v1.0.34"
|
||||
resolved-ref: "9d8afa6b0bc72223213ca30f67c3be2eb129f928"
|
||||
ref: "v1.0.35"
|
||||
resolved-ref: "7964acfe55e3e3f5d5232a0c2371cff5fa7edc4c"
|
||||
url: "https://github.com/lppcg/fl_build.git"
|
||||
source: git
|
||||
version: "1.0.0"
|
||||
@@ -385,8 +385,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "v1.0.77"
|
||||
resolved-ref: "57c4c0187673ea9c38b39889ac467be4a8bbddba"
|
||||
ref: "v1.0.79"
|
||||
resolved-ref: f1bc7dd5ec2af84813b33a9e2149e117dfea3cd0
|
||||
url: "https://github.com/lppcg/fl_lib"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
||||
11
pubspec.yaml
11
pubspec.yaml
@@ -61,15 +61,17 @@ dependencies:
|
||||
fl_lib:
|
||||
git:
|
||||
url: https://github.com/lppcg/fl_lib
|
||||
ref: v1.0.77
|
||||
ref: v1.0.79
|
||||
|
||||
dependency_overrides:
|
||||
# dartssh2:
|
||||
# path: ../dartssh2
|
||||
# fl_lib:
|
||||
# path: ../fl_lib
|
||||
# xterm:
|
||||
# path: ../xterm.dart
|
||||
# fl_lib:
|
||||
# path: ../fl_lib
|
||||
# fl_build:
|
||||
# path: ../fl_build
|
||||
|
||||
dev_dependencies:
|
||||
flutter_native_splash: ^2.1.6
|
||||
@@ -79,10 +81,9 @@ dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
fl_build:
|
||||
# path: ../fl_build
|
||||
git:
|
||||
url: https://github.com/lppcg/fl_build.git
|
||||
ref: v1.0.34
|
||||
ref: v1.0.35
|
||||
|
||||
flutter:
|
||||
generate: true
|
||||
|
||||
Reference in New Issue
Block a user