yay ASv2 removed

This commit is contained in:
ivan2282
2025-11-19 19:19:28 +03:00
parent 575c43ce63
commit 3388b78f8c
6 changed files with 340 additions and 1087 deletions

View File

@@ -4,7 +4,7 @@ import 'dart:async';
import '../connection/connection_logger.dart';
import '../connection/connection_state.dart' as conn_state;
import '../connection/health_monitor.dart';
import '../api_service_v2.dart';
import 'package:gwid/api/api_service.dart';
class ConnectionDebugPanel extends StatefulWidget {
@@ -39,7 +39,7 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
void _setupSubscriptions() {
_logsSubscription = Stream.periodic(const Duration(seconds: 1))
.asyncMap((_) async => ApiServiceV2.instance.logs.take(100).toList())
.asyncMap((_) async => ApiService.instance.logs.take(100).toList())
.listen((logs) {
if (mounted) {
setState(() {
@@ -49,7 +49,7 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
});
_stateSubscription = ApiServiceV2.instance.connectionState.listen((state) {
_stateSubscription = ApiService.instance.connectionState.listen((state) {
if (mounted) {
setState(() {
_stateHistory.add(state);
@@ -61,7 +61,7 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
});
_healthSubscription = ApiServiceV2.instance.healthMetrics.listen((health) {
_healthSubscription = ApiService.instance.healthMetrics.listen((health) {
if (mounted) {
setState(() {
_healthMetrics.add(health);
@@ -93,7 +93,7 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 10,
offset: const Offset(0, -5),
),
@@ -113,7 +113,7 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
color: Theme.of(context).colorScheme.primary.withValues(alpha: 0.1),
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Row(
@@ -223,10 +223,10 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: _getLogColor(log.level).withOpacity(0.1),
color: _getLogColor(log.level).withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: _getLogColor(log.level).withOpacity(0.3),
color: _getLogColor(log.level).withValues(alpha: 0.3),
width: 1,
),
),
@@ -297,10 +297,10 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: _getStateColor(state.state).withOpacity(0.1),
color: _getStateColor(state.state).withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: _getStateColor(state.state).withOpacity(0.3),
color: _getStateColor(state.state).withValues(alpha: 0.3),
width: 1,
),
),
@@ -372,10 +372,10 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
margin: const EdgeInsets.all(8),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: _getHealthColor(health.quality).withOpacity(0.1),
color: _getHealthColor(health.quality).withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: _getHealthColor(health.quality).withOpacity(0.3),
color: _getHealthColor(health.quality).withValues(alpha: 0.3),
width: 1,
),
),
@@ -444,7 +444,7 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.2),
),
),
child: const Center(
@@ -455,7 +455,7 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
Widget _buildStatsTab() {
return FutureBuilder<Map<String, dynamic>>(
future: ApiServiceV2.instance
future: ApiService.instance
.getStatistics(), // Указываем Future, который нужно ожидать
builder: (context, snapshot) {
@@ -667,7 +667,12 @@ class _ConnectionDebugPanelState extends State<ConnectionDebugPanel>
}
void _clearLogs() {
ConnectionLogger().clearLogs();
if (mounted) {
setState(() {
_logs = [];
});
}
}
void _exportLogs() {

View File

@@ -3,7 +3,9 @@ import 'dart:async';
import '../connection/connection_state.dart' as conn_state;
import '../connection/health_monitor.dart';
import '../api_service_v2.dart';
import 'package:gwid/api/api_service.dart';
class ConnectionStatusWidget extends StatefulWidget {
@@ -37,7 +39,7 @@ class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
}
void _setupSubscriptions() {
_stateSubscription = ApiServiceV2.instance.connectionState.listen((state) {
_stateSubscription = ApiService.instance.connectionState.listen((state) {
if (mounted) {
setState(() {
_currentState = state;
@@ -46,7 +48,7 @@ class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
});
if (widget.showHealthMetrics) {
_healthSubscription = ApiServiceV2.instance.healthMetrics.listen((
_healthSubscription = ApiService.instance.healthMetrics.listen((
health,
) {
if (mounted) {
@@ -77,10 +79,10 @@ class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: _getStatusColor().withOpacity(0.1),
color: _getStatusColor().withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: _getStatusColor().withOpacity(0.3),
color: _getStatusColor().withValues(alpha: 0.3),
width: 1,
),
),
@@ -125,7 +127,7 @@ class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: _getStatusColor().withOpacity(0.5),
color: _getStatusColor().withValues(alpha: 0.5),
blurRadius: 4,
spreadRadius: 1,
),
@@ -177,7 +179,7 @@ class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
Text(
'$label: ',
style: TextStyle(
color: _getStatusColor().withOpacity(0.7),
color: _getStatusColor().withValues(alpha: 0.7),
fontSize: 10,
),
),
@@ -200,9 +202,9 @@ class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: _getHealthColor().withOpacity(0.1),
color: _getHealthColor().withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: _getHealthColor().withOpacity(0.3), width: 1),
border: Border.all(color: _getHealthColor().withValues(alpha: 0.3), width: 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -233,7 +235,7 @@ class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
return Container(
height: 4,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.2),
color: Colors.grey.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(2),
),
child: FractionallySizedBox(
@@ -348,7 +350,7 @@ class _ConnectionIndicatorState extends State<ConnectionIndicator> {
@override
Widget build(BuildContext context) {
return StreamBuilder<conn_state.ConnectionInfo>(
stream: ApiServiceV2.instance.connectionState,
stream: ApiService.instance.connectionState,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return SizedBox(
@@ -382,11 +384,11 @@ class _ConnectionIndicatorState extends State<ConnectionIndicator> {
width: widget.size,
height: widget.size,
decoration: BoxDecoration(
color: color.withOpacity(0.3 + (0.7 * value)),
color: color.withValues(alpha: 0.3 + (0.7 * value)),
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: color.withOpacity(0.5 * value),
color: color.withValues(alpha: 0.5 * value),
blurRadius: 8 * value,
spreadRadius: 2 * value,
),
@@ -412,7 +414,7 @@ class _ConnectionIndicatorState extends State<ConnectionIndicator> {
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: color.withOpacity(0.5),
color: color.withValues(alpha: 0.5),
blurRadius: 4,
spreadRadius: 1,
),