Skip to content

Commit

Permalink
feat: Added properties of refresh indicator support in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
i-asimkhan committed Jan 18, 2024
1 parent 6c8c9fd commit 79b905a
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 36 deletions.
2 changes: 1 addition & 1 deletion examples/mirai_gallery/assets/json/home_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@
"leading": {
"type": "icon",
"iconType": "material",
"icon": "table_rows"
"icon": "refresh"
},
"title": {
"type": "text",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

export 'package:mirai/src/parsers/mirai_refresh_indicator/mirai_refresh_indicator_parser.dart';
Expand All @@ -8,8 +9,17 @@ part 'mirai_refresh_indicator.g.dart';
@freezed
class MiraiRefreshIndicator with _$MiraiRefreshIndicator {
const factory MiraiRefreshIndicator({
Map<String, dynamic>? onRefresh,
Map<String, dynamic>? child,
@Default(40) double displacement,
@Default(0) double edgeOffset,
Map<String, dynamic>? onRefresh,
String? color,
String? backgroundColor,
String? semanticsLabel,
String? semanticsValue,
@Default(RefreshProgressIndicator.defaultStrokeWidth) double strokeWidth,
@Default(RefreshIndicatorTriggerMode.onEdge)
RefreshIndicatorTriggerMode triggerMode,
}) = _MiraiRefreshIndicator;

factory MiraiRefreshIndicator.fromJson(Map<String, dynamic> json) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ MiraiRefreshIndicator _$MiraiRefreshIndicatorFromJson(

/// @nodoc
mixin _$MiraiRefreshIndicator {
Map<String, dynamic>? get onRefresh => throw _privateConstructorUsedError;
Map<String, dynamic>? get child => throw _privateConstructorUsedError;
double get displacement => throw _privateConstructorUsedError;
double get edgeOffset => throw _privateConstructorUsedError;
Map<String, dynamic>? get onRefresh => throw _privateConstructorUsedError;
String? get color => throw _privateConstructorUsedError;
String? get backgroundColor => throw _privateConstructorUsedError;
String? get semanticsLabel => throw _privateConstructorUsedError;
String? get semanticsValue => throw _privateConstructorUsedError;
double get strokeWidth => throw _privateConstructorUsedError;
RefreshIndicatorTriggerMode get triggerMode =>
throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
Expand All @@ -36,7 +45,17 @@ abstract class $MiraiRefreshIndicatorCopyWith<$Res> {
$Res Function(MiraiRefreshIndicator) then) =
_$MiraiRefreshIndicatorCopyWithImpl<$Res, MiraiRefreshIndicator>;
@useResult
$Res call({Map<String, dynamic>? onRefresh, Map<String, dynamic>? child});
$Res call(
{Map<String, dynamic>? child,
double displacement,
double edgeOffset,
Map<String, dynamic>? onRefresh,
String? color,
String? backgroundColor,
String? semanticsLabel,
String? semanticsValue,
double strokeWidth,
RefreshIndicatorTriggerMode triggerMode});
}

/// @nodoc
Expand All @@ -53,18 +72,58 @@ class _$MiraiRefreshIndicatorCopyWithImpl<$Res,
@pragma('vm:prefer-inline')
@override
$Res call({
Object? onRefresh = freezed,
Object? child = freezed,
Object? displacement = null,
Object? edgeOffset = null,
Object? onRefresh = freezed,
Object? color = freezed,
Object? backgroundColor = freezed,
Object? semanticsLabel = freezed,
Object? semanticsValue = freezed,
Object? strokeWidth = null,
Object? triggerMode = null,
}) {
return _then(_value.copyWith(
onRefresh: freezed == onRefresh
? _value.onRefresh
: onRefresh // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
child: freezed == child
? _value.child
: child // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
displacement: null == displacement
? _value.displacement
: displacement // ignore: cast_nullable_to_non_nullable
as double,
edgeOffset: null == edgeOffset
? _value.edgeOffset
: edgeOffset // ignore: cast_nullable_to_non_nullable
as double,
onRefresh: freezed == onRefresh
? _value.onRefresh
: onRefresh // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
color: freezed == color
? _value.color
: color // ignore: cast_nullable_to_non_nullable
as String?,
backgroundColor: freezed == backgroundColor
? _value.backgroundColor
: backgroundColor // ignore: cast_nullable_to_non_nullable
as String?,
semanticsLabel: freezed == semanticsLabel
? _value.semanticsLabel
: semanticsLabel // ignore: cast_nullable_to_non_nullable
as String?,
semanticsValue: freezed == semanticsValue
? _value.semanticsValue
: semanticsValue // ignore: cast_nullable_to_non_nullable
as String?,
strokeWidth: null == strokeWidth
? _value.strokeWidth
: strokeWidth // ignore: cast_nullable_to_non_nullable
as double,
triggerMode: null == triggerMode
? _value.triggerMode
: triggerMode // ignore: cast_nullable_to_non_nullable
as RefreshIndicatorTriggerMode,
) as $Val);
}
}
Expand All @@ -78,7 +137,17 @@ abstract class _$$MiraiRefreshIndicatorImplCopyWith<$Res>
__$$MiraiRefreshIndicatorImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({Map<String, dynamic>? onRefresh, Map<String, dynamic>? child});
$Res call(
{Map<String, dynamic>? child,
double displacement,
double edgeOffset,
Map<String, dynamic>? onRefresh,
String? color,
String? backgroundColor,
String? semanticsLabel,
String? semanticsValue,
double strokeWidth,
RefreshIndicatorTriggerMode triggerMode});
}

/// @nodoc
Expand All @@ -93,18 +162,58 @@ class __$$MiraiRefreshIndicatorImplCopyWithImpl<$Res>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? onRefresh = freezed,
Object? child = freezed,
Object? displacement = null,
Object? edgeOffset = null,
Object? onRefresh = freezed,
Object? color = freezed,
Object? backgroundColor = freezed,
Object? semanticsLabel = freezed,
Object? semanticsValue = freezed,
Object? strokeWidth = null,
Object? triggerMode = null,
}) {
return _then(_$MiraiRefreshIndicatorImpl(
onRefresh: freezed == onRefresh
? _value._onRefresh
: onRefresh // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
child: freezed == child
? _value._child
: child // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
displacement: null == displacement
? _value.displacement
: displacement // ignore: cast_nullable_to_non_nullable
as double,
edgeOffset: null == edgeOffset
? _value.edgeOffset
: edgeOffset // ignore: cast_nullable_to_non_nullable
as double,
onRefresh: freezed == onRefresh
? _value._onRefresh
: onRefresh // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
color: freezed == color
? _value.color
: color // ignore: cast_nullable_to_non_nullable
as String?,
backgroundColor: freezed == backgroundColor
? _value.backgroundColor
: backgroundColor // ignore: cast_nullable_to_non_nullable
as String?,
semanticsLabel: freezed == semanticsLabel
? _value.semanticsLabel
: semanticsLabel // ignore: cast_nullable_to_non_nullable
as String?,
semanticsValue: freezed == semanticsValue
? _value.semanticsValue
: semanticsValue // ignore: cast_nullable_to_non_nullable
as String?,
strokeWidth: null == strokeWidth
? _value.strokeWidth
: strokeWidth // ignore: cast_nullable_to_non_nullable
as double,
triggerMode: null == triggerMode
? _value.triggerMode
: triggerMode // ignore: cast_nullable_to_non_nullable
as RefreshIndicatorTriggerMode,
));
}
}
Expand All @@ -113,55 +222,107 @@ class __$$MiraiRefreshIndicatorImplCopyWithImpl<$Res>
@JsonSerializable()
class _$MiraiRefreshIndicatorImpl implements _MiraiRefreshIndicator {
const _$MiraiRefreshIndicatorImpl(
{final Map<String, dynamic>? onRefresh,
final Map<String, dynamic>? child})
: _onRefresh = onRefresh,
_child = child;
{final Map<String, dynamic>? child,
this.displacement = 40,
this.edgeOffset = 0,
final Map<String, dynamic>? onRefresh,
this.color,
this.backgroundColor,
this.semanticsLabel,
this.semanticsValue,
this.strokeWidth = RefreshProgressIndicator.defaultStrokeWidth,
this.triggerMode = RefreshIndicatorTriggerMode.onEdge})
: _child = child,
_onRefresh = onRefresh;

