Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FractionallySizedBox widget #100

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Fractionally SizedBox"
}
},
"body": {
"type": "container",
"height": 400,
"width": 350,
"color": "#A9A9D9",
"child": {
"type": "fractionallySizedBox",
"heightFactor": 0.3,
"widthFactor": 0.8,
"alignment": "bottomRight",
"child": {
"type": "elevatedButton",
"child": {
"type": "text",
"data": "FLUTTER",
"style": {
"color": "#ffffff"
}
},
"onPressed": {}
}
}
}
}
35 changes: 35 additions & 0 deletions examples/mirai_gallery/assets/json/home_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,41 @@
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "space_bar"
},
"title": {
"type": "text",
"data": "Mirai Fractionally Sizedbox",
"align": "center",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A widget that sizes its child to a fraction of the total available space.",
"align": "center",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"style": "list",
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"navigationType": "screen",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/fractionally_sized_box_example.json"
}
}
},
{
"type": "listTile",
"leading": {
Expand Down
2 changes: 1 addition & 1 deletion examples/mirai_gallery/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ packages:
path: "../../packages/mirai"
relative: true
source: path
version: "0.0.5"
version: "0.1.0"
nested:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/mirai/lib/src/framework/mirai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:mirai/src/framework/mirai_parser.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_fractionally_sized_box/mirai_fractionally_sized_box_parser.dart';
import 'package:mirai/src/parsers/mirai_tab/mirai_tab_parser.dart';
import 'package:mirai/src/parsers/parsers.dart';
import 'package:mirai/src/utils/log.dart';
Expand Down Expand Up @@ -36,6 +37,7 @@ class Mirai {
const MiraiTextButtonParser(),
const MiraiScaffoldParser(),
const MiraiSizedBoxParser(),
const MiraiFractionallySizedBoxParser(),
const MiraiTextFormFieldParser(),
const MiraiTabBarViewParser(),
const MiraiTabBarParser(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/mirai.dart';

export 'package:mirai/src/parsers/mirai_sized_box/mirai_sized_box_parser.dart';

part 'mirai_fractionally_sized_box.freezed.dart';
part 'mirai_fractionally_sized_box.g.dart';

@freezed
class MiraiFractionallySizedBox with _$MiraiFractionallySizedBox {
const factory MiraiFractionallySizedBox({
MiraiAlignment? alignment,
double? widthFactor,
double? heightFactor,
Map<String, dynamic>? child,
}) = _MiraiFractionallySizedBox;

factory MiraiFractionallySizedBox.fromJson(Map<String, dynamic> json) =>
_$MiraiFractionallySizedBoxFromJson(json);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
// 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_fractionally_sized_box.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');

MiraiFractionallySizedBox _$MiraiFractionallySizedBoxFromJson(
Map<String, dynamic> json) {
return _MiraiFractionallySizedBox.fromJson(json);
}

/// @nodoc
mixin _$MiraiFractionallySizedBox {
MiraiAlignment? 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)
$MiraiFractionallySizedBoxCopyWith<MiraiFractionallySizedBox> get copyWith =>
throw _privateConstructorUsedError;
}

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

/// @nodoc
class _$MiraiFractionallySizedBoxCopyWithImpl<$Res,
$Val extends MiraiFractionallySizedBox>
implements $MiraiFractionallySizedBoxCopyWith<$Res> {
_$MiraiFractionallySizedBoxCopyWithImpl(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 = freezed,
Object? widthFactor = freezed,
Object? heightFactor = freezed,
Object? child = freezed,
}) {
return _then(_value.copyWith(
alignment: freezed == alignment
? _value.alignment
: alignment // ignore: cast_nullable_to_non_nullable
as MiraiAlignment?,
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 _$$_MiraiFractionallySizedBoxCopyWith<$Res>
implements $MiraiFractionallySizedBoxCopyWith<$Res> {
factory _$$_MiraiFractionallySizedBoxCopyWith(
_$_MiraiFractionallySizedBox value,
$Res Function(_$_MiraiFractionallySizedBox) then) =
__$$_MiraiFractionallySizedBoxCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{MiraiAlignment? alignment,
double? widthFactor,
double? heightFactor,
Map<String, dynamic>? child});
}

/// @nodoc
class __$$_MiraiFractionallySizedBoxCopyWithImpl<$Res>
extends _$MiraiFractionallySizedBoxCopyWithImpl<$Res,
_$_MiraiFractionallySizedBox>
implements _$$_MiraiFractionallySizedBoxCopyWith<$Res> {
__$$_MiraiFractionallySizedBoxCopyWithImpl(
_$_MiraiFractionallySizedBox _value,
$Res Function(_$_MiraiFractionallySizedBox) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? alignment = freezed,
Object? widthFactor = freezed,
Object? heightFactor = freezed,
Object? child = freezed,
}) {
return _then(_$_MiraiFractionallySizedBox(
alignment: freezed == alignment
? _value.alignment
: alignment // ignore: cast_nullable_to_non_nullable
as MiraiAlignment?,
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 _$_MiraiFractionallySizedBox implements _MiraiFractionallySizedBox {
const _$_MiraiFractionallySizedBox(
{this.alignment,
this.widthFactor,
this.heightFactor,
final Map<String, dynamic>? child})
: _child = child;

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

@override
final MiraiAlignment? 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 'MiraiFractionallySizedBox(alignment: $alignment, widthFactor: $widthFactor, heightFactor: $heightFactor, child: $child)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_MiraiFractionallySizedBox &&
(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')
_$$_MiraiFractionallySizedBoxCopyWith<_$_MiraiFractionallySizedBox>
get copyWith => __$$_MiraiFractionallySizedBoxCopyWithImpl<
_$_MiraiFractionallySizedBox>(this, _$identity);

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

abstract class _MiraiFractionallySizedBox implements MiraiFractionallySizedBox {
const factory _MiraiFractionallySizedBox(
{final MiraiAlignment? alignment,
final double? widthFactor,
final double? heightFactor,
final Map<String, dynamic>? child}) = _$_MiraiFractionallySizedBox;

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

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

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

Loading