import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ysairplane/base/YSBase.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; class YSFeedback extends StatefulWidget { @override _YSFeedbackState createState() => _YSFeedbackState(); } class _YSFeedbackState extends State { List _types = []; Map _type; TextEditingController _content = TextEditingController(); @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getTypeData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '意见反馈', yschild: Column( children: [ Divider(height: 5,thickness: 5,color: Color(0xFFF5F6F8),), Container( height: 50, padding: EdgeInsets.only(left: 15,right: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('意见反馈类型',style: TextStyle(fontSize: 16,color: Color(0xFF000000)),), if(_types.length>0)DropdownButton( value: _type, items: [ for(int i=0;i<_types.length;i++)DropdownMenuItem(child: Text('${_types[i]['name']}'),value: _types[i],), ], onChanged: (value){ setState(() { _type = value; }); }, underline: Container(), icon: Icon(Icons.keyboard_arrow_down,size: 20,color: Color(0xFF999999),), style: TextStyle(fontSize: 15,color: Color(0xFF999999)), ) ], ), ), Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF5F6F8),), Container( margin: EdgeInsets.only(top: 15,bottom: 15), width: MediaQuery.of(context).size.width-30, child: Text('留言内容',style: TextStyle(fontSize: 14,color: Color(0xFF999999)),), ), Container( width: MediaQuery.of(context).size.width-30, padding: EdgeInsets.all(5), height: 200, color: Color(0xFFF5F5F7), child: CupertinoTextField( style: TextStyle(fontSize: 14,color: Color(0xFF000000)), decoration: BoxDecoration(), controller: _content, maxLines: 100, placeholder: '请输入反馈内容', ), ), GestureDetector( onTap: (){ _postFeedbackData(); }, child: Container( width: MediaQuery.of(context).size.width-30, margin: EdgeInsets.only(top: 40), height: 40, alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFF0079FF), borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Text('提交',style: TextStyle(fontSize: 17,color: Colors.white,fontWeight: FontWeight.bold),), ), ) ], ), ); } _getTypeData() async{ FocusScope.of(context).unfocus(); Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/feedback/type',parameter: {}, isLoading: false,isToken: true,refresh: (){_getTypeData();}); if(dict!=null){ setState(() { _types = dict['data']; _type = _types[0]; }); } } _postFeedbackData() async{ FocusScope.of(context).unfocus(); if(_content.text.isEmpty){ ysFlutterToast(context, '请输入反馈内容'); return; } Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/feedback/submit',parameter: {'categoryId':_type['id'],'content':_content.text}, isLoading: false,isToken: true,refresh: (){_getTypeData();}); if(dict!=null){ Navigator.pop(context); } } }