Location distance picker fixes

This commit is contained in:
Ilya Laktyushin 2020-10-23 22:18:13 +04:00
parent 7c9ff342fa
commit 44eff9ed95
6 changed files with 56 additions and 4 deletions

View File

@ -397,16 +397,19 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD
}
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let font = Font.regular(17.0)
let string: String
if component == 0 {
let value = unitValues[row]
return "\(value)"
string = "\(value)"
} else if component == 1 {
let value = String(format: "%.2d", smallUnitValues[row])
return ".\(value)"
string = ".\(value)"
} else {
return self.usesMetricSystem() ? self.presentationData.strings.Location_ProximityNotification_DistanceKM : self.presentationData.strings.Location_ProximityNotification_DistanceMI
string = self.usesMetricSystem() ? self.presentationData.strings.Location_ProximityNotification_DistanceKM : self.presentationData.strings.Location_ProximityNotification_DistanceMI
}
return NSAttributedString(string: string, font: font, textColor: self.presentationData.theme.actionSheet.primaryTextColor)
}
func updatePresentationData(_ presentationData: PresentationData) {
@ -431,6 +434,8 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD
self.cancelButton.setTitle(self.presentationData.strings.Common_Cancel, with: Font.regular(17.0), with: self.presentationData.theme.actionSheet.controlAccentColor, for: .normal)
self.doneButton.updateTheme(SolidRoundedButtonTheme(theme: self.presentationData.theme))
self.updateDoneButtonTitle()
}
override func didLoad() {

View File

@ -26,6 +26,23 @@ public enum LocationMapMode {
}
}
public enum LocationTrackingMode {
case none
case follow
case followWithHeading
var userTrackingMode: MKUserTrackingMode {
switch self {
case .follow:
return .follow
case .followWithHeading:
return .followWithHeading
default:
return .none
}
}
}
private class PickerAnnotationContainerView: UIView {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let result = super.hitTest(point, with: event)
@ -352,6 +369,12 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
}
}
var trackingMode: LocationTrackingMode = .none {
didSet {
self.mapView?.userTrackingMode = self.trackingMode.userTrackingMode
}
}
func setMapCenter(coordinate: CLLocationCoordinate2D, span: MKCoordinateSpan = defaultMapSpan, offset: CGPoint = CGPoint(), isUserLocation: Bool = false, hidePicker: Bool = false, animated: Bool = false) {
let region = MKCoordinateRegion(center: coordinate, span: span)
self.ignoreRegionChanges = true

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "ic_gps_filled.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "ic_gps_2.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}