mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
@@ -243,11 +243,4 @@ class AppRoutes {
|
|||||||
static AppRoutes pve({Key? key, required ServerPrivateInfo spi}) {
|
static AppRoutes pve({Key? key, required ServerPrivateInfo spi}) {
|
||||||
return AppRoutes(PvePage(key: key, spi: spi), 'pve');
|
return AppRoutes(PvePage(key: key, spi: spi), 'pve');
|
||||||
}
|
}
|
||||||
|
|
||||||
static AppRoutes kvEditor({Key? key, required Map<String, String> data}) {
|
|
||||||
return AppRoutes(
|
|
||||||
KvEditor(key: key, args: KvEditorArgs(data: data)),
|
|
||||||
'kv_editor',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,14 @@ class Snippet implements TagPickable {
|
|||||||
r'${ctrl': TerminalKey.control,
|
r'${ctrl': TerminalKey.control,
|
||||||
r'${alt': TerminalKey.alt,
|
r'${alt': TerminalKey.alt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const example = Snippet(
|
||||||
|
name: 'example',
|
||||||
|
script: 'echo hello',
|
||||||
|
tags: ['tag'],
|
||||||
|
note: 'note',
|
||||||
|
autoRunOn: ['server_id'],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SnippetResult {
|
class SnippetResult {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:fl_lib/fl_lib.dart';
|
import 'package:fl_lib/fl_lib.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:server_box/core/extension/context/locale.dart';
|
import 'package:server_box/core/extension/context/locale.dart';
|
||||||
import 'package:server_box/core/route.dart';
|
|
||||||
import 'package:server_box/core/utils/misc.dart';
|
import 'package:server_box/core/utils/misc.dart';
|
||||||
import 'package:server_box/data/res/store.dart';
|
import 'package:server_box/data/res/store.dart';
|
||||||
import 'package:server_box/view/page/setting/platform/platform_pub.dart';
|
import 'package:server_box/view/page/setting/platform/platform_pub.dart';
|
||||||
@@ -111,8 +110,11 @@ class _IOSSettingsPageState extends State<IOSSettingsPage> {
|
|||||||
|
|
||||||
void _onTapWatchApp(Map<String, dynamic> map) async {
|
void _onTapWatchApp(Map<String, dynamic> map) async {
|
||||||
final urls = Map<String, String>.from(map['urls'] as Map? ?? {});
|
final urls = Map<String, String>.from(map['urls'] as Map? ?? {});
|
||||||
final result = await AppRoutes.kvEditor(data: urls).go(context);
|
final result = await KvEditor.route.go(
|
||||||
if (result == null || result is! Map<String, String>) return;
|
context,
|
||||||
|
args: KvEditorArgs(data: urls),
|
||||||
|
);
|
||||||
|
if (result == null) return;
|
||||||
|
|
||||||
final (suc, err) = await context.showLoadingDialog(fn: () async {
|
final (suc, err) = await context.showLoadingDialog(fn: () async {
|
||||||
await wc.updateApplicationContext({'urls': result});
|
await wc.updateApplicationContext({'urls': result});
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:fl_lib/fl_lib.dart';
|
import 'package:fl_lib/fl_lib.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
import 'package:server_box/core/extension/context/locale.dart';
|
import 'package:server_box/core/extension/context/locale.dart';
|
||||||
import 'package:server_box/data/model/server/snippet.dart';
|
import 'package:server_box/data/model/server/snippet.dart';
|
||||||
import 'package:server_box/data/res/provider.dart';
|
import 'package:server_box/data/res/provider.dart';
|
||||||
|
import 'package:icons_plus/icons_plus.dart';
|
||||||
|
|
||||||
class SnippetEditPage extends StatefulWidget {
|
class SnippetEditPage extends StatefulWidget {
|
||||||
const SnippetEditPage({super.key, this.snippet});
|
const SnippetEditPage({super.key, this.snippet});
|
||||||
@@ -102,8 +105,9 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
|||||||
|
|
||||||
Widget _buildBody() {
|
Widget _buildBody() {
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: const EdgeInsets.all(13),
|
padding: const EdgeInsets.symmetric(horizontal:13),
|
||||||
children: [
|
children: [
|
||||||
|
_buildImport(),
|
||||||
Input(
|
Input(
|
||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
controller: _nameController,
|
controller: _nameController,
|
||||||
@@ -183,6 +187,61 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildImport() {
|
||||||
|
return Btn.tile(
|
||||||
|
text: l10n.import,
|
||||||
|
icon: const Icon(BoxIcons.bx_import),
|
||||||
|
onTap: (c) async {
|
||||||
|
final data = await c.showImportDialog(
|
||||||
|
title: l10n.snippet,
|
||||||
|
modelDef: Snippet.example.toJson(),
|
||||||
|
);
|
||||||
|
if (data == null) return;
|
||||||
|
final str = String.fromCharCodes(data);
|
||||||
|
final list = json.decode(str) as List;
|
||||||
|
if (list.isEmpty) return;
|
||||||
|
final snippets = <Snippet>[];
|
||||||
|
final errs = <String>[];
|
||||||
|
for (final item in list) {
|
||||||
|
try {
|
||||||
|
final snippet = Snippet.fromJson(item);
|
||||||
|
snippets.add(snippet);
|
||||||
|
} catch (e) {
|
||||||
|
errs.add(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (snippets.isEmpty) {
|
||||||
|
c.showSnackBar(libL10n.empty);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (errs.isNotEmpty) {
|
||||||
|
c.showRoundDialog(
|
||||||
|
title: l10n.error,
|
||||||
|
child: SingleChildScrollView(child: Text(errs.join('\n'))),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final snippetNames = snippets.map((e) => e.name).join(', ');
|
||||||
|
c.showRoundDialog(
|
||||||
|
title: l10n.attention,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Text(l10n.askContinue('${l10n.import} [$snippetNames]')),
|
||||||
|
),
|
||||||
|
actions: Btn.ok(
|
||||||
|
onTap: (c) {
|
||||||
|
for (final snippet in snippets) {
|
||||||
|
Pros.snippet.add(snippet);
|
||||||
|
}
|
||||||
|
c.pop();
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
).toList,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildTip() {
|
Widget _buildTip() {
|
||||||
return CardX(
|
return CardX(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|||||||
@@ -385,8 +385,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "v1.0.105"
|
ref: "v1.0.106"
|
||||||
resolved-ref: "0804b1363d451b6d25028ca393f552fbe1a32690"
|
resolved-ref: "31735eee1d42e6bcb6c3ccd061047401b4a23421"
|
||||||
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"
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ dependencies:
|
|||||||
fl_lib:
|
fl_lib:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/lppcg/fl_lib
|
url: https://github.com/lppcg/fl_lib
|
||||||
ref: v1.0.105
|
ref: v1.0.106
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
# dartssh2:
|
# dartssh2:
|
||||||
|
|||||||
Reference in New Issue
Block a user