import 'package:flutter/material.dart';
import 'package:liftmanager/internal/search/search_router.dart';
import 'package:liftmanager/widgets/app_search_bar.dart';
import 'package:liftmanager/res/resources.dart';
import 'package:liftmanager/routers/fluro_navigator.dart';
import 'package:liftmanager/widgets/load_image.dart';
import 'package:liftmanager/internal/bbs/bbs_router.dart';

class MeansList extends StatefulWidget {
  // QuestionList(this.index);

  // final String index;
  

  @override
  State<StatefulWidget> createState() {
    return MeansListState();
  }
}

class MeansListState extends State<MeansList> {
  // NewsDetailItem item = NewsDetailItem();
  
  ScrollController _scrollController = new ScrollController();

  @override
  void dispose() {
    _scrollController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

    double width = MediaQuery.of(context).size.width;

    return Scaffold(
      appBar: SearchAppBar(
        onPressed: () {
          NavigatorUtils.push(context, SearchRouter.searchPage);
        }
      ),
      body:Container(
              child:ListView(
                children: <Widget>[
                  Container(
                    child:HotProduct()
                  )
                ]
              ),
            ),
    );
  }
}

class HotProduct extends StatelessWidget {
  // const HotProduct({Key key}) : super(key: key);

  static const productList = [
    {
      "brand":"三菱电梯",
      "title":"别墅电梯控制器",
      "pic":"temporary/product1",
      "name":"上海三菱电梯",
      "phone":"027-88888888",
    },
    {
      "brand":"奥的斯",
      "title":"家用电梯报警盒",
      "pic":"temporary/product2",
      "name":"奥的斯中国供应",
      "phone":"027-88888888",
    },
    {
      "brand":"三菱电梯",
      "title":"别墅电梯控制器",
      "pic":"temporary/product1",
      "name":"上海三菱电梯",
      "phone":"027-88888888",
    },
    {
      "brand":"奥的斯",
      "title":"家用电梯报警盒",
      "pic":"temporary/product2",
      "name":"奥的斯中国供应",
      "phone":"027-88888888",
    },
    {
      "brand":"三菱电梯",
      "title":"别墅电梯控制器",
      "pic":"temporary/product1",
      "name":"上海三菱电梯",
      "phone":"027-88888888",
    },
    {
      "brand":"奥的斯",
      "title":"家用电梯报警盒",
      "pic":"temporary/product2",
      "name":"奥的斯中国供应",
      "phone":"027-88888888",
    },
    {
      "brand":"三菱电梯",
      "title":"别墅电梯控制器",
      "pic":"temporary/product1",
      "name":"上海三菱电梯",
      "phone":"027-88888888",
    },
    {
      "brand":"奥的斯",
      "title":"家用电梯报警盒",
      "pic":"temporary/product2",
      "name":"奥的斯中国供应",
      "phone":"027-88888888",
    },
    {
      "brand":"三菱电梯",
      "title":"别墅电梯控制器",
      "pic":"temporary/product1",
      "name":"上海三菱电梯",
      "phone":"027-88888888",
    },
    {
      "brand":"奥的斯",
      "title":"家用电梯报警盒",
      "pic":"temporary/product2",
      "name":"奥的斯中国供应",
      "phone":"027-88888888",
    },
  ];

  List<Widget> listWidget(context) => productList.map((i){
    return InkWell(
      child:Container(
              padding: EdgeInsets.only(left:15,right:15,top:10,bottom:10),
              decoration: BoxDecoration(
                border: Border(
                  bottom: BorderSide(width: 0.5, color: Colours.line),
                ),
              ),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children:<Widget>[
                  ClipRRect(
                    borderRadius: BorderRadius.circular(5),
                    child: Container(
                    padding: EdgeInsets.only(right:10),
                        child: LoadAssetImage(
                          i["pic"],
                          // fit: BoxFit.cover,
                          width: 100,
                          height: 100,
                        ),
                  ),
                  ),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        i["title"],
                        textAlign: TextAlign.left,
                        style: TextStyle(
                          fontSize:16,
                          color:Color(0xff333333),
                        ),
                      ),
                      Text(
                        i["brand"],
                        textAlign: TextAlign.left,
                        style: TextStyle(
                          fontSize:15,
                          color:Color(0xff999999),
                        ),
                      ),
                      Text(
                        "供应商：${i["name"]}",
                        textAlign: TextAlign.left,
                        style: TextStyle(
                          fontSize:15,
                          color:Color(0xff999999),
                        ),
                      ),
                      Text(
                        "Tel：${i["phone"]}",
                        textAlign: TextAlign.left,
                        style: TextStyle(
                          fontSize:15,
                          color:Color(0xff999999),
                        ),
                      ),
                    ],
                  ),
                ]
              ),
            ),
      onTap: (){
        print(i);
        NavigatorUtils.push(context, BbsRouter.productDetail);
      },  
    );
  }).toList();

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        children:listWidget(context)
      ),
    );
  }
}

