diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c7146c3..5da1b7a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,8 +9,9 @@ on: branches: - main pull_request: - branches: - - main + types: + - opened + - synchronize jobs: semantic_pull_request: @@ -22,6 +23,10 @@ jobs: includes: "**/*.md" modified_files_only: false + pana: + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/pana.yml@v1 + + build: - uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1 + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..2b9bda9 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,12 @@ +name: Pub Publish Workflow + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build: + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_pub_publish.yml@v1 + with: + pub_credentials: secrets.PUB_CREDENTIALS \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2f80c34..0105761 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build/ pubspec.lock .vscode -.git \ No newline at end of file +.git +coverage/ \ No newline at end of file diff --git a/README.md b/README.md index 112b25e..a311e1a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # Aura Box [![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link] +[![patrol_finders on pub.dev][patrol_finders_badge]][patrol_finders_link] [![License: MIT][license_badge]][license_link] + Flutter widget that combines multiple radial gradients and blur effect. ![Aura box banner image](https://github.com/GangemiLorenzo/aura_box/assets/26723808/16a43670-17df-4515-8a57-29f17b94607b) @@ -12,6 +14,8 @@ Flutter widget that combines multiple radial gradients and blur effect. [license_link]: https://opensource.org/licenses/MIT [very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg [very_good_analysis_link]: https://pub.dev/packages/very_good_analysis +[patrol_finders_badge]: https://img.shields.io/badge/test-patrol_finders-yellow +[patrol_finders_link]: https://pub.dev/packages/patrol_finders ## Installation diff --git a/lib/src/aura_spot.dart b/lib/src/aura_spot.dart index 0b2a5ea..d9f1e12 100644 --- a/lib/src/aura_spot.dart +++ b/lib/src/aura_spot.dart @@ -73,6 +73,7 @@ class AuraSpot extends StatelessWidget { @override Widget build(BuildContext context) { return ShaderMask( + key: key, shaderCallback: (Rect bounds) { final gradient = RadialGradient( center: alignment, diff --git a/makefile b/makefile new file mode 100644 index 0000000..8cf6db8 --- /dev/null +++ b/makefile @@ -0,0 +1,23 @@ +THIS_FILE := $(lastword $(MAKEFILE_LIST)) + +help: + @make -pRrq -f $(THIS_FILE) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' + +unit: + @flutter test + +cov: + @flutter test --coverage && lcov --remove coverage/lcov.info '**/*.g.dart' -o coverage/lcov.info && genhtml coverage/lcov.info --output=coverage && open coverage/index.html + +clean: + @rm -rf pubspec.lock + @flutter clean + +format: + @dart format . + +lint: + @dart analyze . + +clean-pod: + cd ios && pod deintegrate && pod update && cd .. \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 37eb46f..718055c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: aura_box description: Flutter Widget that combines multiple radial gradients and blur effect. -version: 1.0.1 +version: 1.0.2 homepage: https://github.com/GangemiLorenzo/aura_box environment: @@ -11,4 +11,7 @@ dependencies: sdk: flutter dev_dependencies: + flutter_test: + sdk: flutter + patrol_finders: ^1.0.0 very_good_analysis: ^5.1.0 diff --git a/test/aura_box_test.dart b/test/aura_box_test.dart new file mode 100644 index 0000000..8836e58 --- /dev/null +++ b/test/aura_box_test.dart @@ -0,0 +1,182 @@ +import 'package:aura_box/aura_box.dart'; // Import your AuraBox class +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:patrol_finders/patrol_finders.dart'; + +void main() { + group('AuraBox', () { + testWidgets('renders AuraSpot and ShaderMasks', + (WidgetTester tester) async { + final $ = PatrolTester( + tester: tester, + config: const PatrolTesterConfig(), + ); + + await $.pumpWidget( + MaterialApp( + home: AuraBox( + spots: [ + AuraSpot( + color: Colors.blue, + radius: 50, + alignment: Alignment.center, + blurRadius: 5, + ), + AuraSpot( + color: Colors.red, + radius: 50, + alignment: Alignment.bottomLeft, + blurRadius: 5, + ), + ], + child: Container(), + ), + ), + ); + + expect($(AuraBox), findsOneWidget); + expect($(AuraBox).$(AuraSpot), findsNWidgets(2)); + expect($(AuraBox).$(AuraSpot).$(ShaderMask), findsNWidgets(2)); + }); + + testWidgets('applies decoration over the main container', + (WidgetTester tester) async { + final $ = PatrolTester( + tester: tester, + config: const PatrolTesterConfig(), + ); + + await $.pumpWidget( + MaterialApp( + home: AuraBox( + spots: const [], + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(10), + ), + child: Container(), + ), + ), + ); + + // Verify that the decoration is applied correctly + final container = + $(AuraBox).$(Container).first.evaluate().single.widget as Container; + final decoration = container.decoration! as BoxDecoration; + expect(decoration.color, equals(Colors.red)); + expect(decoration.shape, equals(BoxShape.rectangle)); + expect(decoration.borderRadius, equals(BorderRadius.circular(10))); + }); + + testWidgets('given decoration with border radius, applies ClipRRect', + (WidgetTester tester) async { + final $ = PatrolTester( + tester: tester, + config: const PatrolTesterConfig(), + ); + + await $.pumpWidget( + MaterialApp( + home: AuraBox( + spots: [ + AuraSpot( + color: Colors.blue, + radius: 50, + alignment: Alignment.center, + blurRadius: 5, + stops: const [0.0, 0.5], + ), + AuraSpot( + color: Colors.red, + radius: 50, + alignment: Alignment.bottomLeft, + blurRadius: 5, + ), + ], + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(10), + ), + child: Container(), + ), + ), + ); + + expect($(AuraBox).$(ClipRRect), findsNWidgets(2)); + final clipRRect = + $(AuraBox).$(ClipRRect).first.evaluate().single.widget as ClipRRect; + expect(clipRRect.borderRadius, equals(BorderRadius.circular(10))); + }); + + testWidgets('given decoration with BoxShape.circle, applies ClipOval', + (WidgetTester tester) async { + final $ = PatrolTester( + tester: tester, + config: const PatrolTesterConfig(), + ); + + await $.pumpWidget( + MaterialApp( + home: AuraBox( + spots: [ + AuraSpot( + color: Colors.blue, + radius: 50, + alignment: Alignment.center, + blurRadius: 5, + stops: const [0.0, 0.5], + ), + AuraSpot( + color: Colors.red, + radius: 50, + alignment: Alignment.bottomLeft, + blurRadius: 5, + ), + ], + decoration: const BoxDecoration( + color: Colors.red, + shape: BoxShape.circle, + ), + child: Container(), + ), + ), + ); + + expect($(AuraBox).$(ClipOval), findsNWidgets(2)); + }); + + testWidgets('composes child and spots in a Stack', + (WidgetTester tester) async { + final $ = PatrolTester( + tester: tester, + config: const PatrolTesterConfig(), + ); + await $.pumpWidget( + MaterialApp( + home: AuraBox( + spots: [ + AuraSpot( + color: Colors.blue, + radius: 50, + alignment: Alignment.center, + blurRadius: 5, + stops: const [0.0, 0.5], + ), + AuraSpot( + color: Colors.red, + radius: 50, + alignment: Alignment.bottomLeft, + blurRadius: 5, + ), + ], + child: Container(), + ), + ), + ); + + expect($(Stack), findsOneWidget); + final stack = $(Stack).evaluate().single.widget as Stack; + expect(stack.children.length, equals(3)); + }); + }); +}