diff --git a/README.md b/README.md index cbc20081..aa4f7f4f 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,9 @@ samples, guidance on mobile development, and a full API reference. 小米开放平台 83364300@qq.com 具体问 :(汪姐) 推送:使用腾讯云推送 tpns 需扫码登录 (有问题同华为➕微信||或重新注册账号替换相关appKey) + + 友盟: wu_rong 密码:Zxc09876 + https://pos.platform.lotus-wallet.com/app/ 生产环境 http://192.168.10.236:8765/app/ 测试环境 diff --git a/assets/image/2x/icon_search.webp b/assets/image/2x/icon_search.webp new file mode 100644 index 00000000..7aa75c66 Binary files /dev/null and b/assets/image/2x/icon_search.webp differ diff --git a/assets/image/3x/icon_search.webp b/assets/image/3x/icon_search.webp new file mode 100644 index 00000000..d3f8316e Binary files /dev/null and b/assets/image/3x/icon_search.webp differ diff --git a/assets/image/icon_search.webp b/assets/image/icon_search.webp new file mode 100644 index 00000000..d785e21d Binary files /dev/null and b/assets/image/icon_search.webp differ diff --git a/assets/map_style/chinese_cities.json b/assets/map_style/chinese_cities.json new file mode 100644 index 00000000..0b6d32b6 --- /dev/null +++ b/assets/map_style/chinese_cities.json @@ -0,0 +1,476 @@ +{ + "热门城市": [ + {"area": "上海"}, + {"area": "深圳"}, + {"area": "北京"}, + {"area": "广州"}, + {"area": "成都"}, + {"area": "杭州"}, + {"area": "南京"}, + {"area": "重庆"} + ], + "A": [ + { "area": "阿坝" }, + { "area": "阿克苏" }, + { "area": "阿拉善" }, + { "area": "阿勒泰" }, + { "area": "阿里" }, + { "area": "安庆" }, + { "area": "鞍山" }, + { "area": "安顺" }, + { "area": "安阳" }, + { "area": "澳门" } + ], + "B": [ + { "area": "北京" }, + { "area": "白银" }, + { "area": "保定" }, + { "area": "宝鸡" }, + { "area": "保山" }, + { "area": "包头" }, + { "area": "巴彦淖尔" }, + { "area": "巴音郭楞" }, + { "area": "巴中" }, + { "area": "北海" }, + { "area": "蚌埠" }, + { "area": "本溪" }, + { "area": "毕节" }, + { "area": "滨州" }, + { "area": "百色" } + ], + "C": [ + { "area": "重庆" }, + { "area": "成都" }, + { "area": "长春" }, + { "area": "常德" }, + { "area": "昌都" }, + { "area": "长沙" }, + { "area": "长治" }, + { "area": "常州" }, + { "area": "巢湖" }, + { "area": "朝阳" }, + { "area": "潮州" }, + { "area": "承德" }, + { "area": "郴州" }, + { "area": "赤峰" }, + { "area": "池州" }, + { "area": "崇左" }, + { "area": "楚雄" }, + { "area": "滁州" } + ], + "D": [ + { "area": "大理" }, + { "area": "大连" }, + { "area": "丹东" }, + { "area": "大庆" }, + { "area": "大同" }, + { "area": "大兴安岭" }, + { "area": "达州" }, + { "area": "德宏" }, + { "area": "德阳" }, + { "area": "德州" }, + { "area": "迪庆" }, + { "area": "定西" }, + { "area": "东莞" }, + { "area": "东营" } + ], + "E": [ + { "area": "鄂尔多斯" }, + { "area": "恩施" }, + { "area": "鄂州" } + ], + "F": [ + { "area": "防城港" }, + { "area": "佛山" }, + { "area": "抚顺" }, + { "area": "阜新" }, + { "area": "阜阳" }, + { "area": "福州" }, + { "area": "抚州" } + ], + "G": [ + { "area": "广元" }, + { "area": "广安" }, + { "area": "广州" }, + { "area": "贵港" }, + { "area": "桂林" }, + { "area": "贵阳" }, + { "area": "甘南" }, + { "area": "甘孜" }, + { "area": "赣州" }, + { "area": "固原" }, + { "area": "果洛" } + ], + "H": [ + { "area": "哈尔滨" }, + { "area": "海口" }, + { "area": "海北" }, + { "area": "海东" }, + { "area": "海南" }, + { "area": "海西" }, + { "area": "邯郸" }, + { "area": "杭州" }, + { "area": "汉中" }, + { "area": "鹤壁" }, + { "area": "河池" }, + { "area": "合肥" }, + { "area": "鹤岗" }, + { "area": "黑河" }, + { "area": "衡水" }, + { "area": "衡阳" }, + { "area": "河源" }, + { "area": "菏泽" }, + { "area": "贺州" }, + { "area": "红河" }, + { "area": "淮安" }, + { "area": "淮北" }, + { "area": "怀化" }, + { "area": "淮南" }, + { "area": "黄冈" }, + { "area": "黄南" }, + { "area": "黄山" }, + { "area": "黄石" }, + { "area": "呼和浩特" }, + { "area": "葫芦岛" }, + { "area": "呼伦贝尔" }, + { "area": "湖州" }, + { "area": "惠州" }, + { "area": "蚌埠" } + ], + "J": [ + { "area": "佳木斯" }, + { "area": "吉安" }, + { "area": "江门" }, + { "area": "焦作" }, + { "area": "嘉兴" }, + { "area": "嘉峪关" }, + { "area": "揭阳" }, + { "area": "吉林" }, + { "area": "济南" }, + { "area": "金昌" }, + { "area": "晋城" }, + { "area": "景德镇" }, + { "area": "荆门" }, + { "area": "荆州" }, + { "area": "金华" }, + { "area": "济宁" }, + { "area": "晋中" }, + { "area": "锦州" }, + { "area": "九江" }, + { "area": "酒泉" } + ], + "K": [ + { "area": "昆明" }, + { "area": "开封" }, + { "area": "喀什" }, + { "area": "克拉玛依" }, + { "area": "克孜勒苏" }, + { "area": "来宾" }, + { "area": "莱芜" }, + { "area": "廊坊" }, + { "area": "拉萨" }, + { "area": "乐山" }, + { "area": "凉山" }, + { "area": "连云港" }, + { "area": "聊城" }, + { "area": "辽阳" }, + { "area": "辽源" }, + { "area": "丽江" }, + { "area": "临沧" }, + { "area": "临汾" }, + { "area": "临夏" }, + { "area": "临沂" }, + { "area": "林芝" }, + { "area": "丽水" }, + { "area": "六安" }, + { "area": "六盘水" }, + { "area": "陇南" }, + { "area": "龙岩" }, + { "area": "娄底" }, + { "area": "漯河" }, + { "area": "洛阳" }, + { "area": "泸州" } + ], + "L": [ + { "area": "吕梁" }, + { "area": "来宾" }, + { "area": "莱芜" }, + { "area": "廊坊" }, + { "area": "拉萨" }, + { "area": "乐山" }, + { "area": "凉山" }, + { "area": "连云港" }, + { "area": "聊城" }, + { "area": "辽阳" }, + { "area": "辽源" }, + { "area": "丽江" }, + { "area": "临沧" }, + { "area": "临汾" }, + { "area": "临夏" }, + { "area": "临沂" }, + { "area": "林芝" }, + { "area": "丽水" }, + { "area": "六安" }, + { "area": "六盘水" }, + { "area": "陇南" }, + { "area": "龙岩" }, + { "area": "娄底" }, + { "area": "漯河" }, + { "area": "洛阳" }, + { "area": "泸州" } + ], + "M": [ + { "area": "马鞍山" }, + { "area": "茂名" }, + { "area": "眉山" }, + { "area": "梅州" }, + { "area": "绵阳" }, + { "area": "牡丹江" } + ], + "N": [ + { "area": "南京" }, + { "area": "南昌" }, + { "area": "南宁" }, + { "area": "南充" }, + { "area": "南平" }, + { "area": "南通" }, + { "area": "南阳" }, + { "area": "那曲" }, + { "area": "内江" }, + { "area": "宁德" }, + { "area": "怒江" } + ], + "P": [ + { "area": "攀枝花" }, + { "area": "盘锦" }, + { "area": "平顶山" }, + { "area": "平凉" }, + { "area": "萍乡" }, + { "area": "普洱" }, + { "area": "莆田" }, + { "area": "濮阳" } + ], + "Q": [ + { "area": "黔东南" }, + { "area": "黔南" }, + { "area": "黔西南" }, + { "area": "青岛" }, + { "area": "庆阳" }, + { "area": "清远" }, + { "area": "秦皇岛" }, + { "area": "钦州" }, + { "area": "齐齐哈尔" }, + { "area": "七台河" }, + { "area": "泉州" }, + { "area": "曲靖" }, + { "area": "衢州" } + ], + "R": [ + { "area": "日喀则" }, + { "area": "日照" } + ], + "S": [ + { "area": "上海" }, + { "area": "深圳" }, + { "area": "苏州" }, + { "area": "三门峡" }, + { "area": "三明" }, + { "area": "三亚" }, + { "area": "商洛" }, + { "area": "商丘" }, + { "area": "上饶" }, + { "area": "山南" }, + { "area": "汕头" }, + { "area": "汕尾" }, + { "area": "韶关" }, + { "area": "绍兴" }, + { "area": "邵阳" }, + { "area": "十堰" }, + { "area": "朔州" }, + { "area": "四平" }, + { "area": "松原" }, + { "area": "绥化" }, + { "area": "遂宁" }, + { "area": "随州" }, + { "area": "宿迁" }, + { "area": "宿州" } + ], + "T": [ + { "area": "天津" }, + { "area": "塔城" }, + { "area": "泰安" }, + { "area": "太原" }, + { "area": "台州" }, + { "area": "泰州" }, + { "area": "唐山" }, + { "area": "天水" }, + { "area": "铁岭" }, + { "area": "铜川" }, + { "area": "通化" }, + { "area": "通辽" }, + { "area": "铜陵" }, + { "area": "铜仁" }, + { "area": "台湾" }, + { "area": "吐鲁番" } + ], + "W": [ + { "area": "武汉" }, + { "area": "乌鲁木齐" }, + { "area": "无锡" }, + { "area": "威海" }, + { "area": "潍坊" }, + { "area": "文山" }, + { "area": "温州" }, + { "area": "乌海" }, + { "area": "芜湖" }, + { "area": "乌兰察布" }, + { "area": "武威" }, + { "area": "梧州" } + ], + "X": [ + { "area": "厦门" }, + { "area": "西安" }, + { "area": "湘潭" }, + { "area": "湘西" }, + { "area": "襄阳" }, + { "area": "咸宁" }, + { "area": "咸阳" }, + { "area": "孝感" }, + { "area": "邢台" }, + { "area": "西宁" }, + { "area": "新乡" }, + { "area": "信阳" }, + { "area": "新余" }, + { "area": "忻州" }, + { "area": "西双版纳" }, + { "area": "宣城" }, + { "area": "许昌" }, + { "area": "徐州" } + ], + "Y": [ + { "area": "雅安" }, + { "area": "延安" }, + { "area": "延边" }, + { "area": "盐城" }, + { "area": "阳江" }, + { "area": "阳泉" }, + { "area": "扬州" }, + { "area": "烟台" }, + { "area": "宜宾" }, + { "area": "宜昌" }, + { "area": "伊春" }, + { "area": "宜春" }, + { "area": "伊犁" }, + { "area": "银川" }, + { "area": "营口" }, + { "area": "鹰潭" }, + { "area": "益阳" }, + { "area": "永州" }, + { "area": "岳阳" }, + { "area": "玉林" }, + { "area": "榆林" }, + { "area": "运城" }, + { "area": "云浮" }, + { "area": "玉树" }, + { "area": "玉溪" } + ], + "Z": [ + { "area": "杂多县" }, + { "area": "赞皇县" }, + { "area": "枣强县" }, + { "area": "枣阳市" }, + { "area": "枣庄" }, + { "area": "泽库县" }, + { "area": "增城市" }, + { "area": "曾都区" }, + { "area": "泽普县" }, + { "area": "泽州县" }, + { "area": "札达县" }, + { "area": "扎赉特旗" }, + { "area": "扎兰屯市" }, + { "area": "扎鲁特旗" }, + { "area": "扎囊县" }, + { "area": "张北县" }, + { "area": "张家港市" }, + { "area": "张家界" }, + { "area": "张家口" }, + { "area": "漳平市" }, + { "area": "漳州" }, + { "area": "章丘市" }, + { "area": "彰化县" }, + { "area": "张掖" }, + { "area": "漳浦县" }, + { "area": "章贡区" }, + { "area": "樟树市" }, + { "area": "长子县" }, + { "area": "湛江" }, + { "area": "诏安县" }, + { "area": "召陵区" }, + { "area": "昭平县" }, + { "area": "肇庆" }, + { "area": "昭通" }, + { "area": "赵县" }, + { "area": "昭阳区" }, + { "area": "招远市" }, + { "area": "正安县" }, + { "area": "正定县" }, + { "area": "正蓝旗" }, + { "area": "正宁县" }, + { "area": "蒸湘区" }, + { "area": "政和县" }, + { "area": "柘城县" }, + { "area": "正镶白旗" }, + { "area": "正阳县" }, + { "area": "郑州" }, + { "area": "镇安县" }, + { "area": "镇巴县" }, + { "area": "镇海区" }, + { "area": "镇江" }, + { "area": "镇康县" }, + { "area": "镇宁布依族苗族自治县" }, + { "area": "镇平县" }, + { "area": "镇坪县" }, + { "area": "镇雄县" }, + { "area": "镇原县" }, + { "area": "浈江区" }, + { "area": "志丹县" }, + { "area": "治多县" }, + { "area": "芷江侗族自治县" }, + { "area": "织金县" }, + { "area": "中江县" }, + { "area": "中牟县" }, + { "area": "中宁县" }, + { "area": "中山" }, + { "area": "中卫" }, + { "area": "钟祥市" }, + { "area": "中阳县" }, + { "area": "周宁县" }, + { "area": "周至县" }, + { "area": "庄河市" }, + { "area": "诸城市" }, + { "area": "驻马店" }, + { "area": "准格尔旗" }, + { "area": "涿鹿县" }, + { "area": "卓尼" }, + { "area": "涿州市" }, + { "area": "卓资县" }, + { "area": "珠海" }, + { "area": "珠晖区" }, + { "area": "株洲" }, + { "area": "株洲县" }, + { "area": "诸暨市" }, + { "area": "驻马店" }, + { "area": "庄河市" }, + { "area": "诸城市" }, + { "area": "准格尔旗" }, + { "area": "涿鹿县" }, + { "area": "卓尼" }, + { "area": "涿州市" }, + { "area": "卓资县" }, + { "area": "珠海" }, + { "area": "珠晖区" }, + { "area": "株洲" }, + { "area": "株洲县" }, + { "area": "诸暨市" } + ] +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 98ec30b6..bbacd5b8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -73,6 +73,7 @@ import 'package:huixiang/settlement/settlement.dart'; import 'package:huixiang/store/store_view/product_meals_sku.dart'; import 'package:huixiang/test_page.dart'; import 'package:huixiang/union/location_map_page.dart'; +import 'package:huixiang/union/union_select_city.dart'; import 'package:huixiang/utils/ImgCachePath.dart'; import 'package:huixiang/vip/user_vip_service_page.dart'; @@ -440,4 +441,6 @@ Map routers = { BindingPhonePage(arguments:arguments), '/router/trading_card_page': (context, {arguments}) => TradingCardPage(), + '/router/union_select_city': (context, {arguments}) => + UnionSelectCity(), }; diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index c381f3f0..1137804f 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -37,7 +37,7 @@ class _UnionList extends State { Widget build(BuildContext context) { return Column( children: [ - buildSearchItem(), + // buildSearchItem(), Container( height: MediaQuery.of(context).size.height - 103.h - diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 19e69013..96214aac 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -33,6 +33,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import '../utils/flutter_utils.dart'; +import '../view_widget/item_title.dart'; class UnionPage extends StatefulWidget { final int initialIndex; @@ -61,6 +62,8 @@ class UnionPageState extends State ApiService apiService; bool isKeyBoardShow = false; BMFCoordinate latLng; + final TextEditingController editingController = TextEditingController(); + String areaName = ""; jumpIndex(jpIndex) { tabController.index = jpIndex; @@ -242,7 +245,7 @@ class UnionPageState extends State ); } BaseData> baseData = await apiService.queryStore({ - // "city": city, + "city": city, // "district": district, // "province": province, "latitude": latitude, @@ -303,71 +306,128 @@ class UnionPageState extends State onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: MyAppBar( - title: "", - leading: false, - brightness: Brightness.light, - titleChild: PreferredSize( - preferredSize: Size(double.infinity, 38.h), - child: Theme( - data: ThemeData( - splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 - highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 - ), - child: TabBar( - controller: tabController, - isScrollable: true, - //可滚动 - indicatorColor: Color(0xff39B54A), - labelColor: Colors.black, - labelStyle: TextStyle( - fontSize: 18.sp, - fontWeight: FontWeight.bold, + child:Stack( + children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage("assets/image/settlement_bg.webp"), + ), + ), + width: double.infinity, + height: 306.h, + ), + Scaffold( + backgroundColor: Colors.transparent, + resizeToAvoidBottomInset: false, + appBar: PreferredSize( + preferredSize: Size(double.infinity, 100.h), + child: MyAppBar( + background: Color(0xFF32A060), + title: "", + leading: false, + brightness: Brightness.light, + bottom: PreferredSize( + preferredSize: Size(double.infinity, 38.h), + child:Align( + alignment: Alignment.centerLeft, + child: Theme( + data: ThemeData( + splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 + highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 + ), + child: TabBar( + controller: tabController, + isScrollable: true, + //可滚动 + indicatorColor: Colors.white, + labelColor: Colors.white, + labelStyle: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.bold, + ), + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.normal, + ), + // controller: tabController, + //未选中文字颜色 + unselectedLabelColor: Colors.white, + indicatorSize: TabBarIndicatorSize.label, + //指示器与文字等宽 + tabs: [ + MyTab(text: S.of(context).quanbu), + MyTab(text: S.of(context).chi), + MyTab(text: S.of(context).he), + MyTab(text: S.of(context).wan), + ], + )), ), - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.normal, + ), + titleChild:Row(children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context) + .pushNamed('/router/union_select_city') + .then((value) { + if (value != null) + setState(() { + areaName = value; + }); + }); + }, + child: Row( + children: [ + Text( + areaName ?? "武汉", + overflow: TextOverflow.ellipsis, + maxLines:1, + style: TextStyle( + fontSize: 14.sp, + fontWeight: FontWeight.bold, + color: Colors.white), + ), + Icon( + Icons.keyboard_arrow_down, + color: Colors.white, + size: 24, + ) + ], + ), ), - // controller: tabController, - //未选中文字颜色 - unselectedLabelColor: Color(0xffA29E9E), - indicatorSize: TabBarIndicatorSize.label, - //指示器与文字等宽 - tabs: [ - MyTab(text: S.of(context).quanbu), - MyTab(text: S.of(context).chi), - MyTab(text: S.of(context).he), - MyTab(text: S.of(context).wan), - ], - )), - )), - body: TabBarView( - controller: tabController, - children: [ - UnionList(refreshController, storeList, () { - startLocation(true); - },(txt){ - queryStore("","","","","",txt,0); - }), - UnionList(refreshController1, storeList1, () { - startLocation(true); - },(txt){ - queryStore("","","","","",txt,0); - }), - UnionList(refreshController2, storeList2, () { - startLocation(true); - },(txt){ - queryStore("","","","","",txt,0); - }), - UnionList(refreshController3, storeList3, () { - startLocation(true); - },(txt){ - queryStore("","","","","",txt,0); - }), - ], - ), + SizedBox(width:10.w,), + Expanded(child:buildSearchItem()) + ],)), + ), + body: TabBarView( + controller: tabController, + children: [ + UnionList(refreshController, storeList, () { + startLocation(true); + },(txt){ + queryStore("","","","","",txt,0); + }), + UnionList(refreshController1, storeList1, () { + startLocation(true); + },(txt){ + queryStore("","","","","",txt,0); + }), + UnionList(refreshController2, storeList2, () { + startLocation(true); + },(txt){ + queryStore("","","","","",txt,0); + }), + UnionList(refreshController3, storeList3, () { + startLocation(true); + },(txt){ + queryStore("","","","","",txt,0); + }), + ], + ), + ), + ], )); // GestureDetector( // onTap: () { @@ -519,126 +579,127 @@ class UnionPageState extends State _mapController = controller; } - // Widget buildSearchItem() { - // return Container( - // height: 36.h, - // margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0), - // padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), - // decoration: BoxDecoration( - // color: Color(0xFFF5FAF7), - // borderRadius: BorderRadius.circular(4), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withAlpha(12), - // offset: Offset(0, 3), - // blurRadius: 14, - // spreadRadius: 0, - // ), - // ], - // ), - // child: TextField( - // textInputAction: TextInputAction.search, - // onEditingComplete: () { - // startLocation(false); - // }, - // controller: editingController, - // cursorHeight: 30.h, - // decoration: InputDecoration( - // contentPadding: EdgeInsets.symmetric( - // vertical: 12.h, - // ), - // prefixIcon: Icon( - // Icons.search, - // size: 24, - // color: Colors.black, - // ), - // suffixIcon: InkWell( - // onTap: () { - // editingController.clear(); - // }, - // child: Icon( - // Icons.close, - // size: 19, - // color: Colors.grey, - // ), - // ), - // border: InputBorder.none, - // ), - // ), - // ); - // } + Widget buildSearchItem() { + return Container( + height: 36.h, + margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0), + padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), + decoration: BoxDecoration( + color: Color(0xFFF5FAF7), + borderRadius: BorderRadius.circular(4), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: TextField( + textInputAction: TextInputAction.search, + onEditingComplete: () { + FocusScope.of(context).requestFocus(FocusNode()); + queryStore("","","","","",editingController.text,0); + }, + controller: editingController, + cursorHeight: 25.h, + decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric( + vertical: 12.h, + ), + hintText: "搜索联盟会员店", + hintStyle: TextStyle( + fontSize: 12.sp, + color: Color(0xFFB3B3B3), + ), + prefixIcon:InkWell( + onTap: () { + queryStore("","","","","",editingController.text,0); + }, + child: Image.asset( + "assets/image/icon_search.webp", + width: 16, + height: 16, + ), + ), + border: InputBorder.none, + ), + ), + ); + } - // Widget buildSliverAppBar(BMFMapWidget map) { - // return SliverAppBar( - // // 滑上去时搜索隐藏 - // // floating: true, - // // snap: true, - // pinned: true, - // backgroundColor: Color(0xFFFAFAFA), - // elevation: 0, - // automaticallyImplyLeading: false, - // title: Container( - // height: 36.h, - // margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0), - // padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: BorderRadius.all(Radius.circular(4)), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withAlpha(12), - // offset: Offset(0, 3), - // blurRadius: 14, - // spreadRadius: 0, - // ) - // ]), - // child: TextField( - // textInputAction: TextInputAction.search, - // onEditingComplete: () { - // startLocation(); - // }, - // controller: editingController, - // cursorHeight: 30.h, - // decoration: InputDecoration( - // contentPadding: EdgeInsets.symmetric(vertical: 12.h), - // prefixIcon: Icon( - // Icons.search, - // size: 24, - // color: Colors.black, - // ), - // suffixIcon: InkWell( - // onTap: () { - // editingController.clear(); - // }, - // child: Icon( - // Icons.close, - // size: 19, - // color: Colors.grey, - // ), - // ), - // border: InputBorder.none, - // ), - // ), - // ), - // flexibleSpace: FlexibleSpaceBar( - // background: Container( - // child: map, - // ), - // ), - // expandedHeight: 375.h, - // bottom: PreferredSize( - // preferredSize: Size(double.infinity, 52.h), - // child: Container( - // padding: EdgeInsets.only(top: 6.h), - // color: Color(0xFFFAFAFA), - // child: ItemTitle( - // text: S.of(context).jingbilianmenghuiyuandian, - // imgPath: "assets/image/icon_union_store.webp", - // ), - // ), - // ), - // ); - // } + Widget buildSliverAppBar(BMFMapWidget map) { + return SliverAppBar( + // 滑上去时搜索隐藏 + // floating: true, + // snap: true, + pinned: true, + backgroundColor: Color(0xFFFAFAFA), + elevation: 0, + automaticallyImplyLeading: false, + title: Container( + height: 36.h, + margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0), + padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(4)), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ]), + child: TextField( + textInputAction: TextInputAction.search, + onEditingComplete: () { + startLocation(false); + }, + controller: editingController, + cursorHeight: 30.h, + decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 12.h), + prefixIcon: Icon( + Icons.search, + size: 24, + color: Colors.black, + ), + suffixIcon: InkWell( + onTap: () { + editingController.clear(); + }, + child: Icon( + Icons.close, + size: 19, + color: Colors.grey, + ), + ), + border: InputBorder.none, + ), + ), + ), + flexibleSpace: FlexibleSpaceBar( + background: Container( + child: map, + ), + ), + expandedHeight: 375.h, + bottom: PreferredSize( + preferredSize: Size(double.infinity, 52.h), + child: Container( + padding: EdgeInsets.only(top: 6.h), + color: Color(0xFFFAFAFA), + child: ItemTitle( + text: S.of(context).jingbilianmenghuiyuandian, + imgPath: "assets/image/icon_union_store.webp", + ), + ), + ), + ); + } Widget buildStoreItem(Store store, position) { return Container( diff --git a/lib/union/union_select_city.dart b/lib/union/union_select_city.dart new file mode 100644 index 00000000..ad582e09 --- /dev/null +++ b/lib/union/union_select_city.dart @@ -0,0 +1,415 @@ +import 'dart:convert'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/my_appbar.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; + +class UnionSelectCity extends StatefulWidget { + @override + State createState() { + return _UnionSelectCity(); + } +} + +class _UnionSelectCity extends State { + RefreshController refreshController = RefreshController(); + Map areaMap; + List areaList = []; + final TextEditingController editingController = TextEditingController(); + + @override + void initState() { + super.initState(); + areaCode(); + } + + void areaCode() async { + var value = + await rootBundle.loadString('assets/map_style/chinese_cities.json'); + areaMap = jsonDecode(value); + areaMap.forEach((key, value) { + areaList.add(key); + }); + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: Color(0xFFF0F0F0), + body: Container( + color: Color(0xFFF0F0F0), + child: Column( + children: [ + Container( + color: Colors.white, + padding: EdgeInsets.only(left: 14.w, top: 44.h, bottom: 24.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.of(context).pop(); + }, + child:Container( + padding: EdgeInsets.only(right:21.w), + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + ), + )), + Expanded(child: searchCityItem()) + ], + ), + Padding(padding:EdgeInsets.only(top: 16.h,bottom: 24.h), + child:Row( + children: [ + Padding(padding:EdgeInsets.only(right: 10.w), + child: Text( + "当前位置", + style: TextStyle( + color: Color(0xFFA29E9E), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ),), + Image.asset( + "assets/image/icon_union_location.webp", + width:20, + height:20, + ), + Padding(padding:EdgeInsets.only(left:8.w,), + child: Text( + "当前位置", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ),), + ], + )), + Padding(padding:EdgeInsets.only(bottom: 16.h), + child: Text( + "热门城市", + style: TextStyle( + color: Color(0xFFA29E9E), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ),), + Padding(padding:EdgeInsets.only(right: 14.h,bottom: 14.h), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("上海");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "上海", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("深圳");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "深圳", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + )), GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("北京");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "北京", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + )), GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("广州");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "广州", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + )), + ], + ),), + Padding(padding:EdgeInsets.only(right: 14.h,), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("成都");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "成都", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("杭州");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "杭州", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("南京");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "南京", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: (){ + Navigator.of(context).pop("重庆");}, + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF7F7F7), + borderRadius: BorderRadius.circular(4), + ), + padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), + child: Text( + "重庆", + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ) + ), + ), + ], + ),) + ], + ), + ), + Expanded(child: sortList()) + ], + ), + ), + ); + } + + Widget searchCityItem() { + return Container( + height: 36.h, + margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0), + padding: EdgeInsets.fromLTRB(0, 6.h, 0, 0), + decoration: BoxDecoration( + color: Color(0xFFF1F1F1), + borderRadius: BorderRadius.circular(6), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: TextField( + textInputAction: TextInputAction.search, + onEditingComplete: () { + FocusScope.of(context).requestFocus(FocusNode()); + }, + controller: editingController, + cursorHeight: 25.h, + decoration: InputDecoration( + // contentPadding: EdgeInsets.symmetric( + // vertical: 12.h, + // ), + hintText: "输入城市名进行搜索", + hintStyle: TextStyle( + fontSize: 12.sp, + color: Color(0xFFB3B3B3), + ), + prefixIcon: InkWell( + onTap: () {}, + child:Image.asset( + "assets/image/icon_search.webp", + width: 16, + height: 16, + ), + ), + border: InputBorder.none, + ), + ), + ); + } + + Widget sortList() { + return ListView.builder( + padding: EdgeInsets.zero, + itemCount: areaList.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: sortItem(position), + ); + }, + ); + } + + Widget sortItem(int position) { + return Column( + children: [ + Container( + width: double.infinity, + // color: Colors.white, + padding: EdgeInsets.only(top: 14.h, bottom: 4.h, left: 16.w), + margin: EdgeInsets.only(bottom: 12.h), + child: Text( + areaList[position], + style: TextStyle( + color: Color(0xFF4D4D4D), + fontWeight: MyFontWeight.medium, + fontSize: 16.sp, + ), + ), + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.w), + color: Colors.white, + ), + margin: EdgeInsets.symmetric(horizontal: 14.w), + padding: EdgeInsets.only( + top: 8.h, + ), + child: Column( + children: (areaMap[areaList[position]] as List).map((e) { + return globalRoamingItem(e); + }).toList(), + ), + ) + ], + ); + } + + Widget globalRoamingItem(data) { + return GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.of(context).pop(data["area"]); + }, + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(left: 12.w), + child: Text( + data["area"], + style: TextStyle( + color: Color(0xFF000000), + fontWeight: MyFontWeight.regular, + fontSize: 14.sp, + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(vertical: 16.h), + width: double.infinity, + height: 1.h, + color: Color(0xFFDCDCDC), + ) + ], + ), + ), + ); + } +}