YSSettingUnit.dart 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 YSSettingUnit extends StatefulWidget {
  8. const YSSettingUnit({Key? key}) : super(key: key);
  9. @override
  10. YSSettingUnitState createState() => YSSettingUnitState();
  11. }
  12. class YSSettingUnitState extends State<YSSettingUnit> {
  13. final List _list = [
  14. {'title':S.current.MEIYUAN,'type':'dollar','isChoose':false},
  15. {'title':S.current.RENMINBI,'type':'RMB','isChoose':false}
  16. ];
  17. @override
  18. void initState() {
  19. super.initState();
  20. }
  21. @override
  22. Widget build(BuildContext context) {
  23. return YSBase(
  24. ysTitle: S.current.HUOBIDANWEI,
  25. ysChild: Consumer(
  26. builder: (context,YSUnitNotifier unit,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().unit;
  34. return GestureDetector(
  35. onTap: (){
  36. Provider.of<YSUnitNotifier>(context, listen: false).setUnit(item['type']);
  37. },
  38. behavior: HitTestBehavior.opaque,
  39. child: Padding(
  40. padding: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  41. child: Row(
  42. children: [
  43. Expanded(child: Text(item['title'],style: YSColors.contentStyle(context),)),
  44. if(isChoose)Icon(Icons.check_circle,size: hsp(20),color: Colors.black,)
  45. ],
  46. ),
  47. ),
  48. );
  49. },
  50. separatorBuilder: (context,index){
  51. return Divider(height: hsp(1),color: YSColors.lineColor(context),);
  52. },
  53. itemCount: _list.length,
  54. shrinkWrap: true,
  55. physics: const NeverScrollableScrollPhysics(),
  56. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  57. ),
  58. );
  59. }
  60. ),
  61. );
  62. }
  63. }