Skip to content

Commit 0950de4

Browse files
Merge pull request #156 from ishanvaghani/feat/standardize_button
feat: standardize parameters in buttons
2 parents e41b1db + 29868ae commit 0950de4

20 files changed

+574
-60
lines changed

packages/mirai/lib/src/parsers/mirai_elevated_button/mirai_elevated_button.dart

+4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ part 'mirai_elevated_button.g.dart';
1111
class MiraiElevatedButton with _$MiraiElevatedButton {
1212
const factory MiraiElevatedButton({
1313
Map<String, dynamic>? onPressed,
14+
Map<String, dynamic>? onLongPress,
15+
Map<String, dynamic>? onHover,
16+
Map<String, dynamic>? onFocusChange,
1417
MiraiButtonStyle? style,
1518
@Default(false) bool autofocus,
1619
@Default(Clip.none) Clip clipBehavior,
1720
required Map<String, dynamic> child,
21+
@Default(IconAlignment.start) IconAlignment iconAlignment,
1822
}) = _MiraiElevatedButton;
1923

2024
factory MiraiElevatedButton.fromJson(Map<String, dynamic> json) =>

packages/mirai/lib/src/parsers/mirai_elevated_button/mirai_elevated_button.freezed.dart

+123-7
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ MiraiElevatedButton _$MiraiElevatedButtonFromJson(Map<String, dynamic> json) {
2121
/// @nodoc
2222
mixin _$MiraiElevatedButton {
2323
Map<String, dynamic>? get onPressed => throw _privateConstructorUsedError;
24+
Map<String, dynamic>? get onLongPress => throw _privateConstructorUsedError;
25+
Map<String, dynamic>? get onHover => throw _privateConstructorUsedError;
26+
Map<String, dynamic>? get onFocusChange => throw _privateConstructorUsedError;
2427
MiraiButtonStyle? get style => throw _privateConstructorUsedError;
2528
bool get autofocus => throw _privateConstructorUsedError;
2629
Clip get clipBehavior => throw _privateConstructorUsedError;
2730
Map<String, dynamic> get child => throw _privateConstructorUsedError;
31+
IconAlignment get iconAlignment => throw _privateConstructorUsedError;
2832

2933
/// Serializes this MiraiElevatedButton to a JSON map.
3034
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -44,10 +48,14 @@ abstract class $MiraiElevatedButtonCopyWith<$Res> {
4448
@useResult
4549
$Res call(
4650
{Map<String, dynamic>? onPressed,
51+
Map<String, dynamic>? onLongPress,
52+
Map<String, dynamic>? onHover,
53+
Map<String, dynamic>? onFocusChange,
4754
MiraiButtonStyle? style,
4855
bool autofocus,
4956
Clip clipBehavior,
50-
Map<String, dynamic> child});
57+
Map<String, dynamic> child,
58+
IconAlignment iconAlignment});
5159

5260
$MiraiButtonStyleCopyWith<$Res>? get style;
5361
}
@@ -68,16 +76,32 @@ class _$MiraiElevatedButtonCopyWithImpl<$Res, $Val extends MiraiElevatedButton>
6876
@override
6977
$Res call({
7078
Object? onPressed = freezed,
79+
Object? onLongPress = freezed,
80+
Object? onHover = freezed,
81+
Object? onFocusChange = freezed,
7182
Object? style = freezed,
7283
Object? autofocus = null,
7384
Object? clipBehavior = null,
7485
Object? child = null,
86+
Object? iconAlignment = null,
7587
}) {
7688
return _then(_value.copyWith(
7789
onPressed: freezed == onPressed
7890
? _value.onPressed
7991
: onPressed // ignore: cast_nullable_to_non_nullable
8092
as Map<String, dynamic>?,
93+
onLongPress: freezed == onLongPress
94+
? _value.onLongPress
95+
: onLongPress // ignore: cast_nullable_to_non_nullable
96+
as Map<String, dynamic>?,
97+
onHover: freezed == onHover
98+
? _value.onHover
99+
: onHover // ignore: cast_nullable_to_non_nullable
100+
as Map<String, dynamic>?,
101+
onFocusChange: freezed == onFocusChange
102+
? _value.onFocusChange
103+
: onFocusChange // ignore: cast_nullable_to_non_nullable
104+
as Map<String, dynamic>?,
81105
style: freezed == style
82106
? _value.style
83107
: style // ignore: cast_nullable_to_non_nullable
@@ -94,6 +118,10 @@ class _$MiraiElevatedButtonCopyWithImpl<$Res, $Val extends MiraiElevatedButton>
94118
? _value.child
95119
: child // ignore: cast_nullable_to_non_nullable
96120
as Map<String, dynamic>,
121+
iconAlignment: null == iconAlignment
122+
? _value.iconAlignment
123+
: iconAlignment // ignore: cast_nullable_to_non_nullable
124+
as IconAlignment,
97125
) as $Val);
98126
}
99127

@@ -122,10 +150,14 @@ abstract class _$$MiraiElevatedButtonImplCopyWith<$Res>
122150
@useResult
123151
$Res call(
124152
{Map<String, dynamic>? onPressed,
153+
Map<String, dynamic>? onLongPress,
154+
Map<String, dynamic>? onHover,
155+
Map<String, dynamic>? onFocusChange,
125156
MiraiButtonStyle? style,
126157
bool autofocus,
127158
Clip clipBehavior,
128-
Map<String, dynamic> child});
159+
Map<String, dynamic> child,
160+
IconAlignment iconAlignment});
129161

