Files
plezy/lib/widgets/server_list_tile.dart
T

104 lines
3.3 KiB
Dart
Raw Normal View History

2025-10-18 00:05:20 +02:00
import 'package:flutter/material.dart';
import '../services/plex_auth_service.dart';
2025-11-10 10:02:34 +01:00
import '../i18n/strings.g.dart';
2025-10-18 00:05:20 +02:00
class ServerListTile extends StatelessWidget {
final PlexServer server;
final VoidCallback onTap;
final bool showTrailingIcon;
2025-10-30 18:49:59 +01:00
final bool isCurrentServer;
2025-10-18 00:05:20 +02:00
const ServerListTile({
super.key,
required this.server,
required this.onTap,
this.showTrailingIcon = true,
2025-10-30 18:49:59 +01:00
this.isCurrentServer = false,
2025-10-18 00:05:20 +02:00
});
@override
Widget build(BuildContext context) {
final isOnline = server.isOnline;
2025-11-01 05:50:24 +01:00
return Semantics(
selected: isCurrentServer,
identifier: server.name,
label: server.name,
child: ListTile(
key: ValueKey(server.name),
leading: Icon(
Icons.dns,
color: isOnline
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.5),
2025-11-10 10:02:34 +01:00
semanticLabel: t.common.server,
2025-11-01 05:50:24 +01:00
),
title: Text(server.name),
subtitle: Semantics(
label:
2025-11-10 10:02:34 +01:00
'${isOnline ? t.common.online : t.common.offline}, ${server.owned ? t.common.owned : t.common.shared}',
2025-11-01 05:50:24 +01:00
excludeSemantics: true,
child: Row(
children: [
Semantics(
excludeSemantics: true,
child: Icon(
isOnline ? Icons.circle : Icons.circle_outlined,
size: 10,
color: isOnline ? Colors.green : Colors.grey,
),
2025-10-30 18:49:59 +01:00
),
2025-11-01 05:50:24 +01:00
const SizedBox(width: 4),
Text(
2025-11-10 10:02:34 +01:00
isOnline ? t.common.online : t.common.offline,
2025-10-30 18:49:59 +01:00
style: TextStyle(
2025-11-01 05:50:24 +01:00
fontSize: 12,
color: isOnline ? Colors.green : Colors.grey,
2025-10-30 18:49:59 +01:00
),
),
2025-11-01 05:50:24 +01:00
const SizedBox(width: 8),
Semantics(
excludeSemantics: true,
child: Text(
'•',
style: TextStyle(
fontSize: 12,
color: Theme.of(
context,
).colorScheme.onSurface.withValues(alpha: 0.5),
),
),
),
const SizedBox(width: 8),
Text(
2025-11-10 10:02:34 +01:00
server.owned ? t.common.owned : t.common.shared,
2025-11-01 05:50:24 +01:00
style: const TextStyle(fontSize: 12),
),
],
),
),
trailing: isCurrentServer
? Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
borderRadius: BorderRadius.circular(12),
),
child: Text(
2025-11-10 10:02:34 +01:00
t.common.current,
2025-11-01 05:50:24 +01:00
style: TextStyle(
fontSize: 10,
color: Theme.of(context).colorScheme.onPrimary,
fontWeight: FontWeight.bold,
letterSpacing: 0.5,
),
),
)
: (showTrailingIcon ? const Icon(Icons.chevron_right) : null),
onTap: isCurrentServer ? null : onTap,
enabled: !isCurrentServer,
),
2025-10-18 00:05:20 +02:00
);
}
}