mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new & opt.
- new: support suspend and WOL #172 - opt.: `execWithPwd` when cancel - opt.: extentions
This commit is contained in:
@@ -56,7 +56,7 @@ extension DialogX on BuildContext {
|
||||
void showSnippetDialog(
|
||||
void Function(Snippet s) onSelected,
|
||||
) {
|
||||
if (Providers.snippet.snippets.isEmpty) {
|
||||
if (Pros.snippet.snippets.isEmpty) {
|
||||
showRoundDialog(
|
||||
child: Text(l10n.noSavedSnippet),
|
||||
actions: [
|
||||
@@ -76,12 +76,12 @@ extension DialogX on BuildContext {
|
||||
return;
|
||||
}
|
||||
|
||||
var snippet = Providers.snippet.snippets.first;
|
||||
var snippet = Pros.snippet.snippets.first;
|
||||
showRoundDialog(
|
||||
title: Text(l10n.choose),
|
||||
child: Picker(
|
||||
items: Providers.snippet.snippets.map((e) => Text(e.name)).toList(),
|
||||
onSelected: (idx) => snippet = Providers.snippet.snippets[idx],
|
||||
items: Pros.snippet.snippets.map((e) => Text(e.name)).toList(),
|
||||
onSelected: (idx) => snippet = Pros.snippet.snippets[idx],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
|
||||
@@ -74,9 +74,11 @@ extension SSHClientX on SSHClient {
|
||||
if (context == null) return;
|
||||
final pwd = await context.showPwdDialog(user);
|
||||
if (pwd == null || pwd.isEmpty) {
|
||||
return;
|
||||
// Add ctrl + c to exit.
|
||||
sink.add('\x03'.uint8List);
|
||||
} else {
|
||||
sink.add('$pwd\n'.uint8List);
|
||||
}
|
||||
sink.add('$pwd\n'.uint8List);
|
||||
}
|
||||
},
|
||||
onStdout: onStdout,
|
||||
|
||||
@@ -14,52 +14,5 @@ extension StringX on String {
|
||||
return Color(val);
|
||||
}
|
||||
|
||||
int get i => int.parse(this);
|
||||
|
||||
Uri get uri {
|
||||
return Uri.parse(this);
|
||||
}
|
||||
|
||||
Widget omitStartStr({
|
||||
TextStyle? style,
|
||||
TextOverflow? overflow,
|
||||
int? maxLines,
|
||||
}) {
|
||||
return LayoutBuilder(builder: (context, size) {
|
||||
bool exceeded = false;
|
||||
int len = 0;
|
||||
for (; !exceeded && len < length; len++) {
|
||||
// Build the textspan
|
||||
var span = TextSpan(
|
||||
text: 'A' * 7 + substring(length - len),
|
||||
style: style ?? Theme.of(context).textTheme.bodyMedium,
|
||||
);
|
||||
|
||||
// Use a textpainter to determine if it will exceed max lines
|
||||
var tp = TextPainter(
|
||||
maxLines: maxLines ?? 1,
|
||||
textDirection: TextDirection.ltr,
|
||||
text: span,
|
||||
);
|
||||
|
||||
// trigger it to layout
|
||||
tp.layout(maxWidth: size.maxWidth);
|
||||
|
||||
// whether the text overflowed or not
|
||||
exceeded = tp.didExceedMaxLines;
|
||||
}
|
||||
|
||||
return Text(
|
||||
(exceeded ? '...' : '') + substring(length - len),
|
||||
overflow: overflow ?? TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: maxLines ?? 1,
|
||||
style: style,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
String get withLangExport => 'export LANG=en_US.UTF-8 && $this';
|
||||
|
||||
Uint8List get uint8List => Uint8List.fromList(utf8.encode(this));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
||||
return;
|
||||
}
|
||||
|
||||
Providers.app.newestBuild = newest;
|
||||
Pros.app.newestBuild = newest;
|
||||
|
||||
if (!force && newest <= BuildData.build) {
|
||||
Loggers.app.info('Update ignored: ${BuildData.build} >= $newest');
|
||||
|
||||
@@ -19,10 +19,10 @@ Future<bool> shareFiles(List<String> filePaths) async {
|
||||
} else {
|
||||
text = '${filePaths.length} ${l10n.files}';
|
||||
}
|
||||
Providers.app.moveBg = false;
|
||||
Pros.app.moveBg = false;
|
||||
// ignore: deprecated_member_use
|
||||
await Share.shareFiles(filePaths, subject: text);
|
||||
Providers.app.moveBg = true;
|
||||
Pros.app.moveBg = true;
|
||||
return filePaths.isNotEmpty;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ void copy2Clipboard(String text) {
|
||||
}
|
||||
|
||||
Future<String?> pickOneFile() async {
|
||||
Providers.app.moveBg = false;
|
||||
Pros.app.moveBg = false;
|
||||
final result = await FilePicker.platform.pickFiles(type: FileType.any);
|
||||
Providers.app.moveBg = true;
|
||||
Pros.app.moveBg = true;
|
||||
return result?.files.single.path;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,10 @@ import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'misc.dart';
|
||||
import '../extension/stringx.dart';
|
||||
import '../extension/uint8list.dart';
|
||||
|
||||
Future<bool> openUrl(String url) async {
|
||||
return await launchUrl(url.uri, mode: LaunchMode.externalApplication);
|
||||
return await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
|
||||
}
|
||||
|
||||
void setTransparentNavigationBar(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user