Change ip error refresh button

This commit is contained in:
problematicconsumer
2024-02-17 12:32:11 +03:30
parent 3541f8e3db
commit 71fb84bea1
4 changed files with 63 additions and 33 deletions

View File

@@ -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: [

View File

@@ -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();

View File

@@ -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,
),
),
},
],

View File

@@ -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,14 +38,17 @@ class IPText extends HookConsumerWidget {
return Semantics(
label: t.proxies.ipInfoSemantics.address,
child: InkWell(
onTap: () {
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(
child: switch (ip) {
final ip? => AnimatedCrossFade(
firstChild: Text(
ip,
style: ipStyle,
@@ -63,6 +72,12 @@ class IPText extends HookConsumerWidget {
: CrossFadeState.showSecond,
duration: const Duration(milliseconds: 200),
),
_ => Text(
t.general.unknown,
style: constrained ? textTheme.bodySmall : ipStyle,
overflow: TextOverflow.ellipsis,
),
},
),
),
);