import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:liftmanager/common/common.dart';
import 'package:liftmanager/internal/account/account_router.dart';
import 'package:liftmanager/internal/account/model/user_info_entity.dart';
import 'package:liftmanager/internal/account/provider/user_provider.dart';
import 'package:liftmanager/internal/wode/wode_router.dart';
import 'package:liftmanager/net/api_service.dart';
import 'package:liftmanager/routers/fluro_navigator.dart';
import 'package:liftmanager/utils/image_utils.dart';
import 'package:liftmanager/widgets/app_bar.dart';
import 'package:liftmanager/widgets/click_item.dart';
import 'package:liftmanager/widgets/load_image.dart';
import 'package:liftmanager/widgets/my_button.dart';
import 'package:provider/provider.dart';
import 'package:liftmanager/widgets/bbs_content.dart';
import 'package:liftmanager/internal/bbs/bbs_router.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:liftmanager/widgets/star_item.dart';
import 'package:liftmanager/res/resources.dart';

class CommentMaster extends StatefulWidget {
  // Comment(this.type);

  // final String type;
  @override
  State<StatefulWidget> createState() {
    return CommentMasterState();
  }
}

class CommentMasterState extends State<CommentMaster> with AutomaticKeepAliveClientMixin {
  UserProvider provider = UserProvider();
  Map<String,String>obj={
      "pic":"temporary/avator2",
      "name":"张涛",
      "serviceType":"出诊服务",
      "time":"01月05日",
      "brand":"奥的斯",
      "desc":"电梯故障紧急维修、电梯保养、电梯短路处理、电梯闸门故障维修",
      "price":"20",
      "num":"299",
      "point":"5.0",
      "id":"2",
      "type":"2"
    };
    double serviceLevel = 0;
  double serviceTaidu = 0;
  double speed = 0;
  TextEditingController _controller = TextEditingController();
  @override
  void initState() {
    // TODO: implement initState
    
    
    super.initState();
  }

  @override
  void dispose() {
    // provider.dispose();
    super.dispose();
  }
  
  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    return 
    // Center(child:new Text("个人中心"));
    ChangeNotifierProvider<UserProvider>(
        create: (_) => provider,
        child:
            Scaffold(
              appBar: MyAppBar(
                centerTitle: "评价本次服务",
              ),

                body: Consumer<UserProvider>(builder: (_, provider, __) {
          return Stack(
            children:<Widget>[
              ListView(padding: EdgeInsets.all(0.0), children: <Widget>[
            
            UserDetail(obj: obj,),
            Container(
              color: Color(0xffFAF7FA),
              height: ScreenUtil().setWidth(5),
            ),
            Container(
              padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(15)),
              child: Text(
                                    '您对专家的服务满意吗?',
                                    style: TextStyle(
                                      color:Color(0xff333333),
                                      fontSize:ScreenUtil().setSp(16)
                                    ),
                                    textAlign:TextAlign.start,
                                  ),
            ),
            Container(
              child:Column(
                children:<Widget>[
                  StarItem(
                    title: "技术水平:",
                    starRating: serviceLevel,
                    onRatingChanged: (res){
                      serviceLevel = res;
                      setState(() {

                      });
                    },
                  ),
                  StarItem(
                    title: "服务态度:",
                    starRating: serviceTaidu,
                    onRatingChanged: (res){
                      serviceTaidu = res;
                      setState(() {

                      });
                    },
                  ),
                  StarItem(
                    title: "响应速度:",
                    starRating: speed,
                    onRatingChanged: (res){
                      speed = res;
                      setState(() {

                      });
                    },
                  ),
                  SizedBox(
                    height: 8,
                  ),
                  Container(
                    
                    decoration: BoxDecoration(
                      border: Border.all(
                        width:0.5,
                        color:Color(0xffcccccc)
                      ),
                      color: Colors.white,
                    ),
                    margin: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15)),
                    child: Padding(
                      padding: const EdgeInsets.only(
                          top: 5, left: 15.0, right: 15.0, bottom: 8.0),
                      child: TextField(
                          // maxLength: 100,
                          maxLines: 5,
                          autofocus: false,
                          controller: _controller,
//                    keyboardType: widget.keyboardType,
                          //style: TextStyles.textDark14,
                          decoration: InputDecoration(
                              hintText: "您的满意是对专家最大的支持和鼓励",
                              border: InputBorder.none,
                              hintStyle: TextStyles.textGray14)),
                    ),
                  ),
                ]
              )
            )

         
           
          ]),
          Positioned(
              bottom:0,
              left:0,
              child:Row(
                children:<Widget>[
                  Container(
                  height:ScreenUtil().setWidth(44),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(ScreenUtil().setWidth(22)),
                      gradient: const LinearGradient(
                                        colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
                    ),
                    margin: EdgeInsets.all(ScreenUtil().setWidth(20)),
                    width: width*0.9,
                    child: FlatButton(
                      // padding: EdgeInsets.all(15.0),
                      child: Text("提交"),
                      // color: Theme
                      //     .of(context)
                      //     .primaryColor,
                      textColor: Colors.white,
                      onPressed: () {
                        NavigatorUtils.push(context,WodeRouter.orderPage);
                      },
                    ),
              )
                ]
              )
            )
            ]
          );
        })));
  }
  @override
  bool get wantKeepAlive => true;

}

class UserDetail extends StatelessWidget {
  UserDetail({Key key,this.obj}) : super(key: key);
  Map<String,String>obj;

  @override
  Widget build(BuildContext context) {
    return Container(
      // height: 20,
      padding:EdgeInsets.only(bottom:ScreenUtil().setWidth(20),top:ScreenUtil().setWidth(10)),
      child:  Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Expanded(
              child: GestureDetector(
                onTap: (){
                  NavigatorUtils.push(context, WodeRouter.orderDetail);
                },
                child:Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children:<Widget>[
                  Container(
                    margin: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(10),top:ScreenUtil().setWidth(5)),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(ScreenUtil().setWidth(25)),
                    ),
                    child: LoadAssetImage(
                      // image: AssetImage(i['img']),
                      obj["pic"],
                      width: ScreenUtil().setWidth(43),
                      height:ScreenUtil().setWidth(43),
                      // alignment: Alignment.centerLeft,
                    ),
                  ),
                  Expanded(
                    child: Container(
                      padding: EdgeInsets.only(right:ScreenUtil().setWidth(15)),
                      child:Column(
                      children: <Widget>[
                        Container(
                          child:Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children:<Widget>[
                              Row(
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children:<Widget>[
                                  Text(
                                    obj["name"],
                                    style: TextStyle(
                                      color:Color(0xff333333),
                                      fontSize:ScreenUtil().setSp(18)
                                    ),
                                    textAlign:TextAlign.start,
                                  ),
                                  Container(
                                    padding: EdgeInsets.only(left:5),
                                    child:Text(
                                      obj["brand"],
                                      style: TextStyle(
                                        color:Color(0xff666666),
                                        fontSize:ScreenUtil().setSp(14)
                                      ),
                                      textAlign:TextAlign.start,
                                    ),
                                  )
                                ]
                              ),
                            ]
                          )
                        ),
                        Align(
                                child:Text(
                                    obj["desc"],
                                    style: TextStyle(
                                      color:Color(0xff999999),
                                      fontSize:ScreenUtil().setSp(14)
                                    ),
                                    textAlign:TextAlign.start,
                                  ),
                        ),
                      ],
                    )
                    )
                  )
                ]
              ),
              )
            ),
            
          ],
        ),
    );
  }
}

