opt.: input field suggestion

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-07-22 22:03:56 +08:00
parent 255abe8b11
commit 7a359588db
15 changed files with 75 additions and 50 deletions

View File

@@ -23,7 +23,18 @@ class MyApp extends StatelessWidget {
builder: (context, _) { builder: (context, _) {
if (!Stores.setting.useSystemPrimaryColor.fetch()) { if (!Stores.setting.useSystemPrimaryColor.fetch()) {
UIs.colorSeed = Color(Stores.setting.primaryColor.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( return DynamicColorBuilder(
builder: (light, dark) { builder: (light, dark) {
@@ -36,10 +47,10 @@ class MyApp extends StatelessWidget {
brightness: Brightness.dark, brightness: Brightness.dark,
colorScheme: dark, colorScheme: dark,
); );
if (context.isDark && light != null) { if (context.isDark && dark != null) {
UIs.primaryColor = light.primary;
} else if (!context.isDark && dark != null) {
UIs.primaryColor = dark.primary; UIs.primaryColor = dark.primary;
} else if (!context.isDark && light != null) {
UIs.primaryColor = light.primary;
} }
return _buildApp(context, light: lightTheme, dark: darkTheme); 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(); final tMode = Stores.setting.themeMode.fetch();
// Issue #57 // Issue #57
final themeMode = switch (tMode) { final themeMode = switch (tMode) {
@@ -58,16 +70,6 @@ class MyApp extends StatelessWidget {
}; };
final locale = Stores.setting.locale.fetch().toLocale; 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( return MaterialApp(
locale: locale, locale: locale,
localizationsDelegates: const [ localizationsDelegates: const [
@@ -78,8 +80,8 @@ class MyApp extends StatelessWidget {
localeListResolutionCallback: LocaleUtil.resolve, localeListResolutionCallback: LocaleUtil.resolve,
title: BuildData.name, title: BuildData.name,
themeMode: themeMode, themeMode: themeMode,
theme: light, theme: light.fixWindowsFont,
darkTheme: tMode < 3 ? dark : dark.toAmoled, darkTheme: (tMode < 3 ? dark : dark.toAmoled).fixWindowsFont,
home: Builder( home: Builder(
builder: (context) { builder: (context) {
context.setLibL10n(); context.setLibL10n();

View File

@@ -53,9 +53,7 @@ void _runInZone(void Function() body) {
runZonedGuarded( runZonedGuarded(
body, body,
(obj, trace) { (e, s) => print('[ZONE] $e\n$s'),
Loggers.root.warning(obj, null, trace);
},
zoneSpecification: zoneSpec, zoneSpecification: zoneSpec,
); );
} }
@@ -82,7 +80,6 @@ Future<void> _initApp() async {
} }
Future<void> _initData() async { Future<void> _initData() async {
// await SecureStore.init();
await Hive.initFlutter(); await Hive.initFlutter();
// Ordered by typeId // Ordered by typeId
Hive.registerAdapter(PrivateKeyInfoAdapter()); // 1 Hive.registerAdapter(PrivateKeyInfoAdapter()); // 1
@@ -94,7 +91,7 @@ Future<void> _initData() async {
Hive.registerAdapter(ServerCustomAdapter()); // 7 Hive.registerAdapter(ServerCustomAdapter()); // 7
Hive.registerAdapter(WakeOnLanCfgAdapter()); // 8 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.setting.init();
await Stores.server.init(); await Stores.server.init();

View File

@@ -316,18 +316,21 @@ class BackupPage extends StatelessWidget {
label: 'URL', label: 'URL',
hint: 'https://example.com/webdav/', hint: 'https://example.com/webdav/',
controller: url, controller: url,
suggestion: false,
onSubmitted: (p0) => FocusScope.of(context).requestFocus(nodeUser), onSubmitted: (p0) => FocusScope.of(context).requestFocus(nodeUser),
), ),
Input( Input(
label: l10n.user, label: l10n.user,
controller: user, controller: user,
node: nodeUser, node: nodeUser,
suggestion: false,
onSubmitted: (p0) => FocusScope.of(context).requestFocus(nodePwd), onSubmitted: (p0) => FocusScope.of(context).requestFocus(nodePwd),
), ),
Input( Input(
label: l10n.pwd, label: l10n.pwd,
controller: pwd, controller: pwd,
node: nodePwd, node: nodePwd,
suggestion: false,
onSubmitted: (_) => context.pop(true), onSubmitted: (_) => context.pop(true),
), ),
], ],

View File

@@ -338,18 +338,21 @@ class _ContainerPageState extends State<ContainerPage> {
label: l10n.image, label: l10n.image,
hint: 'xxx:1.1', hint: 'xxx:1.1',
controller: imageCtrl, controller: imageCtrl,
suggestion: false,
), ),
Input( Input(
type: TextInputType.text, type: TextInputType.text,
controller: nameCtrl, controller: nameCtrl,
label: l10n.containerName, label: l10n.containerName,
hint: 'xxx', hint: 'xxx',
suggestion: false,
), ),
Input( Input(
type: TextInputType.text, type: TextInputType.text,
controller: argsCtrl, controller: argsCtrl,
label: l10n.extraArgs, label: l10n.extraArgs,
hint: '-p 2222:22 -v ~/.xxx/:/xxx', hint: '-p 2222:22 -v ~/.xxx/:/xxx',
suggestion: false,
), ),
], ],
), ),
@@ -425,6 +428,7 @@ class _ContainerPageState extends State<ContainerPage> {
controller: ctrl, controller: ctrl,
onSubmitted: _onSaveDockerHost, onSubmitted: _onSaveDockerHost,
hint: 'unix:///run/user/1000/docker.sock', hint: 'unix:///run/user/1000/docker.sock',
suggestion: false,
), ),
actions: [ actions: [
TextButton( TextButton(

View File

@@ -52,12 +52,14 @@ class _IPerfPageState extends State<IPerfPage> {
controller: _hostCtrl, controller: _hostCtrl,
label: l10n.host, label: l10n.host,
icon: Icons.computer, icon: Icons.computer,
suggestion: false,
), ),
Input( Input(
controller: _portCtrl, controller: _portCtrl,
label: l10n.port, label: l10n.port,
type: TextInputType.number, type: TextInputType.number,
icon: Icons.numbers, icon: Icons.numbers,
suggestion: false,
), ),
], ],
); );

View File

@@ -59,6 +59,7 @@ class _PingPageState extends State<PingPage>
controller: _textEditingController, controller: _textEditingController,
hint: l10n.inputDomainHere, hint: l10n.inputDomainHere,
maxLines: 1, maxLines: 1,
suggestion: false,
onSubmitted: (_) => _doPing(), onSubmitted: (_) => _doPing(),
), ),
actions: [ actions: [

View File

@@ -135,6 +135,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
onSubmitted: (_) => _focusScope.requestFocus(_keyNode), onSubmitted: (_) => _focusScope.requestFocus(_keyNode),
label: l10n.name, label: l10n.name,
icon: Icons.info, icon: Icons.info,
suggestion: true,
), ),
Input( Input(
controller: _keyController, controller: _keyController,
@@ -145,6 +146,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
onSubmitted: (_) => _focusScope.requestFocus(_pwdNode), onSubmitted: (_) => _focusScope.requestFocus(_pwdNode),
label: l10n.privateKey, label: l10n.privateKey,
icon: Icons.vpn_key, icon: Icons.vpn_key,
suggestion: false,
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
@@ -181,6 +183,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
obscureText: true, obscureText: true,
label: l10n.pwd, label: l10n.pwd,
icon: Icons.password, icon: Icons.password,
suggestion: false,
onSubmitted: (_) => _onTapSave(), onSubmitted: (_) => _onTapSave(),
), ),
SizedBox(height: MediaQuery.of(context).size.height * 0.1), SizedBox(height: MediaQuery.of(context).size.height * 0.1),

View File

@@ -51,8 +51,7 @@ class _ProcessPageState extends State<ProcessPage> {
Future<void> _refresh() async { Future<void> _refresh() async {
if (mounted) { if (mounted) {
final result = final result = await _client?.run(ShellFunc.process.exec).string;
await _client?.run(ShellFunc.process.exec).string;
if (result == null || result.isEmpty) { if (result == null || result.isEmpty) {
context.showSnackBar(l10n.noResult); context.showSnackBar(l10n.noResult);
return; return;

View File

@@ -196,6 +196,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: l10n.host, label: l10n.host,
icon: BoxIcons.bx_server, icon: BoxIcons.bx_server,
hint: 'example.com', hint: 'example.com',
suggestion: false,
), ),
Input( Input(
controller: _portController, controller: _portController,
@@ -205,6 +206,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: l10n.port, label: l10n.port,
icon: Bootstrap.number_123, icon: Bootstrap.number_123,
hint: '22', hint: '22',
suggestion: false,
), ),
Input( Input(
controller: _usernameController, controller: _usernameController,
@@ -214,6 +216,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: l10n.user, label: l10n.user,
icon: Icons.account_box, icon: Icons.account_box,
hint: 'root', hint: 'root',
suggestion: false,
), ),
Input( Input(
controller: _altUrlController, controller: _altUrlController,
@@ -222,6 +225,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: l10n.fallbackSshDest, label: l10n.fallbackSshDest,
icon: MingCute.link_line, icon: MingCute.link_line,
hint: 'user@ip:port', hint: 'user@ip:port',
suggestion: false,
), ),
TagEditor( TagEditor(
tags: _tags, tags: _tags,
@@ -288,6 +292,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: l10n.pwd, label: l10n.pwd,
icon: Icons.password, icon: Icons.password,
hint: l10n.pwd, hint: l10n.pwd,
suggestion: false,
onSubmitted: (_) => _onSave(), onSubmitted: (_) => _onSave(),
)); ));
} }
@@ -354,6 +359,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
icon: Icons.image, icon: Icons.image,
label: 'URL', label: 'URL',
hint: 'https://example.com/logo.png', hint: 'https://example.com/logo.png',
suggestion: false,
), ),
UIs.height7, UIs.height7,
..._buildPVEs(), ..._buildPVEs(),
@@ -368,6 +374,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: l10n.deviceName, label: l10n.deviceName,
icon: MingCute.low_temperature_line, icon: MingCute.low_temperature_line,
hint: 'nvme-pci-0400', hint: 'nvme-pci-0400',
suggestion: false,
), ),
UIs.height7, UIs.height7,
..._buildWOLs(), ..._buildWOLs(),
@@ -396,6 +403,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
node: node, node: node,
label: 'URL', label: 'URL',
hint: addr, hint: addr,
suggestion: false,
), ),
), ),
ListTile( ListTile(
@@ -429,6 +437,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: 'JSON', label: 'JSON',
icon: Icons.code, icon: Icons.code,
hint: '{${l10n.customCmdHint}}', hint: '{${l10n.customCmdHint}}',
suggestion: false,
), ),
ListTile( ListTile(
leading: const Padding( leading: const Padding(
@@ -460,6 +469,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: 'MAC ${l10n.addr}', label: 'MAC ${l10n.addr}',
icon: Icons.computer, icon: Icons.computer,
hint: '00:11:22:33:44:55', hint: '00:11:22:33:44:55',
suggestion: false,
), ),
Input( Input(
controller: _wolIpCtrl, controller: _wolIpCtrl,
@@ -467,6 +477,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: 'IP ${l10n.addr}', label: 'IP ${l10n.addr}',
icon: Icons.network_cell, icon: Icons.network_cell,
hint: '192.168.1.x', hint: '192.168.1.x',
suggestion: false,
), ),
Input( Input(
controller: _wolPwdCtrl, controller: _wolPwdCtrl,
@@ -475,6 +486,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
label: l10n.pwd, label: l10n.pwd,
icon: Icons.password, icon: Icons.password,
hint: l10n.pwd, hint: l10n.pwd,
suggestion: false,
), ),
]; ];
} }
@@ -620,17 +632,6 @@ class _ServerEditPageState extends State<ServerEditPage> {
wolCfg: wol, 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) { if (widget.spi == null) {
Pros.server.addServer(spi); Pros.server.addServer(spi);
} else { } else {
@@ -645,12 +646,12 @@ class _ServerEditPageState extends State<ServerEditPage> {
leading: const Icon(Icons.tips_and_updates).paddingOnly(left: 13), leading: const Icon(Icons.tips_and_updates).paddingOnly(left: 13),
title: Text(l10n.attention), title: Text(l10n.attention),
onTap: () { onTap: () {
context.showRoundDialog( context.showRoundDialog(
title: l10n.attention, title: l10n.attention,
child: SimpleMarkdown(data: l10n.writeScriptTip), child: SimpleMarkdown(data: l10n.writeScriptTip),
actions: Btns.oks(onTap: () => context.pop(true)), actions: Btns.oks(onTap: () => context.pop(true)),
); );
}, },
trailing: const Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
).cardx; ).cardx;
} }

