-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from cscoderr/spacer
feat: Add support for spacer widget
- Loading branch information
Showing
9 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"type": "scaffold", | ||
"appBar": { | ||
"type": "appBar", | ||
"title": { | ||
"type": "text", | ||
"data": "Spacer" | ||
} | ||
}, | ||
"body": { | ||
"type": "padding", | ||
"padding": { | ||
"left": 20, | ||
"right": 20, | ||
"top": 20, | ||
"bottom": 20 | ||
}, | ||
"child": { | ||
"type": "column", | ||
"children": [ | ||
{ | ||
"type": "textField", | ||
"keyboardType": "text", | ||
"maxLines": 1, | ||
"decoration": { | ||
"hintText": "Enter your pin" | ||
} | ||
}, | ||
{ | ||
"type": "spacer" | ||
}, | ||
{ | ||
"type": "row", | ||
"children": [ | ||
{ | ||
"type": "row", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"data": "Forgot Pin", | ||
"style": { | ||
"fontSize": 17 | ||
} | ||
}, | ||
{ | ||
"type": "icon", | ||
"iconType": "material", | ||
"icon": "keyboard_arrow_right", | ||
"size": 24 | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "spacer" | ||
}, | ||
{ | ||
"type": "text", | ||
"data": "Need help?", | ||
"style": { | ||
"fontSize": 17 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "spacer", | ||
"flex": 2 | ||
}, | ||
{ | ||
"type": "elevatedButton", | ||
"child": { | ||
"type": "text", | ||
"data": "Submit" | ||
}, | ||
"style": { | ||
"backgroundColor": "primary", | ||
"foregroundColor": "#ffffff" | ||
}, | ||
"onPressed": {} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
152 changes: 152 additions & 0 deletions
152
packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.freezed.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// 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_spacer.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#adding-getters-and-methods-to-our-models'); | ||
|
||
MiraiSpacer _$MiraiSpacerFromJson(Map<String, dynamic> json) { | ||
return _MiraiSpacer.fromJson(json); | ||
} | ||
|
||
/// @nodoc | ||
mixin _$MiraiSpacer { | ||
int get flex => throw _privateConstructorUsedError; | ||
|
||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; | ||
@JsonKey(ignore: true) | ||
$MiraiSpacerCopyWith<MiraiSpacer> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} | ||
|
||
/// @nodoc | ||
abstract class $MiraiSpacerCopyWith<$Res> { | ||
factory $MiraiSpacerCopyWith( | ||
MiraiSpacer value, $Res Function(MiraiSpacer) then) = | ||
_$MiraiSpacerCopyWithImpl<$Res, MiraiSpacer>; | ||
@useResult | ||
$Res call({int flex}); | ||
} | ||
|
||
/// @nodoc | ||
class _$MiraiSpacerCopyWithImpl<$Res, $Val extends MiraiSpacer> | ||
implements $MiraiSpacerCopyWith<$Res> { | ||
_$MiraiSpacerCopyWithImpl(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? flex = null, | ||
}) { | ||
return _then(_value.copyWith( | ||
flex: null == flex | ||
? _value.flex | ||
: flex // ignore: cast_nullable_to_non_nullable | ||
as int, | ||
) as $Val); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
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 __$$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(_$MiraiSpacerImpl( | ||
flex: null == flex | ||
? _value.flex | ||
: flex // ignore: cast_nullable_to_non_nullable | ||
as int, | ||
)); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
@JsonSerializable() | ||
class _$MiraiSpacerImpl implements _MiraiSpacer { | ||
const _$MiraiSpacerImpl({this.flex = 1}); | ||
|
||
factory _$MiraiSpacerImpl.fromJson(Map<String, dynamic> json) => | ||
_$$MiraiSpacerImplFromJson(json); | ||
|
||
@override | ||
@JsonKey() | ||
final int flex; | ||
|
||
@override | ||
String toString() { | ||
return 'MiraiSpacer(flex: $flex)'; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
return identical(this, other) || | ||
(other.runtimeType == runtimeType && | ||
other is _$MiraiSpacerImpl && | ||
(identical(other.flex, flex) || other.flex == flex)); | ||
} | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
int get hashCode => Object.hash(runtimeType, flex); | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
@pragma('vm:prefer-inline') | ||
_$$MiraiSpacerImplCopyWith<_$MiraiSpacerImpl> get copyWith => | ||
__$$MiraiSpacerImplCopyWithImpl<_$MiraiSpacerImpl>(this, _$identity); | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return _$$MiraiSpacerImplToJson( | ||
this, | ||
); | ||
} | ||
} | ||
|
||
abstract class _MiraiSpacer implements MiraiSpacer { | ||
const factory _MiraiSpacer({final int flex}) = _$MiraiSpacerImpl; | ||
|
||
factory _MiraiSpacer.fromJson(Map<String, dynamic> json) = | ||
_$MiraiSpacerImpl.fromJson; | ||
|
||
@override | ||
int get flex; | ||
@override | ||
@JsonKey(ignore: true) | ||
_$$MiraiSpacerImplCopyWith<_$MiraiSpacerImpl> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer_parser.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ enum WidgetType { | |
checkBox, | ||
expanded, | ||
flexible, | ||
spacer, | ||
safeArea, | ||
align, | ||
pageView, | ||
|