YSShopListItemView.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import 'package:flutter/material.dart';
  2. import 'package:provider/provider.dart';
  3. import '../../tools/YSColors.dart';
  4. import '../../tools/YSTools.dart';
  5. class YSShopListItemView extends StatefulWidget {
  6. final Map item;
  7. const YSShopListItemView({Key? key, required this.item}) : super(key: key);
  8. @override
  9. YSShopListItemViewState createState() => YSShopListItemViewState();
  10. }
  11. class YSShopListItemViewState extends State<YSShopListItemView> {
  12. @override
  13. Widget build(BuildContext context) {
  14. return Consumer(
  15. builder: (context,YSPriceTypeNotifier value,child) {
  16. Color upColor = Colors.green;
  17. Color downColor = Colors.red;
  18. if(YSUserRecord().priceType=='1'){
  19. upColor = Colors.green;
  20. downColor = Colors.red;
  21. }else{
  22. upColor = Colors.red;
  23. downColor = Colors.green;
  24. }
  25. return Container(
  26. padding: EdgeInsets.only(left: hsp(15),right: hsp(15),top: hsp(10),bottom: hsp(10)),
  27. alignment: Alignment.centerLeft,
  28. child: Row(
  29. children: [
  30. ClipRRect(
  31. borderRadius: const BorderRadius.all(Radius.circular(50)),
  32. child: YSImage.network(widget.item['icon'],height: hsp(40),width: hsp(40),),
  33. ),
  34. Expanded(
  35. child: Container(
  36. padding: EdgeInsets.only(top: hsp(5),bottom: hsp(5),left: hsp(5),right: hsp(5)),
  37. child: Column(
  38. crossAxisAlignment: CrossAxisAlignment.start,
  39. children: [
  40. Text(widget.item['symbol'],style: YSColors.contentStyle(context),),
  41. Padding(
  42. padding: EdgeInsets.only(top: hsp(5)),
  43. child: RichText(text: TextSpan(
  44. style: YSColors.subStyle(context),
  45. children: [
  46. TextSpan(
  47. text: 'Vol \$ ${toFlex('${widget.item['volume']}')} '.fixAutoLines(),
  48. ),
  49. // TextSpan(
  50. // text: '-29535.65',
  51. // style: TextStyle(color: Color(0xFFFF0000))
  52. // )
  53. ]
  54. ))
  55. )
  56. ],
  57. ),
  58. )
  59. ),
  60. Expanded(child: Container(
  61. padding: EdgeInsets.only(top: hsp(5),bottom: hsp(5),left: hsp(5),right: hsp(10)),
  62. child: Column(
  63. crossAxisAlignment: CrossAxisAlignment.end,
  64. children: [
  65. Text('${toFlex('${widget.item['price_usd']}',range: 3)}',style: YSColors.contentStyle(context),),
  66. Padding(
  67. padding: EdgeInsets.only(top: hsp(5)),
  68. child: Text('\$ ${toFlex('${widget.item['price_usd']}')} ',style: YSColors.subStyle(context),)
  69. )
  70. ],
  71. ),
  72. )),
  73. Container(
  74. width: hsp(60),
  75. height: hsp(30),
  76. decoration: BoxDecoration(
  77. color: double.parse('${widget.item['chg']}')>0?upColor:downColor,
  78. borderRadius: const BorderRadius.all(Radius.circular(5))
  79. ),
  80. alignment: Alignment.center,
  81. child: Text('${toPercentage(widget.item['chg'])}',style: YSColors.sub2Style( context),),
  82. )
  83. ],
  84. )
  85. );
  86. }
  87. );
  88. }
  89. }