This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
97 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:flutter_stream_friends/flutter_stream_friends.dart'; | ||
import 'package:beer_me_up/common/hapticfeedback.dart'; | ||
|
||
class RatingStars extends StatelessWidget { | ||
final int rating; | ||
final double size; | ||
final ValueStreamCallback<int> onTap; | ||
final double paddingBetweenStars; | ||
final MainAxisAlignment alignment; | ||
|
||
RatingStars({ | ||
@required this.rating, | ||
@required this.size, | ||
this.onTap, | ||
this.paddingBetweenStars, | ||
this.alignment, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Row( | ||
mainAxisAlignment: alignment ?? MainAxisAlignment.start, | ||
children: <Widget>[ | ||
_buildStar(1, rating >= 1, context), | ||
_buildStar(2, rating >= 2, context), | ||
_buildStar(3, rating >= 3, context), | ||
_buildStar(4, rating >= 4, context), | ||
_buildStar(5, rating >= 5, context), | ||
], | ||
); | ||
} | ||
|
||
Widget _buildStar(int index, bool selected, BuildContext context) { | ||
return Material( | ||
type: MaterialType.transparency, | ||
child: InkWell( | ||
enableFeedback: onTap != null, | ||
onTap: onTap != null ? () { | ||
performSelectionHaptic(context); | ||
onTap(index); | ||
} : null, | ||
borderRadius: const BorderRadius.all(Radius.circular(50.0)), | ||
child: Container( | ||
padding: EdgeInsets.all(paddingBetweenStars ?? 0.0), | ||
child: Icon( | ||
selected ? Icons.star : Icons.star_border, | ||
color: Colors.amberAccent[400], | ||
size: size, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters