import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_tzh/base/YSBase.dart'; import 'package:flutter_tzh/home/view/YSInputView.dart'; import 'package:flutter_tzh/home/view/YSMapView.dart'; import 'package:flutter_tzh/tool/YSFileView.dart'; import 'package:flutter_tzh/tool/YSNetWork.dart'; import 'package:flutter_tzh/tool/YSTools.dart'; //TODO:YSHomeListDetailGather class YSHomeListDetailGather extends StatefulWidget { final int gatherId; const YSHomeListDetailGather({Key? key, required this.gatherId}) : super(key: key); @override YSHomeListDetailGatherState createState() => YSHomeListDetailGatherState(); } class YSHomeListDetailGatherState extends State { bool _isHiden = false; final Map _contentMap = {'title':'采样描述'}; final List _inputArray = []; final List _fileArray = []; String _value = ''; @override void initState() { Future.delayed(const Duration(seconds: 0)).then((value) { _getSamplingFieldIndex(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ysTitle: '采样', ysChild: GestureDetector( // onVerticalDragEnd: (value){ // if(value.primaryVelocity!>0){ // _isHiden = true; // }else if(value.primaryVelocity!<0){ // _isHiden = false; // } // setState(() {}); // }, child: SingleChildScrollView( padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)), child: Column( children: [ ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: Container( height: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(110):hsp(150), decoration: const BoxDecoration( color: Color(0xFF3E434E) ), child: const YSMapView(location: {'latitude': 57.24, 'longitude': 127.38},), ), ), GestureDetector( onTap: (){ _isHiden = !_isHiden; setState(() {}); }, child: Container( padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10)), child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),), ), ), _isHiden?Container( height: hsp(50), decoration: const BoxDecoration( image: DecorationImage(image: AssetImage('images/tzh_hiden.png') ) ), alignment: Alignment.center, padding: EdgeInsets.only(top: hsp(15)), child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ):SizedBox( height: ysHeight(context)-ysTOP(context)-44-hsp(205), child: Column( children: [ SizedBox( height: ysHeight(context)-ysTOP(context)-44-hsp(277), child: SingleChildScrollView( child: Column( children: [ Container( width: ysWidth(context)-hsp(40), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( children: [ Container( height: hsp(50), alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: hsp(15),right: hsp(15)), decoration: BoxDecoration( border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1))) ), child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ), Container( width: ysWidth(context)-hsp(40), padding: EdgeInsets.all(hsp(15)), constraints: BoxConstraints(minHeight: hsp(100)), child: YSInputView2(item: _contentMap), ) ], ), ), Container( margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)), padding: EdgeInsets.all(hsp(15)), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), margin: EdgeInsets.only(bottom: hsp(10)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: CupertinoTextField( placeholder: '请描述内容', style: TextStyle(fontSize: zsp(16),color: Colors.white), padding: const EdgeInsets.all(0), placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white), decoration: const BoxDecoration( color: Colors.transparent ), suffix: Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), maxLines: 100, onChanged: (value){ _value = value; }, ) ) ], ), ), ListView.separated( itemBuilder: (context,index){ Map item = _inputArray[index]; return Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: CupertinoTextField( placeholder: '请输入${item['title']}', style: TextStyle(fontSize: zsp(16),color: Colors.white), padding: const EdgeInsets.all(0), placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white), decoration: const BoxDecoration( color: Colors.transparent ), suffix: Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), inputFormatters: [FilteringTextInputFormatter.allow(RegExp("[0-9.]"))], keyboardType: const TextInputType.numberWithOptions(), maxLines: 100, onChanged: (value){ if(value.isEmpty){ item.remove('value'); }else{ item['value'] = value; } }, ) ) ], ), ); }, separatorBuilder: (context,index){ return Container(height: hsp(10),); }, itemCount: _inputArray.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(0), ), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ), YSUploadFileView2(fileArray: _fileArray), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('建议尺寸900*400,最多4张,单个图片不超过20M。',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ) ], ), ), ], ), ), ), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () async{ FocusScope.of(context).unfocus(); // LogUtil.d(_fileArray); if(_contentMap['value']==null){ ysFlutterToast('请填写采样描述'); return; } if(_value.isEmpty){ ysFlutterToast('请填写有机土壤碳信息'); return; } // for (var element in _inputArray) { // if(element['value']==null){ // ysFlutterToast('请完善${element['title']}'); // return; // } // } List images = []; List video = []; for (var element in _fileArray) { if('${element['url']}'.contains('.mp4')==true){ video.add(element['url']); }else{ images.add(element['url']); } } Map request = {}; request['id'] = widget.gatherId; request['describes'] = _contentMap['value']; request['recordList'] = _inputArray; request['imageList'] = images; if(video.isNotEmpty)request['video'] = video.first; request['value'] = _value; LogUtil.d(request); YSNetWork.ysRequestHttp(context, type: RequestType.post, api: '/samplingRecord/add', parameter: request, successSetter: (dict){ ysFlutterToast('采样点数据更新成功'); Navigator.of(context).pop(''); },isLoading: true); }, child: Image.asset('images/tzh_done.png',height: hsp(72),), ) ], ), ) ], ), ), ), ); } _getSamplingFieldIndex() async{ YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/index', parameter: {}, successSetter: (dict){ _inputArray.clear(); _inputArray.addAll(dict['data']??[]); setState(() {}); }); } } //TODO:YSHomeListDetailGather2 class YSHomeListDetailGather2 extends StatefulWidget { final int gatherId; const YSHomeListDetailGather2({Key? key, required this.gatherId}) : super(key: key); @override YSHomeListDetailGather2State createState() => YSHomeListDetailGather2State(); } class YSHomeListDetailGather2State extends State { bool _isHiden = false; final Map _contentMap = {'title':'采样描述'}; final List _inputArray = []; final List _fileArray = []; String _value = ''; @override void initState() { Future.delayed(const Duration(seconds: 0)).then((value) { _getSamplingFieldData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ysTitle: '采样', ysChild: GestureDetector( // onVerticalDragEnd: (value){ // if(value.primaryVelocity!>0){ // _isHiden = true; // }else if(value.primaryVelocity!<0){ // _isHiden = false; // } // setState(() {}); // }, child: SingleChildScrollView( padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)), child: Column( children: [ ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: Container( height: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(110):hsp(150), decoration: const BoxDecoration( color: Color(0xFF3E434E) ), child: const YSMapView(location: {'latitude': 57.24, 'longitude': 127.38},), ), ), GestureDetector( onTap: (){ _isHiden = !_isHiden; setState(() {}); }, child: Container( padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10)), child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),), ), ), _isHiden?Container( height: hsp(50), decoration: const BoxDecoration( image: DecorationImage(image: AssetImage('images/tzh_hiden.png') ) ), alignment: Alignment.center, padding: EdgeInsets.only(top: hsp(15)), child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ):SizedBox( height: ysHeight(context)-ysTOP(context)-44-hsp(205), child: SingleChildScrollView( child: Column( children: [ Container( width: ysWidth(context)-hsp(40), decoration: const BoxDecoration( color: Color(0xFF3E434E), ), child: Column( children: [ Container( height: hsp(50), alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: hsp(15),right: hsp(15)), decoration: BoxDecoration( border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1))) ), child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ), Container( width: ysWidth(context)-hsp(40), padding: EdgeInsets.all(hsp(15)), constraints: BoxConstraints(minHeight: hsp(100)), child: Text('${_contentMap['value']??''}',style: TextStyle(fontSize: zsp(14),color: ysValueColor),), ) ], ), ), Container( margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)), padding: EdgeInsets.all(hsp(15)), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), margin: EdgeInsets.only(bottom: hsp(10)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(_value,style: TextStyle(fontSize: zsp(16),color: Colors.white),), Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),) ], ) ) ], ), ), ListView.separated( itemBuilder: (context,index){ Map item = _inputArray[index]; return Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${item['total']??''}',style: TextStyle(fontSize: zsp(16),color: Colors.white),), Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),) ], ) ), ], ), ); }, separatorBuilder: (context,index){ return Container(height: hsp(10),); }, itemCount: _inputArray.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(0), ), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ), YSFileView(fileArray: _fileArray), ], ), ), ], ), ), ) ], ), ), ), ); } _getSamplingFieldData() async{ YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){ Map data = dict['data']??{}; _value = '${data['value']}'; _contentMap['value'] = '${data['describes']}'; _fileArray.add({'url':data['video'],'type':2}); List imageList = data['imageList']??[]; for (var element in imageList) { _fileArray.add({'url':element,'type':1}); } _inputArray.addAll(data['getDataVoList']??[]); setState(() {}); }); } } //TODO:YSHomeListDetailGather3 class YSHomeListDetailGather3 extends StatefulWidget { final int gatherId; const YSHomeListDetailGather3({Key? key, required this.gatherId}) : super(key: key); @override YSHomeListDetailGather3State createState() => YSHomeListDetailGather3State(); } class YSHomeListDetailGather3State extends State { bool _isHiden = true; final Map _contentMap = {'title':'采样描述'}; final List _inputArray = []; final List _fileArray = []; String _value = ''; Map _location = {}; @override void initState() { Future.delayed(const Duration(seconds: 0)).then((value) { _getSamplingFieldData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ysTitle: '采样', ysChild: SingleChildScrollView( padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)), child: Stack( children: [ ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: Container( height: ysHeight(context)-ysTOP(context)-44-hsp(110), decoration: const BoxDecoration( color: Color(0xFF3E434E) ), child: _location.isEmpty?Container():YSMapView(location: _location,), ), ), Container( margin: EdgeInsets.only(top: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(95):hsp(150),), child: Column( children: [ GestureDetector( onTap: (){ _isHiden = !_isHiden; setState(() {}); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.only(bottom: hsp(10)), width: ysWidth(context), child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),), ), ), if (_isHiden) Container( height: hsp(50), decoration: const BoxDecoration( image: DecorationImage(image: AssetImage('images/tzh_hiden.png') ) ), alignment: Alignment.center, padding: EdgeInsets.only(top: hsp(15)), child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ) else ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: Container( color: ysBgColor, height: ysHeight(context)-ysTOP(context)-44-hsp(215), child: SingleChildScrollView( child: Column( children: [ Container( width: ysWidth(context)-hsp(40), decoration: const BoxDecoration( color: Color(0xFF3E434E), ), child: Column( children: [ Container( height: hsp(50), alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: hsp(15),right: hsp(15)), decoration: BoxDecoration( border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1))) ), child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ), Container( width: ysWidth(context)-hsp(40), padding: EdgeInsets.all(hsp(15)), constraints: BoxConstraints(minHeight: hsp(100)), child: Text('${_contentMap['value']??''}',style: TextStyle(fontSize: zsp(14),color: ysValueColor),), ) ], ), ), Container( margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)), padding: EdgeInsets.all(hsp(15)), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), margin: EdgeInsets.only(bottom: hsp(10)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(_value,style: TextStyle(fontSize: zsp(16),color: Colors.white),), Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),) ], ) ) ], ), ), ListView.separated( itemBuilder: (context,index){ Map item = _inputArray[index]; return Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${item['total']??''}',style: TextStyle(fontSize: zsp(16),color: Colors.white),), Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),) ], ) ), ], ), ); }, separatorBuilder: (context,index){ return Container(height: hsp(10),); }, itemCount: _inputArray.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(0), ), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ), YSFileView(fileArray: _fileArray), ], ), ), ], ), ), ), ) ], ), ) ], ), ), ); } _getSamplingFieldData() async{ YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){ Map data = dict['data']??{}; _value = '${data['value']}'; _contentMap['value'] = '${data['describes']}'; if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2}); List imageList = data['imageList']??[]; for (var element in imageList) { _fileArray.add({'url':element,'type':1}); } _inputArray.addAll(data['getDataVoList']??[]); if(data['location']!=null){ _location = data['location']; _location['name'] = data['name']; _location['coordinates'] = data['geo']; } setState(() {}); }); } } //TODO:YSHomeListDetailGather4 class YSHomeListDetailGather4 extends StatefulWidget { final int gatherId; const YSHomeListDetailGather4({Key? key, required this.gatherId}) : super(key: key); @override YSHomeListDetailGather4State createState() => YSHomeListDetailGather4State(); } class YSHomeListDetailGather4State extends State { bool _isHiden = false; final Map _contentMap = {'title':'采样描述'}; final List _inputArray = []; final List _fileArray = []; Container _widget = Container(); Map _location = {}; final TextEditingController _valueController = TextEditingController(); @override void initState() { Future.delayed(const Duration(seconds: 0)).then((value) { _getSamplingFieldIndex(); }); super.initState(); } @override void dispose() { _valueController.dispose(); for (var element in _inputArray) { TextEditingController controller = element['controller']; controller.dispose(); } super.dispose(); } @override Widget build(BuildContext context) { // LogUtil.d(_inputArray); return YSBase( ysTitle: '采样', ysChild: SingleChildScrollView( padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)), child: Stack( children: [ ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: Container( height: ysHeight(context)-ysTOP(context)-44-hsp(110), decoration: const BoxDecoration( color: Color(0xFF3E434E) ), child: _location.isEmpty?Container():YSMapView(location: _location,), ), ), Container( margin: EdgeInsets.only(top: hsp(140)+(_isHiden?ysHeight(context)-ysTOP(context)-44-hsp(235):hsp(10))), child: Column( children: [ GestureDetector( onTap: (){ _isHiden = !_isHiden; setState(() {}); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.only(bottom: hsp(10)), width: ysWidth(context), child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),), ), ), if (_isHiden) Container( height: hsp(50), decoration: const BoxDecoration( image: DecorationImage(image: AssetImage('images/tzh_hiden.png') ) ), alignment: Alignment.center, padding: EdgeInsets.only(top: hsp(15)), child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ) else ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: SizedBox( height: ysHeight(context)-ysTOP(context)-44-hsp(205), child: Column( children: [ if (_widget.child==null) Container(height: ysHeight(context)-ysTOP(context)-44-hsp(277),) else _widget, GestureDetector( behavior: HitTestBehavior.opaque, onTap: () async{ FocusScope.of(context).unfocus(); LogUtil.d(_inputArray); if(_contentMap['value']==null){ ysFlutterToast('请填写采样描述'); return; } // if(_valueController.text.isEmpty){ // ysFlutterToast('请填写有机土壤碳信息'); // return; // } // for (var element in _inputArray) { // if(element['value']==null){ // ysFlutterToast('请完善${element['title']}'); // return; // } // } List images = []; List video = []; for (var element in _fileArray) { if('${element['url']}'.contains('.mp4')==true){ video.add(element['url']); }else{ images.add(element['url']); } } List inputArray = []; for (Map element in _inputArray) { Map input = {}; element.forEach((key, value) { if(key!='controller'){ input[key] = value; } }); inputArray.add(input); } Map request = {}; request['id'] = widget.gatherId; request['describes'] = _contentMap['value']; request['recordList'] = inputArray; if(images.isNotEmpty)request['imageList'] = images; if(video.isNotEmpty)request['video'] = video.first; if(_valueController.text.isNotEmpty)request['value'] = _valueController.text; LogUtil.d(request); // return; YSNetWork.ysRequestHttp(context, type: RequestType.post, api: '/samplingRecord/add', parameter: request, successSetter: (dict){ ysFlutterToast('新增采样成功'); Navigator.of(context).pop(''); },isLoading: true); }, child: Image.asset('images/tzh_done.png',height: hsp(72),), ) ], ), ), ) ], ), ) ], ), ), ); } _getSamplingFieldIndex() async{ YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/index', parameter: {}, successSetter: (dict){ _inputArray.clear(); _inputArray.addAll(dict['data']??[]); _getSamplingFieldData(); }); } _getSamplingFieldData() async{ YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){ Map data = dict['data']??{}; if(data['value']!=null)_valueController.text = '${data['value']}'; if(data['describes']!=null)_contentMap['value'] = '${data['describes']}'; if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2}); List imageList = data['imageList']??[]; for (var element in imageList) { _fileArray.add({'url':element,'type':1}); } List getDataVoList = data['getDataVoList']??[]; if(getDataVoList.isNotEmpty){ _inputArray.clear(); _inputArray.addAll(getDataVoList); } if(data['location']!=null){ _location = data['location']; _location['name'] = data['name']; _location['coordinates'] = data['geo']; } for (var element in _inputArray) { element['controller'] =TextEditingController(text: '${element['total']??''}'); } _widget = Container( color: ysBgColor, height: ysHeight(context)-ysTOP(context)-44-hsp(277), child: SingleChildScrollView( child: Column( children: [ Container( width: ysWidth(context)-hsp(40), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( children: [ Container( height: hsp(50), alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: hsp(15),right: hsp(15)), decoration: BoxDecoration( border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1))) ), child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ), Container( width: ysWidth(context)-hsp(40), padding: EdgeInsets.all(hsp(15)), constraints: BoxConstraints(minHeight: hsp(100)), child: YSInputView2(item: _contentMap), ) ], ), ), Container( margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)), padding: EdgeInsets.all(hsp(15)), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), margin: EdgeInsets.only(bottom: hsp(10)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: CupertinoTextField( placeholder: '请描述内容', style: TextStyle(fontSize: zsp(16),color: Colors.white), padding: const EdgeInsets.all(0), placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white), decoration: const BoxDecoration( color: Colors.transparent ), suffix: Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), maxLines: 100, controller: _valueController, inputFormatters: [NumberFormat()], keyboardType: const TextInputType.numberWithOptions(), ) ) ], ), ), ListView.separated( itemBuilder: (context,index){ Map item = _inputArray[index]; return Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: CupertinoTextField( placeholder: '请输入${item['title']}', style: TextStyle(fontSize: zsp(16),color: Colors.white), padding: const EdgeInsets.all(0), placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white), decoration: const BoxDecoration( color: Colors.transparent ), suffix: Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), inputFormatters: [NumberFormat()], keyboardType: const TextInputType.numberWithOptions(), maxLines: 100, onChanged: (value){ if(value.isEmpty){ item.remove('value'); }else{ item['value'] = value; } }, controller: item['controller'], ) ) ], ), ); }, separatorBuilder: (context,index){ return Container(height: hsp(10),); }, itemCount: _inputArray.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(0), ), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ), YSUploadFileView2(fileArray: _fileArray), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('建议尺寸900*400,最多4张,单个图片不超过20M。',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ) ], ), ), ], ), ), ); setState(() {}); }); } } //TODO:YSHomeListDetailGather5 class YSHomeListDetailGather5 extends StatefulWidget { final int gatherId; const YSHomeListDetailGather5({Key? key, required this.gatherId}) : super(key: key); @override YSHomeListDetailGather5State createState() => YSHomeListDetailGather5State(); } class YSHomeListDetailGather5State extends State { bool _isEdit = false; Map _location = {}; Map _data = {}; _getSamplingFieldData() async{ YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/data', parameter: {'pointId':widget.gatherId}, successSetter: (dict){ _data = dict['data']??{}; if(_data['location']!=null){ _location = _data['location']; _location['name'] = _data['name']; _location['coordinates'] = _data['geo']; } setState(() {}); }); } @override void initState() { networkDelay((){ _getSamplingFieldData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ysTitle: '采样', ysRightWidget: GestureDetector( onTap: (){ _isEdit = !_isEdit; setState(() {}); }, child: Text(_isEdit?'详情':'编辑',style: TextStyle(fontSize: zsp(16),color: Colors.white),), ), ysChild: SingleChildScrollView( padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)), child: Stack( children: [ ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: Container( height: ysHeight(context)-ysTOP(context)-44-hsp(110), decoration: const BoxDecoration( color: Color(0xFF3E434E) ), child: _location.isEmpty?Container():YSMapView(location: _location,), ), ), _data.isEmpty?Container():( _isEdit?YSHomeListDetailGatherEditView( gatherId: widget.gatherId,data: _data, ):YSHomeListDetailGatherDetailView( data: _data, ) ) ], ), ), ); } } //TODO:YSHomeListDetailGatherEditView class YSHomeListDetailGatherEditView extends StatefulWidget { final int gatherId; final Map data; const YSHomeListDetailGatherEditView({Key? key, required this.gatherId, required this.data}) : super(key: key); @override YSHomeListDetailGatherEditViewState createState() => YSHomeListDetailGatherEditViewState(); } class YSHomeListDetailGatherEditViewState extends State { bool _isHiden = false; final Map _contentMap = {'title':'采样描述'}; final List _inputArray = []; final List _fileArray = []; Container _widget = Container(); final TextEditingController _valueController = TextEditingController(); @override void initState() { Future.delayed(const Duration(seconds: 0)).then((value) { _getSamplingFieldIndex(); }); super.initState(); } @override void dispose() { _valueController.dispose(); for (var element in _inputArray) { TextEditingController controller = element['controller']; controller.dispose(); } super.dispose(); } @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(top: hsp(140)+(_isHiden?ysHeight(context)-ysTOP(context)-44-hsp(235):hsp(10))), child: Column( children: [ GestureDetector( onTap: (){ _isHiden = !_isHiden; setState(() {}); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.only(bottom: hsp(10)), width: ysWidth(context), child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),), ), ), if (_isHiden) Container( height: hsp(50), decoration: const BoxDecoration( image: DecorationImage(image: AssetImage('images/tzh_hiden.png') ) ), alignment: Alignment.center, padding: EdgeInsets.only(top: hsp(15)), child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ) else ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: SizedBox( height: ysHeight(context)-ysTOP(context)-44-hsp(205), child: Column( children: [ if (_widget.child==null) Container(height: ysHeight(context)-ysTOP(context)-44-hsp(277),) else _widget, GestureDetector( behavior: HitTestBehavior.opaque, onTap: () async{ FocusScope.of(context).unfocus(); LogUtil.d(_inputArray); // if(_contentMap['value']==null){ // ysFlutterToast('请填写采样描述'); // return; // } // if(_valueController.text.isEmpty){ // ysFlutterToast('请填写有机土壤碳信息'); // return; // } // for (var element in _inputArray) { // if(element['value']==null){ // ysFlutterToast('请完善${element['title']}'); // return; // } // } List images = []; List video = []; for (var element in _fileArray) { if('${element['url']}'.contains('.mp4')==true){ video.add(element['url']); }else{ images.add(element['url']); } } List inputArray = []; for (Map element in _inputArray) { Map input = {}; element.forEach((key, value) { if(key!='controller'){ input[key] = value; } }); if(element['value']==null){ input['value'] = '0'; } inputArray.add(input); } Map request = {}; request['id'] = widget.gatherId; // request['describes'] = _contentMap['value']; request['recordList'] = inputArray; if(images.isNotEmpty)request['imageList'] = images; if(video.isNotEmpty)request['video'] = video.first; if(_valueController.text.isNotEmpty)request['value'] = _valueController.text; // LogUtil.d(request); // return; YSNetWork.ysRequestHttp(context, type: RequestType.post, api: '/samplingRecord/add', parameter: request, successSetter: (dict){ ysFlutterToast('新增采样成功'); Navigator.of(context).pop(''); },isLoading: true); }, child: Image.asset('images/tzh_done.png',height: hsp(72),), ) ], ), ), ) ], ), ); } _getSamplingFieldIndex() async{ YSNetWork.ysRequestHttp(context, type: RequestType.get, api: '/samplingField/index', parameter: {}, successSetter: (dict){ _inputArray.clear(); _inputArray.addAll(dict['data']??[]); _getSamplingFieldData(); }); } _getSamplingFieldData() async{ Map data = widget.data; if(data['value']!=null)_valueController.text = '${data['value']}'; if(data['content']!=null)_contentMap['value'] = '${data['content']}'; _fileArray.clear(); if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2}); List imageList = data['imageList']??[]; for (var element in imageList) { _fileArray.add({'url':element,'type':1}); } List getDataVoList = data['getDataVoList']??[]; if(getDataVoList.isNotEmpty){ _inputArray.clear(); _inputArray.addAll(getDataVoList); } for (var element in _inputArray) { element['controller'] =TextEditingController(text: '${element['total']??''}'); } _widget = Container( color: ysBgColor, height: ysHeight(context)-ysTOP(context)-44-hsp(277), child: SingleChildScrollView( child: Column( children: [ Container( width: ysWidth(context)-hsp(40), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( children: [ Container( height: hsp(50), alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: hsp(15),right: hsp(15)), decoration: BoxDecoration( border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1))) ), child: Text('采样内容',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ), Container( width: ysWidth(context)-hsp(40), padding: EdgeInsets.all(hsp(15)), constraints: BoxConstraints(minHeight: hsp(100)), // child: Text(_contentMap['value'],style: TextStyle(fontSize: zsp(14),color: ysValueColor),), child: YSInputView2(item: _contentMap,isEnable: false,), ) ], ), ), Container( margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)), padding: EdgeInsets.all(hsp(15)), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), margin: EdgeInsets.only(bottom: hsp(10)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: CupertinoTextField( placeholder: '请描述内容', style: TextStyle(fontSize: zsp(16),color: Colors.white), padding: const EdgeInsets.all(0), placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white), decoration: const BoxDecoration( color: Colors.transparent ), suffix: Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), maxLines: 100, controller: _valueController, inputFormatters: [NumberFormat()], keyboardType: const TextInputType.numberWithOptions(), ) ) ], ), ), ListView.separated( itemBuilder: (context,index){ Map item = _inputArray[index]; return Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: CupertinoTextField( placeholder: '请输入${item['title']}', style: TextStyle(fontSize: zsp(16),color: Colors.white), padding: const EdgeInsets.all(0), placeholderStyle: TextStyle(fontSize: zsp(16),color: Colors.white), decoration: const BoxDecoration( color: Colors.transparent ), suffix: Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), inputFormatters: [NumberFormat()], keyboardType: const TextInputType.numberWithOptions(), maxLines: 100, onChanged: (value){ if(value.isEmpty){ item.remove('value'); }else{ item['value'] = value; } }, controller: item['controller'], ) ) ], ), ); }, separatorBuilder: (context,index){ return Container(height: hsp(10),); }, itemCount: _inputArray.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(0), ), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ), YSUploadFileView2(fileArray: _fileArray), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('建议尺寸900*400,最多4张,单个图片不超过20M。',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ) ], ), ), ], ), ), ); setState(() {}); } } ////TODO:YSHomeListDetailGatherDetailView class YSHomeListDetailGatherDetailView extends StatefulWidget { final Map data; const YSHomeListDetailGatherDetailView({Key? key, required this.data}) : super(key: key); @override YSHomeListDetailGatherDetailViewState createState() => YSHomeListDetailGatherDetailViewState(); } class YSHomeListDetailGatherDetailViewState extends State { bool _isHiden = true; final Map _contentMap = {'title':'采样描述'}; final List _inputArray = []; final List _fileArray = []; String _value = ''; Map _location = {}; @override void initState() { Future.delayed(const Duration(seconds: 0)).then((value) { _getSamplingFieldData(); }); super.initState(); } @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(top: _isHiden?ysHeight(context)-ysTOP(context)-44-hsp(95):hsp(150),), child: Column( children: [ GestureDetector( onTap: (){ _isHiden = !_isHiden; setState(() {}); }, behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.only(bottom: hsp(10)), width: ysWidth(context), child: Image.asset('images/tzh_${_isHiden?'up':'down1'}.png',height: hsp(15),width: hsp(15),), ), ), if (_isHiden) Container( // margin: EdgeInsets.only(top: ysHeight(context)-ysTOP(context)-44-hsp(250)), height: hsp(50), decoration: const BoxDecoration( image: DecorationImage(image: AssetImage('images/tzh_hiden.png') ) ), alignment: Alignment.center, padding: EdgeInsets.only(top: hsp(15)), child: Text('采样说明',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ) else ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(24)), child: Container( color: ysBgColor, height: ysHeight(context)-ysTOP(context)-44-hsp(215), child: SingleChildScrollView( child: Column( children: [ Container( width: ysWidth(context)-hsp(40), decoration: const BoxDecoration( color: Color(0xFF3E434E), ), child: Column( children: [ Container( height: hsp(50), alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: hsp(15),right: hsp(15)), decoration: BoxDecoration( border: Border(bottom: BorderSide(color: const Color(0x99535966),width: hsp(1))) ), child: Text('采样描述',style: TextStyle(fontSize: zsp(14),color: const Color(0xFFDBE1EA)),), ), Container( width: ysWidth(context)-hsp(40), padding: EdgeInsets.all(hsp(15)), constraints: BoxConstraints(minHeight: hsp(100)), child: Text('${_contentMap['value']??''}',style: TextStyle(fontSize: zsp(14),color: ysValueColor),), ) ], ), ), Container( margin: EdgeInsets.only(top: hsp(15),bottom: hsp(15)), padding: EdgeInsets.all(hsp(15)), decoration: const BoxDecoration( color: Color(0xFF3E434E), borderRadius: BorderRadius.all(Radius.circular(24)) ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), margin: EdgeInsets.only(bottom: hsp(10)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('有机土壤碳',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(_value,style: TextStyle(fontSize: zsp(16),color: Colors.white),), Text('kg',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),) ], ) ) ], ), ), ListView.separated( itemBuilder: (context,index){ Map item = _inputArray[index]; return Container( decoration: BoxDecoration( color: const Color(0xFF1A1C1F), borderRadius: const BorderRadius.all(Radius.circular(3)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), padding: EdgeInsets.only(left: hsp(12),right: hsp(12),top: hsp(5),bottom: hsp(5)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('${item['title']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), SizedBox( height: hsp(20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${item['total']??''}',style: TextStyle(fontSize: zsp(16),color: Colors.white),), Text('${item['unit']}',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),) ], ) ), ], ), ); }, separatorBuilder: (context,index){ return Container(height: hsp(10),); }, itemCount: _inputArray.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(0), ), Container( alignment: Alignment.centerLeft, height: hsp(30), child: Text('附件',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ), YSFileView(fileArray: _fileArray), ], ), ), ], ), ), ), ) ], ), ); } _getSamplingFieldData() async{ Map data = widget.data; _value = '${data['value']??''}'; _contentMap['value'] = '${data['content']}'; _fileArray.clear(); if(data['video']!=null)_fileArray.add({'url':data['video'],'type':2}); List imageList = data['imageList']??[]; for (var element in imageList) { _fileArray.add({'url':element,'type':1}); } _inputArray.addAll(data['getDataVoList']??[]); if(data['location']!=null){ _location = data['location']; _location['name'] = data['name']; } setState(() {}); } }