star_item.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/resources.dart';
  3. import 'package:liftmanager/utils/theme_utils.dart';
  4. import 'package:liftmanager/widgets/load_image.dart';
  5. import 'package:liftmanager/widgets/smooth_star_rating.dart';
  6. class StarItem extends StatelessWidget {
  7. const StarItem({
  8. Key key,
  9. this.onTap,
  10. @required this.title,
  11. this.maxLines: 1,
  12. this.starRating,
  13. this.onRatingChanged,
  14. }): super(key: key);
  15. final GestureTapCallback onTap;
  16. final Function(double) onRatingChanged;
  17. final String title;
  18. final int maxLines;
  19. final double starRating;
  20. @override
  21. Widget build(BuildContext context) {
  22. bool isDark = ThemeUtils.isDark(context);
  23. return InkWell(
  24. onTap: onTap,
  25. child: Container(
  26. padding: const EdgeInsets.fromLTRB(15, 15.0, 15.0, 15.0),
  27. constraints: BoxConstraints(
  28. maxHeight: double.infinity,
  29. minHeight: 50.0
  30. ),
  31. width: double.infinity,
  32. decoration: BoxDecoration(
  33. color: isDark?Colors.black:Colors.white,
  34. border: Border(
  35. bottom: Divider.createBorderSide(context, width: 0.6),
  36. )
  37. ),
  38. child: Row(
  39. //为了数字类文字居中
  40. crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
  41. children: <Widget>[
  42. Expanded(
  43. flex: 4,
  44. child: Text(title),
  45. ),
  46. SmoothStarRating(
  47. iconSelected:LoadAssetImage("icon_star_selected",
  48. width: 18, height: 18),
  49. iconNormal: LoadAssetImage("icon_star_normal",
  50. width: 18, height: 18),
  51. allowHalfRating: false,
  52. onRatingChanged: onRatingChanged,
  53. starCount: 5,
  54. rating: starRating,
  55. size: 30,
  56. color: Color(0xFFF4A22D),
  57. borderColor: Colours.text_gray_c,
  58. )
  59. ],
  60. ),
  61. ),
  62. );
  63. }
  64. }