130162
@override
131163
$MiraiButtonStyleCopyWith<$Res>? get style;
@@ -145,16 +177,32 @@ class __$$MiraiElevatedButtonImplCopyWithImpl<$Res>
145177
@override
146178
$Res call({
147179
Object? onPressed = freezed,
180+
Object? onLongPress = freezed,
181+
Object? onHover = freezed,
182+
Object? onFocusChange = freezed,
148183
Object? style = freezed,
149184
Object? autofocus = null,
150185
Object? clipBehavior = null,
151186
Object? child = null,
187+
Object? iconAlignment = null,
152188
}) {
153189
return _then(_$MiraiElevatedButtonImpl(
154190
onPressed: freezed == onPressed
155191
? _value._onPressed
156192
: onPressed // ignore: cast_nullable_to_non_nullable
157193
as Map<String, dynamic>?,
194+
onLongPress: freezed == onLongPress
195+
? _value._onLongPress
196+
: onLongPress // ignore: cast_nullable_to_non_nullable
197+
as Map<String, dynamic>?,
198+
onHover: freezed == onHover
199+
? _value._onHover
200+
: onHover // ignore: cast_nullable_to_non_nullable
201+
as Map<String, dynamic>?,
202+
onFocusChange: freezed == onFocusChange
203+
? _value._onFocusChange
204+
: onFocusChange // ignore: cast_nullable_to_non_nullable
205+
as Map<String, dynamic>?,
158206
style: freezed == style
159207
? _value.style
160208
: style // ignore: cast_nullable_to_non_nullable
@@ -171,6 +219,10 @@ class __$$MiraiElevatedButtonImplCopyWithImpl<$Res>
171219
? _value._child
172220
: child // ignore: cast_nullable_to_non_nullable
173221
as Map<String, dynamic>,
222+
iconAlignment: null == iconAlignment
223+
? _value.iconAlignment
224+
: iconAlignment // ignore: cast_nullable_to_non_nullable
225+
as IconAlignment,
174226
));
175227
}
176228
}
@@ -180,11 +232,18 @@ class __$$MiraiElevatedButtonImplCopyWithImpl<$Res>
180232
class _$MiraiElevatedButtonImpl implements _MiraiElevatedButton {
181233
const _$MiraiElevatedButtonImpl(
182234
{final Map<String, dynamic>? onPressed,
235+
final Map<String, dynamic>? onLongPress,
236+
final Map<String, dynamic>? onHover,
237+
final Map<String, dynamic>? onFocusChange,
183238
this.style,
184239
this.autofocus = false,
185240
this.clipBehavior = Clip.none,
186-
required final Map<String, dynamic> child})
241+
required final Map<String, dynamic> child,
242+
this.iconAlignment = IconAlignment.start})
187243
: _onPressed = onPressed,
244+
_onLongPress = onLongPress,
245+
_onHover = onHover,
246+
_onFocusChange = onFocusChange,
188247
_child = child;
189248

