From 567c2d536ca9b9c764523014db6f9fd551704d49 Mon Sep 17 00:00:00 2001 From: mabdo Date: Sun, 19 Jan 2025 14:37:21 +0400 Subject: [PATCH] remove MiraiVisibility Widget --- .../assets/json/home_screen.json | 33 -- .../assets/json/visibility_example.json | 46 --- packages/mirai/lib/src/framework/mirai.dart | 1 - .../mirai_visibility/mirai_visibility.dart | 23 -- .../mirai_visibility.freezed.dart | 346 ------------------ .../mirai_visibility/mirai_visibility.g.dart | 33 -- .../mirai_visibility_parser.dart | 31 -- packages/mirai/lib/src/parsers/parsers.dart | 1 - packages/mirai/lib/src/utils/widget_type.dart | 1 - 9 files changed, 515 deletions(-) delete mode 100644 examples/mirai_gallery/assets/json/visibility_example.json delete mode 100644 packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.dart delete mode 100644 packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.freezed.dart delete mode 100644 packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.g.dart delete mode 100644 packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility_parser.dart diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index 2b25534f..bd9d2cfe 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -1729,39 +1729,6 @@ } }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "visibility" - }, - - "title": { - "type": "text", - "data": "Mirai Visibility", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design Mirai Visibility widget", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/visibility_example.json" - } - } - }, - { "type": "sizedBox", diff --git a/examples/mirai_gallery/assets/json/visibility_example.json b/examples/mirai_gallery/assets/json/visibility_example.json deleted file mode 100644 index bf02dbe9..00000000 --- a/examples/mirai_gallery/assets/json/visibility_example.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "type": "scaffold", - "appBar": { - "type": "appBar", - "title": { - "type": "text", - "data": "Visibility" - } - }, - "body": { - "type": "listView", - "shrinkWrap": true, - "children": [ - { - "type": "sizedBox", - "height": 25 - }, - { - "type": "visibility", - "child": { - "type": "text", - "data": "I am visible!" - }, - "visible": true - }, - { - "type": "sizedBox", - "height": 25 - }, - { - "type": "visibility", - "child": { - "type": "text", - "data": "I am hidden!" - }, - "replacement": { - "type": "container", - "color": "#FF5733", - "width": 50, - "height": 50 - }, - "visible": false - } - ] - } -} \ No newline at end of file diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index 301d777b..98cfda8e 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -95,7 +95,6 @@ class Mirai { const MiraiAspectRatioParser(), const MiraiFittedBoxParser(), const MiraiLimitedBoxParser(), - const MiraiVisibilityParser() ]; static final _actionParsers = [ diff --git a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.dart b/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.dart deleted file mode 100644 index 5dd4f45b..00000000 --- a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'package:mirai/src/parsers/mirai_visibility/mirai_visibility_parser.dart'; - -part 'mirai_visibility.freezed.dart'; -part 'mirai_visibility.g.dart'; - -@freezed -class MiraiVisibility with _$MiraiVisibility { - const factory MiraiVisibility({ - required Map child, - Map? replacement, - @Default(true) bool visible, - @Default(false) bool maintainState, - @Default(false) bool maintainAnimation, - @Default(false) bool maintainSize, - @Default(false) bool maintainSemantics, - @Default(false) bool maintainInteractivity, - }) = _MiraiVisibility; - - factory MiraiVisibility.fromJson(Map json) => - _$MiraiVisibilityFromJson(json); -} diff --git a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.freezed.dart b/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.freezed.dart deleted file mode 100644 index fd5d108e..00000000 --- a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.freezed.dart +++ /dev/null @@ -1,346 +0,0 @@ -// 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_visibility.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(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'); - -MiraiVisibility _$MiraiVisibilityFromJson(Map json) { - return _MiraiVisibility.fromJson(json); -} - -/// @nodoc -mixin _$MiraiVisibility { - Map get child => throw _privateConstructorUsedError; - Map? get replacement => throw _privateConstructorUsedError; - bool get visible => throw _privateConstructorUsedError; - bool get maintainState => throw _privateConstructorUsedError; - bool get maintainAnimation => throw _privateConstructorUsedError; - bool get maintainSize => throw _privateConstructorUsedError; - bool get maintainSemantics => throw _privateConstructorUsedError; - bool get maintainInteractivity => throw _privateConstructorUsedError; - - /// Serializes this MiraiVisibility to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of MiraiVisibility - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $MiraiVisibilityCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $MiraiVisibilityCopyWith<$Res> { - factory $MiraiVisibilityCopyWith( - MiraiVisibility value, $Res Function(MiraiVisibility) then) = - _$MiraiVisibilityCopyWithImpl<$Res, MiraiVisibility>; - @useResult - $Res call( - {Map child, - Map? replacement, - bool visible, - bool maintainState, - bool maintainAnimation, - bool maintainSize, - bool maintainSemantics, - bool maintainInteractivity}); -} - -/// @nodoc -class _$MiraiVisibilityCopyWithImpl<$Res, $Val extends MiraiVisibility> - implements $MiraiVisibilityCopyWith<$Res> { - _$MiraiVisibilityCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of MiraiVisibility - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? child = null, - Object? replacement = freezed, - Object? visible = null, - Object? maintainState = null, - Object? maintainAnimation = null, - Object? maintainSize = null, - Object? maintainSemantics = null, - Object? maintainInteractivity = null, - }) { - return _then(_value.copyWith( - child: null == child - ? _value.child - : child // ignore: cast_nullable_to_non_nullable - as Map, - replacement: freezed == replacement - ? _value.replacement - : replacement // ignore: cast_nullable_to_non_nullable - as Map?, - visible: null == visible - ? _value.visible - : visible // ignore: cast_nullable_to_non_nullable - as bool, - maintainState: null == maintainState - ? _value.maintainState - : maintainState // ignore: cast_nullable_to_non_nullable - as bool, - maintainAnimation: null == maintainAnimation - ? _value.maintainAnimation - : maintainAnimation // ignore: cast_nullable_to_non_nullable - as bool, - maintainSize: null == maintainSize - ? _value.maintainSize - : maintainSize // ignore: cast_nullable_to_non_nullable - as bool, - maintainSemantics: null == maintainSemantics - ? _value.maintainSemantics - : maintainSemantics // ignore: cast_nullable_to_non_nullable - as bool, - maintainInteractivity: null == maintainInteractivity - ? _value.maintainInteractivity - : maintainInteractivity // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$MiraiVisibilityImplCopyWith<$Res> - implements $MiraiVisibilityCopyWith<$Res> { - factory _$$MiraiVisibilityImplCopyWith(_$MiraiVisibilityImpl value, - $Res Function(_$MiraiVisibilityImpl) then) = - __$$MiraiVisibilityImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {Map child, - Map? replacement, - bool visible, - bool maintainState, - bool maintainAnimation, - bool maintainSize, - bool maintainSemantics, - bool maintainInteractivity}); -} - -/// @nodoc -class __$$MiraiVisibilityImplCopyWithImpl<$Res> - extends _$MiraiVisibilityCopyWithImpl<$Res, _$MiraiVisibilityImpl> - implements _$$MiraiVisibilityImplCopyWith<$Res> { - __$$MiraiVisibilityImplCopyWithImpl( - _$MiraiVisibilityImpl _value, $Res Function(_$MiraiVisibilityImpl) _then) - : super(_value, _then); - - /// Create a copy of MiraiVisibility - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? child = null, - Object? replacement = freezed, - Object? visible = null, - Object? maintainState = null, - Object? maintainAnimation = null, - Object? maintainSize = null, - Object? maintainSemantics = null, - Object? maintainInteractivity = null, - }) { - return _then(_$MiraiVisibilityImpl( - child: null == child - ? _value._child - : child // ignore: cast_nullable_to_non_nullable - as Map, - replacement: freezed == replacement - ? _value._replacement - : replacement // ignore: cast_nullable_to_non_nullable - as Map?, - visible: null == visible - ? _value.visible - : visible // ignore: cast_nullable_to_non_nullable - as bool, - maintainState: null == maintainState - ? _value.maintainState - : maintainState // ignore: cast_nullable_to_non_nullable - as bool, - maintainAnimation: null == maintainAnimation - ? _value.maintainAnimation - : maintainAnimation // ignore: cast_nullable_to_non_nullable - as bool, - maintainSize: null == maintainSize - ? _value.maintainSize - : maintainSize // ignore: cast_nullable_to_non_nullable - as bool, - maintainSemantics: null == maintainSemantics - ? _value.maintainSemantics - : maintainSemantics // ignore: cast_nullable_to_non_nullable - as bool, - maintainInteractivity: null == maintainInteractivity - ? _value.maintainInteractivity - : maintainInteractivity // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$MiraiVisibilityImpl implements _MiraiVisibility { - const _$MiraiVisibilityImpl( - {required final Map child, - final Map? replacement, - this.visible = true, - this.maintainState = false, - this.maintainAnimation = false, - this.maintainSize = false, - this.maintainSemantics = false, - this.maintainInteractivity = false}) - : _child = child, - _replacement = replacement; - - factory _$MiraiVisibilityImpl.fromJson(Map json) => - _$$MiraiVisibilityImplFromJson(json); - - final Map _child; - @override - Map get child { - if (_child is EqualUnmodifiableMapView) return _child; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_child); - } - - final Map? _replacement; - @override - Map? get replacement { - final value = _replacement; - if (value == null) return null; - if (_replacement is EqualUnmodifiableMapView) return _replacement; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - @JsonKey() - final bool visible; - @override - @JsonKey() - final bool maintainState; - @override - @JsonKey() - final bool maintainAnimation; - @override - @JsonKey() - final bool maintainSize; - @override - @JsonKey() - final bool maintainSemantics; - @override - @JsonKey() - final bool maintainInteractivity; - - @override - String toString() { - return 'MiraiVisibility(child: $child, replacement: $replacement, visible: $visible, maintainState: $maintainState, maintainAnimation: $maintainAnimation, maintainSize: $maintainSize, maintainSemantics: $maintainSemantics, maintainInteractivity: $maintainInteractivity)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MiraiVisibilityImpl && - const DeepCollectionEquality().equals(other._child, _child) && - const DeepCollectionEquality() - .equals(other._replacement, _replacement) && - (identical(other.visible, visible) || other.visible == visible) && - (identical(other.maintainState, maintainState) || - other.maintainState == maintainState) && - (identical(other.maintainAnimation, maintainAnimation) || - other.maintainAnimation == maintainAnimation) && - (identical(other.maintainSize, maintainSize) || - other.maintainSize == maintainSize) && - (identical(other.maintainSemantics, maintainSemantics) || - other.maintainSemantics == maintainSemantics) && - (identical(other.maintainInteractivity, maintainInteractivity) || - other.maintainInteractivity == maintainInteractivity)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_child), - const DeepCollectionEquality().hash(_replacement), - visible, - maintainState, - maintainAnimation, - maintainSize, - maintainSemantics, - maintainInteractivity); - - /// Create a copy of MiraiVisibility - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$MiraiVisibilityImplCopyWith<_$MiraiVisibilityImpl> get copyWith => - __$$MiraiVisibilityImplCopyWithImpl<_$MiraiVisibilityImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$MiraiVisibilityImplToJson( - this, - ); - } -} - -abstract class _MiraiVisibility implements MiraiVisibility { - const factory _MiraiVisibility( - {required final Map child, - final Map? replacement, - final bool visible, - final bool maintainState, - final bool maintainAnimation, - final bool maintainSize, - final bool maintainSemantics, - final bool maintainInteractivity}) = _$MiraiVisibilityImpl; - - factory _MiraiVisibility.fromJson(Map json) = - _$MiraiVisibilityImpl.fromJson; - - @override - Map get child; - @override - Map? get replacement; - @override - bool get visible; - @override - bool get maintainState; - @override - bool get maintainAnimation; - @override - bool get maintainSize; - @override - bool get maintainSemantics; - @override - bool get maintainInteractivity; - - /// Create a copy of MiraiVisibility - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$MiraiVisibilityImplCopyWith<_$MiraiVisibilityImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.g.dart b/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.g.dart deleted file mode 100644 index e9104b19..00000000 --- a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility.g.dart +++ /dev/null @@ -1,33 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'mirai_visibility.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$MiraiVisibilityImpl _$$MiraiVisibilityImplFromJson( - Map json) => - _$MiraiVisibilityImpl( - child: json['child'] as Map, - replacement: json['replacement'] as Map?, - visible: json['visible'] as bool? ?? true, - maintainState: json['maintainState'] as bool? ?? false, - maintainAnimation: json['maintainAnimation'] as bool? ?? false, - maintainSize: json['maintainSize'] as bool? ?? false, - maintainSemantics: json['maintainSemantics'] as bool? ?? false, - maintainInteractivity: json['maintainInteractivity'] as bool? ?? false, - ); - -Map _$$MiraiVisibilityImplToJson( - _$MiraiVisibilityImpl instance) => - { - 'child': instance.child, - 'replacement': instance.replacement, - 'visible': instance.visible, - 'maintainState': instance.maintainState, - 'maintainAnimation': instance.maintainAnimation, - 'maintainSize': instance.maintainSize, - 'maintainSemantics': instance.maintainSemantics, - 'maintainInteractivity': instance.maintainInteractivity, - }; diff --git a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility_parser.dart b/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility_parser.dart deleted file mode 100644 index c9e169f3..00000000 --- a/packages/mirai/lib/src/parsers/mirai_visibility/mirai_visibility_parser.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:mirai/src/framework/framework.dart'; -import 'package:mirai/src/parsers/mirai_visibility/mirai_visibility.dart'; -import 'package:mirai/src/utils/widget_type.dart'; -import 'package:mirai_framework/mirai_framework.dart'; - -class MiraiVisibilityParser extends MiraiParser { - const MiraiVisibilityParser(); - - @override - String get type => WidgetType.visibility.name; - - @override - MiraiVisibility getModel(Map json) => - MiraiVisibility.fromJson(json); - - @override - Widget parse(BuildContext context, MiraiVisibility model) { - return Visibility( - visible: model.visible, - maintainState: model.maintainState, - maintainAnimation: model.maintainAnimation, - maintainSize: model.maintainSize, - maintainSemantics: model.maintainSemantics, - maintainInteractivity: model.maintainInteractivity, - replacement: - Mirai.fromJson(model.replacement, context) ?? SizedBox.shrink(), - child: Mirai.fromJson(model.child, context) ?? SizedBox.shrink(), - ); - } -} diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index 1d0968d2..304ab6be 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -90,4 +90,3 @@ export 'package:mirai/src/parsers/mirai_placeholder/mirai_placeholder.dart'; export 'package:mirai/src/parsers/mirai_aspect_ratio/mirai_aspect_ratio.dart'; export 'package:mirai/src/parsers/mirai_fitted_box/mirai_fitted_box.dart'; export 'package:mirai/src/parsers/mirai_limited_box/mirai_limited_box.dart'; -export 'package:mirai/src/parsers/mirai_visibility/mirai_visibility.dart'; diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index 59dc7ae9..2033b652 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -65,5 +65,4 @@ enum WidgetType { aspectRatio, fittedBox, limitedBox, - visibility, }