View File

@@ -270,6 +270,7 @@ class _SettingPageState extends State<SettingPage> {
controller: ctrl, controller: ctrl,
hint: '#8b2252', hint: '#8b2252',
icon: Icons.colorize, icon: Icons.colorize,
suggestion: false,
), ),
ColorPicker( ColorPicker(
color: Color(_setting.primaryColor.fetch()), color: Color(_setting.primaryColor.fetch()),
@@ -784,6 +785,7 @@ class _SettingPageState extends State<SettingPage> {
icon: Icons.format_size, icon: Icons.format_size,
controller: ctrl, controller: ctrl,
onSubmitted: _onSaveTextScaler, onSubmitted: _onSaveTextScaler,
suggestion: false,
), ),
actions: [ actions: [
TextButton( TextButton(
@@ -888,6 +890,7 @@ class _SettingPageState extends State<SettingPage> {
autoFocus: true, autoFocus: true,
type: TextInputType.number, type: TextInputType.number,
icon: Icons.font_download, icon: Icons.font_download,
suggestion: false,
onSubmitted: (_) => onSave(), onSubmitted: (_) => onSave(),
), ),
actions: [ actions: [
@@ -1151,6 +1154,7 @@ class _SettingPageState extends State<SettingPage> {
hint: 'https://example.com/logo.png', hint: 'https://example.com/logo.png',
icon: Icons.link, icon: Icons.link,
maxLines: 2, maxLines: 2,
suggestion: false,
onSubmitted: onSave, onSubmitted: onSave,
), ),
ListTile( ListTile(

View File

@@ -114,6 +114,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
onSubmitted: (_) => FocusScope.of(context).requestFocus(_scriptNode), onSubmitted: (_) => FocusScope.of(context).requestFocus(_scriptNode),
label: l10n.name, label: l10n.name,
icon: Icons.info, icon: Icons.info,
suggestion: true,
), ),
Input( Input(
controller: _noteController, controller: _noteController,
@@ -122,6 +123,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
type: TextInputType.multiline, type: TextInputType.multiline,
label: l10n.note, label: l10n.note,
icon: Icons.note, icon: Icons.note,
suggestion: true,
), ),
ValBuilder( ValBuilder(
listenable: _tags, listenable: _tags,
@@ -146,6 +148,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
type: TextInputType.multiline, type: TextInputType.multiline,
label: l10n.snippet, label: l10n.snippet,
icon: Icons.code, icon: Icons.code,
suggestion: false,
), ),
_buildAutoRunOn(), _buildAutoRunOn(),
_buildTip(), _buildTip(),

View File

@@ -329,6 +329,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
child: Input( child: Input(
autoFocus: true, autoFocus: true,
controller: TextEditingController(text: fileName), controller: TextEditingController(text: fileName),
suggestion: true,
onSubmitted: (p0) { onSubmitted: (p0) {
context.pop(); context.pop();
final newPath = '${file.parent.path}/$p0'; final newPath = '${file.parent.path}/$p0';

View File

@@ -267,6 +267,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
label: l10n.path, label: l10n.path,
node: node, node: node,
controller: controller, controller: controller,
suggestion: true,
onSubmitted: (value) => context.pop(value), onSubmitted: (value) => context.pop(value),
); );
}, },
@@ -617,6 +618,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
icon: Icons.folder, icon: Icons.folder,
controller: textController, controller: textController,
label: l10n.name, label: l10n.name,
suggestion: true,
onSubmitted: (_) => onSubmitted(), onSubmitted: (_) => onSubmitted(),
), ),
actions: [ actions: [
@@ -672,6 +674,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
icon: Icons.insert_drive_file, icon: Icons.insert_drive_file,
controller: textController, controller: textController,
label: l10n.name, label: l10n.name,
suggestion: true,
onSubmitted: (_) => onSubmitted(), onSubmitted: (_) => onSubmitted(),
), ),
actions: [ actions: [
@@ -723,6 +726,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
icon: Icons.abc, icon: Icons.abc,
controller: textController, controller: textController,
label: l10n.name, label: l10n.name,
suggestion: true,
onSubmitted: (_) => onSubmitted(), onSubmitted: (_) => onSubmitted(),
), ),
actions: [ actions: [

View File

@@ -368,8 +368,8 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
path: "." path: "."
ref: "v1.0.34" ref: "v1.0.35"
resolved-ref: "9d8afa6b0bc72223213ca30f67c3be2eb129f928" resolved-ref: "7964acfe55e3e3f5d5232a0c2371cff5fa7edc4c"
url: "https://github.com/lppcg/fl_build.git" url: "https://github.com/lppcg/fl_build.git"
source: git source: git
version: "1.0.0" version: "1.0.0"
@@ -385,8 +385,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "v1.0.77" ref: "v1.0.79"
resolved-ref: "57c4c0187673ea9c38b39889ac467be4a8bbddba" resolved-ref: f1bc7dd5ec2af84813b33a9e2149e117dfea3cd0
url: "https://github.com/lppcg/fl_lib" url: "https://github.com/lppcg/fl_lib"
source: git source: git
version: "0.0.1" version: "0.0.1"

View File

@@ -61,15 +61,17 @@ dependencies:
fl_lib: fl_lib:
git: git:
url: https://github.com/lppcg/fl_lib url: https://github.com/lppcg/fl_lib
ref: v1.0.77 ref: v1.0.79
dependency_overrides: dependency_overrides:
# dartssh2: # dartssh2:
# path: ../dartssh2 # path: ../dartssh2
# fl_lib:
# path: ../fl_lib
# xterm: # xterm:
# path: ../xterm.dart # path: ../xterm.dart
# fl_lib:
# path: ../fl_lib
# fl_build:
# path: ../fl_build
dev_dependencies: dev_dependencies:
flutter_native_splash: ^2.1.6 flutter_native_splash: ^2.1.6
@@ -79,10 +81,9 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
fl_build: fl_build:
# path: ../fl_build
git: git:
url: https://github.com/lppcg/fl_build.git url: https://github.com/lppcg/fl_build.git
ref: v1.0.34 ref: v1.0.35
flutter: flutter:
generate: true generate: true