190249
factory _$MiraiElevatedButtonImpl.fromJson(Map<String, dynamic> json) =>
@@ -200,6 +259,36 @@ class _$MiraiElevatedButtonImpl implements _MiraiElevatedButton {
200259
return EqualUnmodifiableMapView(value);
201260
}
202261

262+
final Map<String, dynamic>? _onLongPress;
263+
@override
264+
Map<String, dynamic>? get onLongPress {
265+
final value = _onLongPress;
266+
if (value == null) return null;
267+
if (_onLongPress is EqualUnmodifiableMapView) return _onLongPress;
268+
// ignore: implicit_dynamic_type
269+
return EqualUnmodifiableMapView(value);
270+
}
271+
272+
final Map<String, dynamic>? _onHover;
273+
@override
274+
Map<String, dynamic>? get onHover {
275+
final value = _onHover;
276+
if (value == null) return null;
277+
if (_onHover is EqualUnmodifiableMapView) return _onHover;
278+
// ignore: implicit_dynamic_type
279+
return EqualUnmodifiableMapView(value);
280+
}
281+
282+
final Map<String, dynamic>? _onFocusChange;
283+
@override
284+
Map<String, dynamic>? get onFocusChange {
285+
final value = _onFocusChange;
286+
if (value == null) return null;
287+
if (_onFocusChange is EqualUnmodifiableMapView) return _onFocusChange;
288+
// ignore: implicit_dynamic_type
289+
return EqualUnmodifiableMapView(value);
290+
}
291+
203292
@override
204293
final MiraiButtonStyle? style;
205294
@override
@@ -216,9 +305,13 @@ class _$MiraiElevatedButtonImpl implements _MiraiElevatedButton {
216305
return EqualUnmodifiableMapView(_child);
217306
}
218307

308+
@override
309+
@JsonKey()
310+
final IconAlignment iconAlignment;
311+
219312
@override
220313
String toString() {
221-
return 'MiraiElevatedButton(onPressed: $onPressed, style: $style, autofocus: $autofocus, clipBehavior: $clipBehavior, child: $child)';
314+
return 'MiraiElevatedButton(onPressed: $onPressed, onLongPress: $onLongPress, onHover: $onHover, onFocusChange: $onFocusChange, style: $style, autofocus: $autofocus, clipBehavior: $clipBehavior, child: $child, iconAlignment: $iconAlignment)';
222315
}
223316

224317
@override
@@ -228,23 +321,34 @@ class _$MiraiElevatedButtonImpl implements _MiraiElevatedButton {
228321
other is _$MiraiElevatedButtonImpl &&
229322
const DeepCollectionEquality()
230323
.equals(other._onPressed, _onPressed) &&
324+
const DeepCollectionEquality()
325+
.equals(other._onLongPress, _onLongPress) &&
326+
const DeepCollectionEquality().equals(other._onHover, _onHover) &&
327+
const DeepCollectionEquality()
328+
.equals(other._onFocusChange, _onFocusChange) &&
231329
(identical(other.style, style) || other.style == style) &&
232330
(identical(other.autofocus, autofocus) ||
233331
other.autofocus == autofocus) &&
234332
(identical(other.clipBehavior, clipBehavior) ||
235333
other.clipBehavior == clipBehavior) &&
236-
const DeepCollectionEquality().equals(other._child, _child));
334+
const DeepCollectionEquality().equals(other._child, _child) &&
335+
(identical(other.iconAlignment, iconAlignment) ||
336+
other.iconAlignment == iconAlignment));
237337
}
238338

