Skip to content
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
6 changes: 6 additions & 0 deletions packages/theme_tailor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 3.1.1
- Support analyzer: ">=7.5.9 <9.0.0"
- Support build 3.0.0 and ^4.0.0
- Support source_gen 3.0.0 and ^4.0.0
- Use the same versioning for other theme_tailor packages

# 3.1.0
- Support build 3.0.0.
- Support source_gen 3.0.0.
Expand Down
3 changes: 3 additions & 0 deletions packages/theme_tailor/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ analyzer:
exclude:
- "**/*.g.dart"
- "**/*.tailor.dart"
errors:
# Remove when we require analyzer >=8
deprecated_member_use: ignore
6 changes: 6 additions & 0 deletions packages/theme_tailor/lib/src/model/referenced_packages.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class ReferencedPackages {
const ReferencedPackages._();

static const themeTailorAnnotation = 'theme_tailor_annotation';
static const jsonSerializable = 'json_serializable';
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:source_gen/source_gen.dart';
import 'package:theme_tailor/src/model/referenced_packages.dart';
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';

extension ElementAnnotationExtension on ElementAnnotation {
extension ElementAnnotationExtension on Element2 {
bool get isTailorAnnotation {
return const TypeChecker.fromRuntime(TailorMixin).isAssignableFromType(computeConstantValue()!.type!);
return const TypeChecker.typeNamed(
TailorMixin,
inPackage: ReferencedPackages.themeTailorAnnotation,
).hasAnnotationOf(this, throwOnUnresolved: false);
}

bool get isTailorThemeExtension {
return TypeChecker.fromRuntime(themeExtension.runtimeType)
.isAssignableFrom(computeConstantValue()!.type!.element3!);
return const TypeChecker.typeNamed(
TailorThemeExtension,
inPackage: ReferencedPackages.themeTailorAnnotation,
).isAssignableFrom(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import 'package:collection/collection.dart';
import 'package:json_annotation/json_annotation.dart' show JsonSerializable;
import 'package:source_gen/source_gen.dart';
import 'package:theme_tailor/src/model/constructor_data.dart';
import 'package:theme_tailor/src/model/referenced_packages.dart';
import 'package:theme_tailor/src/util/extension/parameter_element_extension.dart';
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';

extension ElementExtension on Element2 {
bool get hasJsonSerializableAnnotation {
const checker = TypeChecker.fromRuntime(JsonSerializable);
const checker = TypeChecker.typeNamed(JsonSerializable, inPackage: ReferencedPackages.jsonSerializable);
return checker.hasAnnotationOf(this, throwOnUnresolved: false);
}

Expand All @@ -17,12 +18,12 @@ extension ElementExtension on Element2 {
}

bool get hasTailorMixinAnnotation {
const checker = TypeChecker.fromRuntime(TailorMixin);
const checker = TypeChecker.typeNamed(TailorMixin, inPackage: ReferencedPackages.jsonSerializable);
return checker.hasAnnotationOf(this, throwOnUnresolved: false);
}

bool get hasThemeExtensionAnnotation {
final checker = TypeChecker.fromRuntime(themeExtension.runtimeType);
const checker = TypeChecker.typeNamed(TailorThemeExtension, inPackage: ReferencedPackages.themeTailorAnnotation);
return checker.hasAnnotationOf(this, throwOnUnresolved: false);
}
}
Expand All @@ -44,9 +45,7 @@ extension ClassElementExtensions on ClassElement2 {

return ConstructorData(
constructorName: ctor!.displayName,
parameterNameToType: Map.fromEntries(
parameters.map((e) => MapEntry(e.name3!, e.parameterType)),
),
parameterNameToType: Map.fromEntries(parameters.map((e) => MapEntry(e.name3!, e.parameterType))),
);
}
}
8 changes: 3 additions & 5 deletions packages/theme_tailor/lib/src/util/theme_encoder_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:collection/collection.dart';
import 'package:source_gen/source_gen.dart';
import 'package:theme_tailor/src/model/referenced_packages.dart';
import 'package:theme_tailor/src/model/theme_encoder_data.dart';
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';

const themeEncoderChecker = TypeChecker.fromRuntime(ThemeEncoder);
const themeEncoderChecker = TypeChecker.typeNamed(ThemeEncoder, inPackage: ReferencedPackages.themeTailorAnnotation);

ThemeEncoderData? extractThemeEncoderData(ElementAnnotation? annotation, DartObject constantValue) {
final encoderClassElement = constantValue.type!.element3 as ClassElement2?;
Expand All @@ -33,10 +34,7 @@ ThemeEncoderData? extractThemeEncoderData(ElementAnnotation? annotation, DartObj
accessString = '${enclosing.name3}.$accessString';
}

return ThemeEncoderData.propertyAccess(
accessString!,
encoderTypeStr,
);
return ThemeEncoderData.propertyAccess(accessString!, encoderTypeStr);
}

final reviver = ConstantReader(constantValue).revive();
Expand Down
8 changes: 4 additions & 4 deletions packages/theme_tailor/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >
Code generator for Flutter's 3.0 ThemeExtension classes.
The generator can create themes and extensions on BuildContext
or ThemeData based on the lists of the theme properties
version: 3.1.0
version: 3.1.1
repository: https://github.com/Iteo/theme_tailor
issue_tracker: https://github.com/Iteo/theme_tailor/issues
homepage: https://github.com/Iteo/theme_tailor
Expand All @@ -13,14 +13,14 @@ environment:
sdk: ">=3.8.0 <4.0.0"

dependencies:
analyzer: ">=7.5.9 <8.0.0"
build: ^3.0.0
analyzer: ">=7.5.9 <9.0.0"
build: ">=3.0.0 <5.0.0"
build_config: ^1.1.0
collection: ^1.15.0
dart_style: ^3.0.1
json_annotation: ^4.6.0
meta: ^1.9.1
source_gen: ^3.0.0
source_gen: ">=4.0.0 <5.0.0"
source_helper: ^1.3.2
theme_tailor_annotation: ^3.0.2

Expand Down
5 changes: 5 additions & 0 deletions packages/theme_tailor_annotation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 3.1.1
- Compatibility with theme_tailor 3.1.1
- _ThemeExtension is now TailorThemeExtension, this class is annotation class and is exposed only for analyzer purposes. It is now possible to use @TailorThemeExtension instead @themeExtension, but using latter is recommended.
- Use the same versioning for other theme_tailor packages

# 3.1.0
- Support build 3.0.0.
- Support source_gen 3.0.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:meta/meta_meta.dart';

/// Hints generator that the type conforms to ThemeExtension and can call lerp()
/// on it.
const themeExtension = _ThemeExtension();
const themeExtension = TailorThemeExtension();

@Target({TargetKind.field})
class _ThemeExtension {
const _ThemeExtension();
class TailorThemeExtension {
const TailorThemeExtension();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ library theme_tailor_annotation;

export 'package:collection/collection.dart' show DeepCollectionEquality;

export 'src/tailor_theme_extension.dart';
export 'src/theme_encoder.dart';
export 'src/theme_extension.dart';
export 'src/theme_getter.dart';
export 'src/theme_ignore.dart';
export 'src/theme_tailor_mixin.dart';
Expand Down
2 changes: 1 addition & 1 deletion packages/theme_tailor_annotation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: theme_tailor_annotation
description: >
Annotations for the Theme Tailor code-generator.
This package does nothing without Theme Tailor.
version: 3.1.0
version: 3.1.1
repository: https://github.com/Iteo/theme_tailor
issue_tracker: https://github.com/Iteo/theme_tailor/issues
homepage: https://github.com/Iteo/theme_tailor
Expand Down
4 changes: 4 additions & 0 deletions packages/theme_tailor_toolbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.1.1
- Compatibility with theme_tailor 3.1.1
- Use the same versioning for other theme_tailor packages

# 3.1.0
- Require Dart 3.8.0
- Use the same versioning for other theme_tailor packages
Expand Down
14 changes: 7 additions & 7 deletions packages/theme_tailor_toolbox/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -420,18 +420,18 @@ packages:
dependency: transitive
description:
name: source_gen
sha256: fc787b1f89ceac9580c3616f899c9a447413cbdac1df071302127764c023a134
sha256: "800f12fb87434defa13432ab37e33051b43b290a174e15259563b043cda40c46"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "4.0.0"
source_helper:
dependency: transitive
description:
name: source_helper
sha256: "4f81479fe5194a622cdd1713fe1ecb683a6e6c85cd8cec8e2e35ee5ab3fdf2a1"
sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723"
url: "https://pub.dev"
source: hosted
version: "1.3.6"
version: "1.3.8"
source_span:
dependency: transitive
description:
Expand Down Expand Up @@ -494,21 +494,21 @@ packages:
path: "../../theme_tailor"
relative: true
source: path
version: "3.1.0"
version: "3.1.1"
theme_tailor_annotation:
dependency: "direct main"
description:
path: "../../theme_tailor_annotation"
relative: true
source: path
version: "3.1.0"
version: "3.1.1"
theme_tailor_toolbox:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "3.1.0"
version: "3.1.1"
timing:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion packages/theme_tailor_toolbox/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ issue_tracker: https://github.com/Iteo/theme_tailor/issues
homepage: https://github.com/Iteo/theme_tailor
documentation: https://github.com/Iteo/theme_tailor/blob/main/packages/theme_tailor/README.md

version: 3.1.0
version: 3.1.1

environment:
sdk: ">=3.8.0 <4.0.0"
Expand Down