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

Fix/animated spec fix #308

Merged
merged 4 commits into from
Jun 19, 2024
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
16 changes: 8 additions & 8 deletions packages/mix/lib/src/specs/flex/flex_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import 'package:flutter/widgets.dart';

import '../../core/styled_widget.dart';
import '../../core/factory/style_mix.dart';
import '../../core/styled_widget.dart';
import '../box/box_spec.dart';
import '../box/box_widget.dart';
import 'flex_spec.dart';
Expand Down Expand Up @@ -56,14 +56,14 @@ class StyledFlex extends StyledWidget {
class FlexSpecWidget extends StatelessWidget {
const FlexSpecWidget({
super.key,
required this.spec,
this.spec,
required this.children,
required this.direction,
});

final List<Widget> children;
final Axis direction;
final FlexSpec spec;
final FlexSpec? spec;

List<Widget> _buildChildren(double? gap) {
if (gap == null) return children;
Expand All @@ -79,17 +79,17 @@ class FlexSpecWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
final gap = spec.gap;
final gap = spec?.gap;

return Flex(
direction: direction,
mainAxisAlignment:
spec.mainAxisAlignment ?? _defaultFlex.mainAxisAlignment,
mainAxisSize: spec.mainAxisSize ?? _defaultFlex.mainAxisSize,
spec?.mainAxisAlignment ?? _defaultFlex.mainAxisAlignment,
mainAxisSize: spec?.mainAxisSize ?? _defaultFlex.mainAxisSize,
crossAxisAlignment:
spec.crossAxisAlignment ?? _defaultFlex.crossAxisAlignment,
spec?.crossAxisAlignment ?? _defaultFlex.crossAxisAlignment,
verticalDirection:
spec.verticalDirection ?? _defaultFlex.verticalDirection,
spec?.verticalDirection ?? _defaultFlex.verticalDirection,
children: _buildChildren(gap),
);
}
Expand Down
8 changes: 3 additions & 5 deletions packages/mix/lib/src/specs/icon/icon_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';

import '../../core/factory/mix_provider.dart';
import '../../core/styled_widget.dart';
import 'icon_spec.dart';

Expand All @@ -23,16 +22,15 @@ class StyledIcon extends StyledWidget {
Widget build(BuildContext context) {
return withMix(context, (context) {
final spec = IconSpec.of(context);
final mix = Mix.of(context);

return mix.isAnimated
return spec.isAnimated
? AnimatedIconSpecWidget(
icon,
spec: spec,
semanticLabel: semanticLabel,
textDirection: textDirection,
curve: mix.animation!.curve,
duration: mix.animation!.duration,
curve: spec.animated!.curve,
duration: spec.animated!.duration,
)
: IconSpecWidget(
icon,
Expand Down
8 changes: 3 additions & 5 deletions packages/mix/lib/src/specs/image/image_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';

import '../../core/styled_widget.dart';
import '../../internal/constants.dart';
import '../../core/factory/mix_provider.dart';
import 'image_spec.dart';

class StyledImage extends StyledWidget {
Expand Down Expand Up @@ -37,10 +36,9 @@ class StyledImage extends StyledWidget {
@override
Widget build(BuildContext context) {
return withMix(context, (context) {
final mix = Mix.of(context);
final spec = ImageSpec.of(context);

return mix.isAnimated
return spec.isAnimated
? AnimatedImageSpecWidget(
spec: spec,
image: image,
Expand All @@ -49,8 +47,8 @@ class StyledImage extends StyledWidget {
errorBuilder: errorBuilder,
semanticLabel: semanticLabel,
excludeFromSemantics: excludeFromSemantics,
duration: mix.animation!.duration,
curve: mix.animation!.curve,
duration: spec.animated!.duration,
curve: spec.animated!.curve,
gaplessPlayback: gaplessPlayback,
isAntiAlias: isAntiAlias,
matchTextDirection: matchTextDirection,
Expand Down
32 changes: 15 additions & 17 deletions packages/mix/lib/src/specs/text/text_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';

import '../../core/factory/mix_provider.dart';
import '../../core/styled_widget.dart';
import 'text_spec.dart';

Expand Down Expand Up @@ -51,17 +50,16 @@
@override
Widget build(BuildContext context) {
return withMix(context, (context) {
final mix = Mix.of(context);
final spec = TextSpec.of(context);

return mix.isAnimated
return spec.isAnimated
? AnimatedTextSpecWidget(
text,
spec: spec,
semanticsLabel: semanticsLabel,
locale: locale,
duration: mix.animation!.duration,
curve: mix.animation!.curve,
duration: spec.animated!.duration,
curve: spec.animated!.curve,
)
: TextSpecWidget(
text,
Expand All @@ -85,25 +83,25 @@
final String text;
final String? semanticsLabel;
final Locale? locale;
final TextSpec spec;
final TextSpec? spec;

@override
Widget build(BuildContext context) {
// The Text widget is used here, applying the resolved styles and properties from TextSpec.
return Text(
spec.directive?.apply(text) ?? text,
style: spec.style,
strutStyle: spec.strutStyle,
textAlign: spec.textAlign,
textDirection: spec.textDirection,
spec?.directive?.apply(text) ?? text,
style: spec?.style,
strutStyle: spec?.strutStyle,
textAlign: spec?.textAlign,
textDirection: spec?.textDirection,
locale: locale,
softWrap: spec.softWrap,
overflow: spec.overflow,
textScaleFactor: spec.textScaleFactor,
maxLines: spec.maxLines,
softWrap: spec?.softWrap,
overflow: spec?.overflow,
textScaleFactor: spec?.textScaleFactor,

Check notice on line 100 in packages/mix/lib/src/specs/text/text_widget.dart

View workflow job for this annotation

GitHub Actions / Test

'textScaleFactor' is deprecated and shouldn't be used. Use textScaler instead. Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. This feature was deprecated after v3.12.0-2.0.pre.

Try replacing the use of the deprecated member with the replacement. See https://dart.dev/diagnostics/deprecated_member_use to learn more about this problem.
maxLines: spec?.maxLines,
semanticsLabel: semanticsLabel,
textWidthBasis: spec.textWidthBasis,
textHeightBehavior: spec.textHeightBehavior,
textWidthBasis: spec?.textWidthBasis,
textHeightBehavior: spec?.textHeightBehavior,
);
}
}
Expand Down
Loading