239339
@JsonKey(includeFromJson: false, includeToJson: false)
240340
@override
241341
int get hashCode => Object.hash(
242342
runtimeType,
243343
const DeepCollectionEquality().hash(_onPressed),
344+
const DeepCollectionEquality().hash(_onLongPress),
345+
const DeepCollectionEquality().hash(_onHover),
346+
const DeepCollectionEquality().hash(_onFocusChange),
244347
style,
245348
autofocus,
246349
clipBehavior,
247-
const DeepCollectionEquality().hash(_child));
350+
const DeepCollectionEquality().hash(_child),
351+
iconAlignment);
248352

249353
/// Create a copy of MiraiElevatedButton
250354
/// with the given fields replaced by the non-null parameter values.
@@ -266,24 +370,36 @@ class _$MiraiElevatedButtonImpl implements _MiraiElevatedButton {
266370
abstract class _MiraiElevatedButton implements MiraiElevatedButton {
267371
const factory _MiraiElevatedButton(
268372
{final Map<String, dynamic>? onPressed,
373+
final Map<String, dynamic>? onLongPress,
374+
final Map<String, dynamic>? onHover,
375+
final Map<String, dynamic>? onFocusChange,
269376
final MiraiButtonStyle? style,
270377
final bool autofocus,
271378
final Clip clipBehavior,
272-
required final Map<String, dynamic> child}) = _$MiraiElevatedButtonImpl;
379+
required final Map<String, dynamic> child,
380+
final IconAlignment iconAlignment}) = _$MiraiElevatedButtonImpl;
273381

274382
factory _MiraiElevatedButton.fromJson(Map<String, dynamic> json) =
275383
_$MiraiElevatedButtonImpl.fromJson;
276384

277385
@override
278386
Map<String, dynamic>? get onPressed;
279387
@override
388+
Map<String, dynamic>? get onLongPress;
389+
@override
390+
Map<String, dynamic>? get onHover;
391+
@override
392+
Map<String, dynamic>? get onFocusChange;
393+
@override
280394
MiraiButtonStyle? get style;
281395
@override
282396
bool get autofocus;
283397
@override
284398
Clip get clipBehavior;
285399
@override
286400
Map<String, dynamic> get child;
401+
@override
402+
IconAlignment get iconAlignment;
287403

288404
/// Create a copy of MiraiElevatedButton
289405
/// with the given fields replaced by the non-null parameter values.

packages/mirai/lib/src/parsers/mirai_elevated_button/mirai_elevated_button.g.dart

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mirai/lib/src/parsers/mirai_elevated_button/mirai_elevated_button_parser.dart

+7
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ class MiraiElevatedButtonParser extends MiraiParser<MiraiElevatedButton> {
2020
onPressed: model.onPressed == null
2121
? null
2222
: () => Mirai.onCallFromJson(model.onPressed, context),
23+
onLongPress: model.onLongPress == null
24+
? null
25+
: () => Mirai.onCallFromJson(model.onLongPress, context),
26+
onHover: (bool value) => value == false ? null : model.onHover,
27+
onFocusChange: (bool value) =>
28+
value == false ? null : model.onFocusChange,
2329
autofocus: model.autofocus,
2430
style: model.style?.parseElevated(context),
2531
clipBehavior: model.clipBehavior,
32+
iconAlignment: model.iconAlignment,
2633
child: Mirai.fromJson(model.child, context),
2734
);
2835
}

packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class MiraiFilledButton with _$MiraiFilledButton {
1818
@Default(false) bool autofocus,
1919
@Default(Clip.none) Clip clipBehavior,
2020
Map<String, dynamic>? child,
21+
@Default(IconAlignment.start) IconAlignment iconAlignment,
2122
}) = _MiraiFilledButton;
2223

2324
factory MiraiFilledButton.fromJson(Map<String, dynamic> json) =>

0 commit comments

Comments
 (0)