diff --git a/.fvmrc b/.fvmrc index a09a8c2f3..c9e0c1af0 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,7 +1,7 @@ { - "flutter": "3.10.6", + "flutter": "3.19.0", "flavors": { "prod": "stable", - "mincompat": "3.10.6" + "mincompat": "3.19.0" } } \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb239c4f6..c8e3ed567 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,4 +46,4 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} run-dcm: false - flutter-version: '3.10.6' \ No newline at end of file + flutter-version: '3.19.0' \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 0565bdbbf..4feffae5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,7 @@ "source.fixAll": "explicit", "source.dcm.fixAll": "explicit" }, - "dart.flutterSdkPath": ".fvm/versions/3.10.6", + "dart.flutterSdkPath": ".fvm/versions/3.19.0", "search.exclude": { "**/.fvm/versions": true }, diff --git a/examples/themed_button/macos/Flutter/GeneratedPluginRegistrant.swift b/examples/themed_button/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 000000000..e777c67df --- /dev/null +++ b/examples/themed_button/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,12 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import path_provider_foundation + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) +} diff --git a/examples/themed_button/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/examples/themed_button/macos/Flutter/ephemeral/Flutter-Generated.xcconfig new file mode 100644 index 000000000..ee4dab857 --- /dev/null +++ b/examples/themed_button/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -0,0 +1,11 @@ +// This is a generated file; do not edit or check into version control. +FLUTTER_ROOT=/Users/lucasoliveira/fvm/versions/3.19.0 +FLUTTER_APPLICATION_PATH=/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/examples/themed_button +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=1.0.0 +FLUTTER_BUILD_NUMBER=1 +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/examples/themed_button/macos/Flutter/ephemeral/flutter_export_environment.sh b/examples/themed_button/macos/Flutter/ephemeral/flutter_export_environment.sh new file mode 100755 index 000000000..4ed367c72 --- /dev/null +++ b/examples/themed_button/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/lucasoliveira/fvm/versions/3.19.0" +export "FLUTTER_APPLICATION_PATH=/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/examples/themed_button" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/examples/themed_button/macos/Podfile b/examples/themed_button/macos/Podfile new file mode 100644 index 000000000..c795730db --- /dev/null +++ b/examples/themed_button/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/examples/themed_button/pubspec.yaml b/examples/themed_button/pubspec.yaml index 22c5bd6e3..4a0b5e3c2 100644 --- a/examples/themed_button/pubspec.yaml +++ b/examples/themed_button/pubspec.yaml @@ -6,8 +6,8 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=3.0.6 <4.0.0" - flutter: ">=3.10.6" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: flutter: diff --git a/examples/todo_list/pubspec.yaml b/examples/todo_list/pubspec.yaml index 15ecfe7b1..3030db5d1 100644 --- a/examples/todo_list/pubspec.yaml +++ b/examples/todo_list/pubspec.yaml @@ -6,8 +6,8 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=3.0.6 <4.0.0" - flutter: ">=3.10.6" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: flutter: diff --git a/melos.yaml b/melos.yaml index ae81efd48..877a6c11d 100644 --- a/melos.yaml +++ b/melos.yaml @@ -18,8 +18,8 @@ categories: command: bootstrap: environment: - sdk: ">=3.0.6 <4.0.0" - flutter: ">=3.10.6" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" publish: hooks: pre: melos run brb diff --git a/packages/mix/analysis_options.yaml b/packages/mix/analysis_options.yaml index e3acf998c..aea72eec4 100644 --- a/packages/mix/analysis_options.yaml +++ b/packages/mix/analysis_options.yaml @@ -25,6 +25,7 @@ dart_code_metrics: avoid-importing-entrypoint-exports: only-in-src: true prefer-match-file-name: false + prefer-overriding-parent-equality: false prefer-correct-callback-field-name: false prefer-single-widget-per-file: false match-getter-setter-field-names: false diff --git a/packages/mix/lib/src/attributes/scalars/scalar_util.dart b/packages/mix/lib/src/attributes/scalars/scalar_util.dart index f880abe4e..747fa5ce1 100644 --- a/packages/mix/lib/src/attributes/scalars/scalar_util.dart +++ b/packages/mix/lib/src/attributes/scalars/scalar_util.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'dart:typed_data'; -import 'dart:ui'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; @@ -161,3 +160,9 @@ final class FontFamilyUtility extends MixUtility with _$FontFamilyUtility { const FontFamilyUtility(super.builder); } + +@MixableClassUtility() +final class TextScalerUtility + extends MixUtility with _$TextScalerUtility { + const TextScalerUtility(super.builder); +} diff --git a/packages/mix/lib/src/attributes/scalars/scalar_util.g.dart b/packages/mix/lib/src/attributes/scalars/scalar_util.g.dart index b1fa8c71b..1bb63e505 100644 --- a/packages/mix/lib/src/attributes/scalars/scalar_util.g.dart +++ b/packages/mix/lib/src/attributes/scalars/scalar_util.g.dart @@ -601,3 +601,22 @@ base mixin _$FontFamilyUtility on MixUtility { /// Creates an [Attribute] instance with the specified String value. T call(String value) => builder(value); } + +/// {@template text_scaler_utility} +/// A utility class for creating [Attribute] instances from [TextScaler] values. +/// +/// This class extends [MixUtility] and provides methods to create [Attribute] instances +/// from predefined [TextScaler] values. +/// {@endtemplate} +base mixin _$TextScalerUtility + on MixUtility { + /// Creates an [Attribute] instance with [TextScaler.noScaling] value. + T noScaling() => builder(TextScaler.noScaling); + + /// Creates an [Attribute] instance using the [TextScaler.linear] constructor. + T linear(double textScaleFactor) => + builder(TextScaler.linear(textScaleFactor)); + + /// Creates an [Attribute] instance with the specified TextScaler value. + T call(TextScaler value) => builder(value); +} diff --git a/packages/mix/lib/src/attributes/text_style/text_style_dto.dart b/packages/mix/lib/src/attributes/text_style/text_style_dto.dart index 3fcdef084..138f83bac 100644 --- a/packages/mix/lib/src/attributes/text_style/text_style_dto.dart +++ b/packages/mix/lib/src/attributes/text_style/text_style_dto.dart @@ -1,6 +1,5 @@ // ignore_for_file: prefer_relative_imports,avoid-importing-entrypoint-exports -import 'dart:ui'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; diff --git a/packages/mix/lib/src/attributes/text_style/text_style_util.dart b/packages/mix/lib/src/attributes/text_style/text_style_util.dart index 2b2a6b095..fb96d5283 100644 --- a/packages/mix/lib/src/attributes/text_style/text_style_util.dart +++ b/packages/mix/lib/src/attributes/text_style/text_style_util.dart @@ -1,4 +1,3 @@ -import 'dart:ui'; import 'package:flutter/widgets.dart'; diff --git a/packages/mix/lib/src/specs/box/box_spec.g.dart b/packages/mix/lib/src/specs/box/box_spec.g.dart index 35620124c..f916dddc8 100644 --- a/packages/mix/lib/src/specs/box/box_spec.g.dart +++ b/packages/mix/lib/src/specs/box/box_spec.g.dart @@ -6,6 +6,8 @@ part of 'box_spec.dart'; // MixableSpecGenerator // ************************************************************************** +// ignore_for_file: deprecated_member_use_from_same_package + base mixin _$BoxSpec on Spec { static BoxSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const BoxSpec(); diff --git a/packages/mix/lib/src/specs/flex/flex_spec.g.dart b/packages/mix/lib/src/specs/flex/flex_spec.g.dart index 78ed6bb1b..2fb8d07dd 100644 --- a/packages/mix/lib/src/specs/flex/flex_spec.g.dart +++ b/packages/mix/lib/src/specs/flex/flex_spec.g.dart @@ -6,6 +6,8 @@ part of 'flex_spec.dart'; // MixableSpecGenerator // ************************************************************************** +// ignore_for_file: deprecated_member_use_from_same_package + base mixin _$FlexSpec on Spec { static FlexSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? diff --git a/packages/mix/lib/src/specs/icon/icon_spec.g.dart b/packages/mix/lib/src/specs/icon/icon_spec.g.dart index d95b3f931..84878f37d 100644 --- a/packages/mix/lib/src/specs/icon/icon_spec.g.dart +++ b/packages/mix/lib/src/specs/icon/icon_spec.g.dart @@ -6,6 +6,8 @@ part of 'icon_spec.dart'; // MixableSpecGenerator // ************************************************************************** +// ignore_for_file: deprecated_member_use_from_same_package + base mixin _$IconSpec on Spec { static IconSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? diff --git a/packages/mix/lib/src/specs/image/image_spec.g.dart b/packages/mix/lib/src/specs/image/image_spec.g.dart index 39d366d13..c34e6e75a 100644 --- a/packages/mix/lib/src/specs/image/image_spec.g.dart +++ b/packages/mix/lib/src/specs/image/image_spec.g.dart @@ -6,6 +6,8 @@ part of 'image_spec.dart'; // MixableSpecGenerator // ************************************************************************** +// ignore_for_file: deprecated_member_use_from_same_package + base mixin _$ImageSpec on Spec { static ImageSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? diff --git a/packages/mix/lib/src/specs/stack/stack_spec.g.dart b/packages/mix/lib/src/specs/stack/stack_spec.g.dart index d64b3b8e7..68528321b 100644 --- a/packages/mix/lib/src/specs/stack/stack_spec.g.dart +++ b/packages/mix/lib/src/specs/stack/stack_spec.g.dart @@ -6,6 +6,8 @@ part of 'stack_spec.dart'; // MixableSpecGenerator // ************************************************************************** +// ignore_for_file: deprecated_member_use_from_same_package + base mixin _$StackSpec on Spec { static StackSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? diff --git a/packages/mix/lib/src/specs/text/text_spec.dart b/packages/mix/lib/src/specs/text/text_spec.dart index a1e0f9a67..e409d6387 100644 --- a/packages/mix/lib/src/specs/text/text_spec.dart +++ b/packages/mix/lib/src/specs/text/text_spec.dart @@ -10,14 +10,17 @@ final class TextSpec extends Spec with _$TextSpec { final TextOverflow? overflow; final StrutStyle? strutStyle; final TextAlign? textAlign; - final double? textScaleFactor; final int? maxLines; final TextWidthBasis? textWidthBasis; final TextHeightBehavior? textHeightBehavior; + final TextScaler? textScaler; final TextStyle? style; final TextDirection? textDirection; final bool? softWrap; + @Deprecated('Use textScaler instead') + final double? textScaleFactor; + @MixableProperty( utilities: [ MixableUtility( @@ -41,7 +44,8 @@ final class TextSpec extends Spec with _$TextSpec { this.overflow, this.strutStyle, this.textAlign, - this.textScaleFactor, + @Deprecated('Use textScaler instead') this.textScaleFactor, + this.textScaler, this.maxLines, this.style, this.textWidthBasis, @@ -50,7 +54,10 @@ final class TextSpec extends Spec with _$TextSpec { this.softWrap, this.directive, super.animated, - }); + }) : assert( + textScaler == null || textScaleFactor == null, + 'textScaleFactor is deprecated and cannot be specified when textScaler is specified.', + ); Widget call(String text, {String? semanticLabel, Locale? locale}) { return isAnimated diff --git a/packages/mix/lib/src/specs/text/text_spec.g.dart b/packages/mix/lib/src/specs/text/text_spec.g.dart index 4c0c25b3e..2d5222d37 100644 --- a/packages/mix/lib/src/specs/text/text_spec.g.dart +++ b/packages/mix/lib/src/specs/text/text_spec.g.dart @@ -6,6 +6,8 @@ part of 'text_spec.dart'; // MixableSpecGenerator // ************************************************************************** +// ignore_for_file: deprecated_member_use_from_same_package + base mixin _$TextSpec on Spec { static TextSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? @@ -37,6 +39,7 @@ base mixin _$TextSpec on Spec { StrutStyle? strutStyle, TextAlign? textAlign, double? textScaleFactor, + TextScaler? textScaler, int? maxLines, TextStyle? style, TextWidthBasis? textWidthBasis, @@ -51,6 +54,7 @@ base mixin _$TextSpec on Spec { strutStyle: strutStyle ?? _$this.strutStyle, textAlign: textAlign ?? _$this.textAlign, textScaleFactor: textScaleFactor ?? _$this.textScaleFactor, + textScaler: textScaler ?? _$this.textScaler, maxLines: maxLines ?? _$this.maxLines, style: style ?? _$this.style, textWidthBasis: textWidthBasis ?? _$this.textWidthBasis, @@ -77,7 +81,7 @@ base mixin _$TextSpec on Spec { /// - [MixHelpers.lerpDouble] for [textScaleFactor]. /// - [MixHelpers.lerpTextStyle] for [style]. - /// For [overflow] and [textAlign] and [maxLines] and [textWidthBasis] and [textHeightBehavior] and [textDirection] and [softWrap] and [directive] and [animated], the interpolation is performed using a step function. + /// For [overflow] and [textAlign] and [textScaler] and [maxLines] and [textWidthBasis] and [textHeightBehavior] and [textDirection] and [softWrap] and [directive] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [TextSpec] is used. Otherwise, the value /// from the [other] [TextSpec] is used. /// @@ -94,6 +98,7 @@ base mixin _$TextSpec on Spec { textAlign: t < 0.5 ? _$this.textAlign : other.textAlign, textScaleFactor: MixHelpers.lerpDouble( _$this.textScaleFactor, other.textScaleFactor, t), + textScaler: t < 0.5 ? _$this.textScaler : other.textScaler, maxLines: t < 0.5 ? _$this.maxLines : other.maxLines, style: MixHelpers.lerpTextStyle(_$this.style, other.style, t), textWidthBasis: t < 0.5 ? _$this.textWidthBasis : other.textWidthBasis, @@ -116,6 +121,7 @@ base mixin _$TextSpec on Spec { _$this.strutStyle, _$this.textAlign, _$this.textScaleFactor, + _$this.textScaler, _$this.maxLines, _$this.style, _$this.textWidthBasis, @@ -141,6 +147,7 @@ final class TextSpecAttribute extends SpecAttribute { final StrutStyleDto? strutStyle; final TextAlign? textAlign; final double? textScaleFactor; + final TextScaler? textScaler; final int? maxLines; final TextStyleDto? style; final TextWidthBasis? textWidthBasis; @@ -154,6 +161,7 @@ final class TextSpecAttribute extends SpecAttribute { this.strutStyle, this.textAlign, this.textScaleFactor, + this.textScaler, this.maxLines, this.style, this.textWidthBasis, @@ -179,6 +187,7 @@ final class TextSpecAttribute extends SpecAttribute { strutStyle: strutStyle?.resolve(mix), textAlign: textAlign, textScaleFactor: textScaleFactor, + textScaler: textScaler, maxLines: maxLines, style: style?.resolve(mix), textWidthBasis: textWidthBasis, @@ -207,6 +216,7 @@ final class TextSpecAttribute extends SpecAttribute { strutStyle: strutStyle?.merge(other.strutStyle) ?? other.strutStyle, textAlign: other.textAlign ?? textAlign, textScaleFactor: other.textScaleFactor ?? textScaleFactor, + textScaler: other.textScaler ?? textScaler, maxLines: other.maxLines ?? maxLines, style: style?.merge(other.style) ?? other.style, textWidthBasis: other.textWidthBasis ?? textWidthBasis, @@ -228,6 +238,7 @@ final class TextSpecAttribute extends SpecAttribute { strutStyle, textAlign, textScaleFactor, + textScaler, maxLines, style, textWidthBasis, @@ -257,6 +268,9 @@ base class TextSpecUtility /// Utility for defining [TextSpecAttribute.textScaleFactor] late final textScaleFactor = DoubleUtility((v) => only(textScaleFactor: v)); + /// Utility for defining [TextSpecAttribute.textScaler] + late final textScaler = TextScalerUtility((v) => only(textScaler: v)); + /// Utility for defining [TextSpecAttribute.maxLines] late final maxLines = IntUtility((v) => only(maxLines: v)); @@ -310,6 +324,7 @@ base class TextSpecUtility StrutStyleDto? strutStyle, TextAlign? textAlign, double? textScaleFactor, + TextScaler? textScaler, int? maxLines, TextStyleDto? style, TextWidthBasis? textWidthBasis, @@ -324,6 +339,7 @@ base class TextSpecUtility strutStyle: strutStyle, textAlign: textAlign, textScaleFactor: textScaleFactor, + textScaler: textScaler, maxLines: maxLines, style: style, textWidthBasis: textWidthBasis, diff --git a/packages/mix/lib/src/specs/text/text_widget.dart b/packages/mix/lib/src/specs/text/text_widget.dart index 79badfb37..64a54834b 100644 --- a/packages/mix/lib/src/specs/text/text_widget.dart +++ b/packages/mix/lib/src/specs/text/text_widget.dart @@ -88,6 +88,7 @@ class TextSpecWidget extends StatelessWidget { @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, @@ -97,7 +98,9 @@ class TextSpecWidget extends StatelessWidget { locale: locale, softWrap: spec?.softWrap, overflow: spec?.overflow, + // ignore: deprecated_member_use, deprecated_member_use_from_same_package textScaleFactor: spec?.textScaleFactor, + textScaler: spec?.textScaler, maxLines: spec?.maxLines, semanticsLabel: semanticsLabel, textWidthBasis: spec?.textWidthBasis, diff --git a/packages/mix/lib/src/theme/tokens/text_style_token.dart b/packages/mix/lib/src/theme/tokens/text_style_token.dart index 37bb4c3d4..4e5b247da 100644 --- a/packages/mix/lib/src/theme/tokens/text_style_token.dart +++ b/packages/mix/lib/src/theme/tokens/text_style_token.dart @@ -1,4 +1,3 @@ -import 'dart:ui'; import 'package:flutter/widgets.dart'; diff --git a/packages/mix/lib/src/widgets/widget_state/pressable_widget.dart b/packages/mix/lib/src/widgets/widget_state/pressable_widget.dart index 2636a8a7b..e113b801b 100644 --- a/packages/mix/lib/src/widgets/widget_state/pressable_widget.dart +++ b/packages/mix/lib/src/widgets/widget_state/pressable_widget.dart @@ -140,7 +140,7 @@ abstract class _MixStateWidgetBuilder extends StatefulWidget { final FocusNode? focusNode; /// {@macro flutter.widgets.Focus.onKey} - final FocusOnKeyCallback? onKey; + final FocusOnKeyEventCallback? onKey; /// {@macro flutter.widgets.Focus.onKeyEvent} final FocusOnKeyEventCallback? onKeyEvent; diff --git a/packages/mix/pubspec.yaml b/packages/mix/pubspec.yaml index bba7aca37..2b39aa835 100644 --- a/packages/mix/pubspec.yaml +++ b/packages/mix/pubspec.yaml @@ -4,8 +4,8 @@ version: 1.2.0 homepage: https://github.com/leoafarias/mix environment: - sdk: ">=3.0.6 <4.0.0" - flutter: ">=3.10.6" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: mix_annotations: ^0.2.0 diff --git a/packages/mix/test/src/attributes/text_style/text_style_util_test.dart b/packages/mix/test/src/attributes/text_style/text_style_util_test.dart index e5dfa2c72..37a46646f 100644 --- a/packages/mix/test/src/attributes/text_style/text_style_util_test.dart +++ b/packages/mix/test/src/attributes/text_style/text_style_util_test.dart @@ -1,6 +1,5 @@ // Import necessary packages -import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/mix/test/src/deprecated/text_attribute_test.dart b/packages/mix/test/src/deprecated/text_attribute_test.dart new file mode 100644 index 000000000..3e8fe3c94 --- /dev/null +++ b/packages/mix/test/src/deprecated/text_attribute_test.dart @@ -0,0 +1,114 @@ +// ignore_for_file: deprecated_member_use_from_same_package +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mix/mix.dart'; + +import '../../helpers/testing_utils.dart'; + +void main() { + group('TextSpecAttribute', () { + final textSpecAttribute = TextSpecAttribute( + overflow: TextOverflow.ellipsis, + strutStyle: const StrutStyleDto( + fontFamily: 'Roboto', + fontSize: 12, + fontWeight: FontWeight.w500, + ), + textAlign: TextAlign.center, + textScaleFactor: 1.5, + maxLines: 2, + style: TextStyleDto( + fontSize: 12, + fontWeight: FontWeight.w500, + fontFamily: 'Roboto', + ), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + textDirection: TextDirection.rtl, + softWrap: true, + ); + + // Constructor + test('constructor', () { + expect(textSpecAttribute.overflow, TextOverflow.ellipsis); + expect(textSpecAttribute.strutStyle, isA()); + expect(textSpecAttribute.textAlign, TextAlign.center); + expect(textSpecAttribute.textScaleFactor, 1.5); + expect(textSpecAttribute.maxLines, 2); + expect(textSpecAttribute.style, isA()); + expect(textSpecAttribute.textWidthBasis, TextWidthBasis.longestLine); + expect(textSpecAttribute.textHeightBehavior, isA()); + expect(textSpecAttribute.textDirection, TextDirection.rtl); + expect(textSpecAttribute.softWrap, true); + }); + + // merge + test('merge', () { + final other = TextSpecAttribute( + overflow: TextOverflow.clip, + strutStyle: const StrutStyleDto( + fontFamily: 'Helvetica', + fontSize: 14, + fontWeight: FontWeight.w500, + ), + textAlign: TextAlign.center, + textScaleFactor: 1.5, + maxLines: 2, + style: TextStyleDto( + fontSize: 16, + fontWeight: FontWeight.w200, + fontFamily: 'Helvetica', + ), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + textDirection: TextDirection.ltr, + softWrap: false, + ); + + final merged = textSpecAttribute.merge(other); + + expect(merged.overflow, TextOverflow.clip); + expect(merged.strutStyle!.fontFamily, 'Helvetica'); + expect(merged.strutStyle!.fontSize, 14); + expect(merged.strutStyle!.fontWeight, FontWeight.w500); + expect(merged.textAlign, TextAlign.center); + expect(merged.textScaleFactor, 1.5); + expect(merged.maxLines, 2); + expect(merged.style!.resolve(EmptyMixData).fontFamily, 'Helvetica'); + expect(merged.style!.resolve(EmptyMixData).fontSize, 16); + expect(merged.style!.resolve(EmptyMixData).fontWeight, FontWeight.w200); + expect(merged.textWidthBasis, TextWidthBasis.longestLine); + expect(merged.textHeightBehavior!.applyHeightToFirstAscent, false); + expect(merged.textHeightBehavior!.applyHeightToLastDescent, false); + expect(merged.textDirection, TextDirection.ltr); + expect(merged.softWrap, false); + }); + + // resolve + test('resolve', () { + final resolved = textSpecAttribute.resolve(EmptyMixData); + + expect(resolved.overflow, TextOverflow.ellipsis); + expect(resolved.strutStyle!.fontFamily, 'Roboto'); + expect(resolved.strutStyle!.fontSize, 12); + expect(resolved.strutStyle!.fontWeight, FontWeight.w500); + expect(resolved.textAlign, TextAlign.center); + expect(resolved.textScaleFactor, 1.5); + expect(resolved.maxLines, 2); + expect(resolved.style!.fontFamily, 'Roboto'); + expect(resolved.style!.fontSize, 12); + expect(resolved.style!.fontWeight, FontWeight.w500); + expect(resolved.textWidthBasis, TextWidthBasis.longestLine); + expect(resolved.textHeightBehavior!.applyHeightToFirstAscent, true); + expect(resolved.textHeightBehavior!.applyHeightToLastDescent, true); + expect(resolved.textDirection, TextDirection.rtl); + expect(resolved.softWrap, true); + }); + }); +} diff --git a/packages/mix/test/src/deprecated/text_spec_test.dart b/packages/mix/test/src/deprecated/text_spec_test.dart new file mode 100644 index 000000000..2c6344cb0 --- /dev/null +++ b/packages/mix/test/src/deprecated/text_spec_test.dart @@ -0,0 +1,289 @@ +// ignore_for_file: deprecated_member_use_from_same_package +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mix/mix.dart'; + +import '../../helpers/testing_utils.dart'; + +void main() { + group('TextSpec', () { + test('resolve', () { + final mix = MixData.create( + MockBuildContext(), + Style( + TextSpecAttribute( + overflow: TextOverflow.ellipsis, + strutStyle: const StrutStyleDto(fontSize: 20.0), + textAlign: TextAlign.center, + textScaleFactor: 1.0, + maxLines: 2, + style: TextStyleDto(color: const ColorDto(Colors.red)), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + textDirection: TextDirection.ltr, + softWrap: true, + ), + ), + ); + + final spec = mix.attributeOf()?.resolve(mix) ?? + const TextSpec(); + + expect(spec.overflow, TextOverflow.ellipsis); + expect(spec.strutStyle, const StrutStyle(fontSize: 20.0)); + expect(spec.textAlign, TextAlign.center); + expect(spec.textScaleFactor, 1.0); + expect(spec.maxLines, 2); + expect(spec.style, const TextStyle(color: Colors.red)); + expect(spec.textWidthBasis, TextWidthBasis.longestLine); + expect( + spec.textHeightBehavior, + const TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + ); + expect(spec.textDirection, TextDirection.ltr); + expect(spec.softWrap, true); + }); + + test('copyWith', () { + const spec = TextSpec( + overflow: TextOverflow.ellipsis, + strutStyle: StrutStyle(fontSize: 20.0), + textAlign: TextAlign.center, + textScaleFactor: 1.0, + maxLines: 2, + style: TextStyle(color: Colors.red), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + textDirection: TextDirection.ltr, + softWrap: true, + ); + + final copiedSpec = spec.copyWith( + softWrap: false, + overflow: TextOverflow.fade, + strutStyle: const StrutStyle(fontSize: 30.0), + textAlign: TextAlign.start, + textScaleFactor: 2.0, + maxLines: 3, + style: const TextStyle(color: Colors.blue), + textWidthBasis: TextWidthBasis.parent, + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + textDirection: TextDirection.rtl, + ); + + expect(copiedSpec.overflow, TextOverflow.fade); + expect(copiedSpec.strutStyle, const StrutStyle(fontSize: 30.0)); + expect(copiedSpec.textAlign, TextAlign.start); + expect(copiedSpec.textScaleFactor, 2.0); + expect(copiedSpec.maxLines, 3); + expect(copiedSpec.style, const TextStyle(color: Colors.blue)); + expect(copiedSpec.textWidthBasis, TextWidthBasis.parent); + expect( + copiedSpec.textHeightBehavior, + const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + ); + + expect(copiedSpec.textDirection, TextDirection.rtl); + expect(copiedSpec.softWrap, false); + }); + + test('lerp', () { + const spec1 = TextSpec( + overflow: TextOverflow.ellipsis, + strutStyle: StrutStyle(fontSize: 20.0), + textAlign: TextAlign.center, + textScaleFactor: 1.0, + maxLines: 2, + style: TextStyle(color: Colors.red), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + textDirection: TextDirection.ltr, + softWrap: true, + ); + + const spec2 = TextSpec( + overflow: TextOverflow.fade, + strutStyle: StrutStyle(fontSize: 30.0), + textAlign: TextAlign.start, + textScaleFactor: 2.0, + maxLines: 3, + style: TextStyle(color: Colors.blue), + textWidthBasis: TextWidthBasis.parent, + textHeightBehavior: TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + textDirection: TextDirection.rtl, + softWrap: false, + ); + + const t = 0.5; + + final lerpedSpec = spec1.lerp(spec2, t); + + expect(lerpedSpec.overflow, TextOverflow.fade); + expect(lerpedSpec.strutStyle, const StrutStyle(fontSize: 25)); + expect(lerpedSpec.textAlign, TextAlign.start); + expect(lerpedSpec.textScaleFactor, 1.5); + expect(lerpedSpec.maxLines, 3); + expect( + lerpedSpec.style, + TextStyle.lerp( + const TextStyle(color: Colors.red), + const TextStyle(color: Colors.blue), + t, + ), + ); + expect(lerpedSpec.textWidthBasis, TextWidthBasis.parent); + + expect( + lerpedSpec.textHeightBehavior, + const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + ); + expect(lerpedSpec.textDirection, TextDirection.rtl); + expect(lerpedSpec.softWrap, false); + + expect(lerpedSpec, isNot(spec1)); + }); + + test('TextSpec.empty() constructor', () { + const spec = TextSpec(); + + expect(spec.overflow, isNull); + expect(spec.strutStyle, isNull); + expect(spec.textAlign, isNull); + expect(spec.textScaleFactor, isNull); + expect(spec.maxLines, isNull); + expect(spec.style, isNull); + expect(spec.textWidthBasis, isNull); + expect(spec.textHeightBehavior, isNull); + expect(spec.textDirection, isNull); + expect(spec.softWrap, isNull); + expect(spec.directive, isNull); + }); + + test('TextSpec.from(MixData mix)', () { + final mixData = MixData.create( + MockBuildContext(), + Style( + TextSpecAttribute( + overflow: TextOverflow.ellipsis, + strutStyle: const StrutStyleDto(fontSize: 20.0), + textAlign: TextAlign.center, + textScaleFactor: 1.0, + maxLines: 2, + style: TextStyleDto(color: const ColorDto(Colors.red)), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + textDirection: TextDirection.ltr, + softWrap: true, + ), + ), + ); + + final spec = TextSpec.from(mixData); + + expect(spec.overflow, TextOverflow.ellipsis); + expect(spec.strutStyle, const StrutStyle(fontSize: 20.0)); + expect(spec.textAlign, TextAlign.center); + expect(spec.textScaleFactor, 1.0); + expect(spec.maxLines, 2); + expect(spec.style, const TextStyle(color: Colors.red)); + expect(spec.textWidthBasis, TextWidthBasis.longestLine); + expect( + spec.textHeightBehavior, + const TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + ); + expect(spec.textDirection, TextDirection.ltr); + expect(spec.softWrap, true); + }); + + test('TextSpecTween lerp', () { + const spec1 = TextSpec( + overflow: TextOverflow.ellipsis, + strutStyle: StrutStyle(fontSize: 20.0), + textAlign: TextAlign.center, + textScaleFactor: 1.0, + maxLines: 2, + style: TextStyle(color: Colors.red), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: TextHeightBehavior( + applyHeightToFirstAscent: true, + applyHeightToLastDescent: true, + ), + textDirection: TextDirection.ltr, + softWrap: true, + ); + + const spec2 = TextSpec( + overflow: TextOverflow.fade, + strutStyle: StrutStyle(fontSize: 30.0), + textAlign: TextAlign.start, + textScaleFactor: 2.0, + maxLines: 3, + style: TextStyle(color: Colors.blue), + textWidthBasis: TextWidthBasis.parent, + textHeightBehavior: TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + textDirection: TextDirection.rtl, + softWrap: false, + ); + + final tween = TextSpecTween(begin: spec1, end: spec2); + + final lerpedSpec = tween.lerp(0.5); + expect(lerpedSpec.overflow, TextOverflow.fade); + expect(lerpedSpec.strutStyle, const StrutStyle(fontSize: 25)); + expect(lerpedSpec.textAlign, TextAlign.start); + expect(lerpedSpec.textScaleFactor, 1.5); + expect(lerpedSpec.maxLines, 3); + expect( + lerpedSpec.style, + TextStyle.lerp( + const TextStyle(color: Colors.red), + const TextStyle(color: Colors.blue), + 0.5, + ), + ); + expect(lerpedSpec.textWidthBasis, TextWidthBasis.parent); + expect( + lerpedSpec.textHeightBehavior, + const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + ); + expect(lerpedSpec.textDirection, TextDirection.rtl); + expect(lerpedSpec.softWrap, false); + }); + }); +} diff --git a/packages/mix/test/src/deprecated/text_widget_test.dart b/packages/mix/test/src/deprecated/text_widget_test.dart new file mode 100644 index 000000000..3cdf5a183 --- /dev/null +++ b/packages/mix/test/src/deprecated/text_widget_test.dart @@ -0,0 +1,246 @@ +// ignore_for_file: deprecated_member_use_from_same_package, deprecated_member_use +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mix/mix.dart'; + +import '../../helpers/testing_utils.dart'; + +void main() { + testWidgets( + 'StyledText should apply modifiers only once', + (tester) async { + await tester.pumpMaterialApp( + StyledText( + 'test', + style: Style( + $box.height(100), + $box.width(100), + $with.align(), + ), + ), + ); + + expect(find.byType(Align), findsOneWidget); + }, + ); + + testWidgets('TextSpec properties should match Text properties', + (WidgetTester tester) async { + const textSpec = TextSpec( + style: TextStyle(fontSize: 20, color: Colors.red), + strutStyle: StrutStyle(fontSize: 16), + textAlign: TextAlign.center, + textDirection: TextDirection.rtl, + softWrap: false, + overflow: TextOverflow.ellipsis, + textScaleFactor: 1.5, + maxLines: 3, + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: false), + ); + + const textKey = Key('text'); + final text = Text( + 'Sample Text', + key: textKey, + style: textSpec.style, + strutStyle: textSpec.strutStyle, + textAlign: textSpec.textAlign, + textDirection: textSpec.textDirection, + softWrap: textSpec.softWrap, + overflow: textSpec.overflow, + textScaleFactor: textSpec.textScaleFactor, + maxLines: textSpec.maxLines, + textWidthBasis: textSpec.textWidthBasis, + textHeightBehavior: textSpec.textHeightBehavior, + ); + const mixedTextKey = Key('mixed_text'); + const mixedText = TextSpecWidget( + 'Mixed Text', + key: mixedTextKey, + spec: textSpec, + ); + + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Column( + children: [text, mixedText], + ), + ), + ), + ); + + final textFinder = find.byKey(textKey); + final textWidget = tester.widget(textFinder); + expect(textFinder, findsOneWidget); + final mixedTextFinder = find.byKey(mixedTextKey); + expect(mixedTextFinder, findsOneWidget); + + final mixedTextWidget = tester.widget(find.descendant( + of: mixedTextFinder, + matching: find.byType(Text), + )); + + expect(textWidget.data, 'Sample Text'); + expect(mixedTextWidget.data, 'Mixed Text'); + expect(textWidget.style, mixedTextWidget.style); + expect(textWidget.strutStyle, mixedTextWidget.strutStyle); + expect(textWidget.textAlign, mixedTextWidget.textAlign); + expect(textWidget.textDirection, mixedTextWidget.textDirection); + expect(textWidget.softWrap, mixedTextWidget.softWrap); + expect(textWidget.overflow, mixedTextWidget.overflow); + expect(textWidget.textScaleFactor, mixedTextWidget.textScaleFactor); + expect(textWidget.maxLines, mixedTextWidget.maxLines); + expect(textWidget.textWidthBasis, mixedTextWidget.textWidthBasis); + expect(textWidget.textHeightBehavior, mixedTextWidget.textHeightBehavior); + }); + + testWidgets('StyledText should apply TextSpec properties', (tester) async { + await tester.pumpMaterialApp( + StyledText( + 'Hello, World!', + style: Style( + $text.style.color(Colors.red), + $text.style.fontSize(24.0), + ), + ), + ); + + final textFinder = find.byType(Text); + expect(textFinder, findsOneWidget); + + final text = tester.widget(textFinder); + expect(text.style?.color, Colors.red); + expect(text.style?.fontSize, 24.0); + }); + + testWidgets('StyledText should handle inherit property', (tester) async { + await tester.pumpMaterialApp( + StyledText( + 'Hello, World!', + style: Style($text.style.color(Colors.red)), + inherit: false, + ), + ); + + final textFinder = find.byType(Text); + expect(textFinder, findsOneWidget); + + final text = tester.widget(textFinder); + expect(text.style?.color, Colors.red); + }); + + testWidgets('StyledText should handle locale property', (tester) async { + await tester.pumpMaterialApp( + StyledText( + 'Hello, World!', + style: Style($text.style.color(Colors.red)), + locale: const Locale('en', 'US'), + ), + ); + + final textFinder = find.byType(Text); + expect(textFinder, findsOneWidget); + + final text = tester.widget(textFinder); + expect(text.locale, const Locale('en', 'US')); + }); + + testWidgets('TextSpecWidget should handle semanticsLabel and locale', + (tester) async { + const spec = TextSpec(style: TextStyle(color: Colors.blue)); + + await tester.pumpMaterialApp( + const TextSpecWidget( + 'Hello, World!', + spec: spec, + semanticsLabel: 'Custom Text', + locale: Locale('fr', 'FR'), + ), + ); + + final textFinder = find.byType(Text); + expect(textFinder, findsOneWidget); + + final text = tester.widget(textFinder); + expect(text.semanticsLabel, 'Custom Text'); + expect(text.locale, const Locale('fr', 'FR')); + }); + + testWidgets('TextSpecWidget should apply TextSpec.directive', (tester) async { + final spec = TextSpec(directive: TextDirective((v) => v.toUpperCase())); + + await tester.pumpMaterialApp( + TextSpecWidget( + 'Hello, World!', + spec: spec, + ), + ); + + final textFinder = find.text('HELLO, WORLD!'); + expect(textFinder, findsOneWidget); + }); + + testWidgets('AnimatedTextSpecWidget should animate TextSpec properties', + (tester) async { + const spec1 = TextSpec(style: TextStyle(color: Colors.red, fontSize: 16.0)); + const spec2 = + TextSpec(style: TextStyle(color: Colors.blue, fontSize: 24.0)); + + await tester.pumpMaterialApp( + const AnimatedTextSpecWidget( + 'Hello, World!', + spec: spec1, + duration: Duration(milliseconds: 500), + ), + ); + + expect(find.byType(TextSpecWidget), findsOneWidget); + Text text = tester.widget(find.byType(Text)); + expect(text.style?.color, Colors.red); + expect(text.style?.fontSize, 16.0); + + await tester.pumpMaterialApp( + const AnimatedTextSpecWidget( + 'Hello, World!', + spec: spec2, + duration: Duration(milliseconds: 500), + ), + ); + await tester.pump(const Duration(milliseconds: 250)); + + expect(find.byType(TextSpecWidget), findsOneWidget); + text = tester.widget(find.byType(Text)); + expect(text.style?.color, Color.lerp(Colors.red, Colors.blue, 0.5)); + expect(text.style?.fontSize, 20.0); + + await tester.pump(const Duration(milliseconds: 250)); + + expect(find.byType(TextSpecWidget), findsOneWidget); + text = tester.widget(find.byType(Text)); + expect(text.style?.color, Colors.blue); + expect(text.style?.fontSize, 24.0); + }); + + testWidgets('AnimatedTextSpecWidget should handle semanticsLabel and locale', + (tester) async { + const spec = TextSpec(style: TextStyle(color: Colors.blue)); + + await tester.pumpMaterialApp( + const AnimatedTextSpecWidget( + 'Hello, World!', + spec: spec, + duration: Duration(milliseconds: 500), + semanticsLabel: 'Custom Animated Text', + locale: Locale('es', 'ES'), + ), + ); + + expect(find.byType(TextSpecWidget), findsOneWidget); + final textSpecWidget = + tester.widget(find.byType(TextSpecWidget)); + expect(textSpecWidget.semanticsLabel, 'Custom Animated Text'); + expect(textSpecWidget.locale, const Locale('es', 'ES')); + }); +} diff --git a/packages/mix/test/src/specs/text/text_attribute_test.dart b/packages/mix/test/src/specs/text/text_attribute_test.dart index b95642261..dac995c8a 100644 --- a/packages/mix/test/src/specs/text/text_attribute_test.dart +++ b/packages/mix/test/src/specs/text/text_attribute_test.dart @@ -98,7 +98,7 @@ void main() { expect(resolved.strutStyle!.fontSize, 12); expect(resolved.strutStyle!.fontWeight, FontWeight.w500); expect(resolved.textAlign, TextAlign.center); - expect(resolved.textScaleFactor, 1.5); + expect(resolved.textScaler, null); expect(resolved.maxLines, 2); expect(resolved.style!.fontFamily, 'Roboto'); expect(resolved.style!.fontSize, 12); diff --git a/packages/mix/test/src/specs/text/text_spec_test.dart b/packages/mix/test/src/specs/text/text_spec_test.dart index 914c204d8..c8d59da27 100644 --- a/packages/mix/test/src/specs/text/text_spec_test.dart +++ b/packages/mix/test/src/specs/text/text_spec_test.dart @@ -14,7 +14,7 @@ void main() { overflow: TextOverflow.ellipsis, strutStyle: const StrutStyleDto(fontSize: 20.0), textAlign: TextAlign.center, - textScaleFactor: 1.0, + textScaler: const TextScaler.linear(1.0), maxLines: 2, style: TextStyleDto(color: const ColorDto(Colors.red)), textWidthBasis: TextWidthBasis.longestLine, @@ -34,7 +34,7 @@ void main() { expect(spec.overflow, TextOverflow.ellipsis); expect(spec.strutStyle, const StrutStyle(fontSize: 20.0)); expect(spec.textAlign, TextAlign.center); - expect(spec.textScaleFactor, 1.0); + expect(spec.textScaler, const TextScaler.linear(1)); expect(spec.maxLines, 2); expect(spec.style, const TextStyle(color: Colors.red)); expect(spec.textWidthBasis, TextWidthBasis.longestLine); @@ -54,7 +54,7 @@ void main() { overflow: TextOverflow.ellipsis, strutStyle: StrutStyle(fontSize: 20.0), textAlign: TextAlign.center, - textScaleFactor: 1.0, + textScaler: TextScaler.linear(1.0), maxLines: 2, style: TextStyle(color: Colors.red), textWidthBasis: TextWidthBasis.longestLine, @@ -71,7 +71,7 @@ void main() { overflow: TextOverflow.fade, strutStyle: const StrutStyle(fontSize: 30.0), textAlign: TextAlign.start, - textScaleFactor: 2.0, + textScaler: const TextScaler.linear(2.0), maxLines: 3, style: const TextStyle(color: Colors.blue), textWidthBasis: TextWidthBasis.parent, @@ -85,7 +85,7 @@ void main() { expect(copiedSpec.overflow, TextOverflow.fade); expect(copiedSpec.strutStyle, const StrutStyle(fontSize: 30.0)); expect(copiedSpec.textAlign, TextAlign.start); - expect(copiedSpec.textScaleFactor, 2.0); + expect(copiedSpec.textScaler, const TextScaler.linear(2)); expect(copiedSpec.maxLines, 3); expect(copiedSpec.style, const TextStyle(color: Colors.blue)); expect(copiedSpec.textWidthBasis, TextWidthBasis.parent); @@ -106,7 +106,7 @@ void main() { overflow: TextOverflow.ellipsis, strutStyle: StrutStyle(fontSize: 20.0), textAlign: TextAlign.center, - textScaleFactor: 1.0, + textScaler: TextScaler.linear(1.0), maxLines: 2, style: TextStyle(color: Colors.red), textWidthBasis: TextWidthBasis.longestLine, @@ -122,7 +122,7 @@ void main() { overflow: TextOverflow.fade, strutStyle: StrutStyle(fontSize: 30.0), textAlign: TextAlign.start, - textScaleFactor: 2.0, + textScaler: TextScaler.linear(2.0), maxLines: 3, style: TextStyle(color: Colors.blue), textWidthBasis: TextWidthBasis.parent, @@ -141,7 +141,7 @@ void main() { expect(lerpedSpec.overflow, TextOverflow.fade); expect(lerpedSpec.strutStyle, const StrutStyle(fontSize: 25)); expect(lerpedSpec.textAlign, TextAlign.start); - expect(lerpedSpec.textScaleFactor, 1.5); + expect(lerpedSpec.textScaler, const TextScaler.linear(2)); expect(lerpedSpec.maxLines, 3); expect( lerpedSpec.style, @@ -172,7 +172,7 @@ void main() { expect(spec.overflow, isNull); expect(spec.strutStyle, isNull); expect(spec.textAlign, isNull); - expect(spec.textScaleFactor, isNull); + expect(spec.textScaler, isNull); expect(spec.maxLines, isNull); expect(spec.style, isNull); expect(spec.textWidthBasis, isNull); @@ -190,7 +190,7 @@ void main() { overflow: TextOverflow.ellipsis, strutStyle: const StrutStyleDto(fontSize: 20.0), textAlign: TextAlign.center, - textScaleFactor: 1.0, + textScaler: const TextScaler.linear(1.0), maxLines: 2, style: TextStyleDto(color: const ColorDto(Colors.red)), textWidthBasis: TextWidthBasis.longestLine, @@ -209,7 +209,7 @@ void main() { expect(spec.overflow, TextOverflow.ellipsis); expect(spec.strutStyle, const StrutStyle(fontSize: 20.0)); expect(spec.textAlign, TextAlign.center); - expect(spec.textScaleFactor, 1.0); + expect(spec.textScaler, const TextScaler.linear(1.0)); expect(spec.maxLines, 2); expect(spec.style, const TextStyle(color: Colors.red)); expect(spec.textWidthBasis, TextWidthBasis.longestLine); @@ -229,7 +229,7 @@ void main() { overflow: TextOverflow.ellipsis, strutStyle: StrutStyle(fontSize: 20.0), textAlign: TextAlign.center, - textScaleFactor: 1.0, + textScaler: TextScaler.linear(1.0), maxLines: 2, style: TextStyle(color: Colors.red), textWidthBasis: TextWidthBasis.longestLine, @@ -245,7 +245,7 @@ void main() { overflow: TextOverflow.fade, strutStyle: StrutStyle(fontSize: 30.0), textAlign: TextAlign.start, - textScaleFactor: 2.0, + textScaler: TextScaler.linear(2.0), maxLines: 3, style: TextStyle(color: Colors.blue), textWidthBasis: TextWidthBasis.parent, @@ -263,7 +263,7 @@ void main() { expect(lerpedSpec.overflow, TextOverflow.fade); expect(lerpedSpec.strutStyle, const StrutStyle(fontSize: 25)); expect(lerpedSpec.textAlign, TextAlign.start); - expect(lerpedSpec.textScaleFactor, 1.5); + expect(lerpedSpec.textScaler, const TextScaler.linear(2)); expect(lerpedSpec.maxLines, 3); expect( lerpedSpec.style, diff --git a/packages/mix/test/src/specs/text/text_widget_test.dart b/packages/mix/test/src/specs/text/text_widget_test.dart index d2bfdf8d2..7b2ac3f5d 100644 --- a/packages/mix/test/src/specs/text/text_widget_test.dart +++ b/packages/mix/test/src/specs/text/text_widget_test.dart @@ -32,7 +32,7 @@ void main() { textDirection: TextDirection.rtl, softWrap: false, overflow: TextOverflow.ellipsis, - textScaleFactor: 1.5, + textScaler: TextScaler.linear(1.5), maxLines: 3, textWidthBasis: TextWidthBasis.longestLine, textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: false), @@ -48,7 +48,7 @@ void main() { textDirection: textSpec.textDirection, softWrap: textSpec.softWrap, overflow: textSpec.overflow, - textScaleFactor: textSpec.textScaleFactor, + textScaler: textSpec.textScaler, maxLines: textSpec.maxLines, textWidthBasis: textSpec.textWidthBasis, textHeightBehavior: textSpec.textHeightBehavior, @@ -90,7 +90,7 @@ void main() { expect(textWidget.textDirection, mixedTextWidget.textDirection); expect(textWidget.softWrap, mixedTextWidget.softWrap); expect(textWidget.overflow, mixedTextWidget.overflow); - expect(textWidget.textScaleFactor, mixedTextWidget.textScaleFactor); + expect(textWidget.textScaler, mixedTextWidget.textScaler); expect(textWidget.maxLines, mixedTextWidget.maxLines); expect(textWidget.textWidthBasis, mixedTextWidget.textWidthBasis); expect(textWidget.textHeightBehavior, mixedTextWidget.textHeightBehavior); diff --git a/packages/mix_annotations/pubspec.yaml b/packages/mix_annotations/pubspec.yaml index b5f20b315..f6c5950ca 100644 --- a/packages/mix_annotations/pubspec.yaml +++ b/packages/mix_annotations/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.2.0 repository: https://github.com/conceptadev/mix environment: - sdk: ">=3.0.6 <4.0.0" + sdk: ">=3.3.0 <4.0.0" dev_dependencies: lints: ^3.0.0 diff --git a/packages/mix_generator/lib/src/mixable_spec_generator.dart b/packages/mix_generator/lib/src/mixable_spec_generator.dart index ba34957c7..0ba7aa6f4 100644 --- a/packages/mix_generator/lib/src/mixable_spec_generator.dart +++ b/packages/mix_generator/lib/src/mixable_spec_generator.dart @@ -41,6 +41,9 @@ class MixableSpecGenerator extends GeneratorForAnnotation { ); final output = ''' + + // ignore_for_file: deprecated_member_use_from_same_package + ${specMixin(context)} ${specAttributeClass(context)} diff --git a/packages/mix_generator/pubspec.yaml b/packages/mix_generator/pubspec.yaml index 8c25e510c..ac054b48f 100644 --- a/packages/mix_generator/pubspec.yaml +++ b/packages/mix_generator/pubspec.yaml @@ -4,8 +4,8 @@ version: 0.2.0 homepage: https://github.com/conceptadev/mix environment: - sdk: ">=3.0.6 <4.0.0" - flutter: ">=3.10.6" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: mix_annotations: ^0.2.0 diff --git a/packages/mix_lint/pubspec.yaml b/packages/mix_lint/pubspec.yaml index e9f1532e3..64e3b41b2 100644 --- a/packages/mix_lint/pubspec.yaml +++ b/packages/mix_lint/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.1.0 repository: https://github.com/conceptadev/mix environment: - sdk: ">=3.0.6 <4.0.0" + sdk: ">=3.3.0 <4.0.0" dependencies: analyzer: ^6.0.0 diff --git a/packages/mix_lint_test/pubspec.yaml b/packages/mix_lint_test/pubspec.yaml index 1a6957cf3..f69f112a5 100644 --- a/packages/mix_lint_test/pubspec.yaml +++ b/packages/mix_lint_test/pubspec.yaml @@ -3,8 +3,8 @@ description: A sample command-line application. publish_to: "none" environment: - sdk: ">=3.0.6 <4.0.0" - flutter: ">=3.10.6" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: flutter: diff --git a/pubspec.yaml b/pubspec.yaml index 6865bfc2f..074865d20 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: mix environment: - sdk: ">=3.0.6 <4.0.0" + sdk: ">=3.3.0 <4.0.0" dev_dependencies: husky: ^0.1.7