|
|
|
|
@ -353,85 +353,91 @@ class _RelayListItem extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Card(
|
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
// Relay URL and status
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
// Status indicator
|
|
|
|
|
// Enabled means connected - if it's enabled but not connected, it should be disabled
|
|
|
|
|
Container(
|
|
|
|
|
width: 12,
|
|
|
|
|
height: 12,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
color: relay.isConnected && relay.isEnabled
|
|
|
|
|
? Colors.green
|
|
|
|
|
: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
// Status indicator
|
|
|
|
|
Container(
|
|
|
|
|
width: 10,
|
|
|
|
|
height: 10,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
color: relay.isConnected && relay.isEnabled
|
|
|
|
|
? Colors.green
|
|
|
|
|
: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
// URL and status text
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
relay.url,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
// Status text
|
|
|
|
|
// Enabled means connected - if it's enabled but not connected, it should be disabled
|
|
|
|
|
Text(
|
|
|
|
|
relay.isConnected && relay.isEnabled
|
|
|
|
|
? 'Connected'
|
|
|
|
|
: 'Disabled',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: relay.isConnected && relay.isEnabled
|
|
|
|
|
? Colors.green
|
|
|
|
|
: Colors.grey,
|
|
|
|
|
const SizedBox(height: 2),
|
|
|
|
|
Text(
|
|
|
|
|
relay.isConnected && relay.isEnabled
|
|
|
|
|
? 'Connected'
|
|
|
|
|
: 'Disabled',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
color: relay.isConnected && relay.isEnabled
|
|
|
|
|
? Colors.green
|
|
|
|
|
: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
// Action buttons
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
// Toggle switch
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
// Toggle switch
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
relay.isEnabled ? 'On' : 'Off',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: Colors.grey[600],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
Switch(
|
|
|
|
|
value: relay.isEnabled,
|
|
|
|
|
onChanged: (_) => onToggle(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
Text(
|
|
|
|
|
relay.isEnabled ? 'ON' : 'OFF',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
color: relay.isEnabled
|
|
|
|
|
? Colors.green
|
|
|
|
|
: Colors.grey[600],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
// Remove button
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.delete, size: 20),
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
tooltip: 'Remove',
|
|
|
|
|
onPressed: onRemove,
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
Transform.scale(
|
|
|
|
|
scale: 0.8,
|
|
|
|
|
child: Switch(
|
|
|
|
|
value: relay.isEnabled,
|
|
|
|
|
onChanged: (_) => onToggle(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
// Remove button
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.delete, size: 18),
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
tooltip: 'Remove',
|
|
|
|
|
onPressed: onRemove,
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
constraints: const BoxConstraints(
|
|
|
|
|
minWidth: 32,
|
|
|
|
|
minHeight: 32,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|