star_item.dart 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/resources.dart';
  3. import 'package:liftmanager/widgets/load_image.dart';
  4. import 'package:liftmanager/widgets/smooth_star_rating.dart';
  5. class StarItem extends StatelessWidget {
  6. const StarItem({
  7. Key key,
  8. this.onTap,
  9. @required this.title,
  10. this.maxLines: 1,
  11. this.starRating,
  12. this.onRatingChanged,
  13. }): super(key: key);
  14. final GestureTapCallback onTap;
  15. final Function(double) onRatingChanged;
  16. final String title;
  17. final int maxLines;
  18. final double starRating;
  19. @override
  20. Widget build(BuildContext context) {
  21. return InkWell(
  22. onTap: onTap,
  23. child: Container(
  24. padding: const EdgeInsets.fromLTRB(15, 15.0, 15.0, 15.0),
  25. constraints: BoxConstraints(
  26. maxHeight: double.infinity,
  27. minHeight: 50.0
  28. ),
  29. width: double.infinity,
  30. // decoration: BoxDecoration(
  31. // color: Colors.white,
  32. // border: Border(
  33. // bottom: Divider.createBorderSide(context, width: 0.6),
  34. // )
  35. // ),
  36. child: Row(
  37. //为了数字类文字居中
  38. crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
  39. mainAxisAlignment: MainAxisAlignment.center,
  40. children: <Widget>[
  41. Container(
  42. // flex: 4,
  43. child: Text(title),
  44. ),
  45. SmoothStarRating(
  46. iconSelected:LoadAssetImage("icon_star_selected",
  47. width: 18, height: 18),
  48. iconNormal: LoadAssetImage("icon_star_normal",
  49. width: 18, height: 18),
  50. allowHalfRating: false,
  51. onRatingChanged: onRatingChanged,
  52. starCount: 5,
  53. rating: starRating,
  54. size: 30,
  55. color: Color(0xFFF4A22D),
  56. borderColor: Colours.text_gray_c,
  57. )
  58. ],
  59. ),
  60. ),
  61. );
  62. }
  63. }
  64. class StarItemShow extends StatelessWidget {
  65. const StarItemShow({
  66. Key key,
  67. this.maxLines: 1,
  68. this.starRating,
  69. }): super(key: key);
  70. final int maxLines;
  71. final double starRating;
  72. @override
  73. Widget build(BuildContext context) {
  74. double width = MediaQuery.of(context).size.width;
  75. return InkWell(
  76. child: Container(
  77. // padding: const EdgeInsets.fromLTRB(15, 15.0, 0, 15.0),
  78. constraints: BoxConstraints(
  79. maxHeight: 20.0,
  80. minHeight: 20.0
  81. ),
  82. width: width*0.4,
  83. // decoration: BoxDecoration(
  84. // color: Colors.white,
  85. // border: Border(
  86. // bottom: Divider.createBorderSide(context, width: 0.6),
  87. // )
  88. // ),
  89. child: Row(
  90. //为了数字类文字居中
  91. crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
  92. mainAxisAlignment: MainAxisAlignment.end,
  93. children: <Widget>[
  94. SmoothStarRating(
  95. paddingLeft:2.0,
  96. paddingRight:2.0,
  97. iconSelected:LoadAssetImage("icon_star_selected",
  98. width: 14, height: 14),
  99. iconNormal: LoadAssetImage("icon_star_normal",
  100. width: 14, height: 14),
  101. allowHalfRating: false,
  102. starCount: 5,
  103. rating: starRating,
  104. size: 15,
  105. color: Color(0xFFF4A22D),
  106. borderColor: Colours.text_gray_c,
  107. )
  108. ],
  109. ),
  110. ),
  111. );
  112. }
  113. }