new & opt.
- new: support suspend and WOL #172 - opt.: `execWithPwd` when cancel - opt.: extentions
This commit is contained in:
52
lib/view/widget/omit_start_text.dart
Normal file
52
lib/view/widget/omit_start_text.dart
Normal 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,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user