123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- import 'package:flutter/material.dart';
- import 'package:liftmanager/res/resources.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) {
- 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: Colors.white,
- // border: Border(
- // bottom: Divider.createBorderSide(context, width: 0.6),
- // )
- // ),
- child: Row(
- //为了数字类文字居中
- crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- // 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,
- )
- ],
- ),
- ),
- );
- }
- }
- class StarItemShow extends StatelessWidget {
- const StarItemShow({
- Key key,
- this.maxLines: 1,
- this.starRating,
- }): super(key: key);
- final int maxLines;
- final double starRating;
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- return InkWell(
- child: Container(
- // padding: const EdgeInsets.fromLTRB(15, 15.0, 0, 15.0),
- constraints: BoxConstraints(
- maxHeight: 20.0,
- minHeight: 20.0
- ),
- width: width*0.4,
- // decoration: BoxDecoration(
- // color: Colors.white,
- // border: Border(
- // bottom: Divider.createBorderSide(context, width: 0.6),
- // )
- // ),
- child: Row(
- //为了数字类文字居中
- crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.end,
- children: <Widget>[
- SmoothStarRating(
- paddingLeft:2.0,
- paddingRight:2.0,
- iconSelected:LoadAssetImage("icon_star_selected",
- width: 14, height: 14),
- iconNormal: LoadAssetImage("icon_star_normal",
- width: 14, height: 14),
- allowHalfRating: false,
- starCount: 5,
- rating: starRating,
- size: 15,
- color: Color(0xFFF4A22D),
- borderColor: Colours.text_gray_c,
- )
- ],
- ),
- ),
- );
- }
- }
|