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

feat: Added support for textButtonTheme in MiraiTheme #98

Merged
merged 6 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions examples/mirai_gallery/assets/json/example_light_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,13 @@
"blurRadius": 1
}
]
},
"textButtonTheme": {
"style": {
"foregroundColor": "#4D00E9",
"iconColor": "#4D00E9",
"disabledForegroundColor": "#604D00E9",
"disabledIconColor": "#604D00E9"
}
i-asimkhan marked this conversation as resolved.
Show resolved Hide resolved
}
}
8 changes: 8 additions & 0 deletions examples/mirai_gallery/assets/json/text_button_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
"data": "BUTTON"
}
]
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class MiraiButtonStyle with _$MiraiButtonStyle {
String? disabledBackgroundColor,
String? shadowColor,
String? surfaceTintColor,
String? iconColor,
String? disabledIconColor,
i-asimkhan marked this conversation as resolved.
Show resolved Hide resolved
double? elevation,
MiraiTextStyle? textStyle,
MiraiEdgeInsets? padding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ mixin _$MiraiButtonStyle {
String? get disabledBackgroundColor => throw _privateConstructorUsedError;
String? get shadowColor => throw _privateConstructorUsedError;
String? get surfaceTintColor => throw _privateConstructorUsedError;
String? get iconColor => throw _privateConstructorUsedError;
String? get disabledIconColor => throw _privateConstructorUsedError;
double? get elevation => throw _privateConstructorUsedError;
MiraiTextStyle? get textStyle => throw _privateConstructorUsedError;
MiraiEdgeInsets? get padding => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -54,6 +56,8 @@ abstract class $MiraiButtonStyleCopyWith<$Res> {
String? disabledBackgroundColor,
String? shadowColor,
String? surfaceTintColor,
String? iconColor,
String? disabledIconColor,
double? elevation,
MiraiTextStyle? textStyle,
MiraiEdgeInsets? padding,
Expand Down Expand Up @@ -89,6 +93,8 @@ class _$MiraiButtonStyleCopyWithImpl<$Res, $Val extends MiraiButtonStyle>
Object? disabledBackgroundColor = freezed,
Object? shadowColor = freezed,
Object? surfaceTintColor = freezed,
Object? iconColor = freezed,
Object? disabledIconColor = freezed,
Object? elevation = freezed,
Object? textStyle = freezed,
Object? padding = freezed,
Expand Down Expand Up @@ -123,6 +129,14 @@ class _$MiraiButtonStyleCopyWithImpl<$Res, $Val extends MiraiButtonStyle>
? _value.surfaceTintColor
: surfaceTintColor // ignore: cast_nullable_to_non_nullable
as String?,
iconColor: freezed == iconColor
? _value.iconColor
: iconColor // ignore: cast_nullable_to_non_nullable
as String?,
disabledIconColor: freezed == disabledIconColor
? _value.disabledIconColor
: disabledIconColor // ignore: cast_nullable_to_non_nullable
as String?,
elevation: freezed == elevation
? _value.elevation
: elevation // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -234,6 +248,8 @@ abstract class _$$_MiraiButtonStyleCopyWith<$Res>
String? disabledBackgroundColor,
String? shadowColor,
String? surfaceTintColor,
String? iconColor,
String? disabledIconColor,
double? elevation,
MiraiTextStyle? textStyle,
MiraiEdgeInsets? padding,
Expand Down Expand Up @@ -272,6 +288,8 @@ class __$$_MiraiButtonStyleCopyWithImpl<$Res>
Object? disabledBackgroundColor = freezed,
Object? shadowColor = freezed,
Object? surfaceTintColor = freezed,
Object? iconColor = freezed,
Object? disabledIconColor = freezed,
Object? elevation = freezed,
Object? textStyle = freezed,
Object? padding = freezed,
Expand Down Expand Up @@ -306,6 +324,14 @@ class __$$_MiraiButtonStyleCopyWithImpl<$Res>
? _value.surfaceTintColor
: surfaceTintColor // ignore: cast_nullable_to_non_nullable
as String?,
iconColor: freezed == iconColor
? _value.iconColor
: iconColor // ignore: cast_nullable_to_non_nullable
as String?,
disabledIconColor: freezed == disabledIconColor
? _value.disabledIconColor
: disabledIconColor // ignore: cast_nullable_to_non_nullable
as String?,
elevation: freezed == elevation
? _value.elevation
: elevation // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -352,6 +378,8 @@ class _$_MiraiButtonStyle implements _MiraiButtonStyle {
this.disabledBackgroundColor,
this.shadowColor,
this.surfaceTintColor,
this.iconColor,
this.disabledIconColor,
this.elevation,
this.textStyle,
this.padding,
Expand All @@ -377,6 +405,10 @@ class _$_MiraiButtonStyle implements _MiraiButtonStyle {
@override
final String? surfaceTintColor;
@override
final String? iconColor;
@override
final String? disabledIconColor;
@override
final double? elevation;
@override
final MiraiTextStyle? textStyle;
Expand All @@ -395,7 +427,7 @@ class _$_MiraiButtonStyle implements _MiraiButtonStyle {

@override
String toString() {
return 'MiraiButtonStyle(foregroundColor: $foregroundColor, backgroundColor: $backgroundColor, disabledForegroundColor: $disabledForegroundColor, disabledBackgroundColor: $disabledBackgroundColor, shadowColor: $shadowColor, surfaceTintColor: $surfaceTintColor, elevation: $elevation, textStyle: $textStyle, padding: $padding, minimumSize: $minimumSize, fixedSize: $fixedSize, maximumSize: $maximumSize, enableFeedback: $enableFeedback, iconSize: $iconSize)';
return 'MiraiButtonStyle(foregroundColor: $foregroundColor, backgroundColor: $backgroundColor, disabledForegroundColor: $disabledForegroundColor, disabledBackgroundColor: $disabledBackgroundColor, shadowColor: $shadowColor, surfaceTintColor: $surfaceTintColor, iconColor: $iconColor, disabledIconColor: $disabledIconColor, elevation: $elevation, textStyle: $textStyle, padding: $padding, minimumSize: $minimumSize, fixedSize: $fixedSize, maximumSize: $maximumSize, enableFeedback: $enableFeedback, iconSize: $iconSize)';
}

@override
Expand All @@ -417,6 +449,10 @@ class _$_MiraiButtonStyle implements _MiraiButtonStyle {
other.shadowColor == shadowColor) &&
(identical(other.surfaceTintColor, surfaceTintColor) ||
other.surfaceTintColor == surfaceTintColor) &&
(identical(other.iconColor, iconColor) ||
other.iconColor == iconColor) &&
(identical(other.disabledIconColor, disabledIconColor) ||
other.disabledIconColor == disabledIconColor) &&
(identical(other.elevation, elevation) ||
other.elevation == elevation) &&
(identical(other.textStyle, textStyle) ||
Expand Down Expand Up @@ -444,6 +480,8 @@ class _$_MiraiButtonStyle implements _MiraiButtonStyle {
disabledBackgroundColor,
shadowColor,
surfaceTintColor,
iconColor,
disabledIconColor,
elevation,
textStyle,
padding,
Expand Down Expand Up @@ -475,6 +513,8 @@ abstract class _MiraiButtonStyle implements MiraiButtonStyle {
final String? disabledBackgroundColor,
final String? shadowColor,
final String? surfaceTintColor,
final String? iconColor,
final String? disabledIconColor,
final double? elevation,
final MiraiTextStyle? textStyle,
final MiraiEdgeInsets? padding,
Expand All @@ -500,6 +540,10 @@ abstract class _MiraiButtonStyle implements MiraiButtonStyle {
@override
String? get surfaceTintColor;
@override
String? get iconColor;
@override
String? get disabledIconColor;
@override
double? get elevation;
@override
MiraiTextStyle? get textStyle;
Expand Down

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,21 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/mirai.dart';

part 'mirai_text_button_theme_data.freezed.dart';
part 'mirai_text_button_theme_data.g.dart';

@freezed
class MiraiTextButtonThemeData with _$MiraiTextButtonThemeData {
const factory MiraiTextButtonThemeData({MiraiButtonStyle? style}) =
_MiraiTextButtonThemeData;

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

extension MiraiTextButtonThemeDataParser on MiraiTextButtonThemeData {
TextButtonThemeData get parse {
return TextButtonThemeData(style: style?.parseText);
}
}
i-asimkhan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// 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_text_button_theme_data.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');

MiraiTextButtonThemeData _$MiraiTextButtonThemeDataFromJson(
Map<String, dynamic> json) {
return _MiraiTextButtonThemeData.fromJson(json);
}

/// @nodoc
mixin _$MiraiTextButtonThemeData {
MiraiButtonStyle? get style => throw _privateConstructorUsedError;

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

/// @nodoc
abstract class $MiraiTextButtonThemeDataCopyWith<$Res> {
factory $MiraiTextButtonThemeDataCopyWith(MiraiTextButtonThemeData value,
$Res Function(MiraiTextButtonThemeData) then) =
_$MiraiTextButtonThemeDataCopyWithImpl<$Res, MiraiTextButtonThemeData>;
@useResult
$Res call({MiraiButtonStyle? style});

$MiraiButtonStyleCopyWith<$Res>? get style;
}

/// @nodoc
class _$MiraiTextButtonThemeDataCopyWithImpl<$Res,
$Val extends MiraiTextButtonThemeData>
implements $MiraiTextButtonThemeDataCopyWith<$Res> {
_$MiraiTextButtonThemeDataCopyWithImpl(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? style = freezed,
}) {
return _then(_value.copyWith(
style: freezed == style
? _value.style
: style // ignore: cast_nullable_to_non_nullable
as MiraiButtonStyle?,
) as $Val);
}

@override
@pragma('vm:prefer-inline')
$MiraiButtonStyleCopyWith<$Res>? get style {
if (_value.style == null) {
return null;
}

return $MiraiButtonStyleCopyWith<$Res>(_value.style!, (value) {
return _then(_value.copyWith(style: value) as $Val);
});
}
}

/// @nodoc
abstract class _$$_MiraiTextButtonThemeDataCopyWith<$Res>
implements $MiraiTextButtonThemeDataCopyWith<$Res> {
factory _$$_MiraiTextButtonThemeDataCopyWith(
_$_MiraiTextButtonThemeData value,
$Res Function(_$_MiraiTextButtonThemeData) then) =
__$$_MiraiTextButtonThemeDataCopyWithImpl<$Res>;
@override
@useResult
$Res call({MiraiButtonStyle? style});

@override
$MiraiButtonStyleCopyWith<$Res>? get style;
}

/// @nodoc
class __$$_MiraiTextButtonThemeDataCopyWithImpl<$Res>
extends _$MiraiTextButtonThemeDataCopyWithImpl<$Res,
_$_MiraiTextButtonThemeData>
implements _$$_MiraiTextButtonThemeDataCopyWith<$Res> {
__$$_MiraiTextButtonThemeDataCopyWithImpl(_$_MiraiTextButtonThemeData _value,
$Res Function(_$_MiraiTextButtonThemeData) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? style = freezed,
}) {
return _then(_$_MiraiTextButtonThemeData(
style: freezed == style
? _value.style
: style // ignore: cast_nullable_to_non_nullable
as MiraiButtonStyle?,
));
}
}

/// @nodoc
@JsonSerializable()
class _$_MiraiTextButtonThemeData implements _MiraiTextButtonThemeData {
const _$_MiraiTextButtonThemeData({this.style});

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

@override
final MiraiButtonStyle? style;

@override
String toString() {
return 'MiraiTextButtonThemeData(style: $style)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_MiraiTextButtonThemeData &&
(identical(other.style, style) || other.style == style));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, style);

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

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

abstract class _MiraiTextButtonThemeData implements MiraiTextButtonThemeData {
const factory _MiraiTextButtonThemeData({final MiraiButtonStyle? style}) =
_$_MiraiTextButtonThemeData;

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

@override
MiraiButtonStyle? get style;
@override
@JsonKey(ignore: true)
_$$_MiraiTextButtonThemeDataCopyWith<_$_MiraiTextButtonThemeData>
get copyWith => throw _privateConstructorUsedError;
}
Loading