Skip to content

Commit

Permalink
Merge branch 'main' into dv/form-builder
Browse files Browse the repository at this point in the history
Signed-off-by: Divyanshu Bhargava <[email protected]>
  • Loading branch information
divyanshub024 authored Oct 17, 2023
2 parents 8f74fb6 + 87c0d79 commit 5131ed9
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 1 deletion.
33 changes: 33 additions & 0 deletions examples/mirai_gallery/assets/json/align_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Align"
}
},
"body": {
"type": "align",
"alignment": "topEnd",
"child": {
"type": "container",
"color": "#FC5632",
"clipBehavior": "hardEdge",
"height": 250,
"width": 200,
"child": {
"type": "align",
"alignment": "bottomCenter",
"child": {
"type": "text",
"data": "Flutter",
"style": {
"fontSize": 23,
"fontWeight": "w600"
}
}
}
}
}
}
15 changes: 14 additions & 1 deletion examples/mirai_gallery/assets/json/container_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@
"color": "#FC5632",
"clipBehavior": "hardEdge",
"height": 250,
"width": 200
"width": 200,
"child": {
"type": "align",
"alignment": "bottomCenter",
"child": {
"type": "text",
"data": "Flutter",
"align": "center",
"style": {
"fontSize": 23,
"fontWeight": "w600"
}
}
}
}
]
}
Expand Down
31 changes: 31 additions & 0 deletions examples/mirai_gallery/assets/json/home_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,37 @@
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "format_align_center"
},
"title": {
"type": "text",
"data": "Mirai Align",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "widget that is used to align its child within itself and optionally sizes itself based on the child’s size",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/align_example.json"
}
}
},
{
"type": "listTile",
"leading": {
Expand Down
4 changes: 4 additions & 0 deletions packages/mirai/lib/src/framework/mirai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mirai/src/action_parsers/action_parsers.dart';
import 'package:mirai/src/framework/mirai_registry.dart';
import 'package:mirai/src/network/mirai_network.dart';
import 'package:mirai/src/network/mirai_request.dart';
import 'package:mirai/src/parsers/mirai_align/mirai_align_parser.dart';
import 'package:mirai/src/parsers/mirai_center/mirai_center_parser.dart';
import 'package:mirai/src/parsers/mirai_check_box_widget/mirai_check_box_widget_parser.dart';
import 'package:mirai/src/parsers/mirai_form/mirai_form_parser.dart';
Expand Down Expand Up @@ -63,6 +66,7 @@ class Mirai {
const MiraiFlexibleParser(),
const MiraiSafeAreaParser(),
const MiraiSwitchParser(),
const MiraiAlignParser(),
];

static final _actionParsers = <MiraiActionParser>[
Expand Down
21 changes: 21 additions & 0 deletions packages/mirai/lib/src/parsers/mirai_align/mirai_align.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/src/parsers/parsers.dart';

export 'package:mirai/src/parsers/mirai_stack/mirai_stack_parser.dart';

part 'mirai_align.freezed.dart';
part 'mirai_align.g.dart';

@freezed
class MiraiAlign with _$MiraiAlign {
const factory MiraiAlign({
@Default(MiraiAlignmentDirectional.center)
MiraiAlignmentDirectional alignment,
double? widthFactor,
double? heightFactor,
Map<String, dynamic>? child,
}) = _MiraiAlign;

factory MiraiAlign.fromJson(Map<String, dynamic> json) =>
_$MiraiAlignFromJson(json);
}
228 changes: 228 additions & 0 deletions packages/mirai/lib/src/parsers/mirai_align/mirai_align.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// 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_align.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

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#custom-getters-and-methods');

MiraiAlign _$MiraiAlignFromJson(Map<String, dynamic> json) {
return _MiraiAlign.fromJson(json);
}

/// @nodoc
mixin _$MiraiAlign {
MiraiAlignmentDirectional get alignment => throw _privateConstructorUsedError;
double? get widthFactor => throw _privateConstructorUsedError;
double? get heightFactor => throw _privateConstructorUsedError;
Map<String, dynamic>? get child => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$MiraiAlignCopyWith<MiraiAlign> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $MiraiAlignCopyWith<$Res> {
factory $MiraiAlignCopyWith(
MiraiAlign value, $Res Function(MiraiAlign) then) =
_$MiraiAlignCopyWithImpl<$Res, MiraiAlign>;
@useResult
$Res call(
{MiraiAlignmentDirectional alignment,
double? widthFactor,
double? heightFactor,
Map<String, dynamic>? child});
}

/// @nodoc
class _$MiraiAlignCopyWithImpl<$Res, $Val extends MiraiAlign>
implements $MiraiAlignCopyWith<$Res> {
_$MiraiAlignCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? alignment = null,
Object? widthFactor = freezed,
Object? heightFactor = freezed,
Object? child = freezed,
}) {
return _then(_value.copyWith(
alignment: null == alignment
? _value.alignment
: alignment // ignore: cast_nullable_to_non_nullable
as MiraiAlignmentDirectional,
widthFactor: freezed == widthFactor
? _value.widthFactor
: widthFactor // ignore: cast_nullable_to_non_nullable
as double?,
heightFactor: freezed == heightFactor
? _value.heightFactor
: heightFactor // ignore: cast_nullable_to_non_nullable
as double?,
child: freezed == child
? _value.child
: child // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
) as $Val);
}
}

/// @nodoc
abstract class _$$MiraiAlignImplCopyWith<$Res>
implements $MiraiAlignCopyWith<$Res> {
factory _$$MiraiAlignImplCopyWith(
_$MiraiAlignImpl value, $Res Function(_$MiraiAlignImpl) then) =
__$$MiraiAlignImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{MiraiAlignmentDirectional alignment,
double? widthFactor,
double? heightFactor,
Map<String, dynamic>? child});
}

/// @nodoc
class __$$MiraiAlignImplCopyWithImpl<$Res>
extends _$MiraiAlignCopyWithImpl<$Res, _$MiraiAlignImpl>
implements _$$MiraiAlignImplCopyWith<$Res> {
__$$MiraiAlignImplCopyWithImpl(
_$MiraiAlignImpl _value, $Res Function(_$MiraiAlignImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? alignment = null,
Object? widthFactor = freezed,
Object? heightFactor = freezed,
Object? child = freezed,
}) {
return _then(_$MiraiAlignImpl(
alignment: null == alignment
? _value.alignment
: alignment // ignore: cast_nullable_to_non_nullable
as MiraiAlignmentDirectional,
widthFactor: freezed == widthFactor
? _value.widthFactor
: widthFactor // ignore: cast_nullable_to_non_nullable
as double?,
heightFactor: freezed == heightFactor
? _value.heightFactor
: heightFactor // ignore: cast_nullable_to_non_nullable
as double?,
child: freezed == child
? _value._child
: child // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
));
}
}

/// @nodoc
@JsonSerializable()
class _$MiraiAlignImpl implements _MiraiAlign {
const _$MiraiAlignImpl(
{this.alignment = MiraiAlignmentDirectional.center,
this.widthFactor,
this.heightFactor,
final Map<String, dynamic>? child})
: _child = child;

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

@override
@JsonKey()
final MiraiAlignmentDirectional alignment;
@override
final double? widthFactor;
@override
final double? heightFactor;
final Map<String, dynamic>? _child;
@override
Map<String, dynamic>? get child {
final value = _child;
if (value == null) return null;
if (_child is EqualUnmodifiableMapView) return _child;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}

@override
String toString() {
return 'MiraiAlign(alignment: $alignment, widthFactor: $widthFactor, heightFactor: $heightFactor, child: $child)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$MiraiAlignImpl &&
(identical(other.alignment, alignment) ||
other.alignment == alignment) &&
(identical(other.widthFactor, widthFactor) ||
other.widthFactor == widthFactor) &&
(identical(other.heightFactor, heightFactor) ||
other.heightFactor == heightFactor) &&
const DeepCollectionEquality().equals(other._child, _child));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, alignment, widthFactor,
heightFactor, const DeepCollectionEquality().hash(_child));

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$MiraiAlignImplCopyWith<_$MiraiAlignImpl> get copyWith =>
__$$MiraiAlignImplCopyWithImpl<_$MiraiAlignImpl>(this, _$identity);

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

abstract class _MiraiAlign implements MiraiAlign {
const factory _MiraiAlign(
{final MiraiAlignmentDirectional alignment,
final double? widthFactor,
final double? heightFactor,
final Map<String, dynamic>? child}) = _$MiraiAlignImpl;

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

@override
MiraiAlignmentDirectional get alignment;
@override
double? get widthFactor;
@override
double? get heightFactor;
@override
Map<String, dynamic>? get child;
@override
@JsonKey(ignore: true)
_$$MiraiAlignImplCopyWith<_$MiraiAlignImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Loading

0 comments on commit 5131ed9

Please sign in to comment.