factory _$MiraiRefreshIndicatorImpl.fromJson(Map<String, dynamic> json) =>
_$$MiraiRefreshIndicatorImplFromJson(json);

final Map<String, dynamic>? _onRefresh;
final Map<String, dynamic>? _child;
@override
Map<String, dynamic>? get onRefresh {
final value = _onRefresh;
Map<String, dynamic>? get child {
final value = _child;
if (value == null) return null;
if (_onRefresh is EqualUnmodifiableMapView) return _onRefresh;
if (_child is EqualUnmodifiableMapView) return _child;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}

final Map<String, dynamic>? _child;
@override
Map<String, dynamic>? get child {
final value = _child;
@JsonKey()
final double displacement;
@override
@JsonKey()
final double edgeOffset;
final Map<String, dynamic>? _onRefresh;
@override
Map<String, dynamic>? get onRefresh {
final value = _onRefresh;
if (value == null) return null;
if (_child is EqualUnmodifiableMapView) return _child;
if (_onRefresh is EqualUnmodifiableMapView) return _onRefresh;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}

@override
final String? color;
@override
final String? backgroundColor;
@override
final String? semanticsLabel;
@override
final String? semanticsValue;
@override
@JsonKey()
final double strokeWidth;
@override
@JsonKey()
final RefreshIndicatorTriggerMode triggerMode;

@override
String toString() {
return 'MiraiRefreshIndicator(onRefresh: $onRefresh, child: $child)';
return 'MiraiRefreshIndicator(child: $child, displacement: $displacement, edgeOffset: $edgeOffset, onRefresh: $onRefresh, color: $color, backgroundColor: $backgroundColor, semanticsLabel: $semanticsLabel, semanticsValue: $semanticsValue, strokeWidth: $strokeWidth, triggerMode: $triggerMode)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$MiraiRefreshIndicatorImpl &&
const DeepCollectionEquality().equals(other._child, _child) &&
(identical(other.displacement, displacement) ||
other.displacement == displacement) &&
(identical(other.edgeOffset, edgeOffset) ||
other.edgeOffset == edgeOffset) &&
const DeepCollectionEquality()
.equals(other._onRefresh, _onRefresh) &&
const DeepCollectionEquality().equals(other._child, _child));
(identical(other.color, color) || other.color == color) &&
(identical(other.backgroundColor, backgroundColor) ||
other.backgroundColor == backgroundColor) &&
(identical(other.semanticsLabel, semanticsLabel) ||
other.semanticsLabel == semanticsLabel) &&
(identical(other.semanticsValue, semanticsValue) ||
other.semanticsValue == semanticsValue) &&
(identical(other.strokeWidth, strokeWidth) ||
other.strokeWidth == strokeWidth) &&
(identical(other.triggerMode, triggerMode) ||
other.triggerMode == triggerMode));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(_child),
displacement,
edgeOffset,
const DeepCollectionEquality().hash(_onRefresh),
const DeepCollectionEquality().hash(_child));
color,
backgroundColor,
semanticsLabel,
semanticsValue,
strokeWidth,
triggerMode);

