opt.: no Tag Switcher on desktop (#932)

This commit is contained in:
lollipopkit🏳️‍⚧️
2025-10-08 21:21:23 +08:00
committed by GitHub
parent 3307fca620
commit bb3e3b4848
6 changed files with 55 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
part of 'tab.dart';
final class _TopBar extends StatelessWidget implements PreferredSizeWidget {
final class _TopBar extends ConsumerWidget implements PreferredSizeWidget {
final ValueNotifier<Set<String>> tags;
final void Function(String) onTagChanged;
final String initTag;
@@ -8,33 +8,53 @@ final class _TopBar extends StatelessWidget implements PreferredSizeWidget {
const _TopBar({required this.initTag, required this.onTagChanged, required this.tags});
@override
Widget build(BuildContext context) {
final isMobile = ResponsiveBreakpoints.of(context).isMobile;
if (!isMobile) return UIs.placeholder;
Widget build(BuildContext context, WidgetRef ref) {
final breakpoints = ResponsiveBreakpoints.of(context);
final isMobile = breakpoints.isMobile;
final padding = EdgeInsets.only(left: isMobile ? 10 : 16, right: isMobile ? 0 : 16);
final Widget leading;
if (isMobile) {
// Keep this btn. For issue #657.
leading = InkWell(
borderRadius: BorderRadius.circular(13),
onTap: () {
SettingsPage.route.go(context);
},
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 7, vertical: 3),
child: Row(
children: [
Text(BuildData.name, style: TextStyle(fontSize: 19)),
SizedBox(width: 5),
Icon(Icons.settings, size: 17),
],
),
),
);
} else {
final servers = ref.watch(serversProvider);
final order = servers.serverOrder;
var connected = 0;
for (final id in order) {
final conn = ref.watch(serverProvider(id).select((value) => value.conn));
if (conn.index >= ServerConn.connected.index) connected++;
}
final total = order.length;
final connectionText = '$connected/$total ${context.l10n.conn}';
leading = Text(
connectionText,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
);
}
return Padding(
padding: const EdgeInsets.only(left: 10),
padding: padding,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Keep this btn. For issue #657.
InkWell(
borderRadius: BorderRadius.circular(13),
onTap: () {
SettingsPage.route.go(context);
},
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 7, vertical: 3),
child: Row(
children: [
Text(BuildData.name, style: TextStyle(fontSize: 19)),
SizedBox(width: 5),
Icon(Icons.settings, size: 17),
],
),
),
),
const SizedBox(width: 30),
leading,
SizedBox(width: isMobile ? 30 : 16),
TagSwitcher(
tags: tags,
onTagChanged: onTagChanged,

View File

@@ -113,11 +113,13 @@ class _ServerOrderPageState extends ConsumerState<ServerOrderPage> {
return const SizedBox();
}
final name = spi.name.characters.firstOrNull ?? '?';
return ListTile(
title: Text(spi.name, style: const TextStyle(fontWeight: FontWeight.w500)),
subtitle: Text(spi.oldId, style: UIs.textGrey),
leading: CircleAvatar(
child: Text(spi.name[0]),
child: Text(name),
),
trailing: ReorderableDragStartListener(index: index, child: const Icon(Icons.drag_handle)),
);