Change ip error refresh button
This commit is contained in:
@@ -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: [
|
||||
|
||||
@@ -40,6 +40,7 @@ class IpInfoNotifier extends _$IpInfoNotifier with AppLogger {
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
if (state is AsyncLoading) return;
|
||||
loggy.debug("refreshing");
|
||||
await ref.read(hapticServiceProvider.notifier).lightImpact();
|
||||
ref.invalidateSelf();
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user