Skip to content

Commit

Permalink
Add support for spacer widget
Browse files Browse the repository at this point in the history
  • Loading branch information
cscoderr committed May 10, 2024
1 parent 985179a commit a4b7344
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 82 deletions.
2 changes: 1 addition & 1 deletion packages/mirai/lib/src/framework/mirai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Mirai {
const MiraiCheckBoxWidgetParser(),
const MiraiExpandedParser(),
const MiraiFlexibleParser(),
const MiraiMiraiSpacerParser(),
const MiraiSpacerParser(),
const MiraiSafeAreaParser(),
const MiraiSwitchParser(),
const MiraiAlignParser(),
Expand Down

This file was deleted.

This file was deleted.

16 changes: 16 additions & 0 deletions packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';

export 'package:mirai/src/parsers/mirai_spacer/mirai_spacer_parser.dart';

part 'mirai_spacer.freezed.dart';
part 'mirai_spacer.g.dart';

@freezed
class MiraiSpacer with _$MiraiSpacer {
const factory MiraiSpacer({
@Default(1) int flex,
}) = _MiraiSpacer;

factory MiraiSpacer.fromJson(Map<String, dynamic> json) =>
_$MiraiSpacerFromJson(json);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'mirai_mirai_spacer.dart';
part of 'mirai_spacer.dart';

// **************************************************************************
// FreezedGenerator
Expand All @@ -14,33 +14,33 @@ T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');

MiraiMiraiSpacer _$MiraiMiraiSpacerFromJson(Map<String, dynamic> json) {
return _MiraiMiraiSpacer.fromJson(json);
MiraiSpacer _$MiraiSpacerFromJson(Map<String, dynamic> json) {
return _MiraiSpacer.fromJson(json);
}

/// @nodoc
mixin _$MiraiMiraiSpacer {
mixin _$MiraiSpacer {
int get flex => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$MiraiMiraiSpacerCopyWith<MiraiMiraiSpacer> get copyWith =>
$MiraiSpacerCopyWith<MiraiSpacer> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $MiraiMiraiSpacerCopyWith<$Res> {
factory $MiraiMiraiSpacerCopyWith(
MiraiMiraiSpacer value, $Res Function(MiraiMiraiSpacer) then) =
_$MiraiMiraiSpacerCopyWithImpl<$Res, MiraiMiraiSpacer>;
abstract class $MiraiSpacerCopyWith<$Res> {
factory $MiraiSpacerCopyWith(
MiraiSpacer value, $Res Function(MiraiSpacer) then) =
_$MiraiSpacerCopyWithImpl<$Res, MiraiSpacer>;
@useResult
$Res call({int flex});
}

/// @nodoc
class _$MiraiMiraiSpacerCopyWithImpl<$Res, $Val extends MiraiMiraiSpacer>
implements $MiraiMiraiSpacerCopyWith<$Res> {
_$MiraiMiraiSpacerCopyWithImpl(this._value, this._then);
class _$MiraiSpacerCopyWithImpl<$Res, $Val extends MiraiSpacer>
implements $MiraiSpacerCopyWith<$Res> {
_$MiraiSpacerCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
Expand All @@ -62,30 +62,30 @@ class _$MiraiMiraiSpacerCopyWithImpl<$Res, $Val extends MiraiMiraiSpacer>
}

/// @nodoc
abstract class _$$MiraiMiraiSpacerImplCopyWith<$Res>
implements $MiraiMiraiSpacerCopyWith<$Res> {
factory _$$MiraiMiraiSpacerImplCopyWith(_$MiraiMiraiSpacerImpl value,
$Res Function(_$MiraiMiraiSpacerImpl) then) =
__$$MiraiMiraiSpacerImplCopyWithImpl<$Res>;
abstract class _$$MiraiSpacerImplCopyWith<$Res>
implements $MiraiSpacerCopyWith<$Res> {
factory _$$MiraiSpacerImplCopyWith(
_$MiraiSpacerImpl value, $Res Function(_$MiraiSpacerImpl) then) =
__$$MiraiSpacerImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int flex});
}

/// @nodoc
class __$$MiraiMiraiSpacerImplCopyWithImpl<$Res>
extends _$MiraiMiraiSpacerCopyWithImpl<$Res, _$MiraiMiraiSpacerImpl>
implements _$$MiraiMiraiSpacerImplCopyWith<$Res> {
__$$MiraiMiraiSpacerImplCopyWithImpl(_$MiraiMiraiSpacerImpl _value,
$Res Function(_$MiraiMiraiSpacerImpl) _then)
class __$$MiraiSpacerImplCopyWithImpl<$Res>
extends _$MiraiSpacerCopyWithImpl<$Res, _$MiraiSpacerImpl>
implements _$$MiraiSpacerImplCopyWith<$Res> {
__$$MiraiSpacerImplCopyWithImpl(
_$MiraiSpacerImpl _value, $Res Function(_$MiraiSpacerImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? flex = null,
}) {
return _then(_$MiraiMiraiSpacerImpl(
return _then(_$MiraiSpacerImpl(
flex: null == flex
? _value.flex
: flex // ignore: cast_nullable_to_non_nullable
Expand All @@ -96,26 +96,26 @@ class __$$MiraiMiraiSpacerImplCopyWithImpl<$Res>

/// @nodoc
@JsonSerializable()
class _$MiraiMiraiSpacerImpl implements _MiraiMiraiSpacer {
const _$MiraiMiraiSpacerImpl({this.flex = 1});
class _$MiraiSpacerImpl implements _MiraiSpacer {
const _$MiraiSpacerImpl({this.flex = 1});

factory _$MiraiMiraiSpacerImpl.fromJson(Map<String, dynamic> json) =>
_$$MiraiMiraiSpacerImplFromJson(json);
factory _$MiraiSpacerImpl.fromJson(Map<String, dynamic> json) =>
_$$MiraiSpacerImplFromJson(json);

@override
@JsonKey()
final int flex;

@override
String toString() {
return 'MiraiMiraiSpacer(flex: $flex)';
return 'MiraiSpacer(flex: $flex)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$MiraiMiraiSpacerImpl &&
other is _$MiraiSpacerImpl &&
(identical(other.flex, flex) || other.flex == flex));
}

Expand All @@ -126,28 +126,27 @@ class _$MiraiMiraiSpacerImpl implements _MiraiMiraiSpacer {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$MiraiMiraiSpacerImplCopyWith<_$MiraiMiraiSpacerImpl> get copyWith =>
__$$MiraiMiraiSpacerImplCopyWithImpl<_$MiraiMiraiSpacerImpl>(
this, _$identity);
_$$MiraiSpacerImplCopyWith<_$MiraiSpacerImpl> get copyWith =>
__$$MiraiSpacerImplCopyWithImpl<_$MiraiSpacerImpl>(this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$MiraiMiraiSpacerImplToJson(
return _$$MiraiSpacerImplToJson(
this,
);
}
}

abstract class _MiraiMiraiSpacer implements MiraiMiraiSpacer {
const factory _MiraiMiraiSpacer({final int flex}) = _$MiraiMiraiSpacerImpl;
abstract class _MiraiSpacer implements MiraiSpacer {
const factory _MiraiSpacer({final int flex}) = _$MiraiSpacerImpl;

factory _MiraiMiraiSpacer.fromJson(Map<String, dynamic> json) =
_$MiraiMiraiSpacerImpl.fromJson;
factory _MiraiSpacer.fromJson(Map<String, dynamic> json) =
_$MiraiSpacerImpl.fromJson;

@override
int get flex;
@override
@JsonKey(ignore: true)
_$$MiraiMiraiSpacerImplCopyWith<_$MiraiMiraiSpacerImpl> get copyWith =>
_$$MiraiSpacerImplCopyWith<_$MiraiSpacerImpl> get copyWith =>
throw _privateConstructorUsedError;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:mirai/src/parsers/mirai_spacer/mirai_spacer.dart';
import 'package:mirai/src/utils/widget_type.dart';
import 'package:mirai_framework/mirai_framework.dart';

class MiraiSpacerParser extends MiraiParser<MiraiSpacer> {
const MiraiSpacerParser();

@override
MiraiSpacer getModel(Map<String, dynamic> json) => MiraiSpacer.fromJson(json);

@override
String get type => WidgetType.spacer.name;

@override
Widget parse(BuildContext context, MiraiSpacer model) {
return Spacer(flex: model.flex);
}
}
2 changes: 1 addition & 1 deletion packages/mirai/lib/src/parsers/parsers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export 'package:mirai/src/parsers/mirai_input_formatters/mirai_input_formatter.d
export 'package:mirai/src/parsers/mirai_list_tile/mirai_list_tile.dart';
export 'package:mirai/src/parsers/mirai_list_tile_theme_data/mirai_list_tile_theme_data.dart';
export 'package:mirai/src/parsers/mirai_list_view/mirai_list_view.dart';
export 'package:mirai/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart';
export 'package:mirai/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart';
export 'package:mirai/src/parsers/mirai_navigation_bar_theme_data/mirai_navigation_bar_theme_data.dart';
export 'package:mirai/src/parsers/mirai_network_widget/mirai_network_widget.dart';
Expand All @@ -62,6 +61,7 @@ export 'package:mirai/src/parsers/mirai_scaffold/mirai_scaffold.dart';
export 'package:mirai/src/parsers/mirai_single_child_scroll_view/mirai_single_child_scroll_view.dart';
export 'package:mirai/src/parsers/mirai_size/mirai_size.dart';
export 'package:mirai/src/parsers/mirai_sized_box/mirai_sized_box.dart';
export 'package:mirai/src/parsers/mirai_spacer/mirai_spacer.dart';
export 'package:mirai/src/parsers/mirai_stack/mirai_stack.dart';
export 'package:mirai/src/parsers/mirai_switch/mirai_switch.dart';
export 'package:mirai/src/parsers/mirai_tab/mirai_tab.dart';
Expand Down

0 comments on commit a4b7344

Please sign in to comment.