connection button by proxy status indicator, change connected to connecting when timeout
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/widget/animated_visibility.dart';
|
||||
import 'package:hiddify/core/widget/shimmer_skeleton.dart';
|
||||
import 'package:hiddify/features/connection/model/connection_status.dart';
|
||||
import 'package:hiddify/features/proxy/active/active_proxy_notifier.dart';
|
||||
import 'package:hiddify/features/system_tray/notifier/system_tray_notifier.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:tray_manager/tray_manager.dart';
|
||||
|
||||
class ActiveProxyDelayIndicator extends HookConsumerWidget {
|
||||
const ActiveProxyDelayIndicator({super.key});
|
||||
@@ -24,17 +29,15 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget {
|
||||
case AsyncData(value: final proxy):
|
||||
final delay = proxy.urlTestDelay;
|
||||
final timeout = delay > 65000;
|
||||
|
||||
return Center(
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
await ref
|
||||
.read(activeProxyNotifierProvider.notifier)
|
||||
.urlTest(proxy.tag);
|
||||
await ref.read(activeProxyNotifierProvider.notifier).urlTest(proxy.tag);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -42,9 +45,7 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget {
|
||||
const Gap(8),
|
||||
if (delay > 0)
|
||||
Text.rich(
|
||||
semanticsLabel: timeout
|
||||
? t.proxies.delaySemantics.timeout
|
||||
: t.proxies.delaySemantics.result(delay: delay),
|
||||
semanticsLabel: timeout ? t.proxies.delaySemantics.timeout : t.proxies.delaySemantics.result(delay: delay),
|
||||
TextSpan(
|
||||
children: [
|
||||
if (timeout)
|
||||
@@ -58,8 +59,7 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget {
|
||||
else ...[
|
||||
TextSpan(
|
||||
text: delay.toString(),
|
||||
style: theme.textTheme.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
style: theme.textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const TextSpan(text: " ms"),
|
||||
],
|
||||
|
||||
@@ -78,11 +78,11 @@ class IpInfoNotifier extends _$IpInfoNotifier with AppLogger {
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
@Riverpod(keepAlive: true)
|
||||
class ActiveProxyNotifier extends _$ActiveProxyNotifier with AppLogger {
|
||||
@override
|
||||
Stream<ProxyItemEntity> build() async* {
|
||||
ref.disposeDelay(const Duration(seconds: 20));
|
||||
// ref.disposeDelay(const Duration(seconds: 20));
|
||||
|
||||
final serviceRunning = await ref.watch(serviceRunningProvider.future);
|
||||
if (!serviceRunning) {
|
||||
|
||||
Reference in New Issue
Block a user