YSChoose.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
  4. import 'package:flutterappfuyou/code/base/YSTools.dart';
  5. import 'base/YSBase.dart';
  6. class YSChooseArea extends StatefulWidget {
  7. @override
  8. _YSChooseAreaState createState() => _YSChooseAreaState();
  9. }
  10. class _YSChooseAreaState extends State<YSChooseArea> {
  11. List _dataArray = [];
  12. bool _isStreet = false;
  13. Map _area;
  14. Map _street;
  15. @override
  16. void initState() {
  17. Future.delayed(Duration(seconds: 0)).then((value){
  18. _getAreaData();
  19. });
  20. super.initState();
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return YSBase(
  25. ystitle: '区域选择',
  26. yschild: Container(
  27. height: MediaQuery.of(context).size.height,
  28. width: MediaQuery.of(context).size.width,
  29. decoration: BoxDecoration(
  30. borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20)),
  31. color: Colors.white,
  32. ),
  33. child: ListView.builder(
  34. itemBuilder: (context,index){
  35. return Column(
  36. children: [
  37. GestureDetector(
  38. behavior: HitTestBehavior.opaque,
  39. onTap: (){
  40. if(_isStreet==false){
  41. _isStreet = true;
  42. _area = _dataArray[index];
  43. _getStreetData(_dataArray[index]);
  44. }else{
  45. _street = _dataArray[index];
  46. _getHealthData();
  47. }
  48. },
  49. child: Container(
  50. padding: EdgeInsets.all(15),
  51. height: 50,
  52. child: Row(
  53. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  54. children: [
  55. Text('${_dataArray[index]['name']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  56. Icon(Icons.keyboard_arrow_right,size: 20,color: Color(0xFFAEB3BD),),
  57. ],
  58. )
  59. ),
  60. ),
  61. Container(
  62. width: MediaQuery.of(context).size.width,
  63. height: 1.5,
  64. child: Image.asset('lib/images/line.png'),
  65. )
  66. ],
  67. );
  68. },
  69. itemCount: _dataArray.length,
  70. padding: EdgeInsets.only(top: 10),
  71. ),
  72. ),
  73. );
  74. }
  75. _getAreaData() async{
  76. Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'common/county', {});
  77. if(dict!=null){
  78. setState(() {
  79. _dataArray = dict['data'];
  80. });
  81. }
  82. }
  83. _getStreetData(Map area) async{
  84. Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'common/street', {'id':area['id']});
  85. if(dict!=null){
  86. setState(() {
  87. _dataArray = dict['data'];
  88. });
  89. }
  90. }
  91. _getHealthData() async{
  92. Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'common/countyHealth', {'region_id':_area['id']});
  93. if(dict!=null){
  94. // LogUtil.d(_area);
  95. // return;
  96. List datas = dict['data']['datas']??[];
  97. LogUtil.d(datas);
  98. if(datas.isNotEmpty){
  99. Navigator.of(context).pop({
  100. 'healthId':datas[0]['id'],
  101. 'health':'${datas[0]['name']}',
  102. 'areaId':_area['id'],
  103. 'area':'${_area['name']}',
  104. 'streetId':_street['id'],
  105. 'street':'${_street['name']}'
  106. });
  107. }else{
  108. Navigator.of(context).pop({
  109. 'healthId':0,
  110. 'health':'',
  111. 'areaId':_area['id'],
  112. 'area':'${_area['name']}',
  113. 'streetId':_street['id'],
  114. 'street':'${_street['name']}'
  115. });
  116. }
  117. }
  118. }
  119. }
  120. class YSChooseType extends StatelessWidget {
  121. final List dataArray = ['居民身份证','军人身份证','护照','港澳居民来往内地通行证','台湾居民来往内地通行证','中华人民共和国旅行证','其他'];
  122. @override
  123. Widget build(BuildContext context) {
  124. return YSBase(
  125. ystitle: '类型选择',
  126. yschild: Container(
  127. decoration: BoxDecoration(
  128. borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20)),
  129. color: Colors.white,
  130. ),
  131. child: ListView.builder(
  132. itemBuilder: (context,index){
  133. return GestureDetector(
  134. behavior: HitTestBehavior.opaque,
  135. onTap: (){
  136. Navigator.of(context).pop(dataArray[index].toString());
  137. },
  138. child: Column(
  139. crossAxisAlignment: CrossAxisAlignment.start,
  140. children: [
  141. Container(
  142. padding: EdgeInsets.all(15),
  143. height: 50,
  144. child: Text(dataArray[index].toString(),style: TextStyle(fontSize: 14,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  145. ),
  146. Container(
  147. width: MediaQuery.of(context).size.width,
  148. height: 1.5,
  149. child: Image.asset('lib/images/line.png'),
  150. )
  151. ],
  152. ),
  153. );
  154. },
  155. itemCount: dataArray.length
  156. ),
  157. ),
  158. );
  159. }
  160. }