new & opt.

- new: support suspend and WOL #172
- opt.: `execWithPwd` when cancel
- opt.: extentions
This commit is contained in:
lollipopkit
2023-09-25 18:51:14 +08:00
parent df84aeb8b2
commit 4d06a52e99
45 changed files with 251 additions and 176 deletions

View File

@@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
class OmitStartText extends StatelessWidget {
final String text;
final int? maxLines;
final TextStyle? style;
final TextOverflow? overflow;
const OmitStartText(
this.text, {
Key? key,
this.maxLines,
this.style,
this.overflow,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, size) {
bool exceeded = false;
int len = 0;
for (; !exceeded && len < text.length; len++) {
// Build the textspan
var span = TextSpan(
text: 'A' * 7 + text.substring(text.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 ? '...' : '') + text.substring(text.length - len),
overflow: overflow ?? TextOverflow.fade,
softWrap: false,
maxLines: maxLines ?? 1,
style: style,
);
});
}
}

View File

@@ -99,14 +99,14 @@ void _onTapMoreBtns(
final snippets = await showDialog<List<Snippet>>(
context: context,
builder: (_) => TagPicker<Snippet>(
items: Providers.snippet.snippets,
tags: Providers.server.tags.toSet(),
items: Pros.snippet.snippets,
tags: Pros.server.tags.toSet(),
),
);
if (snippets == null) {
return;
}
final result = await Providers.server.runSnippets(spi.id, snippets);
final result = await Pros.server.runSnippets(spi.id, snippets);
if (result != null && result.isNotEmpty) {
context.showRoundDialog(
title: Text(l10n.result),
@@ -188,7 +188,7 @@ Future<void> _gotoSSH(
}
bool _checkClient(BuildContext context, String id) {
final server = Providers.server.pick(id: id);
final server = Pros.server.pick(id: id);
if (server == null || server.client == null) {
context.showSnackBar(l10n.waitConnection);
return false;