diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7ca032e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Flutter + uses: subosito/flutter-action@v2.10.0 + + - name: Install dependencies + run: flutter pub get + + - name: Analyze + run: flutter analyze + + - name: Run tests + run: flutter test + + - name: Format code + run: dart format --fix . + + - name: Check Publish Warnings + run: dart pub publish --dry-run + + - name: Publish + uses: k-paxian/dart-package-publisher@v1.5.1 + with: + credentialJson: ${{ secrets.CREDENTIAL_JSON }} + flutter: true + skipTests: true \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..40c1e18 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: Test + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + + - run: flutter pub get + + - name: Analyze project source + run: dart analyze + + - name: Format code + run: dart format --fix . + + - name: Run tests + run: flutter test diff --git a/.gitignore b/.gitignore index 8921a0c..bc9a109 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ -./idea -./vscode +#Flutter versions manager +.fvm/ + +.idea/ +.vscode/ # Miscellaneous *.class @@ -64,6 +67,7 @@ build/ **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* @@ -73,3 +77,4 @@ build/ !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +!flutter_reaction_button.iml \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e7f25df..5c140e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,74 +1,134 @@ -## 0.0.1 +## 3.0.0+3 +* Fix reactions box overflow -* Describe initial release. +## 3.0.0+2 +* Minor updates -## 0.1.0 +## 3.0.0+1 +* Update README -* Update Description pubspec.yaml. +## 3.0.0 -## 0.1.1 +- **BREAKING CHANGE**: + - `FlutterReactionButton` and `FlutterReactionButtonToggle` removed + - `itemSize` is required in `ReactionButton` + - `onReactionChanged` callback updated + - `VerticalPosition` and `HorizontalPosition` removed +- Adds `child` to `ReactionButton` +- Animated `ReactionsBox` -* Reactions List @required. +## 2.0.2 -## 0.1.2 +* Pipeline setup -* From plugin to packages. +## 2.0.1+1 -## 0.1.2+1 +* Minor bugs fixed. Thanks to [Kyle Venn](https://github.com/kvenn) -* Add Example. +## 2.0.1 -## 0.1.3 +* Adds ReactionContainer +* Bugs fix and code improvements, Thanks to [Felix Gabler](https://github.com/felixgabler) -* Selected rection index. +## 2.0.0+3 -## 1.0.0 +* Upgrade flutter version -* Add ripple effect. +## 2.0.0+2 -## 1.0.1 +* Fix Offscreen Issue. Thanks to [rlee1990](https://github.com/rlee1990) -* define reaction by id. -* alternative to popup menu. -* enable/disable reaction click. +## 2.0.0+1 -## 1.0.2 +* Dragging improvement -* code improvements +## 2.0.0 -## 1.0.3 +* Change `FlutterReactionButton` to `ReactionButton` +* Change `FlutterReactionButtonCheck` to `ReactionButtonToggle` +* Change `Function(Reaction, int, bool) onReactionChanged` to `Function(T?, bool) onReactionChanged` +* Change `Function(Reaction, int) onReactionChanged` to `Function(T?) onReactionChanged` +* Dynamic scale depending on the hover position +* Dynamic horizontal alignment +* Scrollable position +* Minor bugs fixed -* change state externally +## 1.0.8 -## 1.0.4 +* Added support null safety -* reactions box alignment +## 1.0.7+3 -## 1.0.5 +* Deprecated Reaction id -* items spacing / box padding +## 1.0.7+2 -## 1.0.6 +* Improvement box flow + +## 1.0.7 + +* Remove reaction id +* Clean code + +## 1.0.6+2 -* reaction title +* Minor bugs fixed ## 1.0.6+1 -* minor bugs fixed +* Minor bugs fixed -## 1.0.6+2 +## 1.0.6 -* minor bugs fixed +* Reaction title -## 1.0.7 +## 1.0.5 -* Remove reaction id -* Clean code +* Items spacing +* Box padding -## 1.0.7+2 +## 1.0.4 -* Improvement box flow +* Reactions box alignment -## 1.0.7+3 +## 1.0.3 + +* Change state externally + +## 1.0.2 + +* Code improvements + +## 1.0.1 -* Deprecated Reaction id \ No newline at end of file +* Define reaction by id. +* Alternative to popup menu. +* Enable/disable reaction click. + +## 1.0.0 + +* Adds ripple effect. + +## 0.1.3 + +* Selected rection index. + +## 0.1.2+1 + +* Adds Example. + +## 0.1.2 + +* From plugin to packages. + +## 0.1.1 + +* Reactions List @required. + +## 0.1.0 + +* Update Description pubspec.yaml. + +## 0.0.1 + +* Describe initial release. diff --git a/README.md b/README.md index e059b3e..69c4e10 100644 --- a/README.md +++ b/README.md @@ -1,184 +1,62 @@ -# Flutter Reaction Button - [![pub package](https://img.shields.io/pub/v/flutter_reaction_button.svg)](https://pub.dartlang.org/packages/flutter_reaction_button) -Flutter button reaction it is fully customizable widget such as Facebook reaction button. +# Flutter reaction button -## Preview +Flutter Reaction Button is a customizable Flutter package that allows you to easily create interactive buttons with reaction emojis, similar to Facebook's iconic reaction buttons. - -## Usage +## Screenshot + +![App Screenshot](https://raw.githubusercontent.com/GeekAbdelouahed/flutter-reaction-button/master/images/flutter_reaction_button_preview.png) -[Include 'flutter_reaction_button' from Dart Pub.](https://pub.dartlang.org/packages/flutter_reaction_button) + +## Installation ```yaml # pubspec.yaml - dependencies: flutter: sdk: flutter flutter_reaction_button: ``` - -Next, import 'flutter_reaction_button.dart' into your dart code. +## Usage ```dart import 'package:flutter_reaction_button/flutter_reaction_button.dart'; -``` - -## Examples -# flutter_reaction_button - -This is example Flutter Reaction Button Check: - - - -```dart -FlutterReactionButtonCheck( - onReactionChanged: (reaction, index, isChecked) { - print('reaction selected index: $index'); +ReactionButton( + onReactionChanged: (Reaction? reaction) { + debugPrint('Selected value: ${reaction?.value}'); }, - reactions: [ - Reaction( - previewIcon: buildWidgetPreview( - icon: 'like.gif', - ), - icon: buildWidget( - icon: 'like_fill.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'love.gif', - ), - icon: buildWidget( - icon: 'love.png' - ), + reactions: >[ + Reaction( + value: 'like', + icon: widget, ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'wow.gif', - ), - icon: buildWidget( - icon: 'wow.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'haha.gif', - ), - icon: buildWidget( - icon: 'haha.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'sad.gif', - ), - icon: buildWidget( - icon: 'sad.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'angry.gif', - ), - icon: buildWidget( - icon: 'angry.png' - ), + Reaction( + value: 'love', + icon: widget, ), + ... ], - initialReaction: Reaction( - icon: buildWidget( - icon: 'like.png' - ), + initialReaction: Reaction( + value: 'like', + icon: widget, ), - selectedReaction: Reaction( - icon: buildWidget( - icon: 'like_fill.png' - ), + selectedReaction: Reaction( + value: 'like_fill', + icon: widget, ), ) ``` - -This is a example Flutter Reaction Button: - - - -```dart -FlutterReactionButton( - onReactionChanged: (reaction, index) { - print('reaction selected index: $index'); - }, - reactions: [ - Reaction( - previewIcon: buildWidgetPreview( - title: 'English', - icon: 'united-kingdom-round.png', - ), - icon: buildWidget( - icon: 'united-kingdom.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'Arabic', - icon: 'algeria-round.png', - ), - icon: buildWidget( - icon: 'algeria.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'German', - icon: 'germany-round.png', - ), - icon: buildWidget( - icon: 'germany.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'Spanish', - icon: 'spain-round.png', - ), - icon: buildWidget( - icon: 'spain.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'Chinese', - icon: 'china-round.png', - ), - icon: buildWidget( - icon: 'china.png' - ), - ), - ], - initialReaction: Reaction( - previewIcon: buildWidgetPreview( - title: 'English', - icon: 'united-kingdom-round.png', - ), - icon: buildWidget( - icon: 'united-kingdom.png' - ), - ), -) -``` - -## LICENSE +## License ```legal MIT License -Copyright (c) 2019 Abdelouahed Medjoudja +Copyright (c) 2023 Abdelouahed Medjoudja Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..839cc64 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options \ No newline at end of file diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies deleted file mode 100644 index 35fadf0..0000000 --- a/example/.flutter-plugins-dependencies +++ /dev/null @@ -1 +0,0 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.18\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.1+1\\\\","dependencies":[]}],"android":[{"name":"path_provider","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.18\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.1+1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+4\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.1+1\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\Lenovo\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.4+1\\\\","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2021-02-12 11:21:18.662164","version":"1.22.0-12.3.pre"} \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore index ac4a906..65d3f4f 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,3 +1,6 @@ +#Flutter versions manager +.fvm/ + # Miscellaneous *.class *.log @@ -69,4 +72,4 @@ !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages \ No newline at end of file diff --git a/example/README.md b/example/README.md index 0b62225..30e8a55 100644 --- a/example/README.md +++ b/example/README.md @@ -1,143 +1,57 @@ # flutter_reaction_button_example -This is example Flutter Reaction Button Check: - - +ReactionButton: ```dart -FlutterReactionButtonCheck( - onReactionChanged: (reaction, index, isChecked) { - print('reaction selected index: $index'); +ReactionButton( + onReactionChanged: (Reaction? reaction) { + debugPrint('Selected value: ${reaction?.value}'); }, - reactions: [ - Reaction( - previewIcon: buildWidgetPreview( - icon: 'like.gif', - ), - icon: buildWidget( - icon: 'like_fill.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'love.gif', - ), - icon: buildWidget( - icon: 'love.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'wow.gif', - ), - icon: buildWidget( - icon: 'wow.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'haha.gif', - ), - icon: buildWidget( - icon: 'haha.png' - ), + reactions: >[ + Reaction( + value: 'like', + icon: widget, ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'sad.gif', - ), - icon: buildWidget( - icon: 'sad.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - icon: 'angry.gif', - ), - icon: buildWidget( - icon: 'angry.png' - ), + Reaction( + value: 'love', + icon: widget, ), + ... ], - initialReaction: Reaction( - icon: buildWidget( - icon: 'like.png' - ), + initialReaction: Reaction( + value: 'like', + icon: widget, ), - selectedReaction: Reaction( - icon: buildWidget( - icon: 'like_fill.png' - ), + selectedReaction: Reaction( + value: 'like_fill', + icon: widget, ), ) ``` - -This is a example Flutter Reaction Button: - - +ReactionButton: ```dart -FlutterReactionButton( - onReactionChanged: (reaction, index) { - print('reaction selected index: $index'); +ReactionButton( + toggle: false, + onReactionChanged: (Reaction? reaction) { + debugPrint('Selected language: ${reaction?.value}'); }, - reactions: [ - Reaction( - previewIcon: buildWidgetPreview( - title: 'English', - icon: 'united-kingdom-round.png', - ), - icon: buildWidget( - icon: 'united-kingdom.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'Arabic', - icon: 'algeria-round.png', - ), - icon: buildWidget( - icon: 'algeria.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'German', - icon: 'germany-round.png', - ), - icon: buildWidget( - icon: 'germany.png' - ), + reactions: >[ + Reaction( + value: 'en', + icon: widget, ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'Spanish', - icon: 'spain-round.png', - ), - icon: buildWidget( - icon: 'spain.png' - ), - ), - Reaction( - previewIcon: buildWidgetPreview( - title: 'Chinese', - icon: 'china-round.png', - ), - icon: buildWidget( - icon: 'china.png' - ), + Reaction( + value: 'ar', + icon: widget, ), + ... ], - initialReaction: Reaction( - previewIcon: buildWidgetPreview( - title: 'English', - icon: 'united-kingdom-round.png', - ), - icon: buildWidget( - icon: 'united-kingdom.png' - ), + initialReaction: Reaction( + value: null, + icon: Icon(Icons.language), ), ) ``` \ No newline at end of file diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..839cc64 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options \ No newline at end of file diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..0a741cb --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,11 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 8718b8b..91d236f 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -39,8 +39,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "abdelouahedmedjoudja.flutter_reaction_button_test" - minSdkVersion 16 - targetSdkVersion 28 + minSdkVersion 21 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index 719e6f6..aefab97 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -3,5 +3,5 @@ - + diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 83c4e34..a3056be 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -7,16 +7,17 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + android:name="${applicationName}" + android:icon="@mipmap/ic_launcher" + android:label="flutter_reaction_button_test"> + android:launchMode="singleTop" + android:theme="@style/LaunchTheme" + android:windowSoftInputMode="adjustResize" + android:exported="true"> + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 00fa441..26e896f 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,5 +1,6 @@ +