import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class TypeHeader extends StatefulWidget {
  TypeHeader({Key? key, required this.type}) : super(key: key);

  final bool type;

  @override
  State<TypeHeader> createState() => _TypeHeaderState();
}

class _TypeHeaderState extends State<TypeHeader> {
  @override
  Widget build(BuildContext context) {
    if (widget.type) {
      return GestureDetector(
        onTap: () {
          Get.toNamed("/citySelect");
        },
          child: Container(
            height: 32.w,
            decoration: BoxDecoration(color: Colors.white),
            child: Row(
              children: [
                Image(
                  image: AssetImage('images/gpsImgae.png'),
                  fit: BoxFit.cover,
                  width: 14.w,
                  height: 17.h,
                ),
                Padding(
                  padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
                  child: Text(
                    '邓州市',
                    style: TextStyle(
                      color: Color(0xff202020),
                      fontSize: 16.sp,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                Container(
                  padding: EdgeInsets.fromLTRB(0, 0, 10, 0),
                  child: Icon(Icons.arrow_drop_down),
                ),
                Expanded(
                  flex: 1,
                  child:_initWidget(),
                ),
              ],
            ),
          )
      );
    } else {
      return _initWidget();
    }
  }
}
//

class _initWidget extends StatelessWidget {
  const _initWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
        height: 32.w,
        decoration: const BoxDecoration(color: Colors.white),
        child: GestureDetector(
            onTap: () {
              print('点击了搜索');
              Get.toNamed('/searchPage');
            },
            child: Container(
              decoration: const BoxDecoration(
                // color: Colors.red,
                color: Color(0x30cccccc),
                borderRadius: BorderRadius.all(Radius.circular(25)),
              ),
              child: Row(
                children: [
                  Padding(
                    padding: EdgeInsets.fromLTRB(10.w, 0, 5, 0),
                    child: Icon(
                      Icons.search,
                      size: 19,
                      color: Color(0xff666666),
                    ),
                  ),
                  Text(
                    '请输入关键字查询',
                    style: TextStyle(color: Color(0xff666666), fontSize: 14),
                  )
                ],
              ),
            )
            // Search(),
            ));
  }
}