mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: can't quit app
This commit is contained in:
@@ -19,12 +19,12 @@ class SnippetEditPage extends StatefulWidget {
|
||||
|
||||
class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
with AfterLayoutMixin {
|
||||
final nameController = TextEditingController();
|
||||
final scriptController = TextEditingController();
|
||||
final scriptNode = FocusNode();
|
||||
final _nameController = TextEditingController();
|
||||
final _scriptController = TextEditingController();
|
||||
final _scriptNode = FocusNode();
|
||||
|
||||
late SnippetProvider _provider;
|
||||
late S s;
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -35,14 +35,14 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
s = S.of(context);
|
||||
_s = S.of(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(s.edit, style: textSize18),
|
||||
title: Text(_s.edit, style: textSize18),
|
||||
actions: [
|
||||
widget.snippet != null
|
||||
? IconButton(
|
||||
@@ -50,7 +50,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
_provider.del(widget.snippet!);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
tooltip: s.delete,
|
||||
tooltip: _s.delete,
|
||||
icon: const Icon(Icons.delete))
|
||||
: const SizedBox()
|
||||
],
|
||||
@@ -59,30 +59,31 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
padding: const EdgeInsets.all(13),
|
||||
children: [
|
||||
TextField(
|
||||
controller: nameController,
|
||||
controller: _nameController,
|
||||
keyboardType: TextInputType.text,
|
||||
onSubmitted: (_) => FocusScope.of(context).requestFocus(scriptNode),
|
||||
decoration: buildDecoration(s.name, icon: Icons.info),
|
||||
onSubmitted: (_) =>
|
||||
FocusScope.of(context).requestFocus(_scriptNode),
|
||||
decoration: buildDecoration(_s.name, icon: Icons.info),
|
||||
),
|
||||
TextField(
|
||||
controller: scriptController,
|
||||
controller: _scriptController,
|
||||
autocorrect: false,
|
||||
focusNode: scriptNode,
|
||||
focusNode: _scriptNode,
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
keyboardType: TextInputType.text,
|
||||
enableSuggestions: false,
|
||||
decoration: buildDecoration(s.snippet, icon: Icons.code),
|
||||
decoration: buildDecoration(_s.snippet, icon: Icons.code),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.send),
|
||||
onPressed: () {
|
||||
final name = nameController.text;
|
||||
final script = scriptController.text;
|
||||
final name = _nameController.text;
|
||||
final script = _scriptController.text;
|
||||
if (name.isEmpty || script.isEmpty) {
|
||||
showSnackBar(context, Text(s.fieldMustNotEmpty));
|
||||
showSnackBar(context, Text(_s.fieldMustNotEmpty));
|
||||
return;
|
||||
}
|
||||
final snippet = Snippet(name, script);
|
||||
@@ -100,8 +101,8 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
@override
|
||||
void afterFirstLayout(BuildContext context) {
|
||||
if (widget.snippet != null) {
|
||||
nameController.text = widget.snippet!.name;
|
||||
scriptController.text = widget.snippet!.script;
|
||||
_nameController.text = widget.snippet!.name;
|
||||
_scriptController.text = widget.snippet!.script;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,19 +27,19 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
|
||||
final _textStyle = TextStyle(color: primaryColor);
|
||||
|
||||
late S s;
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
s = S.of(context);
|
||||
_s = S.of(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(s.snippet, style: textSize18),
|
||||
title: Text(_s.snippet, style: textSize18),
|
||||
),
|
||||
body: _buildBody(),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
@@ -79,7 +79,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
'snippet edit page')
|
||||
.go(context),
|
||||
child: Text(
|
||||
s.edit,
|
||||
_s.edit,
|
||||
style: _textStyle,
|
||||
),
|
||||
),
|
||||
@@ -93,7 +93,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
run(context, snippet);
|
||||
},
|
||||
child: Text(
|
||||
s.run,
|
||||
_s.run,
|
||||
style: _textStyle,
|
||||
),
|
||||
)
|
||||
@@ -106,7 +106,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
},
|
||||
)
|
||||
: Center(
|
||||
child: Text(s.noSavedSnippet),
|
||||
child: Text(_s.noSavedSnippet),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -115,11 +115,11 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
void _showRunDialog(Snippet snippet) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
s.chooseDestination,
|
||||
_s.chooseDestination,
|
||||
Consumer<ServerProvider>(
|
||||
builder: (_, provider, __) {
|
||||
if (provider.servers.isEmpty) {
|
||||
return Text(s.noServerAvailable);
|
||||
return Text(_s.noServerAvailable);
|
||||
}
|
||||
_selectedIndex = provider.servers.first.info;
|
||||
return SizedBox(
|
||||
@@ -163,11 +163,11 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () async => run(context, snippet),
|
||||
child: Text(s.run),
|
||||
child: Text(_s.run),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.cancel),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -179,12 +179,12 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
if (result != null) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
s.result,
|
||||
_s.result,
|
||||
Text(result, style: const TextStyle(fontSize: 13)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.close),
|
||||
child: Text(_s.close),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user