@JsonKey(ignore: true)
@override
Expand All @@ -180,16 +341,41 @@ class _$MiraiRefreshIndicatorImpl implements _MiraiRefreshIndicator {

abstract class _MiraiRefreshIndicator implements MiraiRefreshIndicator {
const factory _MiraiRefreshIndicator(
{final Map<String, dynamic>? onRefresh,
final Map<String, dynamic>? child}) = _$MiraiRefreshIndicatorImpl;
{final Map<String, dynamic>? child,
final double displacement,
final double edgeOffset,
final Map<String, dynamic>? onRefresh,
final String? color,
final String? backgroundColor,
final String? semanticsLabel,
final String? semanticsValue,
final double strokeWidth,
final RefreshIndicatorTriggerMode triggerMode}) =
_$MiraiRefreshIndicatorImpl;

factory _MiraiRefreshIndicator.fromJson(Map<String, dynamic> json) =
_$MiraiRefreshIndicatorImpl.fromJson;

@override
Map<String, dynamic>? get child;
@override
double get displacement;
@override
double get edgeOffset;
@override
Map<String, dynamic>? get onRefresh;
@override
Map<String, dynamic>? get child;
String? get color;
@override
String? get backgroundColor;
@override
String? get semanticsLabel;
@override
String? get semanticsValue;
@override
double get strokeWidth;
@override
RefreshIndicatorTriggerMode get triggerMode;
@override
@JsonKey(ignore: true)
_$$MiraiRefreshIndicatorImplCopyWith<_$MiraiRefreshIndicatorImpl>
Expand Down
Loading

0 comments on commit 79b905a

Please sign in to comment.