123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import 'package:flutter/material.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/widgets/smooth_star_rating.dart';
- class StarItem extends StatelessWidget {
- const StarItem({
- Key key,
- this.onTap,
- @required this.title,
- this.maxLines: 1,
- this.starRating,
- this.onRatingChanged,
- }): super(key: key);
- final GestureTapCallback onTap;
- final Function(double) onRatingChanged;
- final String title;
- final int maxLines;
- final double starRating;
- @override
- Widget build(BuildContext context) {
- bool isDark = ThemeUtils.isDark(context);
- return InkWell(
- onTap: onTap,
- child: Container(
- padding: const EdgeInsets.fromLTRB(15, 15.0, 15.0, 15.0),
- constraints: BoxConstraints(
- maxHeight: double.infinity,
- minHeight: 50.0
- ),
- width: double.infinity,
- decoration: BoxDecoration(
- color: isDark?Colors.black:Colors.white,
- border: Border(
- bottom: Divider.createBorderSide(context, width: 0.6),
- )
- ),
- child: Row(
- //为了数字类文字居中
- crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
- children: <Widget>[
- Expanded(
- flex: 4,
- child: Text(title),
- ),
- SmoothStarRating(
- iconSelected:LoadAssetImage("icon_star_selected",
- width: 18, height: 18),
- iconNormal: LoadAssetImage("icon_star_normal",
- width: 18, height: 18),
- allowHalfRating: false,
- onRatingChanged: onRatingChanged,
- starCount: 5,
- rating: starRating,
- size: 30,
- color: Color(0xFFF4A22D),
- borderColor: Colours.text_gray_c,
- )
- ],
- ),
- ),
- );
- }
- }
|