mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 08:22:16 +03:00
update property names of KeyCustomization
This commit is contained in:
parent
15212af086
commit
9c4e31ef46
@ -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<void> write() async {
|
||||
|
@ -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<String, dynamic> json) =>
|
||||
|
@ -21,9 +21,9 @@ KeyCustomization _$KeyCustomizationFromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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 =>
|
||||
|
@ -10,15 +10,14 @@ _$KeyCustomizationImpl _$$KeyCustomizationImplFromJson(
|
||||
Map<String, dynamic> 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<String, dynamic> _$$KeyCustomizationImplToJson(
|
||||
_$KeyCustomizationImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'serial': instance.serial,
|
||||
'custom_name': instance.customName,
|
||||
'custom_color': const _ColorConverter().toJson(instance.customColor),
|
||||
'name': instance.name,
|
||||
'color': const _ColorConverter().toJson(instance.color),
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -195,7 +195,7 @@ class ThemeNotifier extends Notifier<ThemeData> {
|
||||
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(
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user