2023-07-06 17:18:41 +03:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hiddify/domain/clash/clash.dart';
|
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
|
|
|
|
|
|
class ProxyTile extends HookConsumerWidget {
|
|
|
|
|
const ProxyTile(
|
|
|
|
|
this.proxy, {
|
|
|
|
|
super.key,
|
|
|
|
|
required this.selected,
|
|
|
|
|
required this.onSelect,
|
|
|
|
|
this.delay,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final ClashProxy proxy;
|
|
|
|
|
final bool selected;
|
|
|
|
|
final VoidCallback onSelect;
|
|
|
|
|
final int? delay;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2023-08-19 22:27:23 +03:30
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
|
2023-07-06 17:18:41 +03:30
|
|
|
return ListTile(
|
2023-08-25 13:29:39 +03:30
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
2023-07-06 17:18:41 +03:30
|
|
|
title: Text(
|
2023-08-19 22:27:23 +03:30
|
|
|
switch (proxy) {
|
|
|
|
|
ClashProxyGroup(:final name) => name.toUpperCase(),
|
|
|
|
|
ClashProxyItem(:final name) => name,
|
|
|
|
|
},
|
2023-07-06 17:18:41 +03:30
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
2023-08-19 22:27:23 +03:30
|
|
|
leading: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 6,
|
|
|
|
|
height: double.maxFinite,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
color: selected ? theme.colorScheme.primary : Colors.transparent,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text.rich(
|
|
|
|
|
TextSpan(
|
|
|
|
|
children: [
|
|
|
|
|
TextSpan(text: proxy.type.label),
|
2023-08-25 13:29:39 +03:30
|
|
|
// if (proxy.udp)
|
|
|
|
|
// WidgetSpan(
|
|
|
|
|
// child: Padding(
|
|
|
|
|
// padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
|
|
|
// child: DecoratedBox(
|
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
|
// border: Border.all(
|
|
|
|
|
// color: theme.colorScheme.tertiaryContainer,
|
|
|
|
|
// ),
|
|
|
|
|
// borderRadius: BorderRadius.circular(6),
|
|
|
|
|
// ),
|
|
|
|
|
// child: Text(
|
|
|
|
|
// " UDP ",
|
|
|
|
|
// style: TextStyle(
|
|
|
|
|
// fontSize: theme.textTheme.labelSmall?.fontSize,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
2023-08-19 22:27:23 +03:30
|
|
|
if (proxy case ClashProxyGroup(:final now)) ...[
|
|
|
|
|
TextSpan(text: " ($now)"),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
2023-08-25 13:29:39 +03:30
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-08-19 22:27:23 +03:30
|
|
|
),
|
2023-07-06 17:18:41 +03:30
|
|
|
trailing: delay != null ? Text(delay.toString()) : null,
|
|
|
|
|
selected: selected,
|
|
|
|
|
onTap: onSelect,
|
2023-08-19 22:27:23 +03:30
|
|
|
horizontalTitleGap: 4,
|
2023-07-06 17:18:41 +03:30
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|