| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'util/models.dart';
- // ignore: must_be_immutable
- class ShowLineModal extends Dialog {
- List<CompanyOfLineList> lineList = [];
- final childCallback;
- ShowLineModal(
- {Key key, @required this.lineList, @required this.childCallback})
- : super(key: key);
- String lineId = '-1';
- @override
- Widget build(BuildContext context) {
- return new Material(
- //创建透明层
- type: MaterialType.transparency, //透明类型
- child: new Center(
- //保证控件居中效果
- child: Container(
- width: ScreenUtil.getInstance().setWidth(600),
- height: ScreenUtil.getInstance().setHeight(345),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(8))),
- child: new Container(
- child: new Column(
- children: <Widget>[
- Container(
- height: ScreenUtil.getInstance().setHeight(255),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 1,
- color: Color.fromRGBO(151, 151, 151, 0.27)))),
- child: LineWidget(
- lineList: lineList,
- callback: (val) {
- lineId = val.toString();
- },
- )),
- Expanded(
- flex: 1,
- child: Container(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Expanded(
- flex: 1,
- child: InkWell(
- child: Container(
- decoration: BoxDecoration(
- border: Border(
- right: BorderSide(
- width: 1,
- color: Color.fromRGBO(
- 151, 151, 151, 0.27))),
- ),
- child: Center(
- child: Text(
- '取消',
- style: TextStyle(
- fontSize: ScreenUtil.getInstance()
- .setSp(32),
- color:
- Color.fromRGBO(64, 98, 254, 1)),
- ),
- )),
- onTap: () {
- Navigator.pop(context);
- },
- )),
- Expanded(
- flex: 1,
- child: InkWell(
- child: Container(
- decoration: BoxDecoration(
- border: Border(
- right: BorderSide(
- width: 1,
- color: Color.fromRGBO(
- 151, 151, 151, 0.27))),
- ),
- child: Center(
- child: Text(
- '确定',
- style: TextStyle(
- fontSize: ScreenUtil.getInstance()
- .setSp(32),
- color:
- Color.fromRGBO(64, 98, 254, 1)),
- ),
- )),
- onTap: () {
- Navigator.pop(context);
- childCallback(lineId);
- },
- )),
- ],
- ),
- ))
- ],
- ),
- ),
- ),
- ),
- );
- }
- }
- class LineWidget extends StatefulWidget {
- final List<CompanyOfLineList> lineList;
- final callback;
- LineWidget({Key key, this.lineList, this.callback}) : super(key: key);
- _LineWidgetState createState() => _LineWidgetState();
- }
- class _LineWidgetState extends State<LineWidget> {
- @override
- Widget build(BuildContext context) {
- return Column(
- children: <Widget>[
- Container(
- height: ScreenUtil.getInstance().setHeight(60),
- child:Center(
- child: Text('请选择线路'),
- ),
- ),
-
- Expanded(
- flex: 1,
- child: ListView.builder(
- itemCount: widget.lineList.length,
- itemBuilder: (BuildContext context, int index) {
- return InkWell(
- child: Container(
- height: ScreenUtil.getInstance().setHeight(100),
- padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- widget.lineList[index].lineName,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(35)),
- ),
- Icon(Icons.check,color: widget.lineList[index].checkedStatus?Colors.black:Colors.white,)
- ],
- ),
- ),
- onTap: (){
- setState(() {
- for(int i=0;i<widget.lineList.length;i++){
- if(i==index){
- widget.lineList[i].checkedStatus = true;
- widget.callback(widget.lineList[i].lineId);
- }else{
- widget.lineList[i].checkedStatus = false;
- }
- }
- });
- },
- );
- },
- ),
- )
- ],
- );
- }
- }
|