diff --git a/submodules/DrawingUI/Sources/DrawingLocationEntity.swift b/submodules/DrawingUI/Sources/DrawingLocationEntity.swift index 5f2eefede7..23c293d3e1 100644 --- a/submodules/DrawingUI/Sources/DrawingLocationEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingLocationEntity.swift @@ -70,7 +70,7 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg self.textView.keyboardAppearance = .dark self.textView.autocorrectionType = .default self.textView.spellCheckingType = .no - self.textView.textContainer.maximumNumberOfLines = 1 + self.textView.textContainer.maximumNumberOfLines = 2 self.textView.textContainer.lineBreakMode = .byTruncatingTail self.iconView = UIImageView() @@ -111,7 +111,7 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg public override func layoutSubviews() { super.layoutSubviews() - let iconSize = floor(self.bounds.height * 0.6) + let iconSize = min(76.0, floor(self.bounds.height * 0.6)) self.iconView.frame = CGRect(origin: CGPoint(x: floor(iconSize * 0.2), y: floorToScreenPixels((self.bounds.height - iconSize) / 2.0)), size: CGSize(width: iconSize, height: iconSize)) self.textView.frame = CGRect(origin: CGPoint(x: self.bounds.width - self.textSize.width, y: floorToScreenPixels((self.bounds.height - self.textSize.height) / 2.0)), size: self.textSize) self.backgroundView.frame = self.bounds @@ -165,7 +165,7 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg self.textView.font = font let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.alignment = .right + paragraphStyle.alignment = .left text.addAttribute(.paragraphStyle, value: paragraphStyle, range: range) let textColor: UIColor @@ -202,7 +202,7 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg self.textView.textColor = .white self.backgroundView.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.2) } - self.textView.textAlignment = .right + self.textView.textAlignment = .left self.updateText() diff --git a/submodules/LocationUI/Sources/LocationInfoListItem.swift b/submodules/LocationUI/Sources/LocationInfoListItem.swift index aea066e37b..915a36b7f0 100644 --- a/submodules/LocationUI/Sources/LocationInfoListItem.swift +++ b/submodules/LocationUI/Sources/LocationInfoListItem.swift @@ -342,7 +342,7 @@ final class LocationInfoListItemNode: ListViewItemNode { shapes.append(.roundedRectLine(startPoint: CGPoint(x: directionsWidth + directionsSpacing, y: 0.0), width: directionsWidth, diameter: 32.0)) shapes.append(.roundedRectLine(startPoint: CGPoint(x: directionsWidth + directionsSpacing + directionsWidth + directionsSpacing, y: 0.0), width: directionsWidth, diameter: 32.0)) - shimmerNode.update(backgroundColor: item.presentationData.theme.list.itemBlocksBackgroundColor, foregroundColor: item.presentationData.theme.list.mediaPlaceholderColor, shimmeringColor: item.presentationData.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), shapes: shapes, size: shimmerNode.frame.size) + shimmerNode.update(backgroundColor: item.presentationData.theme.list.plainBackgroundColor, foregroundColor: item.presentationData.theme.list.mediaPlaceholderColor, shimmeringColor: item.presentationData.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), shapes: shapes, size: shimmerNode.frame.size) } else if let shimmerNode = strongSelf.placeholderNode { strongSelf.placeholderNode = nil shimmerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak shimmerNode] _ in diff --git a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift index 7caa6e9527..a68645f6a0 100644 --- a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift @@ -37,7 +37,7 @@ private enum LocationPickerEntryId: Hashable { private enum LocationPickerEntry: Comparable, Identifiable { case city(PresentationTheme, String, String, TelegramMediaMap?, Int64?, String?, CLLocationCoordinate2D?, String?) - case location(PresentationTheme, String, String, TelegramMediaMap?, Int64?, String?, CLLocationCoordinate2D?, String?) + case location(PresentationTheme, String, String, TelegramMediaMap?, Int64?, String?, CLLocationCoordinate2D?, String?, Bool) case liveLocation(PresentationTheme, String, String, CLLocationCoordinate2D?) case header(PresentationTheme, String) case venue(PresentationTheme, TelegramMediaMap?, Int64?, String?, Int) @@ -68,8 +68,8 @@ private enum LocationPickerEntry: Comparable, Identifiable { } else { return false } - case let .location(lhsTheme, lhsTitle, lhsSubtitle, lhsVenue, lhsQueryId, lhsResultId, lhsCoordinate, lhsName): - if case let .location(rhsTheme, rhsTitle, rhsSubtitle, rhsVenue, rhsQueryId, rhsResultId, rhsCoordinate, rhsName) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, lhsVenue?.venue?.id == rhsVenue?.venue?.id, lhsQueryId == rhsQueryId && lhsResultId == rhsResultId, lhsCoordinate == rhsCoordinate, lhsName == rhsName { + case let .location(lhsTheme, lhsTitle, lhsSubtitle, lhsVenue, lhsQueryId, lhsResultId, lhsCoordinate, lhsName, lhsIsTop): + if case let .location(rhsTheme, rhsTitle, rhsSubtitle, rhsVenue, rhsQueryId, rhsResultId, rhsCoordinate, rhsName, rhsIsTop) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, lhsVenue?.venue?.id == rhsVenue?.venue?.id, lhsQueryId == rhsQueryId && lhsResultId == rhsResultId, lhsCoordinate == rhsCoordinate, lhsName == rhsName, lhsIsTop == rhsIsTop { return true } else { return false @@ -161,7 +161,7 @@ private enum LocationPickerEntry: Comparable, Identifiable { }, highlighted: { highlighted in interaction?.updateSendActionHighlight(highlighted) }) - case let .location(_, title, subtitle, venue, queryId, resultId, coordinate, name): + case let .location(_, title, subtitle, venue, queryId, resultId, coordinate, name, isTop): let icon: LocationActionListItemIcon if let venue = venue { icon = .venue(venue) @@ -175,7 +175,9 @@ private enum LocationPickerEntry: Comparable, Identifiable { interaction?.sendLocation(coordinate, name) } }, highlighted: { highlighted in - interaction?.updateSendActionHighlight(highlighted) + if isTop { + interaction?.updateSendActionHighlight(highlighted) + } }) case let .liveLocation(_, title, subtitle, coordinate): return LocationActionListItem(presentationData: ItemListPresentationData(presentationData), engine: engine, title: title, subtitle: subtitle, icon: .liveLocation, beginTimeAndTimeout: nil, action: { @@ -585,7 +587,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM case .pick: title = presentationData.strings.Map_SetThisLocation } - entries.append(.location(presentationData.theme, title, address ?? presentationData.strings.Map_Locating, nil, nil, nil, coordinate, state.street)) + entries.append(.location(presentationData.theme, title, address ?? presentationData.strings.Map_Locating, nil, nil, nil, coordinate, state.street, true)) case .selecting: let title: String switch strongSelf.mode { @@ -598,7 +600,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM case .pick: title = presentationData.strings.Map_SetThisLocation } - entries.append(.location(presentationData.theme, title, presentationData.strings.Map_Locating, nil, nil, nil, nil, nil)) + entries.append(.location(presentationData.theme, title, presentationData.strings.Map_Locating, nil, nil, nil, nil, nil, true)) case let .venue(venue, queryId, resultId): let title: String switch strongSelf.mode { @@ -607,7 +609,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM case .pick: title = presentationData.strings.Map_SetThisPlace } - entries.append(.location(presentationData.theme, title, venue.venue?.title ?? "", venue, queryId, resultId, venue.coordinate, nil)) + entries.append(.location(presentationData.theme, title, venue.venue?.title ?? "", venue, queryId, resultId, venue.coordinate, nil, true)) case .none: let title: String var coordinate = userLocation?.coordinate @@ -627,10 +629,14 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM title = presentationData.strings.Map_SetThisLocation } if source == .story { - entries.append(.city(presentationData.theme, state.city ?? presentationData.strings.Map_Locating, "City", nil, nil, nil, coordinate, state.city)) - entries.append(.location(presentationData.theme, state.street ?? presentationData.strings.Map_Locating, "Street", nil, nil, nil, coordinate, state.street)) + if state.city != "" { + entries.append(.city(presentationData.theme, state.city ?? presentationData.strings.Map_Locating, "City", nil, nil, nil, coordinate, state.city)) + } + if state.street != "" { + entries.append(.location(presentationData.theme, state.street ?? presentationData.strings.Map_Locating, "Street", nil, nil, nil, coordinate, state.street, false)) + } } else { - entries.append(.location(presentationData.theme, title, (userLocation?.horizontalAccuracy).flatMap { presentationData.strings.Map_AccurateTo(stringForDistance(strings: presentationData.strings, distance: $0)).string } ?? presentationData.strings.Map_Locating, nil, nil, nil, coordinate, state.street)) + entries.append(.location(presentationData.theme, title, (userLocation?.horizontalAccuracy).flatMap { presentationData.strings.Map_AccurateTo(stringForDistance(strings: presentationData.strings, distance: $0)).string } ?? presentationData.strings.Map_Locating, nil, nil, nil, coordinate, state.street, true)) } } @@ -781,9 +787,20 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM var streetName: String? if let city = placemark?.city, let country = placemark?.country { cityName = "\(city), \(country)" + } else { + cityName = "" } - if let street = placemark?.street, let city = placemark?.city { - streetName = "\(street), \(city)" + if let street = placemark?.street { + if let city = placemark?.city { + streetName = "\(street), \(city)" + } else { + streetName = street + } + } else { + streetName = "" + } + if streetName == "" && cityName == "" { + streetName = "Location" } strongSelf.updateState { state in var state = state @@ -808,9 +825,20 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM var streetName: String? if let city = placemark?.city, let country = placemark?.country { cityName = "\(city), \(country)" + } else { + cityName = "" } - if let street = placemark?.street, let city = placemark?.city { - streetName = "\(street), \(city)" + if let street = placemark?.street { + if let city = placemark?.city { + streetName = "\(street), \(city)" + } else { + streetName = street + } + } else { + streetName = "" + } + if streetName == "" && cityName == "" { + streetName = "Location" } strongSelf.updateState { state in var state = state diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 7da31228f6..0ea9957fc1 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -804,7 +804,7 @@ public final class StoryItemSetContainerComponent: Component { let rotatedX = tx * cosTheta - ty * sinTheta let rotatedY = tx * sinTheta + ty * cosTheta - return abs(rotatedX) <= area.coordinates.width / 100.0 * referenceSize.width / 2.0 && abs(rotatedY) <= area.coordinates.height / 100.0 * referenceSize.height / 2.0 + return abs(rotatedX) <= area.coordinates.width / 100.0 * referenceSize.width / 2.0 * 1.1 && abs(rotatedY) <= area.coordinates.height / 100.0 * referenceSize.height / 2.0 * 1.1 } for area in component.slice.item.storyItem.mediaAreas { diff --git a/submodules/TranslateUI/Sources/LanguageSelectionController.swift b/submodules/TranslateUI/Sources/LanguageSelectionController.swift index 0f00678760..a9d2e4ea86 100644 --- a/submodules/TranslateUI/Sources/LanguageSelectionController.swift +++ b/submodules/TranslateUI/Sources/LanguageSelectionController.swift @@ -90,7 +90,7 @@ private struct LanguageSelectionControllerState: Equatable { var toLanguage: String } -public func languageSelectionController(context: AccountContext, fromLanguage: String, toLanguage: String, completion: @escaping (String, String) -> Void) -> ViewController { +public func languageSelectionController(context: AccountContext, forceTheme: PresentationTheme? = nil, fromLanguage: String, toLanguage: String, completion: @escaping (String, String) -> Void) -> ViewController { let statePromise = ValuePromise(LanguageSelectionControllerState(section: .translation, fromLanguage: fromLanguage, toLanguage: toLanguage), ignoreRepeated: true) let stateValue = Atomic(value: LanguageSelectionControllerState(section: .translation, fromLanguage: fromLanguage, toLanguage: toLanguage)) let updateState: ((LanguageSelectionControllerState) -> LanguageSelectionControllerState) -> Void = { f in @@ -149,6 +149,10 @@ public func languageSelectionController(context: AccountContext, fromLanguage: S let signal = combineLatest(queue: Queue.mainQueue(), context.sharedContext.presentationData, statePromise.get()) |> map { presentationData, state -> (ItemListControllerState, (ItemListNodeState, Any)) in + var presentationData = presentationData + if let forceTheme { + presentationData = presentationData.withUpdated(theme: forceTheme) + } let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .sectionControl([presentationData.strings.Translate_Languages_Original, presentationData.strings.Translate_Languages_Translation], 1), leftNavigationButton: ItemListNavigationButton(content: .none, style: .regular, enabled: false, action: {}), rightNavigationButton: ItemListNavigationButton(content: .text(presentationData.strings.Common_Done), style: .bold, enabled: true, action: { completion(state.fromLanguage, state.toLanguage) dismissImpl?() diff --git a/submodules/TranslateUI/Sources/TranslateScreen.swift b/submodules/TranslateUI/Sources/TranslateScreen.swift index 68d096e956..66cd55f4be 100644 --- a/submodules/TranslateUI/Sources/TranslateScreen.swift +++ b/submodules/TranslateUI/Sources/TranslateScreen.swift @@ -1043,8 +1043,8 @@ public class TranslateScreen: ViewController { changeLanguageImpl = { [weak self] fromLang, toLang, completion in let pushController = self?.pushController let presentController = self?.presentController - let controller = languageSelectionController(context: context, fromLanguage: fromLang, toLanguage: toLang, completion: { fromLang, toLang in - let controller = TranslateScreen(context: context, text: text, canCopy: canCopy, fromLanguage: fromLang, toLanguage: toLang, isExpanded: true) + let controller = languageSelectionController(context: context, forceTheme: forceTheme, fromLanguage: fromLang, toLanguage: toLang, completion: { fromLang, toLang in + let controller = TranslateScreen(context: context, forceTheme: forceTheme, text: text, canCopy: canCopy, fromLanguage: fromLang, toLanguage: toLang, isExpanded: true) controller.pushController = pushController ?? { _ in } controller.presentController = presentController ?? { _ in } presentController?(controller)