mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 15:54:35 +01:00
opt.: no app restart required
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
@@ -27,8 +27,6 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
final _noteController = TextEditingController();
|
||||
final _scriptNode = FocusNode();
|
||||
|
||||
late S _s;
|
||||
|
||||
List<String> _tags = [];
|
||||
|
||||
@override
|
||||
@@ -39,17 +37,11 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
_scriptNode.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: Text(_s.edit, style: UIs.textSize18),
|
||||
title: Text(l10n.edit, style: UIs.textSize18),
|
||||
actions: _buildAppBarActions(),
|
||||
),
|
||||
body: _buildBody(),
|
||||
@@ -67,7 +59,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
Providers.snippet.del(widget.snippet!);
|
||||
context.pop();
|
||||
},
|
||||
tooltip: _s.delete,
|
||||
tooltip: l10n.delete,
|
||||
icon: const Icon(Icons.delete),
|
||||
)
|
||||
];
|
||||
@@ -81,7 +73,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
final name = _nameController.text;
|
||||
final script = _scriptController.text;
|
||||
if (name.isEmpty || script.isEmpty) {
|
||||
context.showSnackBar(_s.fieldMustNotEmpty);
|
||||
context.showSnackBar(l10n.fieldMustNotEmpty);
|
||||
return;
|
||||
}
|
||||
final note = _noteController.text;
|
||||
@@ -110,7 +102,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
controller: _nameController,
|
||||
type: TextInputType.text,
|
||||
onSubmitted: (_) => FocusScope.of(context).requestFocus(_scriptNode),
|
||||
label: _s.name,
|
||||
label: l10n.name,
|
||||
icon: Icons.info,
|
||||
),
|
||||
Input(
|
||||
@@ -118,7 +110,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
minLines: 3,
|
||||
maxLines: 3,
|
||||
type: TextInputType.multiline,
|
||||
label: _s.note,
|
||||
label: l10n.note,
|
||||
icon: Icons.note,
|
||||
),
|
||||
TagEditor(
|
||||
@@ -126,7 +118,6 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
onChanged: (p0) => setState(() {
|
||||
_tags = p0;
|
||||
}),
|
||||
s: _s,
|
||||
allTags: [...Providers.server.tags],
|
||||
onRenameTag: (old, n) => setState(() {
|
||||
Providers.server.renameTag(old, n);
|
||||
@@ -138,7 +129,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
type: TextInputType.multiline,
|
||||
label: _s.snippet,
|
||||
label: l10n.snippet,
|
||||
icon: Icons.code,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/order.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
@@ -23,7 +23,6 @@ class SnippetListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SnippetListPageState extends State<SnippetListPage> {
|
||||
late S _s;
|
||||
late MediaQueryData _media;
|
||||
|
||||
String? _tag;
|
||||
@@ -31,7 +30,6 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_s = S.of(context)!;
|
||||
_media = MediaQuery.of(context);
|
||||
}
|
||||
|
||||
@@ -52,7 +50,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
builder: (_, provider, __) {
|
||||
if (provider.snippets.isEmpty) {
|
||||
return Center(
|
||||
child: Text(_s.noSavedSnippet),
|
||||
child: Text(l10n.noSavedSnippet),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,7 +75,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
tags: provider.tags,
|
||||
onTagChanged: (tag) => setState(() => _tag = tag),
|
||||
initTag: _tag,
|
||||
all: _s.all,
|
||||
all: l10n.all,
|
||||
width: _media.size.width,
|
||||
),
|
||||
footer: UIs.height77,
|
||||
@@ -148,12 +146,12 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
results,
|
||||
).entries.map((e) => '${e.key}:\n${e.value}').join('\n');
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.result),
|
||||
title: Text(l10n.result),
|
||||
child: Text(result),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => copy2Clipboard(result),
|
||||
child: Text(_s.copy),
|
||||
child: Text(l10n.copy),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user