From 7a87084b78a8fc4ca1156dc12fa600567696bf36 Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Fri, 27 Oct 2023 13:03:27 +0330 Subject: [PATCH] Add url test delay color --- lib/features/proxies/widgets/proxy_tile.dart | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/features/proxies/widgets/proxy_tile.dart b/lib/features/proxies/widgets/proxy_tile.dart index e4ed134a..9396c730 100644 --- a/lib/features/proxies/widgets/proxy_tile.dart +++ b/lib/features/proxies/widgets/proxy_tile.dart @@ -39,11 +39,30 @@ class ProxyTile extends HookConsumerWidget { proxy.type.label, overflow: TextOverflow.ellipsis, ), - trailing: - proxy.urlTestDelay != 0 ? Text(proxy.urlTestDelay.toString()) : null, + trailing: proxy.urlTestDelay != 0 + ? Text( + proxy.urlTestDelay.toString(), + style: TextStyle(color: delayColor(context, proxy.urlTestDelay)), + ) + : null, selected: selected, onTap: onSelect, horizontalTitleGap: 4, ); } + + Color delayColor(BuildContext context, int delay) { + if (Theme.of(context).brightness == Brightness.dark) { + return switch (delay) { + < 800 => Colors.lightGreen, + < 1500 => Colors.orange, + _ => Colors.redAccent + }; + } + return switch (delay) { + < 800 => Colors.green, + < 1500 => Colors.deepOrangeAccent, + _ => Colors.red + }; + } }