YSSettingPrice.dart 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_wallet/generated/l10n.dart';
  3. import 'package:provider/provider.dart';
  4. import '../base/YSBase.dart';
  5. import '../tools/YSColors.dart';
  6. import '../tools/YSTools.dart';
  7. class YSSettingPrice extends StatefulWidget {
  8. const YSSettingPrice({Key? key}) : super(key: key);
  9. @override
  10. YSSettingPriceState createState() => YSSettingPriceState();
  11. }
  12. class YSSettingPriceState extends State<YSSettingPrice> {
  13. final List _list = [
  14. {'title':S.current.LVZHANGHONGDIE,'type':'1'},
  15. {'title':S.current.HONGZHANGLVDIE,'type':'2'}
  16. ];
  17. @override
  18. void initState() {
  19. super.initState();
  20. }
  21. @override
  22. Widget build(BuildContext context) {
  23. return YSBase(
  24. ysTitle: S.current.HANGQINGSHEZHI,
  25. ysChild: Consumer(
  26. builder: (context,YSPriceTypeNotifier value,child) {
  27. return Container(
  28. width: ysWidth(context),
  29. color: YSColors.containColor(context),
  30. child: ListView.separated(
  31. itemBuilder: (context,index){
  32. Map item = _list[index];
  33. bool isChoose = item['type']==YSUserRecord().priceType;
  34. return GestureDetector(
  35. onTap: (){
  36. YSSharedPreferences.setStringValue('priceType', item['type']);
  37. Provider.of<YSPriceTypeNotifier>(context, listen: false).setType(item['type']);
  38. },
  39. behavior: HitTestBehavior.opaque,
  40. child: Padding(
  41. padding: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  42. child: Row(
  43. children: [
  44. Expanded(child: RichText(
  45. text: TextSpan(
  46. style: YSColors.contentStyle(context),
  47. text: item['title'],
  48. children: const [
  49. // WidgetSpan(child: SizedBox(
  50. // width: hsp(30),
  51. // child: Row(
  52. // children: [
  53. // Padding(
  54. // padding: EdgeInsets.only(left: hsp(5),right: hsp(5)),
  55. // child: Image.asset(YSColors.imageStyle(context, '数据折线上升4备份'),height: hsp(10),width: hsp(10),),
  56. // ),
  57. // Image.asset(YSColors.imageStyle(context, '数据折线上升4'),height: hsp(10),width: hsp(10),),
  58. // ],
  59. // ),
  60. // ),alignment: PlaceholderAlignment.middle)
  61. ]
  62. ),
  63. )),
  64. if(isChoose)Icon(Icons.check_circle,size: hsp(20),color: Colors.black,)
  65. ],
  66. ),
  67. ),
  68. );
  69. },
  70. separatorBuilder: (context,index){
  71. return Divider(height: hsp(1),color: YSColors.lineColor(context),);
  72. },
  73. itemCount: _list.length,
  74. shrinkWrap: true,
  75. physics: const NeverScrollableScrollPhysics(),
  76. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  77. ),
  78. );
  79. }
  80. ),
  81. );
  82. }
  83. }