showCitiesSelector static method
Future<Result?>
showCitiesSelector({
- required BuildContext context,
- ThemeData? theme,
- String? locationCode,
- String title = '城市选择器',
- Map<
String, dynamic> citiesData = meta.citiesData, - Map<
String, String> provincesData = meta.provincesData, - AppBarBuilder? appBarBuilder,
- List<
HotCity> ? hotCities, - BaseStyle? sideBarStyle,
- BaseStyle? cityItemStyle,
- BaseStyle? topStickStyle,
- Color? scaffoldBackgroundColor,
- bool useSearchAppBar = false,
- EdgeInsetsGeometry tagBarTextPadding = const EdgeInsets.symmetric(horizontal: 4.0),
Implementation
static Future<Result?> showCitiesSelector({
required BuildContext context,
ThemeData? theme,
String? locationCode,
String title = '城市选择器',
Map<String, dynamic> citiesData = meta.citiesData,
Map<String, String> provincesData = meta.provincesData,
AppBarBuilder? appBarBuilder,
List<HotCity>? hotCities,
BaseStyle? sideBarStyle,
BaseStyle? cityItemStyle,
BaseStyle? topStickStyle,
Color? scaffoldBackgroundColor,
bool useSearchAppBar = false,
EdgeInsetsGeometry tagBarTextPadding =
const EdgeInsets.symmetric(horizontal: 4.0),
}) {
BaseStyle _sideBarStyle = BaseStyle(
fontSize: 14,
color: defaultTagFontColor,
activeColor: defaultTagActiveBgColor,
backgroundColor: defaultTagBgColor,
backgroundActiveColor: defaultTagActiveBgColor,
);
if (sideBarStyle != null) {
_sideBarStyle = _sideBarStyle.merge(sideBarStyle);
}
BaseStyle _cityItemStyle = BaseStyle(
fontSize: 12,
color: Colors.black,
activeColor: Colors.red,
);
if (cityItemStyle != null) {
_cityItemStyle = _cityItemStyle.merge(cityItemStyle);
}
BaseStyle _topStickStyle = BaseStyle(
fontSize: 16,
height: 40,
color: defaultTopIndexFontColor,
backgroundColor: defaultTopIndexBgColor,
);
if (topStickStyle != null) {
_topStickStyle = _topStickStyle.merge(topStickStyle);
}
return Navigator.push(
context,
new PageRouteBuilder(
transitionDuration: const Duration(milliseconds: 250),
pageBuilder: (context, _, __) => new Theme(
data: theme ?? Theme.of(context),
child: CitiesSelectorPage(
title: title,
appBarBuilder: appBarBuilder,
scaffoldBackgroundColor:
scaffoldBackgroundColor ?? defaultScaffoldBackgroundColor,
useSearchAppBar: useSearchAppBar,
provincesData: provincesData,
citiesData: citiesData,
buildCitiesSelector: (context, cities) => CitiesSelector(
cities: cities,
hotCities: hotCities,
locationCode: locationCode,
tagBarActiveColor: _sideBarStyle.backgroundActiveColor!,
tagBarFontActiveColor: _sideBarStyle.activeColor!,
tagBarBgColor: _sideBarStyle.backgroundColor!,
tagBarFontColor: _sideBarStyle.color,
tagBarFontSize: _sideBarStyle.fontSize,
tagBarTextPadding: tagBarTextPadding,
topIndexFontSize: _topStickStyle.fontSize,
topIndexHeight: _topStickStyle.height!,
topIndexFontColor: _topStickStyle.color,
topIndexBgColor: _topStickStyle.backgroundColor!,
itemFontColor: _cityItemStyle.color,
itemFontSize: _cityItemStyle.fontSize,
itemSelectFontColor: _cityItemStyle.activeColor,
onSelected: (value) => Navigator.pop(context, value),
),
),
),
transitionsBuilder:
(_, Animation<double> animation, __, Widget child) =>
new SlideTransition(
position: new Tween<Offset>(
begin: Offset(0.0, 1.0),
end: Offset(0.0, 0.0),
).animate(animation),
child: child,
),
),
);
}