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: 3 additions & 3 deletions .github/workflows/enhanced_gradients-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: enhanced_gradients publish

on:
push:
tags: ['enhanced_gradients-v*']
tags: ["enhanced_gradients-v*"]

jobs:
publish:
Expand All @@ -25,12 +25,12 @@ jobs:
- name: Set up Dart
uses: dart-lang/setup-dart@v1
with:
sdk: 3.3
sdk: 3.6

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.19.x
flutter-version: 3.27.x
cache: true

- name: Publish and release
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/enhanced_gradients-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name: enhanced_gradients test
on:
push:
branches: [master]
tags-ignore: ['enhanced_gradients-v*']
tags-ignore: ["enhanced_gradients-v*"]
paths:
- 'packages/enhanced_gradients/**'
- "packages/enhanced_gradients/**"
pull_request:
branches: [master]
paths:
- 'packages/enhanced_gradients/**'
- "packages/enhanced_gradients/**"
# Run a check daily due to the dependency on `material_color_utilities: any`
schedule:
- cron: '0 17 * * *'
- cron: "0 17 * * *"

jobs:
test:
Expand All @@ -23,8 +23,8 @@ jobs:
fail-fast: false
matrix:
include:
- version: '3.19.x'
- channel: 'stable'
- version: "3.27.x"
- channel: "stable"

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion packages/enhanced_gradients/.fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.19.6"
"flutter": "3.27.2"
}
4 changes: 4 additions & 0 deletions packages/enhanced_gradients/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.0

- BREAKING CHANGE: Raise minimum Flutter version to 3.27.0, which supports wide gamut color spaces.

## 2.0.0

- BREAKING CHANGE: Raise minimum Flutter version to 3.19.0. Previous versions of enhanced_gradients were incompatible with Flutter 3.19 due to dependency constraints.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: package:flutter_lints/flutter.yaml
include: package:leancode_lint/analysis_options.yaml
6 changes: 3 additions & 3 deletions packages/enhanced_gradients/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ publish_to: "none"
version: 0.1.0

environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
sdk: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"

dependencies:
enhanced_gradients:
Expand All @@ -16,7 +16,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
leancode_lint: ^15.0.0

flutter:
uses-material-design: true
24 changes: 18 additions & 6 deletions packages/enhanced_gradients/lib/src/hct_color_tween.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,31 @@ Color? lerpHct(Color? colorA, Color? colorB, double t) =>
};

Color _lerpHctNonNullable(Color colorA, Color colorB, double t) {
final beginHct = Hct.fromInt(colorA.value);
final endHct = Hct.fromInt(colorB.value);
final beginHct = Hct.fromInt(_colorToInt(colorA));
final endHct = Hct.fromInt(_colorToInt(colorB));

final opacity = lerpDouble(colorA.opacity, colorB.opacity, t)!;
final alpha = lerpDouble(colorA.a, colorB.a, t)!;
final hue = lerpDegrees(beginHct.hue, endHct.hue, t)!;
final chroma = lerpDouble(beginHct.chroma, endHct.chroma, t)!;
final tone = lerpDouble(beginHct.tone, endHct.tone, t)!;

return Color(
Hct.from(hue, chroma, tone).toInt(),
).withOpacity(opacity);
).withValues(alpha: alpha);
}

Color _scaleAlpha(Color a, double factor) {
return a.withAlpha((a.alpha * factor).round().clamp(0, 255));
Color _scaleAlpha(Color color, double factor) {
return color.withValues(alpha: color.a * factor);
}

/// [Hct] requires int values, so we need to convert [Color].
int _colorToInt(Color color) {
return _floatToInt8(color.a) << 24 |
_floatToInt8(color.r) << 16 |
_floatToInt8(color.g) << 8 |
_floatToInt8(color.b) << 0;
}

int _floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}
6 changes: 3 additions & 3 deletions packages/enhanced_gradients/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: enhanced_gradients
version: 2.0.0
version: 3.0.0
homepage: https://github.com/leancodepl/flutter_corelibrary/tree/master/packages/enhanced_gradients
repository: https://github.com/leancodepl/flutter_corelibrary
description: >-
Expand All @@ -10,7 +10,7 @@ environment:
flutter: ">=3.19.0"

dependencies:
collection: ^1.17.1
collection: ^1.19.0
flutter:
sdk: flutter
material_color_utilities: any
Expand All @@ -19,5 +19,5 @@ dev_dependencies:
flutter_test:
sdk: flutter
glados: ^1.1.6
leancode_lint: ">=12.1.0 <15.0.0"
leancode_lint: ^15.0.0
meta: ^1.9.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ void main() {
(colorB, t) {
final result = lerpHct(null, colorB, t);

final resultAlpha = result!.alpha;
final expectedAlpha = colorB.alpha * t;
final resultAlpha = result!.a;
final expectedAlpha = colorB.a * t;

expect(resultAlpha, closeTo(expectedAlpha, 1));
});
Expand All @@ -37,8 +37,8 @@ void main() {
(colorA, t) {
final result = lerpHct(colorA, null, t);

final resultAlpha = result!.alpha;
final expectedAlpha = colorA.alpha * (1 - t);
final resultAlpha = result!.a;
final expectedAlpha = colorA.a * (1 - t);

expect(resultAlpha, closeTo(expectedAlpha, 1));
});
Expand Down
Loading