From 9c4e31ef460e3bb53c68e1e07b25682f3b0b09b0 Mon Sep 17 00:00:00 2001 From: Adam Velebil Date: Wed, 24 Jan 2024 11:14:55 +0100 Subject: [PATCH] update property names of KeyCustomization --- .../key_customization/key_customization.dart | 9 ++- lib/app/key_customization/models.dart | 4 +- lib/app/key_customization/models.freezed.dart | 72 ++++++++----------- lib/app/key_customization/models.g.dart | 9 ++- .../views/key_customization_dialog.dart | 8 +-- lib/app/state.dart | 2 +- lib/app/views/device_picker.dart | 6 +- 7 files changed, 49 insertions(+), 61 deletions(-) diff --git a/lib/app/key_customization/key_customization.dart b/lib/app/key_customization/key_customization.dart index ab40b861..9139385b 100644 --- a/lib/app/key_customization/key_customization.dart +++ b/lib/app/key_customization/key_customization.dart @@ -51,11 +51,10 @@ class KeyCustomizationManager { return _customizations[serial]; } - void set({required String serial, String? customName, Color? customColor}) { - _log.debug( - 'Setting key customization for $serial: $customName, $customColor'); - _customizations[serial] = KeyCustomization( - serial: serial, customName: customName, customColor: customColor); + void set({required String serial, String? name, Color? color}) { + _log.debug('Setting key customization for $serial: $name, $color'); + _customizations[serial] = + KeyCustomization(serial: serial, name: name, color: color); } Future write() async { diff --git a/lib/app/key_customization/models.dart b/lib/app/key_customization/models.dart index 1d2bf4bf..794f6d3d 100644 --- a/lib/app/key_customization/models.dart +++ b/lib/app/key_customization/models.dart @@ -26,8 +26,8 @@ part 'models.g.dart'; class KeyCustomization with _$KeyCustomization { factory KeyCustomization({ required String serial, - String? customName, - @_ColorConverter() Color? customColor, + String? name, + @_ColorConverter() Color? color, }) = _KeyCustomization; factory KeyCustomization.fromJson(Map json) => diff --git a/lib/app/key_customization/models.freezed.dart b/lib/app/key_customization/models.freezed.dart index ce2945da..351def15 100644 --- a/lib/app/key_customization/models.freezed.dart +++ b/lib/app/key_customization/models.freezed.dart @@ -21,9 +21,9 @@ KeyCustomization _$KeyCustomizationFromJson(Map json) { /// @nodoc mixin _$KeyCustomization { String get serial => throw _privateConstructorUsedError; - String? get customName => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; @_ColorConverter() - Color? get customColor => throw _privateConstructorUsedError; + Color? get color => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -37,10 +37,7 @@ abstract class $KeyCustomizationCopyWith<$Res> { KeyCustomization value, $Res Function(KeyCustomization) then) = _$KeyCustomizationCopyWithImpl<$Res, KeyCustomization>; @useResult - $Res call( - {String serial, - String? customName, - @_ColorConverter() Color? customColor}); + $Res call({String serial, String? name, @_ColorConverter() Color? color}); } /// @nodoc @@ -57,21 +54,21 @@ class _$KeyCustomizationCopyWithImpl<$Res, $Val extends KeyCustomization> @override $Res call({ Object? serial = null, - Object? customName = freezed, - Object? customColor = freezed, + Object? name = freezed, + Object? color = freezed, }) { return _then(_value.copyWith( serial: null == serial ? _value.serial : serial // ignore: cast_nullable_to_non_nullable as String, - customName: freezed == customName - ? _value.customName - : customName // ignore: cast_nullable_to_non_nullable + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable as String?, - customColor: freezed == customColor - ? _value.customColor - : customColor // ignore: cast_nullable_to_non_nullable + color: freezed == color + ? _value.color + : color // ignore: cast_nullable_to_non_nullable as Color?, ) as $Val); } @@ -85,10 +82,7 @@ abstract class _$$KeyCustomizationImplCopyWith<$Res> __$$KeyCustomizationImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {String serial, - String? customName, - @_ColorConverter() Color? customColor}); + $Res call({String serial, String? name, @_ColorConverter() Color? color}); } /// @nodoc @@ -103,21 +97,21 @@ class __$$KeyCustomizationImplCopyWithImpl<$Res> @override $Res call({ Object? serial = null, - Object? customName = freezed, - Object? customColor = freezed, + Object? name = freezed, + Object? color = freezed, }) { return _then(_$KeyCustomizationImpl( serial: null == serial ? _value.serial : serial // ignore: cast_nullable_to_non_nullable as String, - customName: freezed == customName - ? _value.customName - : customName // ignore: cast_nullable_to_non_nullable + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable as String?, - customColor: freezed == customColor - ? _value.customColor - : customColor // ignore: cast_nullable_to_non_nullable + color: freezed == color + ? _value.color + : color // ignore: cast_nullable_to_non_nullable as Color?, )); } @@ -127,9 +121,7 @@ class __$$KeyCustomizationImplCopyWithImpl<$Res> @JsonSerializable() class _$KeyCustomizationImpl implements _KeyCustomization { _$KeyCustomizationImpl( - {required this.serial, - this.customName, - @_ColorConverter() this.customColor}); + {required this.serial, this.name, @_ColorConverter() this.color}); factory _$KeyCustomizationImpl.fromJson(Map json) => _$$KeyCustomizationImplFromJson(json); @@ -137,14 +129,14 @@ class _$KeyCustomizationImpl implements _KeyCustomization { @override final String serial; @override - final String? customName; + final String? name; @override @_ColorConverter() - final Color? customColor; + final Color? color; @override String toString() { - return 'KeyCustomization(serial: $serial, customName: $customName, customColor: $customColor)'; + return 'KeyCustomization(serial: $serial, name: $name, color: $color)'; } @override @@ -153,15 +145,13 @@ class _$KeyCustomizationImpl implements _KeyCustomization { (other.runtimeType == runtimeType && other is _$KeyCustomizationImpl && (identical(other.serial, serial) || other.serial == serial) && - (identical(other.customName, customName) || - other.customName == customName) && - (identical(other.customColor, customColor) || - other.customColor == customColor)); + (identical(other.name, name) || other.name == name) && + (identical(other.color, color) || other.color == color)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, serial, customName, customColor); + int get hashCode => Object.hash(runtimeType, serial, name, color); @JsonKey(ignore: true) @override @@ -181,8 +171,8 @@ class _$KeyCustomizationImpl implements _KeyCustomization { abstract class _KeyCustomization implements KeyCustomization { factory _KeyCustomization( {required final String serial, - final String? customName, - @_ColorConverter() final Color? customColor}) = _$KeyCustomizationImpl; + final String? name, + @_ColorConverter() final Color? color}) = _$KeyCustomizationImpl; factory _KeyCustomization.fromJson(Map json) = _$KeyCustomizationImpl.fromJson; @@ -190,10 +180,10 @@ abstract class _KeyCustomization implements KeyCustomization { @override String get serial; @override - String? get customName; + String? get name; @override @_ColorConverter() - Color? get customColor; + Color? get color; @override @JsonKey(ignore: true) _$$KeyCustomizationImplCopyWith<_$KeyCustomizationImpl> get copyWith => diff --git a/lib/app/key_customization/models.g.dart b/lib/app/key_customization/models.g.dart index a3d11a64..c5768daa 100644 --- a/lib/app/key_customization/models.g.dart +++ b/lib/app/key_customization/models.g.dart @@ -10,15 +10,14 @@ _$KeyCustomizationImpl _$$KeyCustomizationImplFromJson( Map json) => _$KeyCustomizationImpl( serial: json['serial'] as String, - customName: json['custom_name'] as String?, - customColor: - const _ColorConverter().fromJson(json['custom_color'] as int?), + name: json['name'] as String?, + color: const _ColorConverter().fromJson(json['color'] as int?), ); Map _$$KeyCustomizationImplToJson( _$KeyCustomizationImpl instance) => { 'serial': instance.serial, - 'custom_name': instance.customName, - 'custom_color': const _ColorConverter().toJson(instance.customColor), + 'name': instance.name, + 'color': const _ColorConverter().toJson(instance.color), }; diff --git a/lib/app/key_customization/views/key_customization_dialog.dart b/lib/app/key_customization/views/key_customization_dialog.dart index 618869dd..82d07395 100644 --- a/lib/app/key_customization/views/key_customization_dialog.dart +++ b/lib/app/key_customization/views/key_customization_dialog.dart @@ -52,8 +52,8 @@ class _KeyCustomizationDialogState @override void initState() { super.initState(); - _customName = widget.initialCustomization?.customName; - _customColor = widget.initialCustomization?.customColor; + _customName = widget.initialCustomization?.name; + _customColor = widget.initialCustomization?.color; } @override @@ -100,8 +100,8 @@ class _KeyCustomizationDialogState final manager = ref.read(keyCustomizationManagerProvider); manager.set( serial: widget.initialCustomization!.serial, - customName: _customName, - customColor: _customColor); + name: _customName, + color: _customColor); await manager.write(); ref.invalidate(lightThemeProvider); diff --git a/lib/app/state.dart b/lib/app/state.dart index 6abc22c3..43840386 100755 --- a/lib/app/state.dart +++ b/lib/app/state.dart @@ -195,7 +195,7 @@ class ThemeNotifier extends Notifier { if (yubiKeyData != null) { final manager = ref.read(keyCustomizationManagerProvider); final customization = manager.get(yubiKeyData.info.serial?.toString()); - primaryColor = customization?.customColor ?? color; + primaryColor = customization?.color ?? color; if (primaryColor != null) { // remember the last used color prefs.setString( diff --git a/lib/app/views/device_picker.dart b/lib/app/views/device_picker.dart index 8647cb2a..837d09e2 100644 --- a/lib/app/views/device_picker.dart +++ b/lib/app/views/device_picker.dart @@ -417,7 +417,7 @@ _DeviceRow _buildDeviceRow( final keyCustomization = ref.read(keyCustomizationManagerProvider).get(info?.serial?.toString()); - String displayName = keyCustomization?.customName ?? node.name; + String displayName = keyCustomization?.name ?? node.name; return _DeviceRow( key: ValueKey(node.path.key), @@ -453,8 +453,8 @@ _DeviceRow _buildCurrentDeviceRow( final keyCustomization = ref.read(keyCustomizationManagerProvider).get(serialNumber); - String displayName = keyCustomization?.customName ?? title; - Color? displayColor = keyCustomization?.customColor; + String displayName = keyCustomization?.name ?? title; + Color? displayColor = keyCustomization?.color; return _DeviceRow( key: keys.deviceInfoListTile,