-
Notifications
You must be signed in to change notification settings - Fork 21
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 #20 from bhattkrutij/support-for-the-Divider-widget
feat: Add support for the Divider widget
- Loading branch information
Showing
9 changed files
with
338 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"type": "scaffold", | ||
"appBar": { | ||
"type": "appBar", | ||
"title": { | ||
"type": "text", | ||
"data": "Divider" | ||
} | ||
}, | ||
"body": { | ||
"type": "listView", | ||
"children": [{ | ||
"type": "divider", | ||
"thickness": 5, | ||
"height": 5, | ||
"color": "#672BFF" | ||
}, | ||
{ | ||
"type": "sizedBox", | ||
"height": 20 | ||
}, | ||
{ | ||
"type": "divider", | ||
"thickness": 3, | ||
"height": 3, | ||
"color": "#FC5632" | ||
}, | ||
{ | ||
"type": "sizedBox", | ||
"height": 20 | ||
}, | ||
{ | ||
"type": "divider", | ||
"thickness": 2, | ||
"height": 2, | ||
"color": "#32FC88" | ||
}] | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
packages/mirai/lib/src/parsers/mirai_divider/mirai_divider.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'; | ||
|
||
part 'mirai_divider.freezed.dart'; // Auto-generated Freezed file | ||
part 'mirai_divider.g.dart'; // Auto-generated JSON serialization file | ||
|
||
@freezed | ||
class MiraiDivider with _$MiraiDivider { | ||
const factory MiraiDivider({ | ||
double? thickness, | ||
double? height, | ||
String? color, | ||
}) = _MiraiDivider; | ||
|
||
factory MiraiDivider.fromJson(Map<String, dynamic> json) => | ||
_$MiraiDividerFromJson(json); | ||
} |
200 changes: 200 additions & 0 deletions
200
packages/mirai/lib/src/parsers/mirai_divider/mirai_divider.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,200 @@ | ||
// 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_divider.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'); | ||
|
||
MiraiDivider _$MiraiDividerFromJson(Map<String, dynamic> json) { | ||
return _MiraiDivider.fromJson(json); | ||
} | ||
|
||
/// @nodoc | ||
mixin _$MiraiDivider { | ||
double? get thickness => throw _privateConstructorUsedError; | ||
double? get height => throw _privateConstructorUsedError; | ||
String? get color => throw _privateConstructorUsedError; | ||
|
||
/// Serializes this MiraiDivider to a JSON map. | ||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; | ||
|
||
/// Create a copy of MiraiDivider | ||
/// with the given fields replaced by the non-null parameter values. | ||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
$MiraiDividerCopyWith<MiraiDivider> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} | ||
|
||
/// @nodoc | ||
abstract class $MiraiDividerCopyWith<$Res> { | ||
factory $MiraiDividerCopyWith( | ||
MiraiDivider value, $Res Function(MiraiDivider) then) = | ||
_$MiraiDividerCopyWithImpl<$Res, MiraiDivider>; | ||
@useResult | ||
$Res call({double? thickness, double? height, String? color}); | ||
} | ||
|
||
/// @nodoc | ||
class _$MiraiDividerCopyWithImpl<$Res, $Val extends MiraiDivider> | ||
implements $MiraiDividerCopyWith<$Res> { | ||
_$MiraiDividerCopyWithImpl(this._value, this._then); | ||
|
||
// ignore: unused_field | ||
final $Val _value; | ||
// ignore: unused_field | ||
final $Res Function($Val) _then; | ||
|
||
/// Create a copy of MiraiDivider | ||
/// with the given fields replaced by the non-null parameter values. | ||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? thickness = freezed, | ||
Object? height = freezed, | ||
Object? color = freezed, | ||
}) { | ||
return _then(_value.copyWith( | ||
thickness: freezed == thickness | ||
? _value.thickness | ||
: thickness // ignore: cast_nullable_to_non_nullable | ||
as double?, | ||
height: freezed == height | ||
? _value.height | ||
: height // ignore: cast_nullable_to_non_nullable | ||
as double?, | ||
color: freezed == color | ||
? _value.color | ||
: color // ignore: cast_nullable_to_non_nullable | ||
as String?, | ||
) as $Val); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
abstract class _$$MiraiDividerImplCopyWith<$Res> | ||
implements $MiraiDividerCopyWith<$Res> { | ||
factory _$$MiraiDividerImplCopyWith( | ||
_$MiraiDividerImpl value, $Res Function(_$MiraiDividerImpl) then) = | ||
__$$MiraiDividerImplCopyWithImpl<$Res>; | ||
@override | ||
@useResult | ||
$Res call({double? thickness, double? height, String? color}); | ||
} | ||
|
||
/// @nodoc | ||
class __$$MiraiDividerImplCopyWithImpl<$Res> | ||
extends _$MiraiDividerCopyWithImpl<$Res, _$MiraiDividerImpl> | ||
implements _$$MiraiDividerImplCopyWith<$Res> { | ||
__$$MiraiDividerImplCopyWithImpl( | ||
_$MiraiDividerImpl _value, $Res Function(_$MiraiDividerImpl) _then) | ||
: super(_value, _then); | ||
|
||
/// Create a copy of MiraiDivider | ||
/// with the given fields replaced by the non-null parameter values. | ||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? thickness = freezed, | ||
Object? height = freezed, | ||
Object? color = freezed, | ||
}) { | ||
return _then(_$MiraiDividerImpl( | ||
thickness: freezed == thickness | ||
? _value.thickness | ||
: thickness // ignore: cast_nullable_to_non_nullable | ||
as double?, | ||
height: freezed == height | ||
? _value.height | ||
: height // ignore: cast_nullable_to_non_nullable | ||
as double?, | ||
color: freezed == color | ||
? _value.color | ||
: color // ignore: cast_nullable_to_non_nullable | ||
as String?, | ||
)); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
@JsonSerializable() | ||
class _$MiraiDividerImpl implements _MiraiDivider { | ||
const _$MiraiDividerImpl({this.thickness, this.height, this.color}); | ||
|
||
factory _$MiraiDividerImpl.fromJson(Map<String, dynamic> json) => | ||
_$$MiraiDividerImplFromJson(json); | ||
|
||
@override | ||
final double? thickness; | ||
@override | ||
final double? height; | ||
@override | ||
final String? color; | ||
|
||
@override | ||
String toString() { | ||
return 'MiraiDivider(thickness: $thickness, height: $height, color: $color)'; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
return identical(this, other) || | ||
(other.runtimeType == runtimeType && | ||
other is _$MiraiDividerImpl && | ||
(identical(other.thickness, thickness) || | ||
other.thickness == thickness) && | ||
(identical(other.height, height) || other.height == height) && | ||
(identical(other.color, color) || other.color == color)); | ||
} | ||
|
||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
@override | ||
int get hashCode => Object.hash(runtimeType, thickness, height, color); | ||
|
||
/// Create a copy of MiraiDivider | ||
/// with the given fields replaced by the non-null parameter values. | ||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
@override | ||
@pragma('vm:prefer-inline') | ||
_$$MiraiDividerImplCopyWith<_$MiraiDividerImpl> get copyWith => | ||
__$$MiraiDividerImplCopyWithImpl<_$MiraiDividerImpl>(this, _$identity); | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return _$$MiraiDividerImplToJson( | ||
this, | ||
); | ||
} | ||
} | ||
|
||
abstract class _MiraiDivider implements MiraiDivider { | ||
const factory _MiraiDivider( | ||
{final double? thickness, | ||
final double? height, | ||
final String? color}) = _$MiraiDividerImpl; | ||
|
||
factory _MiraiDivider.fromJson(Map<String, dynamic> json) = | ||
_$MiraiDividerImpl.fromJson; | ||
|
||
@override | ||
double? get thickness; | ||
@override | ||
double? get height; | ||
@override | ||
String? get color; | ||
|
||
/// Create a copy of MiraiDivider | ||
/// with the given fields replaced by the non-null parameter values. | ||
@override | ||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
_$$MiraiDividerImplCopyWith<_$MiraiDividerImpl> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/mirai/lib/src/parsers/mirai_divider/mirai_divider.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
packages/mirai/lib/src/parsers/mirai_divider/mirai_divider_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,24 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:mirai/mirai.dart'; | ||
import 'package:mirai/src/utils/widget_type.dart'; | ||
|
||
class MiraiDividerParser extends MiraiParser<MiraiDivider> { | ||
const MiraiDividerParser(); | ||
|
||
@override | ||
MiraiDivider getModel(Map<String, dynamic> json) { | ||
return MiraiDivider.fromJson(json); | ||
} | ||
|
||
@override | ||
Widget parse(BuildContext context, MiraiDivider model) { | ||
return Divider( | ||
thickness: model.thickness, | ||
color: model.color.toColor(context), | ||
height: model.height, | ||
); | ||
} | ||
|
||
@override | ||
String get type => WidgetType.divider.name; | ||
} |
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 |
---|---|---|
|
@@ -53,4 +53,5 @@ enum WidgetType { | |
tableCell, | ||
carouselView, | ||
coloredBox, | ||
divider | ||
} |