Skip to content

Commit

Permalink
Version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbagyastha committed Apr 5, 2019
1 parent 4fe284d commit 49711b8
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 52 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
## 1.1.0

* [ignoreGestures](https://pub.dartlang.org/documentation/flutter_rating_bar/latest/flutter_rating_bar/FlutterRatingBar/ignoreGestures.html) property added to FlutterRatingBar as per [#1](https://github.com/sarbagyastha/flutter_rating_bar/issues/1) by @Skquark.
* [tapOnlyMode](https://pub.dartlang.org/documentation/flutter_rating_bar/latest/flutter_rating_bar/FlutterRatingBar/tapOnlyMode.html) property added to FlutterRatingBar.
* Readme updated with customization images and links to api docs.

## 1.1.0

* FlutterRatingBar is also fully customizable as Indicator now.
* Readme updated with customization examples.
* Dart-complaint docs added.
* [Breaking Change] size property in FlutterRatingBar is changed to itemSize for the sake of consistency.


## 1.0.0

* Initial release
42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flutter Rating Bar

[![pub package](https://img.shields.io/badge/pub-v1.1.0-green.svg)](https://pub.dartlang.org/packages/flutter_rating_bar) [![licence](https://img.shields.io/badge/Licence-MIT-orange.svg)](https://github.com/sarbagyastha/flutter_rating_bar/blob/master/LICENSE)
[![pub package](https://img.shields.io/badge/pub-v1.1.1-green.svg)](https://pub.dartlang.org/packages/flutter_rating_bar) [![licence](https://img.shields.io/badge/Licence-MIT-orange.svg)](https://github.com/sarbagyastha/flutter_rating_bar/blob/master/LICENSE)

A simple yet fully customizable ratingbar for flutter which also include a rating bar indicator, supporting any fraction of rating.

Expand All @@ -14,7 +14,7 @@ Add this to you package's `pubspec.yaml` file:

```yaml
dependencies:
flutter_rating_bar: ^1.1.0
flutter_rating_bar: ^1.1.1
```
#### 2\. Install
Expand Down Expand Up @@ -60,20 +60,10 @@ FlutterRatingBarIndicator(

In order to make the indicator scrollable, just use 'physics' property as in the [example](https://github.com/sarbagyastha/flutter_rating_bar/blob/master/example/lib/main.dart).

## Customize Rating Bar
```dart
FlutterRatingBarIndicator(
rating: _userRating,
pathClipper: DiamondClipper(),
itemCount: 5,
itemSize: 50.0,
emptyColor: Colors.amber.withAlpha(50),
),
class DiamondClipper extends CustomClipper<Path> {...}
```

## Customize Rating Bar Indicator
![CUSTOM_DEMO](heart_rating.png)

```dart
FlutterRatingBar(
initialRating: 2.87,
Expand All @@ -99,8 +89,28 @@ Widget _image(String asset) {

Heart Icons are [Available Here](https://github.com/sarbagyastha/flutter_rating_bar/tree/master/example/assets).

## After Customization
<img src="custom_example.png" width="200" alt="Custom Demo">

## Customize Rating Bar
![CUSTOM_DEMO](diamond_rating.png)

```dart
FlutterRatingBarIndicator(
rating: _userRating,
pathClipper: DiamondClipper(),
itemCount: 5,
itemSize: 50.0,
emptyColor: Colors.amber.withAlpha(50),
),
class DiamondClipper extends CustomClipper<Path> {...}
```

DiamondClipper can be found [here](https://github.com/sarbagyastha/flutter_rating_bar/tree/master/example/assets).

## Info
To know more about the available properties, head on to [api docs](https://pub.dartlang.org/documentation/flutter_rating_bar/latest/flutter_rating_bar/flutter_rating_bar-library.html).

Feel Free to request any missing features or report issues [here](https://github.com/sarbagyastha/flutter_rating_bar/issues).

## License

Expand Down
Binary file removed custom_example.png
Binary file not shown.
Binary file added diamond_rating.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class _MyAppState extends State<MyApp> {
FlutterRatingBar(
initialRating: 3,
allowHalfRating: true,
ignoreGestures: false,
tapOnlyMode: false,
itemCount: 6,
itemPadding: EdgeInsets.symmetric(horizontal: 4.0),
fullRatingWidget:
_customize ? _image("assets/heart.png") : null,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.1.0"
version: "1.1.1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
Binary file added heart_rating.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 47 additions & 33 deletions lib/flutter_rating_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ class FlutterRatingBar extends StatefulWidget {
/// [itemPadding] gives padding to each rating item.
final EdgeInsets itemPadding;

/// [ignoreGestures]=false, if set to true will disable any gestures over the rating bar.
final bool ignoreGestures;

/// [tapOnlyMode]=false, if set to true will disable drag to rate feature. Note: Enabling this mode will disable half rating capability.
final bool tapOnlyMode;

FlutterRatingBar({
this.itemCount = 5,
this.initialRating = 0.0,
Expand All @@ -174,6 +180,8 @@ class FlutterRatingBar extends StatefulWidget {
this.halfRatingWidget,
this.noRatingWidget,
this.itemPadding = const EdgeInsets.all(0.0),
this.ignoreGestures = false,
this.tapOnlyMode = false,
});

@override
Expand Down Expand Up @@ -241,39 +249,45 @@ class _FlutterRatingBarState extends State<FlutterRatingBar> {
iconRating += 1.0;
}

return GestureDetector(
onTap: () {
if (widget.onRatingUpdate != null) {
widget.onRatingUpdate(index + 1.0);
setState(() {
_rating = index + 1.0;
});
}
},
onHorizontalDragEnd: (_) {
widget.onRatingUpdate(iconRating);
iconRating = 0.0;
},
onHorizontalDragUpdate: (dragDetails) {
RenderBox box = context.findRenderObject();
var _pos = box.globalToLocal(dragDetails.globalPosition);
var i = _pos.dx / widget.itemSize;
var currentRating = widget.allowHalfRating ? i : i.round().toDouble();
if (currentRating > widget.itemCount) {
currentRating = widget.itemCount.toDouble();
}
if (currentRating < 0) {
currentRating = 0.0;
}
if (widget.onRatingUpdate != null) {
setState(() {
_rating = currentRating;
});
}
},
child: Padding(
padding: widget.itemPadding,
child: ratingWidget,
return IgnorePointer(
ignoring: widget.ignoreGestures,
child: GestureDetector(
onTap: () {
if (widget.onRatingUpdate != null) {
widget.onRatingUpdate(index + 1.0);
setState(() {
_rating = index + 1.0;
});
}
},
onHorizontalDragEnd: (_) {
widget.onRatingUpdate(iconRating);
iconRating = 0.0;
},
onHorizontalDragUpdate: (dragDetails) {
if (!widget.tapOnlyMode) {
RenderBox box = context.findRenderObject();
var _pos = box.globalToLocal(dragDetails.globalPosition);
var i = _pos.dx / widget.itemSize;
var currentRating =
widget.allowHalfRating ? i : i.round().toDouble();
if (currentRating > widget.itemCount) {
currentRating = widget.itemCount.toDouble();
}
if (currentRating < 0) {
currentRating = 0.0;
}
if (widget.onRatingUpdate != null) {
setState(() {
_rating = currentRating;
});
}
}
},
child: Padding(
padding: widget.itemPadding,
child: ratingWidget,
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_rating_bar
description: A simple yet fully customizable ratingbar for flutter which also include a rating bar indicator, supporting any fraction of rating.
version: 1.1.0
version: 1.1.1
author: Sarbagya Dhaubanjar <[email protected]>
homepage: https://github.com/sarbagyastha/flutter_rating_bar

Expand Down

0 comments on commit 49711b8

Please sign in to comment.