YSWriteOff.dart 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import 'package:flutter/material.dart';
  2. import 'package:flutterappfuyou/code/base/YSBase.dart';
  3. import 'package:flutterappfuyou/code/version3/view/YSWriteOffListItemView.dart';
  4. import '../base/YSTools.dart';
  5. class YSWriteOff extends StatefulWidget {
  6. const YSWriteOff({Key key}) : super(key: key);
  7. @override
  8. _YSWriteOffState createState() => _YSWriteOffState();
  9. }
  10. class _YSWriteOffState extends State<YSWriteOff> with SingleTickerProviderStateMixin{
  11. List _dataArray = [];
  12. List _titles = [
  13. {'title':'已核销','type':1},
  14. {'title':'已作废','type':2}
  15. ];
  16. TabController _tabController;
  17. @override
  18. void initState() {
  19. _tabController = TabController(
  20. vsync: this,
  21. length: _titles.length,
  22. );
  23. super.initState();
  24. }
  25. @override
  26. Widget build(BuildContext context) {
  27. return YSBase(
  28. ysBgColor: Colors.white,
  29. ystitle: '核销记录',
  30. yschild: DefaultTabController(
  31. length: _titles.length,
  32. child: SingleChildScrollView(
  33. child: Column(
  34. children: [
  35. Container(
  36. height: 50,
  37. child: TabBar(
  38. controller: _tabController,
  39. indicatorColor: Color(0xFFEE6B8F),
  40. labelColor: Color(0xFFEE6B8F),
  41. indicatorWeight: 3,
  42. indicatorSize: TabBarIndicatorSize.label,
  43. labelStyle: TextStyle(fontSize: 14),
  44. unselectedLabelColor: Color(0xFFC8C9CC),
  45. tabs: _titles.map((f) {
  46. return Tab(
  47. child: Row(
  48. mainAxisSize: MainAxisSize.min,
  49. children: [
  50. Text(f['title'])
  51. ],
  52. ),
  53. );
  54. }).toList(),
  55. ),
  56. ),
  57. Container(
  58. height: ysHeight(context)-ysTOP(context)-100,
  59. child: TabBarView(
  60. controller: _tabController,
  61. children: _titles.map((f) {
  62. return YSWriteOffDataView(f: f,);
  63. }).toList(),
  64. ),
  65. )
  66. ],
  67. ),
  68. ),
  69. ),
  70. );
  71. }
  72. }
  73. class YSWriteOffDataView extends StatefulWidget {
  74. final Map f;
  75. const YSWriteOffDataView({Key key, this.f}) : super(key: key);
  76. @override
  77. _YSWriteOffDataViewState createState() => _YSWriteOffDataViewState();
  78. }
  79. class _YSWriteOffDataViewState extends State<YSWriteOffDataView> {
  80. List _dataArray = [];
  81. @override
  82. Widget build(BuildContext context) {
  83. return Container(
  84. height: ysHeight(context)-ysTOP(context)-100,
  85. child: YSRefreshLoad2(
  86. url: widget.f['type']==1?'transfer/coupon/getWriteOffRecord':'transfer/coupon/queryExpired',
  87. request: {'idcard':User().idCard,'pageSize':10},
  88. postData: (value){
  89. _dataArray = value;
  90. setState(() {});
  91. },
  92. dataWidget: SingleChildScrollView(
  93. child: ListView.separated(
  94. itemBuilder: (context,index){
  95. Map item = _dataArray[index];
  96. return YSWriteOffListItemView(item: item,);
  97. },
  98. separatorBuilder: (context,index){
  99. return Container(height: 15,);
  100. },
  101. itemCount: _dataArray.length,
  102. padding: EdgeInsets.all(15),
  103. shrinkWrap: true,
  104. physics: NeverScrollableScrollPhysics(),
  105. ),
  106. ),
  107. ),
  108. );
  109. }
  110. }