mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
8de066f912
commit
d4b769f5a1
@ -160,7 +160,6 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.webPage = result
|
|
||||||
self.updateWebPage(result, anchor: self.initialAnchor)
|
self.updateWebPage(result, anchor: self.initialAnchor)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,10 @@ final class CameraDevice {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.transaction(device) { device in
|
self.transaction(device) { device in
|
||||||
device.torchMode = active ? .on : .off
|
let torchMode: AVCaptureDevice.TorchMode = active ? .on : .off
|
||||||
|
if device.isTorchModeSupported(torchMode) {
|
||||||
|
device.torchMode = active ? .on : .off
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +266,7 @@ struct LocationPickerState {
|
|||||||
var mapMode: LocationMapMode
|
var mapMode: LocationMapMode
|
||||||
var displayingMapModeOptions: Bool
|
var displayingMapModeOptions: Bool
|
||||||
var selectedLocation: LocationPickerLocation
|
var selectedLocation: LocationPickerLocation
|
||||||
|
var appxCoordinate: CLLocationCoordinate2D?
|
||||||
var geoAddress: MapGeoAddress?
|
var geoAddress: MapGeoAddress?
|
||||||
var city: String?
|
var city: String?
|
||||||
var street: String?
|
var street: String?
|
||||||
@ -279,6 +280,7 @@ struct LocationPickerState {
|
|||||||
self.mapMode = .map
|
self.mapMode = .map
|
||||||
self.displayingMapModeOptions = false
|
self.displayingMapModeOptions = false
|
||||||
self.selectedLocation = .none
|
self.selectedLocation = .none
|
||||||
|
self.appxCoordinate = nil
|
||||||
self.geoAddress = nil
|
self.geoAddress = nil
|
||||||
self.city = nil
|
self.city = nil
|
||||||
self.street = nil
|
self.street = nil
|
||||||
@ -636,7 +638,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
|||||||
let title: String
|
let title: String
|
||||||
var coordinate = userLocation?.coordinate
|
var coordinate = userLocation?.coordinate
|
||||||
switch strongSelf.mode {
|
switch strongSelf.mode {
|
||||||
case .share:
|
case .share:
|
||||||
if source == .story {
|
if source == .story {
|
||||||
if let initialLocation = strongSelf.controller?.initialLocation {
|
if let initialLocation = strongSelf.controller?.initialLocation {
|
||||||
title = presentationData.strings.Location_AddThisLocation
|
title = presentationData.strings.Location_AddThisLocation
|
||||||
@ -647,12 +649,24 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
|||||||
} else {
|
} else {
|
||||||
title = presentationData.strings.Map_SendMyCurrentLocation
|
title = presentationData.strings.Map_SendMyCurrentLocation
|
||||||
}
|
}
|
||||||
case .pick:
|
case .pick:
|
||||||
title = presentationData.strings.Map_SetThisLocation
|
title = presentationData.strings.Map_SetThisLocation
|
||||||
}
|
}
|
||||||
if source == .story {
|
if source == .story {
|
||||||
if state.city != "" {
|
if state.city != "" {
|
||||||
entries.append(.city(presentationData.theme, state.city ?? presentationData.strings.Map_Locating, presentationData.strings.Location_TypeCity, nil, nil, nil, coordinate, state.city, state.geoAddress))
|
let title: String
|
||||||
|
let name: String?
|
||||||
|
let geoAddress: MapGeoAddress?
|
||||||
|
if let city = state.city, let _ = state.appxCoordinate {
|
||||||
|
title = city
|
||||||
|
name = city
|
||||||
|
geoAddress = state.geoAddress
|
||||||
|
} else {
|
||||||
|
title = presentationData.strings.Map_Locating
|
||||||
|
name = nil
|
||||||
|
geoAddress = nil
|
||||||
|
}
|
||||||
|
entries.append(.city(presentationData.theme, title, presentationData.strings.Location_TypeCity, nil, nil, nil, state.appxCoordinate, name, geoAddress))
|
||||||
}
|
}
|
||||||
if state.street != "" {
|
if state.street != "" {
|
||||||
entries.append(.location(presentationData.theme, state.street ?? presentationData.strings.Map_Locating, state.isStreet ? presentationData.strings.Location_TypeStreet : presentationData.strings.Location_TypeLocation, nil, nil, nil, coordinate, state.street, state.geoAddress, false))
|
entries.append(.location(presentationData.theme, state.street ?? presentationData.strings.Map_Locating, state.isStreet ? presentationData.strings.Location_TypeStreet : presentationData.strings.Location_TypeLocation, nil, nil, nil, coordinate, state.street, state.geoAddress, false))
|
||||||
@ -801,13 +815,44 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
|||||||
let locale = localeWithStrings(presentationData.strings)
|
let locale = localeWithStrings(presentationData.strings)
|
||||||
let enLocale = Locale(identifier: "en-US")
|
let enLocale = Locale(identifier: "en-US")
|
||||||
|
|
||||||
let setupGeocoding: (CLLocationCoordinate2D, @escaping (MapGeoAddress?, String, String?, String?, String?, Bool) -> Void) -> Void = { coordinate, completion in
|
let setupGeocoding: (CLLocationCoordinate2D, Bool, @escaping (MapGeoAddress?, CLLocationCoordinate2D?, String, String?, String?, String?, Bool) -> Void) -> Void = { coordinate, current, completion in
|
||||||
strongSelf.geocodingDisposable.set(
|
strongSelf.geocodingDisposable.set(
|
||||||
combineLatest(
|
combineLatest(
|
||||||
queue: Queue.mainQueue(),
|
queue: Queue.mainQueue(),
|
||||||
reverseGeocodeLocation(latitude: coordinate.latitude, longitude: coordinate.longitude, locale: locale),
|
reverseGeocodeLocation(latitude: coordinate.latitude, longitude: coordinate.longitude, locale: locale),
|
||||||
reverseGeocodeLocation(latitude: coordinate.latitude, longitude: coordinate.longitude, locale: enLocale)
|
reverseGeocodeLocation(latitude: coordinate.latitude, longitude: coordinate.longitude, locale: enLocale)
|
||||||
).start(next: { placemark, enPlacemark in
|
|> mapToSignal { placemark -> Signal<(ReverseGeocodedPlacemark, CLLocationCoordinate2D)?, NoError> in
|
||||||
|
guard let placemark else {
|
||||||
|
return .single(nil)
|
||||||
|
}
|
||||||
|
if current {
|
||||||
|
var cityName: String
|
||||||
|
if let city = placemark.city {
|
||||||
|
if let countryCode = placemark.countryCode {
|
||||||
|
cityName = "\(city), \(displayCountryName(countryCode, locale: locale))"
|
||||||
|
} else {
|
||||||
|
cityName = city
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cityName = ""
|
||||||
|
}
|
||||||
|
if !cityName.isEmpty {
|
||||||
|
return geocodeLocation(address: cityName, locale: enLocale)
|
||||||
|
|> map { placemarks in
|
||||||
|
if let location = placemarks?.first(where: { $0.thoroughfare == nil })?.location {
|
||||||
|
return (placemark, location.coordinate)
|
||||||
|
} else {
|
||||||
|
return (placemark, coordinate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .single((placemark, coordinate))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .single((placemark, coordinate))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).start(next: { placemark, enPlacemarkAndAppCoordinate in
|
||||||
var address = placemark?.fullAddress ?? ""
|
var address = placemark?.fullAddress ?? ""
|
||||||
if address.isEmpty {
|
if address.isEmpty {
|
||||||
address = presentationData.strings.Map_Unknown
|
address = presentationData.strings.Map_Unknown
|
||||||
@ -842,16 +887,24 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mapGeoAddress: MapGeoAddress?
|
var mapGeoAddress: MapGeoAddress?
|
||||||
if let countryCode, let enPlacemark {
|
if let countryCode, let enPlacemark = enPlacemarkAndAppCoordinate?.0 {
|
||||||
mapGeoAddress = MapGeoAddress(country: countryCode, state: enPlacemark.state, city: enPlacemark.city, street: enPlacemark.street)
|
mapGeoAddress = MapGeoAddress(country: countryCode, state: enPlacemark.state, city: enPlacemark.city, street: enPlacemark.street)
|
||||||
}
|
}
|
||||||
completion(mapGeoAddress, address, cityName, streetName, countryCode, placemark?.street != nil)
|
var resolvedAppxCoordinate: CLLocationCoordinate2D?
|
||||||
|
if current, let appxCoordinate = enPlacemarkAndAppCoordinate?.1 {
|
||||||
|
let loc = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
|
||||||
|
let appxLoc = CLLocation(latitude: appxCoordinate.latitude, longitude: appxCoordinate.longitude)
|
||||||
|
if appxLoc.distance(from: loc) < 1000000 {
|
||||||
|
resolvedAppxCoordinate = appxCoordinate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
completion(mapGeoAddress, resolvedAppxCoordinate, address, cityName, streetName, countryCode, placemark?.street != nil)
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
if case let .location(coordinate, address, global) = state.selectedLocation, address == nil {
|
if case let .location(coordinate, address, global) = state.selectedLocation, address == nil {
|
||||||
setupGeocoding(coordinate, { [weak self] geoAddress, address, cityName, streetName, countryCode, isStreet in
|
setupGeocoding(coordinate, false, { [weak self] geoAddress, _, address, cityName, streetName, countryCode, isStreet in
|
||||||
self?.updateState { state in
|
self?.updateState { state in
|
||||||
var state = state
|
var state = state
|
||||||
state.selectedLocation = .location(coordinate, address, global)
|
state.selectedLocation = .location(coordinate, address, global)
|
||||||
@ -866,10 +919,11 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
|||||||
} else {
|
} else {
|
||||||
let coordinate = controller.initialLocation ?? userLocation?.coordinate
|
let coordinate = controller.initialLocation ?? userLocation?.coordinate
|
||||||
if case .none = state.selectedLocation, let coordinate, state.city == nil {
|
if case .none = state.selectedLocation, let coordinate, state.city == nil {
|
||||||
setupGeocoding(coordinate, { [weak self] geoAddress, address, cityName, streetName, countryCode, isStreet in
|
setupGeocoding(coordinate, true, { [weak self] geoAddress, appxCoordinate, address, cityName, streetName, countryCode, isStreet in
|
||||||
self?.updateState { state in
|
self?.updateState { state in
|
||||||
var state = state
|
var state = state
|
||||||
state.geoAddress = geoAddress
|
state.geoAddress = geoAddress
|
||||||
|
state.appxCoordinate = appxCoordinate
|
||||||
state.city = cityName
|
state.city = cityName
|
||||||
state.street = streetName
|
state.street = streetName
|
||||||
state.countryCode = countryCode
|
state.countryCode = countryCode
|
||||||
|
@ -873,7 +873,7 @@ class StatsOverviewItemNode: ListViewItemNode {
|
|||||||
item.presentationData,
|
item.presentationData,
|
||||||
presentationStringsFormattedNumber(Int32(stats.balances.availableBalance), item.presentationData.dateTimeFormat.groupingSeparator),
|
presentationStringsFormattedNumber(Int32(stats.balances.availableBalance), item.presentationData.dateTimeFormat.groupingSeparator),
|
||||||
item.presentationData.strings.Monetization_StarsProceeds_Available,
|
item.presentationData.strings.Monetization_StarsProceeds_Available,
|
||||||
(stats.balances.availableBalance == 0 ? "" : "≈\(formatTonUsdValue(stats.balances.availableBalance, rate: stats.usdRate, dateTimeFormat: item.presentationData.dateTimeFormat))", .generic),
|
(stats.balances.availableBalance == 0 ? "" : "≈\(formatTonUsdValue(stats.balances.availableBalance, divide: false, rate: stats.usdRate, dateTimeFormat: item.presentationData.dateTimeFormat))", .generic),
|
||||||
.stars
|
.stars
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -883,7 +883,7 @@ class StatsOverviewItemNode: ListViewItemNode {
|
|||||||
item.presentationData,
|
item.presentationData,
|
||||||
presentationStringsFormattedNumber(Int32(stats.balances.currentBalance), item.presentationData.dateTimeFormat.groupingSeparator),
|
presentationStringsFormattedNumber(Int32(stats.balances.currentBalance), item.presentationData.dateTimeFormat.groupingSeparator),
|
||||||
item.presentationData.strings.Monetization_StarsProceeds_Current,
|
item.presentationData.strings.Monetization_StarsProceeds_Current,
|
||||||
(stats.balances.currentBalance == 0 ? "" : "≈\(formatTonUsdValue(stats.balances.currentBalance, rate: stats.usdRate, dateTimeFormat: item.presentationData.dateTimeFormat))", .generic),
|
(stats.balances.currentBalance == 0 ? "" : "≈\(formatTonUsdValue(stats.balances.currentBalance, divide: false, rate: stats.usdRate, dateTimeFormat: item.presentationData.dateTimeFormat))", .generic),
|
||||||
.stars
|
.stars
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -893,7 +893,7 @@ class StatsOverviewItemNode: ListViewItemNode {
|
|||||||
item.presentationData,
|
item.presentationData,
|
||||||
presentationStringsFormattedNumber(Int32(stats.balances.overallRevenue), item.presentationData.dateTimeFormat.groupingSeparator),
|
presentationStringsFormattedNumber(Int32(stats.balances.overallRevenue), item.presentationData.dateTimeFormat.groupingSeparator),
|
||||||
item.presentationData.strings.Monetization_StarsProceeds_Total,
|
item.presentationData.strings.Monetization_StarsProceeds_Total,
|
||||||
(stats.balances.overallRevenue == 0 ? "" : "≈\(formatTonUsdValue(stats.balances.overallRevenue, rate: stats.usdRate, dateTimeFormat: item.presentationData.dateTimeFormat))", .generic),
|
(stats.balances.overallRevenue == 0 ? "" : "≈\(formatTonUsdValue(stats.balances.overallRevenue, divide: false, rate: stats.usdRate, dateTimeFormat: item.presentationData.dateTimeFormat))", .generic),
|
||||||
.stars
|
.stars
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -331,11 +331,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
|
|||||||
self.updateScreenBrightness(isFlashOn: isFlashOn)
|
self.updateScreenBrightness(isFlashOn: isFlashOn)
|
||||||
|
|
||||||
if controller.cameraState.position == .back {
|
if controller.cameraState.position == .back {
|
||||||
if isFlashOn {
|
camera.setTorchActive(isFlashOn)
|
||||||
camera.setTorchActive(true)
|
|
||||||
} else {
|
|
||||||
camera.setTorchActive(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user