43 lines
1.0 KiB
Dart
43 lines
1.0 KiB
Dart
|
|
// lib/features/reviews/widgets/star_display.dart
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
class StarDisplay extends StatelessWidget {
|
||
|
|
final double rating;
|
||
|
|
final double size;
|
||
|
|
final Color filledColor;
|
||
|
|
final Color emptyColor;
|
||
|
|
|
||
|
|
const StarDisplay({
|
||
|
|
Key? key,
|
||
|
|
required this.rating,
|
||
|
|
this.size = 16,
|
||
|
|
this.filledColor = const Color(0xFFFBBF24),
|
||
|
|
this.emptyColor = const Color(0xFFD1D5DB),
|
||
|
|
}) : super(key: key);
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Row(
|
||
|
|
mainAxisSize: MainAxisSize.min,
|
||
|
|
children: List.generate(5, (i) {
|
||
|
|
final starPos = i + 1;
|
||
|
|
IconData icon;
|
||
|
|
Color color;
|
||
|
|
|
||
|
|
if (rating >= starPos) {
|
||
|
|
icon = Icons.star_rounded;
|
||
|
|
color = filledColor;
|
||
|
|
} else if (rating >= starPos - 0.5) {
|
||
|
|
icon = Icons.star_half_rounded;
|
||
|
|
color = filledColor;
|
||
|
|
} else {
|
||
|
|
icon = Icons.star_outline_rounded;
|
||
|
|
color = emptyColor;
|
||
|
|
}
|
||
|
|
|
||
|
|
return Icon(icon, size: size, color: color);
|
||
|
|
}),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|