import 'package:equatable/equatable.dart'; enum GeViScopeConnectionStatus { disconnected, connecting, connected, error, } class MediaChannel { final int channelId; final int globalNumber; final String name; final String description; final bool isActive; const MediaChannel({ required this.channelId, required this.globalNumber, required this.name, required this.description, required this.isActive, }); factory MediaChannel.fromJson(Map json) { return MediaChannel( channelId: json['channelID'] ?? json['channelId'] ?? 0, globalNumber: json['globalNumber'] ?? 0, name: json['name'] ?? '', description: json['description'] ?? '', isActive: json['isActive'] ?? false, ); } } class GeViScopeState extends Equatable { final GeViScopeConnectionStatus connectionStatus; final String? serverAddress; final String? username; final int channelCount; final List channels; final DateTime? connectedAt; final bool isLoading; final String? lastActionResult; final bool lastActionSuccess; final String? errorMessage; final List messageLog; const GeViScopeState({ this.connectionStatus = GeViScopeConnectionStatus.disconnected, this.serverAddress, this.username, this.channelCount = 0, this.channels = const [], this.connectedAt, this.isLoading = false, this.lastActionResult, this.lastActionSuccess = false, this.errorMessage, this.messageLog = const [], }); bool get isConnected => connectionStatus == GeViScopeConnectionStatus.connected; GeViScopeState copyWith({ GeViScopeConnectionStatus? connectionStatus, String? serverAddress, String? username, int? channelCount, List? channels, DateTime? connectedAt, bool? isLoading, String? lastActionResult, bool? lastActionSuccess, String? errorMessage, List? messageLog, bool clearServerAddress = false, bool clearUsername = false, bool clearConnectedAt = false, bool clearErrorMessage = false, bool clearLastActionResult = false, }) { return GeViScopeState( connectionStatus: connectionStatus ?? this.connectionStatus, serverAddress: clearServerAddress ? null : (serverAddress ?? this.serverAddress), username: clearUsername ? null : (username ?? this.username), channelCount: channelCount ?? this.channelCount, channels: channels ?? this.channels, connectedAt: clearConnectedAt ? null : (connectedAt ?? this.connectedAt), isLoading: isLoading ?? this.isLoading, lastActionResult: clearLastActionResult ? null : (lastActionResult ?? this.lastActionResult), lastActionSuccess: lastActionSuccess ?? this.lastActionSuccess, errorMessage: clearErrorMessage ? null : (errorMessage ?? this.errorMessage), messageLog: messageLog ?? this.messageLog, ); } @override List get props => [ connectionStatus, serverAddress, username, channelCount, channels, connectedAt, isLoading, lastActionResult, lastActionSuccess, errorMessage, messageLog, ]; }