Improve temporary state

This commit is contained in:
CodeDoctorDE
2024-12-28 15:12:35 +01:00
parent 463a446a5c
commit 4b24340bd2
32 changed files with 497 additions and 446 deletions

View File

@ -43,6 +43,8 @@ enum SelectMode { rectangle, lasso }
enum LaserAnimation { fade, path }
enum ToolCategory { normal, import, surface, action, view }
@Freezed(equal: false)
sealed class Tool with _$Tool {
Tool._();
@ -190,10 +192,50 @@ sealed class Tool with _$Tool {
@Default(SurfaceTexture.pattern()) SurfaceTexture texture,
}) = TextureTool;
factory Tool.ruler({
@Default('') String name,
@Default('') String displayIcon,
@Default(SRGBColor.black) @ColorJsonConverter() SRGBColor gridColor,
}) = RulerTool;
factory Tool.grid({
@Default('') String name,
@Default('') String displayIcon,
@Default(SRGBColor.black) @ColorJsonConverter() SRGBColor color,
@Default(20) double xSize,
@Default(20) double ySize,
}) = GridTool;
factory Tool.eyeDropper({
@Default('') String name,
@Default('') String displayIcon,
}) = EyeDropperTool;
factory Tool.fromJson(Map<String, dynamic> json) => _$ToolFromJson(json);
ToolCategory get category => switch (this) {
SelectTool() => ToolCategory.normal,
HandTool() => ToolCategory.normal,
ImportTool() => ToolCategory.import,
UndoTool() => ToolCategory.action,
RedoTool() => ToolCategory.action,
LabelTool() => ToolCategory.normal,
PenTool() => ToolCategory.normal,
EraserTool() => ToolCategory.normal,
PathEraserTool() => ToolCategory.normal,
CollectionTool() => ToolCategory.normal,
AreaTool() => ToolCategory.normal,
LaserTool() => ToolCategory.normal,
ShapeTool() => ToolCategory.surface,
StampTool() => ToolCategory.surface,
PresentationTool() => ToolCategory.normal,
SpacerTool() => ToolCategory.normal,
FullScreenTool() => ToolCategory.action,
AssetTool() => ToolCategory.import,
ExportTool() => ToolCategory.action,
TextureTool() => ToolCategory.surface,
RulerTool() => ToolCategory.view,
GridTool() => ToolCategory.view,
EyeDropperTool() => ToolCategory.action,
};
}

View File

