Merge branch 'lollipopkit:main' into main

This commit is contained in:
Thomas
2023-05-12 15:30:17 +02:00
committed by GitHub
12 changed files with 165 additions and 95 deletions

View File

@@ -103,7 +103,7 @@ class _MyHomePageState extends State<MyHomePage>
return Scaffold(
drawer: _buildDrawer(),
appBar: AppBar(
title: Text(tabTitleName(context, _selectIndex)),
title: const Text(BuildData.name),
actions: [
IconButton(
icon: const Icon(Icons.developer_mode, size: 23),

View File

@@ -83,7 +83,7 @@ class _ServerPageState extends State<ServerPage>
await _serverProvider.refreshData(onlyFailed: true),
child: Consumer<ServerProvider>(
builder: (_, pro, __) {
if (pro.servers.isEmpty) {
if (pro.serverOrder.isEmpty) {
return Center(
child: Text(
_s.serverTabEmpty,
@@ -91,21 +91,16 @@ class _ServerPageState extends State<ServerPage>
),
);
}
final keys = pro.servers.keys.toList();
return ListView.separated(
return ReorderableListView(
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (ctx, idx) {
if (idx == pro.servers.length) {
return SizedBox(height: _media.padding.bottom);
}
return _buildEachServerCard(pro.servers[keys[idx]]);
},
itemCount: pro.servers.length,
separatorBuilder: (_, __) => const SizedBox(
height: 3,
),
onReorder: (oldIndex, newIndex) => setState(() {
pro.serverOrder.move(oldIndex, newIndex);
}),
children: pro.serverOrder
.where((e) => pro.servers.containsKey(e))
.map((e) => _buildEachServerCard(pro.servers[e]))
.toList(),
);
},
),
@@ -116,21 +111,18 @@ class _ServerPageState extends State<ServerPage>
if (si == null) {
return const SizedBox();
}
return GestureDetector(
onLongPress: () => AppRoute(
ServerEditPage(spi: si.spi),
'Edit server info page',
).go(context),
child: RoundRectCard(
Padding(
return RoundRectCard(
GestureDetector(
child: Padding(
padding: const EdgeInsets.all(13),
child: _buildRealServerCard(si.status, si.spi.name, si.state, si.spi),
),
onTap: () => AppRoute(
ServerDetailPage(si.spi.id),
'server detail page',
).go(context),
),
onTap: () => AppRoute(
ServerDetailPage(si.spi.id),
'server detail page',
).go(context),
key: Key(si.spi.id),
);
}
@@ -177,8 +169,8 @@ class _ServerPageState extends State<ServerPage>
child: Text(ss.failedInfo ?? _s.unknownError),
actions: [
TextButton(
onPressed: () =>
copy(ss.failedInfo ?? _s.unknownError),
onPressed: () => copy2Clipboard(
ss.failedInfo ?? _s.unknownError),
child: Text(_s.copy),
)
],

View File

@@ -427,7 +427,7 @@ class _SettingPageState extends State<SettingPage> {
padding: EdgeInsets.zero,
onPressed: () {
if (_pushToken != null) {
copy(_pushToken!);
copy2Clipboard(_pushToken!);
showSnackBar(context, Text(_s.success));
} else {
showSnackBar(context, Text(_s.getPushTokenFailed));
@@ -453,9 +453,10 @@ class _SettingPageState extends State<SettingPage> {
}
Widget _buildFont() {
final fontName = getFileName(_setting.fontPath.fetch());
return ListTile(
title: Text(_s.chooseFontFile),
trailing: Text(getFileName(_setting.fontPath.fetch()) ?? _s.notSelected),
title: Text(_s.choose),
trailing: Text(fontName ?? _s.notSelected),
onTap: () {
showRoundDialog(
context: context,

View File

@@ -222,7 +222,10 @@ class _SSHPageState extends State<SSHPage> {
_paste();
break;
case VirtualKeyFunc.copy:
copy(terminalSelected);
final selected = terminalSelected;
if (selected != null) {
copy2Clipboard(selected);
}
break;
case VirtualKeyFunc.snippet:
showSnippetDialog(context, _s, (s) {
@@ -241,10 +244,10 @@ class _SSHPageState extends State<SSHPage> {
});
}
String get terminalSelected {
String? get terminalSelected {
final range = _terminalController.selection;
if (range == null) {
return '';
return null;
}
return _terminal.buffer.getText(range);
}
@@ -255,29 +258,30 @@ class _SSHPageState extends State<SSHPage> {
return;
}
final selected = terminalSelected;
if (selected.trim().isEmpty) {
// _menuController.show(
// context: context,
// contextMenuBuilder: (context) {
// return TextSelectionToolbar(
// anchorAbove: details.globalPosition,
// anchorBelow: details.globalPosition,
// children: [
// TextButton(
// child: Text(
// _s.paste,
// style: _menuTextStyle,
// ),
// onPressed: () async {
// _paste();
// _menuController.remove();
// },
// )
// ],
// );
// },
// );
return;
final children = <Widget>[
TextButton(
onPressed: () {
_paste();
},
child: Text(_s.paste),
),
];
if (selected?.trim().isNotEmpty ?? false) {
children.add(
TextButton(
child: Text(
_s.copy,
style: _menuTextStyle,
),
onPressed: () {
_terminalController.setSelection(null);
if (selected != null) {
copy2Clipboard(selected);
}
_menuController.remove();
},
),
);
}
_menuController.show(
context: context,
@@ -285,19 +289,7 @@ class _SSHPageState extends State<SSHPage> {
return TextSelectionToolbar(
anchorAbove: details.globalPosition,
anchorBelow: details.globalPosition,
children: [
TextButton(
child: Text(
_s.copy,
style: _menuTextStyle,
),
onPressed: () {
_terminalController.setSelection(null);
copy(selected);
_menuController.remove();
},
),
],
children: children,
);
},
);