diff --git a/lib/features/proxy/active/active_proxy_footer.dart b/lib/features/proxy/active/active_proxy_footer.dart index 2cd90270..1f855fc4 100644 --- a/lib/features/proxy/active/active_proxy_footer.dart +++ b/lib/features/proxy/active/active_proxy_footer.dart @@ -56,9 +56,18 @@ class ActiveProxyFooter extends HookConsumerWidget { ), ], ), - AsyncError() => _InfoProp( - icon: FluentIcons.error_circle_20_regular, - text: t.general.unknown, + AsyncError() => Row( + children: [ + const Icon(FluentIcons.error_circle_20_regular), + const Gap(8), + IPText.unknown( + onLongPress: () async { + ref + .read(ipInfoNotifierProvider.notifier) + .refresh(); + }, + ), + ], ), _ => const Row( children: [ diff --git a/lib/features/proxy/active/active_proxy_notifier.dart b/lib/features/proxy/active/active_proxy_notifier.dart index 71006acc..f7509983 100644 --- a/lib/features/proxy/active/active_proxy_notifier.dart +++ b/lib/features/proxy/active/active_proxy_notifier.dart @@ -40,6 +40,7 @@ class IpInfoNotifier extends _$IpInfoNotifier with AppLogger { } Future refresh() async { + if (state is AsyncLoading) return; loggy.debug("refreshing"); await ref.read(hapticServiceProvider.notifier).lightImpact(); ref.invalidateSelf(); diff --git a/lib/features/proxy/active/active_proxy_sidebar_card.dart b/lib/features/proxy/active/active_proxy_sidebar_card.dart index f0dc6bd3..a5c230b7 100644 --- a/lib/features/proxy/active/active_proxy_sidebar_card.dart +++ b/lib/features/proxy/active/active_proxy_sidebar_card.dart @@ -86,7 +86,12 @@ class ActiveProxySideBarCard extends HookConsumerWidget { ), _ => buildProp( const Icon(FluentIcons.error_circle_20_regular), - propText(t.general.unknown), + IPText.unknown( + onLongPress: () async { + ref.read(ipInfoNotifierProvider.notifier).refresh(); + }, + constrained: true, + ), ), }, ], diff --git a/lib/features/proxy/active/ip_widget.dart b/lib/features/proxy/active/ip_widget.dart index eeb1fe70..2099248c 100644 --- a/lib/features/proxy/active/ip_widget.dart +++ b/lib/features/proxy/active/ip_widget.dart @@ -12,14 +12,20 @@ final _showIp = StateProvider.autoDispose((ref) { class IPText extends HookConsumerWidget { const IPText({ - required this.ip, - required this.onLongPress, + required String this.ip, + required VoidCallback this.onLongPress, this.constrained = false, super.key, }); - final String ip; - final VoidCallback onLongPress; + const IPText.unknown({ + this.onLongPress, + this.constrained = false, + super.key, + }) : ip = null; + + final String? ip; + final VoidCallback? onLongPress; final bool constrained; @override @@ -32,37 +38,46 @@ class IPText extends HookConsumerWidget { return Semantics( label: t.proxies.ipInfoSemantics.address, child: InkWell( - onTap: () { - ref.read(_showIp.notifier).state = !isVisible; - }, + onTap: ip == null + ? null + : () { + ref.read(_showIp.notifier).state = !isVisible; + }, onLongPress: onLongPress, borderRadius: BorderRadius.circular(12), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 2), - child: AnimatedCrossFade( - firstChild: Text( - ip, - style: ipStyle, - textDirection: TextDirection.ltr, - overflow: TextOverflow.ellipsis, - ), - secondChild: Padding( - padding: constrained - ? EdgeInsets.zero - : const EdgeInsetsDirectional.only(end: 48), - child: Text( - obscureIp(ip), - semanticsLabel: t.general.hidden, - style: ipStyle, - textDirection: TextDirection.ltr, + child: switch (ip) { + final ip? => AnimatedCrossFade( + firstChild: Text( + ip, + style: ipStyle, + textDirection: TextDirection.ltr, + overflow: TextOverflow.ellipsis, + ), + secondChild: Padding( + padding: constrained + ? EdgeInsets.zero + : const EdgeInsetsDirectional.only(end: 48), + child: Text( + obscureIp(ip), + semanticsLabel: t.general.hidden, + style: ipStyle, + textDirection: TextDirection.ltr, + overflow: TextOverflow.ellipsis, + ), + ), + crossFadeState: isVisible + ? CrossFadeState.showFirst + : CrossFadeState.showSecond, + duration: const Duration(milliseconds: 200), + ), + _ => Text( + t.general.unknown, + style: constrained ? textTheme.bodySmall : ipStyle, overflow: TextOverflow.ellipsis, ), - ), - crossFadeState: isVisible - ? CrossFadeState.showFirst - : CrossFadeState.showSecond, - duration: const Duration(milliseconds: 200), - ), + }, ), ), );