From 7a359588dbc79f80a1b2f45e57d882ba0e9f589b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:03:56 +0800 Subject: [PATCH] opt.: input field suggestion --- lib/app.dart | 36 +++++++++++++++-------------- lib/main.dart | 7 ++---- lib/view/page/backup.dart | 3 +++ lib/view/page/container.dart | 4 ++++ lib/view/page/iperf.dart | 2 ++ lib/view/page/ping.dart | 1 + lib/view/page/private_key/edit.dart | 3 +++ lib/view/page/process.dart | 3 +-- lib/view/page/server/edit.dart | 35 ++++++++++++++-------------- lib/view/page/setting/entry.dart | 4 ++++ lib/view/page/snippet/edit.dart | 3 +++ lib/view/page/storage/local.dart | 1 + lib/view/page/storage/sftp.dart | 4 ++++ pubspec.lock | 8 +++---- pubspec.yaml | 11 +++++---- 15 files changed, 75 insertions(+), 50 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index 2ae7064e..49f59472 100644 --- a/lib/app.dart +++ b/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(); diff --git a/lib/main.dart b/lib/main.dart index 582b62c1..ac4ba923 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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 _initApp() async { } Future _initData() async { - // await SecureStore.init(); await Hive.initFlutter(); // Ordered by typeId Hive.registerAdapter(PrivateKeyInfoAdapter()); // 1 @@ -94,7 +91,7 @@ Future _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(); diff --git a/lib/view/page/backup.dart b/lib/view/page/backup.dart index f24f83d0..46daa910 100644 --- a/lib/view/page/backup.dart +++ b/lib/view/page/backup.dart @@ -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), ), ], diff --git a/lib/view/page/container.dart b/lib/view/page/container.dart index 3a64c76e..aa966eaf 100644 --- a/lib/view/page/container.dart +++ b/lib/view/page/container.dart @@ -338,18 +338,21 @@ class _ContainerPageState extends State { 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 { controller: ctrl, onSubmitted: _onSaveDockerHost, hint: 'unix:///run/user/1000/docker.sock', + suggestion: false, ), actions: [ TextButton( diff --git a/lib/view/page/iperf.dart b/lib/view/page/iperf.dart index f7dc80f2..f913a24a 100644 --- a/lib/view/page/iperf.dart +++ b/lib/view/page/iperf.dart @@ -52,12 +52,14 @@ class _IPerfPageState extends State { controller: _hostCtrl, label: l10n.host, icon: Icons.computer, + suggestion: false, ), Input( controller: _portCtrl, label: l10n.port, type: TextInputType.number, icon: Icons.numbers, + suggestion: false, ), ], ); diff --git a/lib/view/page/ping.dart b/lib/view/page/ping.dart index 5b3c9dfb..7988ab30 100644 --- a/lib/view/page/ping.dart +++ b/lib/view/page/ping.dart @@ -59,6 +59,7 @@ class _PingPageState extends State controller: _textEditingController, hint: l10n.inputDomainHere, maxLines: 1, + suggestion: false, onSubmitted: (_) => _doPing(), ), actions: [ diff --git a/lib/view/page/private_key/edit.dart b/lib/view/page/private_key/edit.dart index ed05449a..dee480e0 100644 --- a/lib/view/page/private_key/edit.dart +++ b/lib/view/page/private_key/edit.dart @@ -135,6 +135,7 @@ class _PrivateKeyEditPageState extends State { onSubmitted: (_) => _focusScope.requestFocus(_keyNode), label: l10n.name, icon: Icons.info, + suggestion: true, ), Input( controller: _keyController, @@ -145,6 +146,7 @@ class _PrivateKeyEditPageState extends State { onSubmitted: (_) => _focusScope.requestFocus(_pwdNode), label: l10n.privateKey, icon: Icons.vpn_key, + suggestion: false, ), TextButton( onPressed: () async { @@ -181,6 +183,7 @@ class _PrivateKeyEditPageState extends State { obscureText: true, label: l10n.pwd, icon: Icons.password, + suggestion: false, onSubmitted: (_) => _onTapSave(), ), SizedBox(height: MediaQuery.of(context).size.height * 0.1), diff --git a/lib/view/page/process.dart b/lib/view/page/process.dart index 667faad9..a81ec708 100644 --- a/lib/view/page/process.dart +++ b/lib/view/page/process.dart @@ -51,8 +51,7 @@ class _ProcessPageState extends State { Future _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; diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index 00bcad9b..914bf188 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -196,6 +196,7 @@ class _ServerEditPageState extends State { label: l10n.host, icon: BoxIcons.bx_server, hint: 'example.com', + suggestion: false, ), Input( controller: _portController, @@ -205,6 +206,7 @@ class _ServerEditPageState extends State { label: l10n.port, icon: Bootstrap.number_123, hint: '22', + suggestion: false, ), Input( controller: _usernameController, @@ -214,6 +216,7 @@ class _ServerEditPageState extends State { label: l10n.user, icon: Icons.account_box, hint: 'root', + suggestion: false, ), Input( controller: _altUrlController, @@ -222,6 +225,7 @@ class _ServerEditPageState extends State { label: l10n.fallbackSshDest, icon: MingCute.link_line, hint: 'user@ip:port', + suggestion: false, ), TagEditor( tags: _tags, @@ -288,6 +292,7 @@ class _ServerEditPageState extends State { label: l10n.pwd, icon: Icons.password, hint: l10n.pwd, + suggestion: false, onSubmitted: (_) => _onSave(), )); } @@ -354,6 +359,7 @@ class _ServerEditPageState extends State { icon: Icons.image, label: 'URL', hint: 'https://example.com/logo.png', + suggestion: false, ), UIs.height7, ..._buildPVEs(), @@ -368,6 +374,7 @@ class _ServerEditPageState extends State { 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 { node: node, label: 'URL', hint: addr, + suggestion: false, ), ), ListTile( @@ -429,6 +437,7 @@ class _ServerEditPageState extends State { label: 'JSON', icon: Icons.code, hint: '{${l10n.customCmdHint}}', + suggestion: false, ), ListTile( leading: const Padding( @@ -460,6 +469,7 @@ class _ServerEditPageState extends State { 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 { 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 { label: l10n.pwd, icon: Icons.password, hint: l10n.pwd, + suggestion: false, ), ]; } @@ -620,17 +632,6 @@ class _ServerEditPageState extends State { 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 { @@ -645,12 +646,12 @@ class _ServerEditPageState extends State { leading: const Icon(Icons.tips_and_updates).paddingOnly(left: 13), title: Text(l10n.attention), onTap: () { - context.showRoundDialog( - title: l10n.attention, - child: SimpleMarkdown(data: l10n.writeScriptTip), - actions: Btns.oks(onTap: () => context.pop(true)), - ); - }, + context.showRoundDialog( + title: l10n.attention, + child: SimpleMarkdown(data: l10n.writeScriptTip), + actions: Btns.oks(onTap: () => context.pop(true)), + ); + }, trailing: const Icon(Icons.keyboard_arrow_right), ).cardx; } diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index 9474cd4a..73927554 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -270,6 +270,7 @@ class _SettingPageState extends State { controller: ctrl, hint: '#8b2252', icon: Icons.colorize, + suggestion: false, ), ColorPicker( color: Color(_setting.primaryColor.fetch()), @@ -784,6 +785,7 @@ class _SettingPageState extends State { icon: Icons.format_size, controller: ctrl, onSubmitted: _onSaveTextScaler, + suggestion: false, ), actions: [ TextButton( @@ -888,6 +890,7 @@ class _SettingPageState extends State { autoFocus: true, type: TextInputType.number, icon: Icons.font_download, + suggestion: false, onSubmitted: (_) => onSave(), ), actions: [ @@ -1151,6 +1154,7 @@ class _SettingPageState extends State { hint: 'https://example.com/logo.png', icon: Icons.link, maxLines: 2, + suggestion: false, onSubmitted: onSave, ), ListTile( diff --git a/lib/view/page/snippet/edit.dart b/lib/view/page/snippet/edit.dart index 93f9d9ab..8b5d21d6 100644 --- a/lib/view/page/snippet/edit.dart +++ b/lib/view/page/snippet/edit.dart @@ -114,6 +114,7 @@ class _SnippetEditPageState extends State 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 type: TextInputType.multiline, label: l10n.note, icon: Icons.note, + suggestion: true, ), ValBuilder( listenable: _tags, @@ -146,6 +148,7 @@ class _SnippetEditPageState extends State type: TextInputType.multiline, label: l10n.snippet, icon: Icons.code, + suggestion: false, ), _buildAutoRunOn(), _buildTip(), diff --git a/lib/view/page/storage/local.dart b/lib/view/page/storage/local.dart index e0dc8da5..93ccb993 100644 --- a/lib/view/page/storage/local.dart +++ b/lib/view/page/storage/local.dart @@ -329,6 +329,7 @@ class _LocalStoragePageState extends State { child: Input( autoFocus: true, controller: TextEditingController(text: fileName), + suggestion: true, onSubmitted: (p0) { context.pop(); final newPath = '${file.parent.path}/$p0'; diff --git a/lib/view/page/storage/sftp.dart b/lib/view/page/storage/sftp.dart index 5406e6c4..f5aa9355 100644 --- a/lib/view/page/storage/sftp.dart +++ b/lib/view/page/storage/sftp.dart @@ -267,6 +267,7 @@ class _SftpPageState extends State with AfterLayoutMixin { label: l10n.path, node: node, controller: controller, + suggestion: true, onSubmitted: (value) => context.pop(value), ); }, @@ -617,6 +618,7 @@ class _SftpPageState extends State with AfterLayoutMixin { icon: Icons.folder, controller: textController, label: l10n.name, + suggestion: true, onSubmitted: (_) => onSubmitted(), ), actions: [ @@ -672,6 +674,7 @@ class _SftpPageState extends State 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 with AfterLayoutMixin { icon: Icons.abc, controller: textController, label: l10n.name, + suggestion: true, onSubmitted: (_) => onSubmitted(), ), actions: [ diff --git a/pubspec.lock b/pubspec.lock index d4459f0b..1c132f13 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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" diff --git a/pubspec.yaml b/pubspec.yaml index 2f1c635d..3f3571f0 100644 --- a/pubspec.yaml +++ b/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