find device command
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
@@ -22,18 +21,18 @@ abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel {
|
||||
required String identificator,
|
||||
int? battery,
|
||||
String? userId,
|
||||
@Default({}) Map<String, dynamic> flags,
|
||||
required Map<String, dynamic> flags,
|
||||
String? carrierGenre,
|
||||
String? carrierBirthday,
|
||||
int? carrierBirthday,
|
||||
int? carrierWeight,
|
||||
int? carrierStepLength,
|
||||
required String carrierName,
|
||||
String? phone,
|
||||
@Default({}) Map<String, dynamic> settings,
|
||||
required Map<String, dynamic> settings,
|
||||
required String connectionServer,
|
||||
required String protocol,
|
||||
required String type,
|
||||
required String createdAt,
|
||||
required int createdAt,
|
||||
}) = _GetDevicesItemResponseModel;
|
||||
|
||||
factory GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -43,26 +42,26 @@ abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel {
|
||||
extension GetDevicesResponseModelMapper on GetDevicesResponseModel {
|
||||
List<DeviceEntity> toEntity() {
|
||||
return items
|
||||
.map(
|
||||
(item) => DeviceEntity(
|
||||
id: item.id,
|
||||
identificator: item.identificator,
|
||||
battery: item.battery,
|
||||
userId: item.userId,
|
||||
flags: item.flags,
|
||||
carrierGenre: item.carrierGenre,
|
||||
carrierBirthday: item.carrierBirthday,
|
||||
carrierWeight: item.carrierWeight,
|
||||
carrierStepLength: item.carrierStepLength,
|
||||
carrierName: item.carrierName,
|
||||
phone: item.phone,
|
||||
settings: item.settings,
|
||||
connectionServer: item.connectionServer,
|
||||
protocol: item.protocol,
|
||||
type: item.type,
|
||||
createdAt: item.createdAt,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
.map(
|
||||
(item) => DeviceEntity(
|
||||
id: item.id,
|
||||
identificator: item.identificator,
|
||||
battery: item.battery,
|
||||
userId: item.userId,
|
||||
flags: item.flags,
|
||||
carrierGenre: item.carrierGenre,
|
||||
carrierBirthday: item.carrierBirthday.toString(),
|
||||
carrierWeight: item.carrierWeight,
|
||||
carrierStepLength: item.carrierStepLength,
|
||||
carrierName: item.carrierName,
|
||||
phone: item.phone,
|
||||
settings: item.settings,
|
||||
connectionServer: item.connectionServer,
|
||||
protocol: item.protocol,
|
||||
type: item.type,
|
||||
createdAt: item.createdAt.toString(),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ as List<GetDevicesItemResponseModel>,
|
||||
/// @nodoc
|
||||
mixin _$GetDevicesItemResponseModel {
|
||||
|
||||
String get id; String get identificator; int? get battery; String? get userId; Map<String, dynamic> get flags; String? get carrierGenre; String? get carrierBirthday; int? get carrierWeight; int? get carrierStepLength; String get carrierName; String? get phone; Map<String, dynamic> get settings; String get connectionServer; String get protocol; String get type; String get createdAt;
|
||||
String get id; String get identificator; int? get battery; String? get userId; Map<String, dynamic> get flags; String? get carrierGenre; int? get carrierBirthday; int? get carrierWeight; int? get carrierStepLength; String get carrierName; String? get phone; Map<String, dynamic> get settings; String get connectionServer; String get protocol; String get type; int get createdAt;
|
||||
/// Create a copy of GetDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -317,7 +317,7 @@ abstract mixin class $GetDevicesItemResponseModelCopyWith<$Res> {
|
||||
factory $GetDevicesItemResponseModelCopyWith(GetDevicesItemResponseModel value, $Res Function(GetDevicesItemResponseModel) _then) = _$GetDevicesItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, String? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, String createdAt
|
||||
String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt
|
||||
});
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullab
|
||||
as String?,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
|
||||
as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
|
||||
as String?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
|
||||
as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
|
||||
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
|
||||
as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
@@ -352,7 +352,7 @@ as Map<String, dynamic>,connectionServer: null == connectionServer ? _self.conne
|
||||
as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
|
||||
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, String? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, String createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetDevicesItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
|
||||
@@ -458,7 +458,7 @@ return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.fl
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, String? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, String createdAt) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetDevicesItemResponseModel():
|
||||
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
|
||||
@@ -478,7 +478,7 @@ return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.fl
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, String? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, String createdAt)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetDevicesItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
|
||||
@@ -493,7 +493,7 @@ return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.fl
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
|
||||
const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, final Map<String, dynamic> flags = const {}, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.phone, final Map<String, dynamic> settings = const {}, required this.connectionServer, required this.protocol, required this.type, required this.createdAt}): _flags = flags,_settings = settings;
|
||||
const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, required final Map<String, dynamic> flags, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.phone, required final Map<String, dynamic> settings, required this.connectionServer, required this.protocol, required this.type, required this.createdAt}): _flags = flags,_settings = settings;
|
||||
factory _GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetDevicesItemResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@@ -501,20 +501,20 @@ class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
|
||||
@override final int? battery;
|
||||
@override final String? userId;
|
||||
final Map<String, dynamic> _flags;
|
||||
@override@JsonKey() Map<String, dynamic> get flags {
|
||||
@override Map<String, dynamic> get flags {
|
||||
if (_flags is EqualUnmodifiableMapView) return _flags;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_flags);
|
||||
}
|
||||
|
||||
@override final String? carrierGenre;
|
||||
@override final String? carrierBirthday;
|
||||
@override final int? carrierBirthday;
|
||||
@override final int? carrierWeight;
|
||||
@override final int? carrierStepLength;
|
||||
@override final String carrierName;
|
||||
@override final String? phone;
|
||||
final Map<String, dynamic> _settings;
|
||||
@override@JsonKey() Map<String, dynamic> get settings {
|
||||
@override Map<String, dynamic> get settings {
|
||||
if (_settings is EqualUnmodifiableMapView) return _settings;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_settings);
|
||||
@@ -523,7 +523,7 @@ class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
|
||||
@override final String connectionServer;
|
||||
@override final String protocol;
|
||||
@override final String type;
|
||||
@override final String createdAt;
|
||||
@override final int createdAt;
|
||||
|
||||
/// Create a copy of GetDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -558,7 +558,7 @@ abstract mixin class _$GetDevicesItemResponseModelCopyWith<$Res> implements $Get
|
||||
factory _$GetDevicesItemResponseModelCopyWith(_GetDevicesItemResponseModel value, $Res Function(_GetDevicesItemResponseModel) _then) = __$GetDevicesItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, String? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, String createdAt
|
||||
String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt
|
||||
});
|
||||
|
||||
|
||||
@@ -584,7 +584,7 @@ as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullab
|
||||
as String?,flags: null == flags ? _self._flags : flags // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
|
||||
as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
|
||||
as String?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
|
||||
as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
|
||||
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
|
||||
as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
@@ -593,7 +593,7 @@ as Map<String, dynamic>,connectionServer: null == connectionServer ? _self.conne
|
||||
as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
|
||||
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,18 +27,18 @@ _GetDevicesItemResponseModel _$GetDevicesItemResponseModelFromJson(
|
||||
identificator: json['identificator'] as String,
|
||||
battery: (json['battery'] as num?)?.toInt(),
|
||||
userId: json['userId'] as String?,
|
||||
flags: json['flags'] as Map<String, dynamic>? ?? const {},
|
||||
flags: json['flags'] as Map<String, dynamic>,
|
||||
carrierGenre: json['carrierGenre'] as String?,
|
||||
carrierBirthday: json['carrierBirthday'] as String?,
|
||||
carrierBirthday: (json['carrierBirthday'] as num?)?.toInt(),
|
||||
carrierWeight: (json['carrierWeight'] as num?)?.toInt(),
|
||||
carrierStepLength: (json['carrierStepLength'] as num?)?.toInt(),
|
||||
carrierName: json['carrierName'] as String,
|
||||
phone: json['phone'] as String?,
|
||||
settings: json['settings'] as Map<String, dynamic>? ?? const {},
|
||||
settings: json['settings'] as Map<String, dynamic>,
|
||||
connectionServer: json['connectionServer'] as String,
|
||||
protocol: json['protocol'] as String,
|
||||
type: json['type'] as String,
|
||||
createdAt: json['createdAt'] as String,
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetDevicesItemResponseModelToJson(
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:device_management/src/features/locate_device/presentation/state/locate_device_view_state.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
final locateDeviceViewModelProvider =
|
||||
NotifierProvider.autoDispose<LocateDeviceViewModel, LocateDeviceViewState>(
|
||||
@@ -19,17 +18,22 @@ class LocateDeviceViewModel extends Notifier<LocateDeviceViewState> {
|
||||
LocateDeviceViewState build() {
|
||||
_sendCommandUseCase = ref.read(sendCommandUseCaseProvider);
|
||||
|
||||
state = const LocateDeviceViewState();
|
||||
|
||||
_init();
|
||||
|
||||
return const LocateDeviceViewState();
|
||||
return state;
|
||||
}
|
||||
|
||||
Future<void> _init() async {
|
||||
final selectedDevice = ref.read(selectedDeviceProvider);
|
||||
// setSelectedDevice(selectedDevice);
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(device: selectedDevice);
|
||||
}
|
||||
|
||||
Future<void> locateDevice() async {
|
||||
if (state.isLoading) return;
|
||||
|
||||
try {
|
||||
state = state.copyWith(
|
||||
isLoading: true,
|
||||
@@ -37,7 +41,7 @@ class LocateDeviceViewModel extends Notifier<LocateDeviceViewState> {
|
||||
errorMessage: '',
|
||||
);
|
||||
|
||||
final request = SendCommandRequestModel(deviceName: ''/*state.selectedDevice*/, command: 'FIND_DEVICE');
|
||||
final request = SendCommandRequestModel(device: state.device!.identificator, command: 'FIND_DEVICE');
|
||||
await _sendCommandUseCase.send(request: request);
|
||||
|
||||
state = state.copyWith(
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
part 'locate_device_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LocateDeviceViewState with _$LocateDeviceViewState {
|
||||
const factory LocateDeviceViewState({
|
||||
DeviceEntity? device,
|
||||
@Default(false) bool isLoading,
|
||||
@Default(false) bool isComplete,
|
||||
@Default('') String errorMessage,
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LocateDeviceViewState {
|
||||
|
||||
bool get isLoading; bool get isComplete; String get errorMessage;
|
||||
DeviceEntity? get device; bool get isLoading; bool get isComplete; String get errorMessage;
|
||||
/// Create a copy of LocateDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $LocateDeviceViewStateCopyWith<LocateDeviceViewState> get copyWith => _$LocateDe
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LocateDeviceViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LocateDeviceViewState&&(identical(other.device, device) || other.device == device)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,device,isLoading,isComplete,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LocateDeviceViewState(isLoading: $isLoading, isComplete: $isComplete, errorMessage: $errorMessage)';
|
||||
return 'LocateDeviceViewState(device: $device, isLoading: $isLoading, isComplete: $isComplete, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ abstract mixin class $LocateDeviceViewStateCopyWith<$Res> {
|
||||
factory $LocateDeviceViewStateCopyWith(LocateDeviceViewState value, $Res Function(LocateDeviceViewState) _then) = _$LocateDeviceViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isComplete, String errorMessage
|
||||
DeviceEntity? device, bool isLoading, bool isComplete, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
|
||||
$DeviceEntityCopyWith<$Res>? get device;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@@ -62,15 +62,28 @@ class _$LocateDeviceViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LocateDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? device = freezed,Object? isLoading = null,Object? isComplete = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
device: freezed == device ? _self.device : device // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
/// Create a copy of LocateDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get device {
|
||||
if (_self.device == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.device!, (value) {
|
||||
return _then(_self.copyWith(device: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,10 +165,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( DeviceEntity? device, bool isLoading, bool isComplete, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LocateDeviceViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
return $default(_that.device,_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -173,10 +186,10 @@ return $default(_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( DeviceEntity? device, bool isLoading, bool isComplete, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LocateDeviceViewState():
|
||||
return $default(_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
return $default(_that.device,_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -193,10 +206,10 @@ return $default(_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( DeviceEntity? device, bool isLoading, bool isComplete, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LocateDeviceViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
return $default(_that.device,_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -208,9 +221,10 @@ return $default(_that.isLoading,_that.isComplete,_that.errorMessage);case _:
|
||||
|
||||
|
||||
class _LocateDeviceViewState implements LocateDeviceViewState {
|
||||
const _LocateDeviceViewState({this.isLoading = false, this.isComplete = false, this.errorMessage = ''});
|
||||
const _LocateDeviceViewState({this.device, this.isLoading = false, this.isComplete = false, this.errorMessage = ''});
|
||||
|
||||
|
||||
@override final DeviceEntity? device;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isComplete;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@@ -225,16 +239,16 @@ _$LocateDeviceViewStateCopyWith<_LocateDeviceViewState> get copyWith => __$Locat
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LocateDeviceViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LocateDeviceViewState&&(identical(other.device, device) || other.device == device)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,device,isLoading,isComplete,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LocateDeviceViewState(isLoading: $isLoading, isComplete: $isComplete, errorMessage: $errorMessage)';
|
||||
return 'LocateDeviceViewState(device: $device, isLoading: $isLoading, isComplete: $isComplete, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +259,11 @@ abstract mixin class _$LocateDeviceViewStateCopyWith<$Res> implements $LocateDev
|
||||
factory _$LocateDeviceViewStateCopyWith(_LocateDeviceViewState value, $Res Function(_LocateDeviceViewState) _then) = __$LocateDeviceViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isComplete, String errorMessage
|
||||
DeviceEntity? device, bool isLoading, bool isComplete, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
|
||||
@override $DeviceEntityCopyWith<$Res>? get device;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@@ -262,16 +276,29 @@ class __$LocateDeviceViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LocateDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? device = freezed,Object? isLoading = null,Object? isComplete = null,Object? errorMessage = null,}) {
|
||||
return _then(_LocateDeviceViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
device: freezed == device ? _self.device : device // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of LocateDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get device {
|
||||
if (_self.device == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.device!, (value) {
|
||||
return _then(_self.copyWith(device: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
|
||||
@@ -17,8 +17,8 @@ class LocateDialog extends ConsumerWidget {
|
||||
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||
),
|
||||
width: SizeUtils.getByScreen(small: 360, big: 350),
|
||||
height: SizeUtils.getByScreen(small: 210, big: 205),
|
||||
@@ -31,14 +31,14 @@ class LocateDialog extends ConsumerWidget {
|
||||
fontSize: SizeUtils.getByScreen(small: 25, big: 24),
|
||||
),
|
||||
))),
|
||||
if (viewState.isComplete)
|
||||
if (!viewState.isLoading && viewState.isComplete)
|
||||
Expanded(child: Center(child: Text(context.translate('Sent successfully'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 25, big: 24),
|
||||
),
|
||||
))),
|
||||
if (viewState.errorMessage.isNotEmpty) ...[
|
||||
if (!viewState.isComplete && viewState.errorMessage.isNotEmpty) ...[
|
||||
Expanded(child: Center(child: Text(context.translate('The device is not connected to the Internet'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
|
||||
Reference in New Issue
Block a user