123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- import 'package:audioplayers/audioplayers.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
- import 'base/YSBase.dart';
- class YSQuestionDetail extends StatefulWidget {
- final bool isPolicy;
- final int questionId;
- const YSQuestionDetail({Key key, this.questionId,this.isPolicy}) : super(key: key);
- @override
- _YSQuestionDetailState createState() => _YSQuestionDetailState();
- }
- class _YSQuestionDetailState extends State<YSQuestionDetail> {
- Map _infoData;
- AudioPlayer audioPlayer = AudioPlayer();
- @override
- void initState() {
- Future.delayed(Duration(seconds: 0)).then((value){
- widget.isPolicy==false?_getQuestionDetailData():_getPolicyDetailData();
- });
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return YSBase(
- ystitle: '问题详情',
- yschild: Container(
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20))
- ),
- child: _infoData==null?Container():SingleChildScrollView(
- padding: EdgeInsets.only(left: 15,right: 15,top: 20,bottom: 15),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- margin: EdgeInsets.only(bottom: 15),
- child: Row(
- children: [
- Container(
- height: 35,
- width: 35,
- decoration: BoxDecoration(
- color: Color(0xFFF5F3F0),
- borderRadius: BorderRadius.all(Radius.circular(17.5)),
- image: DecorationImage(image: NetworkImage('${_infoData['doctor_avatar']}'),fit: BoxFit.fill)
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 10),
- width: MediaQuery.of(context).size.width-85,
- child: Text('${_infoData['doctor_name']}医生 解答了该问题',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),overflow: TextOverflow.ellipsis,),
- )
- ],
- ),
- ),
- Container(
- child: Text('标题:${_infoData['question_title']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929))),
- ),
- Container(
- margin: EdgeInsets.only(bottom: 15,top: 15),
- child: Text('问:${_infoData['question_body']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),),
- ),
- Container(
- width: MediaQuery.of(context).size.width-40,
- child: _infoData['answer_type']=='voice'?Row(
- children: [
- Text('医生解答:',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
- Container(
- height: 26,
- width: 59,
- decoration: BoxDecoration(
- color: Color(0xFFF5F3F0),
- borderRadius: BorderRadius.all(Radius.circular(4))
- ),
- alignment: Alignment.center,
- child: Stack(
- children: [
- Row(
- children: [
- Container(
- child: Image.asset('lib/images/voice2.png'),
- height: 15,
- width: 15,
- margin: EdgeInsets.only(left: 10,right: 5),
- ),
- Text('4',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
- ],
- )
- ],
- ),
- )
- ],
- ):Text('医生解答:${(_infoData['answer_body'])??''}',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),),
- ),
- Container(
- margin: EdgeInsets.only(top: 15),
- child: Text('${_infoData['question_time']??_infoData['created_at']}',style: TextStyle(fontSize: 12,color: Color(0xFF808080))),
- )
- ],
- ),
- ),
- ),
- );
- }
- _getQuestionDetailData() async{
- Map dict = await ysRequestHttp(context, requestType.post, 'question/info', {'question_id':widget.questionId});
- if(dict!=null){
- setState(() {
- _infoData = dict['data'];
- });
- }
- }
- _getPolicyDetailData() async{
- Map dict = await ysRequestHttp(context, requestType.get, 'policy/info', {'id':widget.questionId});
- if(dict!=null){
- setState(() {
- _infoData = dict['data'];
- });
- }
- }
- play() async {
- audioPlayer.play(UrlSource(''));
- // if (result == 1) {
- // // success
- // print('play success');
- // } else {
- // print('play failed');
- // }
- }
- }
|