Change ip error refresh button
This commit is contained in:
@@ -56,9 +56,18 @@ class ActiveProxyFooter extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
AsyncError() => _InfoProp(
|
AsyncError() => Row(
|
||||||
icon: FluentIcons.error_circle_20_regular,
|
children: [
|
||||||
text: t.general.unknown,
|
const Icon(FluentIcons.error_circle_20_regular),
|
||||||
|
const Gap(8),
|
||||||
|
IPText.unknown(
|
||||||
|
onLongPress: () async {
|
||||||
|
ref
|
||||||
|
.read(ipInfoNotifierProvider.notifier)
|
||||||
|
.refresh();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
_ => const Row(
|
_ => const Row(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class IpInfoNotifier extends _$IpInfoNotifier with AppLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
|
if (state is AsyncLoading) return;
|
||||||
loggy.debug("refreshing");
|
loggy.debug("refreshing");
|
||||||
await ref.read(hapticServiceProvider.notifier).lightImpact();
|
await ref.read(hapticServiceProvider.notifier).lightImpact();
|
||||||
ref.invalidateSelf();
|
ref.invalidateSelf();
|
||||||
|
|||||||
@@ -86,7 +86,12 @@ class ActiveProxySideBarCard extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
_ => buildProp(
|
_ => buildProp(
|
||||||
const Icon(FluentIcons.error_circle_20_regular),
|
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 {
|
class IPText extends HookConsumerWidget {
|
||||||
const IPText({
|
const IPText({
|
||||||
required this.ip,
|
required String this.ip,
|
||||||
required this.onLongPress,
|
required VoidCallback this.onLongPress,
|
||||||
this.constrained = false,
|
this.constrained = false,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String ip;
|
const IPText.unknown({
|
||||||
final VoidCallback onLongPress;
|
this.onLongPress,
|
||||||
|
this.constrained = false,
|
||||||
|
super.key,
|
||||||
|
}) : ip = null;
|
||||||
|
|
||||||
|
final String? ip;
|
||||||
|
final VoidCallback? onLongPress;
|
||||||
final bool constrained;
|
final bool constrained;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -32,37 +38,46 @@ class IPText extends HookConsumerWidget {
|
|||||||
return Semantics(
|
return Semantics(
|
||||||
label: t.proxies.ipInfoSemantics.address,
|
label: t.proxies.ipInfoSemantics.address,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: ip == null
|
||||||
ref.read(_showIp.notifier).state = !isVisible;
|
? null
|
||||||
},
|
: () {
|
||||||
|
ref.read(_showIp.notifier).state = !isVisible;
|
||||||
|
},
|
||||||
onLongPress: onLongPress,
|
onLongPress: onLongPress,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||||
child: AnimatedCrossFade(
|
child: switch (ip) {
|
||||||
firstChild: Text(
|
final ip? => AnimatedCrossFade(
|
||||||
ip,
|
firstChild: Text(
|
||||||
style: ipStyle,
|
ip,
|
||||||
textDirection: TextDirection.ltr,
|
style: ipStyle,
|
||||||
overflow: TextOverflow.ellipsis,
|
textDirection: TextDirection.ltr,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
secondChild: Padding(
|
),
|
||||||
padding: constrained
|
secondChild: Padding(
|
||||||
? EdgeInsets.zero
|
padding: constrained
|
||||||
: const EdgeInsetsDirectional.only(end: 48),
|
? EdgeInsets.zero
|
||||||
child: Text(
|
: const EdgeInsetsDirectional.only(end: 48),
|
||||||
obscureIp(ip),
|
child: Text(
|
||||||
semanticsLabel: t.general.hidden,
|
obscureIp(ip),
|
||||||
style: ipStyle,
|
semanticsLabel: t.general.hidden,
|
||||||
textDirection: TextDirection.ltr,
|
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,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
},
|
||||||
crossFadeState: isVisible
|
|
||||||
? CrossFadeState.showFirst
|
|
||||||
: CrossFadeState.showSecond,
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user