@ -56,6 +56,10 @@ Tool _$ToolFromJson(Map<String, dynamic> json) {
return ExportTool.fromJson(json);
case 'texture':
return TextureTool.fromJson(json);
case 'ruler':
return RulerTool.fromJson(json);
case 'grid':
return GridTool.fromJson(json);
case 'eyeDropper':
return EyeDropperTool.fromJson(json);
@ -2785,6 +2789,272 @@ abstract class TextureTool extends Tool {
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$RulerToolImplCopyWith<$Res> implements $ToolCopyWith<$Res> {
factory _$$RulerToolImplCopyWith(
_$RulerToolImpl value, $Res Function(_$RulerToolImpl) then) =
__$$RulerToolImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String name,
String displayIcon,
@ColorJsonConverter() SRGBColor gridColor});
}
/// @nodoc
class __$$RulerToolImplCopyWithImpl<$Res>
extends _$ToolCopyWithImpl<$Res, _$RulerToolImpl>
implements _$$RulerToolImplCopyWith<$Res> {
__$$RulerToolImplCopyWithImpl(
_$RulerToolImpl _value, $Res Function(_$RulerToolImpl) _then)
: super(_value, _then);
/// Create a copy of Tool
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? displayIcon = null,
Object? gridColor = null,
}) {
return _then(_$RulerToolImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
displayIcon: null == displayIcon
? _value.displayIcon
: displayIcon // ignore: cast_nullable_to_non_nullable
as String,
gridColor: null == gridColor
? _value.gridColor
: gridColor // ignore: cast_nullable_to_non_nullable
as SRGBColor,
));
}
}
/// @nodoc
@JsonSerializable()
class _$RulerToolImpl extends RulerTool {
_$RulerToolImpl(
{this.name = '',
this.displayIcon = '',
@ColorJsonConverter() this.gridColor = SRGBColor.black,
final String? $type})
: $type = $type ?? 'ruler',
super._();
factory _$RulerToolImpl.fromJson(Map<String, dynamic> json) =>
_$$RulerToolImplFromJson(json);
@override
@JsonKey()
final String name;
@override
@JsonKey()
final String displayIcon;
@override
@JsonKey()
@ColorJsonConverter()
final SRGBColor gridColor;
@JsonKey(name: 'type')
final String $type;
@override
String toString() {
return 'Tool.ruler(name: $name, displayIcon: $displayIcon, gridColor: $gridColor)';
}
/// Create a copy of Tool
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$RulerToolImplCopyWith<_$RulerToolImpl> get copyWith =>
__$$RulerToolImplCopyWithImpl<_$RulerToolImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$RulerToolImplToJson(
this,
);
}
}
abstract class RulerTool extends Tool {
factory RulerTool(
{final String name,
final String displayIcon,
@ColorJsonConverter() final SRGBColor gridColor}) = _$RulerToolImpl;
RulerTool._() : super._();
factory RulerTool.fromJson(Map<String, dynamic> json) =
_$RulerToolImpl.fromJson;
@override
String get name;
@override
String get displayIcon;
@ColorJsonConverter()
SRGBColor get gridColor;
/// Create a copy of Tool
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$RulerToolImplCopyWith<_$RulerToolImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$GridToolImplCopyWith<$Res> implements $ToolCopyWith<$Res> {
factory _$$GridToolImplCopyWith(
_$GridToolImpl value, $Res Function(_$GridToolImpl) then) =
__$$GridToolImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String name,
String displayIcon,
@ColorJsonConverter() SRGBColor color,
double xSize,
double ySize});
}
/// @nodoc
class __$$GridToolImplCopyWithImpl<$Res>
extends _$ToolCopyWithImpl<$Res, _$GridToolImpl>
implements _$$GridToolImplCopyWith<$Res> {
__$$GridToolImplCopyWithImpl(
_$GridToolImpl _value, $Res Function(_$GridToolImpl) _then)
: super(_value, _then);
/// Create a copy of Tool
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? displayIcon = null,
Object? color = null,
Object? xSize = null,
Object? ySize = null,
}) {
return _then(_$GridToolImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
displayIcon: null == displayIcon
? _value.displayIcon
: displayIcon // ignore: cast_nullable_to_non_nullable
as String,
color: null == color
? _value.color
: color // ignore: cast_nullable_to_non_nullable
as SRGBColor,
xSize: null == xSize
? _value.xSize
: xSize // ignore: cast_nullable_to_non_nullable
as double,
ySize: null == ySize
? _value.ySize
: ySize // ignore: cast_nullable_to_non_nullable
as double,
));
}
}
/// @nodoc
@JsonSerializable()
class _$GridToolImpl extends GridTool {
_$GridToolImpl(
{this.name = '',
this.displayIcon = '',
@ColorJsonConverter() this.color = SRGBColor.black,
this.xSize = 20,
this.ySize = 20,
final String? $type})
: $type = $type ?? 'grid',
super._();
factory _$GridToolImpl.fromJson(Map<String, dynamic> json) =>
_$$GridToolImplFromJson(json);
@override
@JsonKey()
final String name;
@override
@JsonKey()
final String displayIcon;
@override
@JsonKey()
@ColorJsonConverter()
final SRGBColor color;
@override
@JsonKey()
final double xSize;
@override
@JsonKey()
final double ySize;
@JsonKey(name: 'type')
final String $type;
@override
String toString() {
return 'Tool.grid(name: $name, displayIcon: $displayIcon, color: $color, xSize: $xSize, ySize: $ySize)';
}
/// Create a copy of Tool
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GridToolImplCopyWith<_$GridToolImpl> get copyWith =>
__$$GridToolImplCopyWithImpl<_$GridToolImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$GridToolImplToJson(
this,
);
}
}
abstract class GridTool extends Tool {
factory GridTool(
{final String name,
final String displayIcon,
@ColorJsonConverter() final SRGBColor color,
final double xSize,
final double ySize}) = _$GridToolImpl;
GridTool._() : super._();
factory GridTool.fromJson(Map<String, dynamic> json) =
_$GridToolImpl.fromJson;
@override
String get name;
@override
String get displayIcon;
@ColorJsonConverter()
SRGBColor get color;
double get xSize;
double get ySize;
/// Create a copy of Tool
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GridToolImplCopyWith<_$GridToolImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$EyeDropperToolImplCopyWith<$Res>
implements $ToolCopyWith<$Res> {

View File

@ -424,6 +424,45 @@ Map<String, dynamic> _$$TextureToolImplToJson(_$TextureToolImpl instance) =>
'type': instance.$type,
};
_$RulerToolImpl _$$RulerToolImplFromJson(Map json) => _$RulerToolImpl(
name: json['name'] as String? ?? '',
displayIcon: json['displayIcon'] as String? ?? '',
gridColor: json['gridColor'] == null
? SRGBColor.black
: const ColorJsonConverter()
.fromJson((json['gridColor'] as num).toInt()),
$type: json['type'] as String?,
);
Map<String, dynamic> _$$RulerToolImplToJson(_$RulerToolImpl instance) =>
<String, dynamic>{
'name': instance.name,
'displayIcon': instance.displayIcon,
'gridColor': const ColorJsonConverter().toJson(instance.gridColor),
'type': instance.$type,
};
_$GridToolImpl _$$GridToolImplFromJson(Map json) => _$GridToolImpl(
name: json['name'] as String? ?? '',
displayIcon: json['displayIcon'] as String? ?? '',
color: json['color'] == null
? SRGBColor.black
: const ColorJsonConverter().fromJson((json['color'] as num).toInt()),
xSize: (json['xSize'] as num?)?.toDouble() ?? 20,
ySize: (json['ySize'] as num?)?.toDouble() ?? 20,
$type: json['type'] as String?,
);
Map<String, dynamic> _$$GridToolImplToJson(_$GridToolImpl instance) =>
<String, dynamic>{
'name': instance.name,
'displayIcon': instance.displayIcon,
'color': const ColorJsonConverter().toJson(instance.color),
'xSize': instance.xSize,
'ySize': instance.ySize,
'type': instance.$type,
};
_$EyeDropperToolImpl _$$EyeDropperToolImplFromJson(Map json) =>
_$EyeDropperToolImpl(
name: json['name'] as String? ?? '',

View File

@ -1,6 +1,3 @@
import 'dart:math';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'utilities.g.dart';
@ -13,13 +10,7 @@ sealed class UtilitiesState with _$UtilitiesState {
@Default(false) bool lockZoom,
@Default(false) bool lockHorizontal,
@Default(false) bool lockVertical,
@Default(false) bool rulerEnabled,
@Default(false) bool gridEnabled,
@Default(false) bool fullSelection,
@DoublePointJsonConverter()
@Default(Point(0.0, 0.0))
Point<double> rulerPosition,
@Default(0) double rulerAngle,
}) = _UtilitiesState;
factory UtilitiesState.fromJson(Map<String, dynamic> json) =>

View File

@ -24,12 +24,7 @@ mixin _$UtilitiesState {
bool get lockZoom => throw _privateConstructorUsedError;
bool get lockHorizontal => throw _privateConstructorUsedError;
bool get lockVertical => throw _privateConstructorUsedError;
bool get rulerEnabled => throw _privateConstructorUsedError;
bool get gridEnabled => throw _privateConstructorUsedError;
bool get fullSelection => throw _privateConstructorUsedError;
@DoublePointJsonConverter()
Point<double> get rulerPosition => throw _privateConstructorUsedError;
double get rulerAngle => throw _privateConstructorUsedError;
/// Serializes this UtilitiesState to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@ -52,11 +47,7 @@ abstract class $UtilitiesStateCopyWith<$Res> {
bool lockZoom,
bool lockHorizontal,
bool lockVertical,
bool rulerEnabled,
bool gridEnabled,
bool fullSelection,
@DoublePointJsonConverter() Point<double> rulerPosition,
double rulerAngle});
bool fullSelection});
}
/// @nodoc
@ -78,11 +69,7 @@ class _$UtilitiesStateCopyWithImpl<$Res, $Val extends UtilitiesState>
Object? lockZoom = null,
Object? lockHorizontal = null,
Object? lockVertical = null,
Object? rulerEnabled = null,
Object? gridEnabled = null,
Object? fullSelection = null,
Object? rulerPosition = null,
Object? rulerAngle = null,
}) {
return _then(_value.copyWith(
lockCollection: null == lockCollection
@ -101,26 +88,10 @@ class _$UtilitiesStateCopyWithImpl<$Res, $Val extends UtilitiesState>
? _value.lockVertical
: lockVertical // ignore: cast_nullable_to_non_nullable
as bool,
rulerEnabled: null == rulerEnabled
? _value.rulerEnabled
: rulerEnabled // ignore: cast_nullable_to_non_nullable
as bool,
gridEnabled: null == gridEnabled
? _value.gridEnabled
: gridEnabled // ignore: cast_nullable_to_non_nullable
as bool,
fullSelection: null == fullSelection
? _value.fullSelection
: fullSelection // ignore: cast_nullable_to_non_nullable
as bool,
rulerPosition: null == rulerPosition
? _value.rulerPosition
: rulerPosition // ignore: cast_nullable_to_non_nullable
as Point<double>,
rulerAngle: null == rulerAngle
? _value.rulerAngle
: rulerAngle // ignore: cast_nullable_to_non_nullable
as double,
) as $Val);
}
}
@ -138,11 +109,7 @@ abstract class _$$UtilitiesStateImplCopyWith<$Res>
bool lockZoom,
bool lockHorizontal,
bool lockVertical,
bool rulerEnabled,
bool gridEnabled,
bool fullSelection,
@DoublePointJsonConverter() Point<double> rulerPosition,
double rulerAngle});
bool fullSelection});
}
/// @nodoc
@ -162,11 +129,7 @@ class __$$UtilitiesStateImplCopyWithImpl<$Res>
Object? lockZoom = null,
Object? lockHorizontal = null,
Object? lockVertical = null,
Object? rulerEnabled = null,
Object? gridEnabled = null,
Object? fullSelection = null,
Object? rulerPosition = null,
Object? rulerAngle = null,
}) {
return _then(_$UtilitiesStateImpl(
lockCollection: null == lockCollection
@ -185,26 +148,10 @@ class __$$UtilitiesStateImplCopyWithImpl<$Res>
? _value.lockVertical
: lockVertical // ignore: cast_nullable_to_non_nullable
as bool,
rulerEnabled: null == rulerEnabled
? _value.rulerEnabled
: rulerEnabled // ignore: cast_nullable_to_non_nullable
as bool,
gridEnabled: null == gridEnabled
? _value.gridEnabled
: gridEnabled // ignore: cast_nullable_to_non_nullable
as bool,
fullSelection: null == fullSelection
? _value.fullSelection
: fullSelection // ignore: cast_nullable_to_non_nullable
as bool,
rulerPosition: null == rulerPosition
? _value.rulerPosition
: rulerPosition // ignore: cast_nullable_to_non_nullable
as Point<double>,
rulerAngle: null == rulerAngle
? _value.rulerAngle
: rulerAngle // ignore: cast_nullable_to_non_nullable
as double,
));
}
}
@ -217,11 +164,7 @@ class _$UtilitiesStateImpl implements _UtilitiesState {
this.lockZoom = false,
this.lockHorizontal = false,
this.lockVertical = false,
this.rulerEnabled = false,
this.gridEnabled = false,
this.fullSelection = false,
@DoublePointJsonConverter() this.rulerPosition = const Point(0.0, 0.0),
this.rulerAngle = 0});
this.fullSelection = false});
factory _$UtilitiesStateImpl.fromJson(Map<String, dynamic> json) =>
_$$UtilitiesStateImplFromJson(json);
@ -240,24 +183,11 @@ class _$UtilitiesStateImpl implements _UtilitiesState {
final bool lockVertical;
@override
@JsonKey()
final bool rulerEnabled;
@override
@JsonKey()
final bool gridEnabled;
@override
@JsonKey()
final bool fullSelection;
@override
@JsonKey()
@DoublePointJsonConverter()
final Point<double> rulerPosition;
@override
@JsonKey()
final double rulerAngle;
@override
String toString() {
return 'UtilitiesState(lockCollection: $lockCollection, lockZoom: $lockZoom, lockHorizontal: $lockHorizontal, lockVertical: $lockVertical, rulerEnabled: $rulerEnabled, gridEnabled: $gridEnabled, fullSelection: $fullSelection, rulerPosition: $rulerPosition, rulerAngle: $rulerAngle)';
return 'UtilitiesState(lockCollection: $lockCollection, lockZoom: $lockZoom, lockHorizontal: $lockHorizontal, lockVertical: $lockVertical, fullSelection: $fullSelection)';
}
@override
@ -273,31 +203,14 @@ class _$UtilitiesStateImpl implements _UtilitiesState {
other.lockHorizontal == lockHorizontal) &&
(identical(other.lockVertical, lockVertical) ||
other.lockVertical == lockVertical) &&
(identical(other.rulerEnabled, rulerEnabled) ||
other.rulerEnabled == rulerEnabled) &&
(identical(other.gridEnabled, gridEnabled) ||
other.gridEnabled == gridEnabled) &&
(identical(other.fullSelection, fullSelection) ||
other.fullSelection == fullSelection) &&
(identical(other.rulerPosition, rulerPosition) ||
other.rulerPosition == rulerPosition) &&
(identical(other.rulerAngle, rulerAngle) ||
other.rulerAngle == rulerAngle));
other.fullSelection == fullSelection));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
lockCollection,
lockZoom,
lockHorizontal,
lockVertical,
rulerEnabled,
gridEnabled,
fullSelection,
rulerPosition,
rulerAngle);
int get hashCode => Object.hash(runtimeType, lockCollection, lockZoom,
lockHorizontal, lockVertical, fullSelection);
/// Create a copy of UtilitiesState
/// with the given fields replaced by the non-null parameter values.
@ -322,11 +235,7 @@ abstract class _UtilitiesState implements UtilitiesState {
final bool lockZoom,
final bool lockHorizontal,
final bool lockVertical,
final bool rulerEnabled,
final bool gridEnabled,
final bool fullSelection,
@DoublePointJsonConverter() final Point<double> rulerPosition,
final double rulerAngle}) = _$UtilitiesStateImpl;
final bool fullSelection}) = _$UtilitiesStateImpl;
factory _UtilitiesState.fromJson(Map<String, dynamic> json) =
_$UtilitiesStateImpl.fromJson;
@ -340,16 +249,7 @@ abstract class _UtilitiesState implements UtilitiesState {
@override
bool get lockVertical;
@override
bool get rulerEnabled;
@override
bool get gridEnabled;
@override
bool get fullSelection;
@override
@DoublePointJsonConverter()
Point<double> get rulerPosition;
@override
double get rulerAngle;
/// Create a copy of UtilitiesState
/// with the given fields replaced by the non-null parameter values.

View File

@ -12,14 +12,7 @@ _$UtilitiesStateImpl _$$UtilitiesStateImplFromJson(Map json) =>
lockZoom: json['lockZoom'] as bool? ?? false,
lockHorizontal: json['lockHorizontal'] as bool? ?? false,
lockVertical: json['lockVertical'] as bool? ?? false,
rulerEnabled: json['rulerEnabled'] as bool? ?? false,
gridEnabled: json['gridEnabled'] as bool? ?? false,
fullSelection: json['fullSelection'] as bool? ?? false,
rulerPosition: json['rulerPosition'] == null
? const Point(0.0, 0.0)
: const DoublePointJsonConverter()
.fromJson(json['rulerPosition'] as Map),
rulerAngle: (json['rulerAngle'] as num?)?.toDouble() ?? 0,
);
Map<String, dynamic> _$$UtilitiesStateImplToJson(
@ -29,10 +22,5 @@ Map<String, dynamic> _$$UtilitiesStateImplToJson(
'lockZoom': instance.lockZoom,
'lockHorizontal': instance.lockHorizontal,
'lockVertical': instance.lockVertical,
'rulerEnabled': instance.rulerEnabled,
'gridEnabled': instance.gridEnabled,
'fullSelection': instance.fullSelection,
'rulerPosition':
const DoublePointJsonConverter().toJson(instance.rulerPosition),
'rulerAngle': instance.rulerAngle,
};

View File

@ -1,5 +1,3 @@
import 'package:butterfly_api/src/converter/color.dart';
import 'package:dart_leap/dart_leap.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'view.freezed.dart';
@ -7,11 +5,7 @@ part 'view.g.dart';
@freezed
sealed class ViewOption with _$ViewOption {
const factory ViewOption({
@Default(SRGBColor.black) @ColorJsonConverter() SRGBColor gridColor,
@Default(20) double gridXSize,
@Default(20) double gridYSize,
}) = _ViewOption;
const factory ViewOption() = _ViewOption;
factory ViewOption.fromJson(Map<String, dynamic> json) =>
_$ViewOptionFromJson(json);

View File

@ -20,19 +20,8 @@ ViewOption _$ViewOptionFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$ViewOption {
@ColorJsonConverter()
SRGBColor get gridColor => throw _privateConstructorUsedError;
double get gridXSize => throw _privateConstructorUsedError;
double get gridYSize => throw _privateConstructorUsedError;
/// Serializes this ViewOption to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of ViewOption
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ViewOptionCopyWith<ViewOption> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
@ -40,11 +29,6 @@ abstract class $ViewOptionCopyWith<$Res> {
factory $ViewOptionCopyWith(
ViewOption value, $Res Function(ViewOption) then) =
_$ViewOptionCopyWithImpl<$Res, ViewOption>;
@useResult
$Res call(
{@ColorJsonConverter() SRGBColor gridColor,
double gridXSize,
double gridYSize});
}
/// @nodoc
@ -59,42 +43,13 @@ class _$ViewOptionCopyWithImpl<$Res, $Val extends ViewOption>
/// Create a copy of ViewOption
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? gridColor = null,
Object? gridXSize = null,
Object? gridYSize = null,
}) {
return _then(_value.copyWith(
gridColor: null == gridColor
? _value.gridColor
: gridColor // ignore: cast_nullable_to_non_nullable
as SRGBColor,
gridXSize: null == gridXSize
? _value.gridXSize
: gridXSize // ignore: cast_nullable_to_non_nullable
as double,
gridYSize: null == gridYSize
? _value.gridYSize
: gridYSize // ignore: cast_nullable_to_non_nullable
as double,
) as $Val);
}
}
/// @nodoc
abstract class _$$ViewOptionImplCopyWith<$Res>
implements $ViewOptionCopyWith<$Res> {
abstract class _$$ViewOptionImplCopyWith<$Res> {
factory _$$ViewOptionImplCopyWith(
_$ViewOptionImpl value, $Res Function(_$ViewOptionImpl) then) =
__$$ViewOptionImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{@ColorJsonConverter() SRGBColor gridColor,
double gridXSize,
double gridYSize});
}
/// @nodoc
@ -107,81 +62,30 @@ class __$$ViewOptionImplCopyWithImpl<$Res>
/// Create a copy of ViewOption
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? gridColor = null,
Object? gridXSize = null,
Object? gridYSize = null,
}) {
return _then(_$ViewOptionImpl(
gridColor: null == gridColor
? _value.gridColor
: gridColor // ignore: cast_nullable_to_non_nullable
as SRGBColor,
gridXSize: null == gridXSize
? _value.gridXSize
: gridXSize // ignore: cast_nullable_to_non_nullable
as double,
gridYSize: null == gridYSize
? _value.gridYSize
: gridYSize // ignore: cast_nullable_to_non_nullable
as double,
));
}
}
/// @nodoc
@JsonSerializable()
class _$ViewOptionImpl implements _ViewOption {
const _$ViewOptionImpl(
{@ColorJsonConverter() this.gridColor = SRGBColor.black,
this.gridXSize = 20,
this.gridYSize = 20});
const _$ViewOptionImpl();
factory _$ViewOptionImpl.fromJson(Map<String, dynamic> json) =>
_$$ViewOptionImplFromJson(json);
@override
@JsonKey()
@ColorJsonConverter()
final SRGBColor gridColor;
@override
@JsonKey()
final double gridXSize;
@override
@JsonKey()
final double gridYSize;
@override
String toString() {
return 'ViewOption(gridColor: $gridColor, gridXSize: $gridXSize, gridYSize: $gridYSize)';
return 'ViewOption()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ViewOptionImpl &&
(identical(other.gridColor, gridColor) ||
other.gridColor == gridColor) &&
(identical(other.gridXSize, gridXSize) ||
other.gridXSize == gridXSize) &&
(identical(other.gridYSize, gridYSize) ||
other.gridYSize == gridYSize));
(other.runtimeType == runtimeType && other is _$ViewOptionImpl);
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, gridColor, gridXSize, gridYSize);
/// Create a copy of ViewOption
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ViewOptionImplCopyWith<_$ViewOptionImpl> get copyWith =>
__$$ViewOptionImplCopyWithImpl<_$ViewOptionImpl>(this, _$identity);
int get hashCode => runtimeType.hashCode;
@override
Map<String, dynamic> toJson() {
@ -192,26 +96,8 @@ class _$ViewOptionImpl implements _ViewOption {
}
abstract class _ViewOption implements ViewOption {
const factory _ViewOption(
{@ColorJsonConverter() final SRGBColor gridColor,
final double gridXSize,
final double gridYSize}) = _$ViewOptionImpl;
const factory _ViewOption() = _$ViewOptionImpl;
factory _ViewOption.fromJson(Map<String, dynamic> json) =
_$ViewOptionImpl.fromJson;
@override
@ColorJsonConverter()
SRGBColor get gridColor;
@override
double get gridXSize;
@override
double get gridYSize;
/// Create a copy of ViewOption
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ViewOptionImplCopyWith<_$ViewOptionImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -6,18 +6,7 @@ part of 'view.dart';
// JsonSerializableGenerator
// **************************************************************************
_$ViewOptionImpl _$$ViewOptionImplFromJson(Map json) => _$ViewOptionImpl(
gridColor: json['gridColor'] == null
? SRGBColor.black
: const ColorJsonConverter()
.fromJson((json['gridColor'] as num).toInt()),
gridXSize: (json['gridXSize'] as num?)?.toDouble() ?? 20,
gridYSize: (json['gridYSize'] as num?)?.toDouble() ?? 20,
);
_$ViewOptionImpl _$$ViewOptionImplFromJson(Map json) => _$ViewOptionImpl();
Map<String, dynamic> _$$ViewOptionImplToJson(_$ViewOptionImpl instance) =>
<String, dynamic>{
'gridColor': const ColorJsonConverter().toJson(instance.gridColor),
'gridXSize': instance.gridXSize,
'gridYSize': instance.gridYSize,
};
<String, dynamic>{};