|
|
|
@ -32,7 +32,8 @@ import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
|
|
|
|
|
|
|
|
|
|
class UnionPage extends StatefulWidget { |
|
|
|
|
final int initialIndex; |
|
|
|
|
UnionPage(Key key,this.initialIndex): super(key: key); |
|
|
|
|
|
|
|
|
|
UnionPage(Key key, this.initialIndex) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
@ -57,7 +58,7 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
bool isKeyBoardShow = false; |
|
|
|
|
BMFCoordinate latLng; |
|
|
|
|
|
|
|
|
|
jumpIndex(jpIndex){ |
|
|
|
|
jumpIndex(jpIndex) { |
|
|
|
|
tabController.index = jpIndex; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -98,7 +99,8 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
if (tabController == null) |
|
|
|
|
tabController = TabController(length: 4, vsync: this,initialIndex: widget.initialIndex); |
|
|
|
|
tabController = TabController( |
|
|
|
|
length: 4, vsync: this, initialIndex: widget.initialIndex); |
|
|
|
|
// tabController?.addListener(() { |
|
|
|
|
// startLocation(); |
|
|
|
|
// }); |
|
|
|
@ -114,18 +116,20 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
startLocation(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RefreshController tabRefresh(){ |
|
|
|
|
RefreshController tabRefresh() { |
|
|
|
|
RefreshController tempRef; |
|
|
|
|
if (tabController.index == 0) tempRef = refreshController; |
|
|
|
|
else if (tabController.index == 1) tempRef = refreshController1; |
|
|
|
|
else if (tabController.index == 2) tempRef = refreshController2; |
|
|
|
|
if (tabController.index == 0) |
|
|
|
|
tempRef = refreshController; |
|
|
|
|
else if (tabController.index == 1) |
|
|
|
|
tempRef = refreshController1; |
|
|
|
|
else if (tabController.index == 2) |
|
|
|
|
tempRef = refreshController2; |
|
|
|
|
else if (tabController.index == 3) tempRef = refreshController3; |
|
|
|
|
return tempRef; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
startLocation(bool isOnRefresh) async { |
|
|
|
|
if(!isOnRefresh) |
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
|
if (!isOnRefresh) EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
|
Location.getInstance() |
|
|
|
|
.aMapFlutterLocation |
|
|
|
|
.onResultCallback() |
|
|
|
@ -141,9 +145,9 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
latLng = BMFCoordinate(event["latitude"], event["longitude"]); |
|
|
|
|
} |
|
|
|
|
BMFCalculateUtils.coordConvert( |
|
|
|
|
coordinate: latLng, |
|
|
|
|
fromType: BMF_COORD_TYPE.BD09LL, |
|
|
|
|
toType: BMF_COORD_TYPE.COMMON) |
|
|
|
|
coordinate: latLng, |
|
|
|
|
fromType: BMF_COORD_TYPE.BD09LL, |
|
|
|
|
toType: BMF_COORD_TYPE.COMMON) |
|
|
|
|
.then((value) { |
|
|
|
|
this.latLng = value; |
|
|
|
|
saveLatLng( |
|
|
|
@ -157,21 +161,20 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
event["province"], |
|
|
|
|
event["city"], |
|
|
|
|
event["district"], |
|
|
|
|
editingController.text,-1); |
|
|
|
|
editingController.text, |
|
|
|
|
-1); |
|
|
|
|
if (_mapController != null) |
|
|
|
|
_mapController.updateMapOptions(BMFMapOptions( |
|
|
|
|
center: value, |
|
|
|
|
zoomLevel: 15, |
|
|
|
|
)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
getLatLng(); |
|
|
|
|
// EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Location.getInstance().prepareLoc(); |
|
|
|
|
Location.getInstance().startLocation(context).then((value) { |
|
|
|
|
if (!value) { |
|
|
|
@ -211,7 +214,8 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
value.getString("province"), |
|
|
|
|
value.getString("city"), |
|
|
|
|
value.getString("district"), |
|
|
|
|
editingController.text,-1), |
|
|
|
|
editingController.text, |
|
|
|
|
-1), |
|
|
|
|
setState(() { |
|
|
|
|
if (_mapController != null) { |
|
|
|
|
_mapController.updateMapOptions(BMFMapOptions( |
|
|
|
@ -223,7 +227,7 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
queryStore("", "", "", "", "", editingController.text,-1), |
|
|
|
|
queryStore("", "", "", "", "", editingController.text, -1), |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
@ -234,7 +238,8 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
List<Store> storeList2; |
|
|
|
|
List<Store> storeList3; |
|
|
|
|
|
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,int index) async { |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey, |
|
|
|
|
int index) async { |
|
|
|
|
if (apiService == null) { |
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
apiService = ApiService( |
|
|
|
@ -254,31 +259,38 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
? "" |
|
|
|
|
: ((tabController.index == 1 && index == -1) || index == 1 |
|
|
|
|
? "EATSTORE" |
|
|
|
|
: ((tabController.index == 2 && index == -1) || index == 2 ? "DRINKSTORE" : "HAPPYSTORE")), |
|
|
|
|
: ((tabController.index == 2 && index == -1) || index == 2 |
|
|
|
|
? "DRINKSTORE" |
|
|
|
|
: "HAPPYSTORE")), |
|
|
|
|
}).catchError((error) { |
|
|
|
|
if(index == -1) |
|
|
|
|
tabRefresh().refreshFailed(); |
|
|
|
|
if (index == -1) tabRefresh().refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
if(index == -1 && storeList == null){ |
|
|
|
|
if (index == -1 && storeList == null) { |
|
|
|
|
if (tabController.index != 0) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,0); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 0); |
|
|
|
|
if (tabController.index != 1) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,1); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 1); |
|
|
|
|
if (tabController.index != 2) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,2); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 2); |
|
|
|
|
if (tabController.index != 3) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,3); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 3); |
|
|
|
|
} |
|
|
|
|
if ((tabController.index == 0 && index == -1) || index == 0) storeList = baseData.data; |
|
|
|
|
else if ((tabController.index == 1 && index == -1) || index == 1) storeList1 = baseData.data; |
|
|
|
|
else if ((tabController.index == 2 && index == -1) || index == 2) storeList2 = baseData.data; |
|
|
|
|
else if ((tabController.index == 3 && index == -1) || index == 3) storeList3 = baseData.data; |
|
|
|
|
if(index == -1) |
|
|
|
|
tabRefresh().refreshCompleted(); |
|
|
|
|
if ((tabController.index == 0 && index == -1) || index == 0) |
|
|
|
|
storeList = baseData.data; |
|
|
|
|
else if ((tabController.index == 1 && index == -1) || index == 1) |
|
|
|
|
storeList1 = baseData.data; |
|
|
|
|
else if ((tabController.index == 2 && index == -1) || index == 2) |
|
|
|
|
storeList2 = baseData.data; |
|
|
|
|
else if ((tabController.index == 3 && index == -1) || index == 3) |
|
|
|
|
storeList3 = baseData.data; |
|
|
|
|
if (index == -1) tabRefresh().refreshCompleted(); |
|
|
|
|
} else { |
|
|
|
|
if(index == -1) |
|
|
|
|
tabRefresh().refreshFailed(); |
|
|
|
|
if (index == -1) tabRefresh().refreshFailed(); |
|
|
|
|
} |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
setState(() {}); |
|
|
|
@ -291,54 +303,67 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
super.build(context); |
|
|
|
|
return GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.translucent, |
|
|
|
|
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: TabBar( |
|
|
|
|
controller: tabController, |
|
|
|
|
isScrollable: true, |
|
|
|
|
//可滚动 |
|
|
|
|
indicatorColor: Color(0xff39B54A), |
|
|
|
|
labelColor: Colors.black, |
|
|
|
|
labelStyle: TextStyle( |
|
|
|
|
fontSize: 18.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
), |
|
|
|
|
unselectedLabelStyle: TextStyle( |
|
|
|
|
fontSize: 15.sp, |
|
|
|
|
fontWeight: FontWeight.normal, |
|
|
|
|
), |
|
|
|
|
// controller: tabController, |
|
|
|
|
//未选中文字颜色 |
|
|
|
|
unselectedLabelColor: Color(0xffA29E9E), |
|
|
|
|
indicatorSize: TabBarIndicatorSize.label, |
|
|
|
|
//指示器与文字等宽 |
|
|
|
|
tabs: <Widget>[ |
|
|
|
|
MyTab(text: S.of(context).quanbu), |
|
|
|
|
MyTab(text: "吃"), |
|
|
|
|
MyTab(text: "喝"), |
|
|
|
|
MyTab(text: "玩"), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
body: TabBarView( |
|
|
|
|
controller: tabController, |
|
|
|
|
children: [ |
|
|
|
|
UnionList(refreshController, storeList,(){startLocation(true);}), |
|
|
|
|
UnionList(refreshController1, storeList1,(){startLocation(true);}), |
|
|
|
|
UnionList(refreshController2, storeList2,(){startLocation(true);}), |
|
|
|
|
UnionList(refreshController3, storeList3,(){startLocation(true);}), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)); |
|
|
|
|
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, |
|
|
|
|
), |
|
|
|
|
unselectedLabelStyle: TextStyle( |
|
|
|
|
fontSize: 15.sp, |
|
|
|
|
fontWeight: FontWeight.normal, |
|
|
|
|
), |
|
|
|
|
// controller: tabController, |
|
|
|
|
//未选中文字颜色 |
|
|
|
|
unselectedLabelColor: Color(0xffA29E9E), |
|
|
|
|
indicatorSize: TabBarIndicatorSize.label, |
|
|
|
|
//指示器与文字等宽 |
|
|
|
|
tabs: <Widget>[ |
|
|
|
|
MyTab(text: S.of(context).quanbu), |
|
|
|
|
MyTab(text: "吃"), |
|
|
|
|
MyTab(text: "喝"), |
|
|
|
|
MyTab(text: "玩"), |
|
|
|
|
], |
|
|
|
|
)), |
|
|
|
|
)), |
|
|
|
|
body: TabBarView( |
|
|
|
|
controller: tabController, |
|
|
|
|
children: [ |
|
|
|
|
UnionList(refreshController, storeList, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
UnionList(refreshController1, storeList1, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
UnionList(refreshController2, storeList2, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
UnionList(refreshController3, storeList3, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)); |
|
|
|
|
// GestureDetector( |
|
|
|
|
// onTap: () { |
|
|
|
|
// FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|