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,6 +1,6 @@
|
||||
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/data/res/provider.dart';
|
||||
|
||||
import '../../../data/model/server/snippet.dart';
|
||||
@@ -41,37 +41,35 @@ extension DialogX on BuildContext {
|
||||
String? user,
|
||||
) async {
|
||||
if (!mounted) return null;
|
||||
final s = S.of(this)!;
|
||||
return await showRoundDialog<String>(
|
||||
title: Text(user ?? s.pwd),
|
||||
title: Text(user ?? l10n.pwd),
|
||||
child: Input(
|
||||
autoFocus: true,
|
||||
type: TextInputType.visiblePassword,
|
||||
obscureText: true,
|
||||
onSubmitted: (val) => pop(val.trim()),
|
||||
label: s.pwd,
|
||||
label: l10n.pwd,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showSnippetDialog(
|
||||
S s,
|
||||
void Function(Snippet s) onSelected,
|
||||
) {
|
||||
if (Providers.snippet.snippets.isEmpty) {
|
||||
showRoundDialog(
|
||||
child: Text(s.noSavedSnippet),
|
||||
child: Text(l10n.noSavedSnippet),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => pop(),
|
||||
child: Text(s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
pop();
|
||||
AppRoute.snippetEdit().go(this);
|
||||
},
|
||||
child: Text(s.add),
|
||||
child: Text(l10n.add),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -80,7 +78,7 @@ extension DialogX on BuildContext {
|
||||
|
||||
var snippet = Providers.snippet.snippets.first;
|
||||
showRoundDialog(
|
||||
title: Text(s.choose),
|
||||
title: Text(l10n.choose),
|
||||
child: Picker(
|
||||
items: Providers.snippet.snippets.map((e) => Text(e.name)).toList(),
|
||||
onSelected: (idx) => snippet = Providers.snippet.snippets[idx],
|
||||
@@ -91,7 +89,7 @@ extension DialogX on BuildContext {
|
||||
pop();
|
||||
onSelected(snippet);
|
||||
},
|
||||
child: Text(s.ok),
|
||||
child: Text(l10n.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
7
lib/core/extension/context/locale.dart
Normal file
7
lib/core/extension/context/locale.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
late S _s;
|
||||
S get l10n => _s;
|
||||
set l10n(S s) {
|
||||
_s = s;
|
||||
}
|
||||
Reference in New Issue
Block a user