mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: note of Snippet
This commit is contained in:
@@ -890,6 +890,12 @@ abstract class S {
|
||||
/// **'Not selected'**
|
||||
String get notSelected;
|
||||
|
||||
/// No description provided for @note.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Note'**
|
||||
String get note;
|
||||
|
||||
/// No description provided for @nullToken.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -420,6 +420,9 @@ class SDe extends S {
|
||||
@override
|
||||
String get notSelected => 'Nicht ausgewählt';
|
||||
|
||||
@override
|
||||
String get note => 'Hinweis';
|
||||
|
||||
@override
|
||||
String get nullToken => 'Null token';
|
||||
|
||||
|
||||
@@ -420,6 +420,9 @@ class SEn extends S {
|
||||
@override
|
||||
String get notSelected => 'Not selected';
|
||||
|
||||
@override
|
||||
String get note => 'Note';
|
||||
|
||||
@override
|
||||
String get nullToken => 'Null token';
|
||||
|
||||
|
||||
@@ -420,6 +420,9 @@ class SId extends S {
|
||||
@override
|
||||
String get notSelected => 'Tidak terpilih';
|
||||
|
||||
@override
|
||||
String get note => 'Catatan';
|
||||
|
||||
@override
|
||||
String get nullToken => 'Token NULL';
|
||||
|
||||
|
||||
@@ -420,6 +420,9 @@ class SZh extends S {
|
||||
@override
|
||||
String get notSelected => '未选择';
|
||||
|
||||
@override
|
||||
String get note => '备注';
|
||||
|
||||
@override
|
||||
String get nullToken => '无Token';
|
||||
|
||||
@@ -1149,6 +1152,9 @@ class SZhTw extends SZh {
|
||||
@override
|
||||
String get notSelected => '未選擇';
|
||||
|
||||
@override
|
||||
String get note => '備註';
|
||||
|
||||
@override
|
||||
String get nullToken => '無Token';
|
||||
|
||||
|
||||
@@ -12,18 +12,28 @@ class Snippet implements TagPickable {
|
||||
final String script;
|
||||
@HiveField(2)
|
||||
final List<String>? tags;
|
||||
const Snippet(this.name, this.script, this.tags);
|
||||
@HiveField(3)
|
||||
final String? note;
|
||||
|
||||
const Snippet({
|
||||
required this.name,
|
||||
required this.script,
|
||||
this.tags,
|
||||
this.note,
|
||||
});
|
||||
|
||||
Snippet.fromJson(Map<String, dynamic> json)
|
||||
: name = json['name'].toString(),
|
||||
script = json['script'].toString(),
|
||||
tags = json['tags']?.cast<String>();
|
||||
tags = json['tags']?.cast<String>(),
|
||||
note = json['note']?.toString();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['name'] = name;
|
||||
data['script'] = script;
|
||||
data['tags'] = tags;
|
||||
data['note'] = note;
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -38,7 +48,9 @@ class Snippet implements TagPickable {
|
||||
|
||||
/// Snippet for installing ServerBoxMonitor
|
||||
const installSBM = Snippet(
|
||||
'Install ServerBoxMonitor',
|
||||
name: 'Install ServerBoxMonitor',
|
||||
script:
|
||||
'curl -fsSL https://raw.githubusercontent.com/lollipopkit/server_box_monitor/main/install.sh | sh -s -- install',
|
||||
null,
|
||||
tags: ['ServerBoxMonitor'],
|
||||
note: 'One click script to install ServerBoxMonitor',
|
||||
);
|
||||
|
||||
@@ -17,22 +17,25 @@ class SnippetAdapter extends TypeAdapter<Snippet> {
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return Snippet(
|
||||
fields[0] as String,
|
||||
fields[1] as String,
|
||||
(fields[2] as List?)?.cast<String>(),
|
||||
name: fields[0] as String,
|
||||
script: fields[1] as String,
|
||||
tags: (fields[2] as List?)?.cast<String>(),
|
||||
note: fields[3] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, Snippet obj) {
|
||||
writer
|
||||
..writeByte(3)
|
||||
..writeByte(4)
|
||||
..writeByte(0)
|
||||
..write(obj.name)
|
||||
..writeByte(1)
|
||||
..write(obj.script)
|
||||
..writeByte(2)
|
||||
..write(obj.tags);
|
||||
..write(obj.tags)
|
||||
..writeByte(3)
|
||||
..write(obj.note);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -27,6 +27,7 @@ class SettingStore extends PersistentStore {
|
||||
'timeOut',
|
||||
5,
|
||||
);
|
||||
|
||||
/// Duration of [timeout]
|
||||
Duration get timeoutD => Duration(seconds: timeout.fetch());
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"noTask": "Nicht fragen",
|
||||
"noUpdateAvailable": "Kein Update verfügbar",
|
||||
"notSelected": "Nicht ausgewählt",
|
||||
"note": "Hinweis",
|
||||
"nullToken": "Null token",
|
||||
"ok": "OK",
|
||||
"onServerDetailPage": "in Detailansicht des Servers",
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"noTask": "No task",
|
||||
"noUpdateAvailable": "No update available",
|
||||
"notSelected": "Not selected",
|
||||
"note": "Note",
|
||||
"nullToken": "Null token",
|
||||
"ok": "OK",
|
||||
"onServerDetailPage": "On server detail page",
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"noTask": "Tidak bertanya",
|
||||
"noUpdateAvailable": "Tidak ada pembaruan yang tersedia",
|
||||
"notSelected": "Tidak terpilih",
|
||||
"note": "Catatan",
|
||||
"nullToken": "Token NULL",
|
||||
"ok": "OKE",
|
||||
"onServerDetailPage": "Di halaman detail server",
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"noTask": "没有任务",
|
||||
"noUpdateAvailable": "没有可用更新",
|
||||
"notSelected": "未选择",
|
||||
"note": "备注",
|
||||
"nullToken": "无Token",
|
||||
"ok": "好",
|
||||
"onServerDetailPage": "在服务器详情页",
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"noTask": "沒有任務",
|
||||
"noUpdateAvailable": "沒有可用更新",
|
||||
"notSelected": "未選擇",
|
||||
"note": "備註",
|
||||
"nullToken": "無Token",
|
||||
"ok": "好",
|
||||
"onServerDetailPage": "在服務器詳情頁",
|
||||
|
||||
@@ -25,6 +25,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
with AfterLayoutMixin {
|
||||
final _nameController = TextEditingController();
|
||||
final _scriptController = TextEditingController();
|
||||
final _noteController = TextEditingController();
|
||||
final _scriptNode = FocusNode();
|
||||
|
||||
late SnippetProvider _provider;
|
||||
@@ -91,7 +92,13 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
showSnackBar(context, Text(_s.fieldMustNotEmpty));
|
||||
return;
|
||||
}
|
||||
final snippet = Snippet(name, script, _tags);
|
||||
final note = _noteController.text;
|
||||
final snippet = Snippet(
|
||||
name: name,
|
||||
script: script,
|
||||
tags: _tags.isEmpty ? null : _tags,
|
||||
note: note.isEmpty ? null : note,
|
||||
);
|
||||
if (widget.snippet != null) {
|
||||
_provider.update(widget.snippet!, snippet);
|
||||
} else {
|
||||
@@ -115,13 +122,12 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
icon: Icons.info,
|
||||
),
|
||||
Input(
|
||||
controller: _scriptController,
|
||||
node: _scriptNode,
|
||||
controller: _noteController,
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
maxLines: 3,
|
||||
type: TextInputType.multiline,
|
||||
label: _s.snippet,
|
||||
icon: Icons.code,
|
||||
label: _s.note,
|
||||
icon: Icons.note,
|
||||
),
|
||||
TagEditor(
|
||||
tags: _tags,
|
||||
@@ -133,7 +139,16 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
onRenameTag: (old, n) => setState(() {
|
||||
_provider.renameTag(old, n);
|
||||
}),
|
||||
)
|
||||
),
|
||||
Input(
|
||||
controller: _scriptController,
|
||||
node: _scriptNode,
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
type: TextInputType.multiline,
|
||||
label: _s.snippet,
|
||||
icon: Icons.code,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -143,6 +158,10 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
if (widget.snippet != null) {
|
||||
_nameController.text = widget.snippet!.name;
|
||||
_scriptController.text = widget.snippet!.script;
|
||||
if (widget.snippet!.note != null) {
|
||||
_noteController.text = widget.snippet!.note!;
|
||||
}
|
||||
|
||||
if (widget.snippet!.tags != null) {
|
||||
_tags = widget.snippet!.tags!;
|
||||
setState(() {});
|
||||
|
||||
@@ -108,9 +108,9 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
maxLines: 1,
|
||||
),
|
||||
subtitle: Text(
|
||||
snippet.script,
|
||||
snippet.note ?? snippet.script,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
maxLines: 3,
|
||||
style: grey,
|
||||
),
|
||||
trailing: Row(
|
||||
|
||||
Reference in New Issue
Block a user