parent
89da62244a
commit
09b1527e7a
@ -1 +1,2 @@
|
||||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
@ -1 +1,2 @@
|
||||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
@ -0,0 +1,41 @@
|
||||
# Uncomment this line to define a global platform for your project
|
||||
# platform :ios, '9.0'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
project 'Runner', {
|
||||
'Debug' => :debug,
|
||||
'Profile' => :release,
|
||||
'Release' => :release,
|
||||
}
|
||||
|
||||
def flutter_root
|
||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
||||
end
|
||||
|
||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||
return matches[1].strip if matches
|
||||
end
|
||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
|
||||
end
|
||||
|
||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||
|
||||
flutter_ios_podfile_setup
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
flutter_additional_ios_build_settings(target)
|
||||
end
|
||||
end
|
@ -0,0 +1,160 @@
|
||||
import 'package:ansu_ui/ansu_ui.dart';
|
||||
import 'package:ansu_ui/utils/city_util.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ASCityPicker extends StatefulWidget {
|
||||
ASCityPicker({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ASCityPickerState createState() => _ASCityPickerState();
|
||||
}
|
||||
|
||||
class _ASCityPickerState extends State<ASCityPicker> {
|
||||
double getFontSize(String text) {
|
||||
double fontSize = 13.sp;
|
||||
int len = text?.length ?? 0;
|
||||
if (len >= 1 && len <= 3) {
|
||||
fontSize = 20.w;
|
||||
} else if (len > 3 && len <= 4) {
|
||||
fontSize = 18.sp;
|
||||
} else if (len > 4 && len <= 5) {
|
||||
fontSize = 16.sp;
|
||||
} else if (len > 5 && len <= 6) {
|
||||
fontSize = 14.sp;
|
||||
} else if (len > 6 && len <= 9) {
|
||||
fontSize = 12.sp;
|
||||
} else if (len > 9) {
|
||||
fontSize = 8.sp;
|
||||
}
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
ProvinceModel _selectedProvince;
|
||||
CityModel _selectedCity;
|
||||
CityModel _selectedDistrict;
|
||||
|
||||
FixedExtentScrollController _cityController = FixedExtentScrollController();
|
||||
FixedExtentScrollController _districtController =
|
||||
FixedExtentScrollController();
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selectedProvince = CityUtil.provinceModel.first;
|
||||
_selectedCity = CityUtil.getCityModelByCode(_selectedProvince.code).first;
|
||||
_selectedDistrict = CityUtil.getCityModelByCode(_selectedCity.code).first;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_cityController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ASPickerBox(
|
||||
onPressed: () {
|
||||
Navigator.pop(context, _selectedDistrict);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CupertinoPicker(
|
||||
offAxisFraction: -0.6,
|
||||
itemExtent: 30,
|
||||
useMagnifier: true,
|
||||
magnification: 1.1,
|
||||
onSelectedItemChanged: (value) {
|
||||
_cityController.animateToItem(
|
||||
0,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
_districtController.animateToItem(
|
||||
0,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
setState(() {
|
||||
_selectedProvince = CityUtil.provinceModel[value];
|
||||
_selectedCity =
|
||||
CityUtil.getCityModelByCode(_selectedProvince.code).first;
|
||||
_selectedDistrict =
|
||||
CityUtil.getCityModelByCode(_selectedCity.code).first;
|
||||
});
|
||||
},
|
||||
children: CityUtil.provinceModel
|
||||
.map((e) => Center(
|
||||
child: Text(
|
||||
e.name,
|
||||
style: TextStyle(
|
||||
fontSize: getFontSize(e.name),
|
||||
),
|
||||
)))
|
||||
.toList(),
|
||||
looping: true,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CupertinoPicker(
|
||||
looping:
|
||||
CityUtil.getCityModelByCode(_selectedProvince.code).length >
|
||||
1,
|
||||
scrollController: _cityController,
|
||||
itemExtent: 30,
|
||||
useMagnifier: true,
|
||||
magnification: 1.1,
|
||||
onSelectedItemChanged: (value) {
|
||||
_districtController.animateToItem(
|
||||
0,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
setState(() {
|
||||
_selectedCity = CityUtil.getCityModelByCode(
|
||||
_selectedProvince.code)[value];
|
||||
_selectedDistrict =
|
||||
CityUtil.getCityModelByCode(_selectedCity.code).first;
|
||||
});
|
||||
},
|
||||
children: CityUtil.getCityModelByCode(_selectedProvince.code)
|
||||
.map((e) => Center(
|
||||
child: Text(
|
||||
e.name,
|
||||
style: TextStyle(
|
||||
fontSize: getFontSize(e.name),
|
||||
),
|
||||
)))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CupertinoPicker(
|
||||
offAxisFraction: 0.6,
|
||||
looping:
|
||||
CityUtil.getCityModelByCode(_selectedCity.code).length > 1,
|
||||
itemExtent: 30,
|
||||
useMagnifier: true,
|
||||
magnification: 1.1,
|
||||
scrollController: _districtController,
|
||||
onSelectedItemChanged: (value) {
|
||||
_selectedDistrict =
|
||||
CityUtil.getCityModelByCode(_selectedCity.code)[value];
|
||||
},
|
||||
children: CityUtil.getCityModelByCode(_selectedCity.code)
|
||||
.map((e) => Center(
|
||||
child: Text(
|
||||
e.name,
|
||||
style: TextStyle(
|
||||
fontSize: getFontSize(e.name),
|
||||
),
|
||||
)))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import 'package:ansu_ui/ansu_ui.dart';
|
||||
import 'package:ansu_ui/utils/city_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<CityModel> showCityPicker(BuildContext context,
|
||||
{String initCode}) async {
|
||||
return await showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ASCityPicker();
|
||||
},
|
||||
);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,47 @@
|
||||
import 'package:ansu_ui/utils/cities.dart';
|
||||
|
||||
class CityUtil {
|
||||
static List<ProvinceModel> get provinceModel {
|
||||
return provincesData.entries
|
||||
.map((e) => ProvinceModel(
|
||||
code: e.key,
|
||||
name: e.value,
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
|
||||
static List<CityModel> getCityModelByCode(String code) {
|
||||
Map<String, dynamic> temp = citiesData[code];
|
||||
if (temp?.entries?.isEmpty ?? true)
|
||||
return [
|
||||
CityModel(
|
||||
code: code,
|
||||
name: provincesData[code] ?? citiesData[code] ?? '',
|
||||
)
|
||||
];
|
||||
return temp.entries
|
||||
.map((e) => CityModel(
|
||||
code: e.key,
|
||||
name: e.value['name'],
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
class ProvinceModel {
|
||||
String code;
|
||||
String name;
|
||||
ProvinceModel({
|
||||
this.code,
|
||||
this.name,
|
||||
});
|
||||
}
|
||||
|
||||
class CityModel {
|
||||
String code;
|
||||
String name;
|
||||
CityModel({
|
||||
this.code,
|
||||
this.name,
|
||||
});
|
||||
}
|
Loading…
Reference in new issue