diff --git a/submodules/LocationUI/BUCK b/submodules/LocationUI/BUCK index d43367add4..81ccd85fdc 100644 --- a/submodules/LocationUI/BUCK +++ b/submodules/LocationUI/BUCK @@ -30,5 +30,6 @@ static_library( "$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/UIKit.framework", "$SDKROOT/System/Library/Frameworks/CoreLocation.framework", + "$SDKROOT/System/Library/Frameworks/MapKit.framework", ], ) diff --git a/submodules/LocationUI/Sources/LocationActionListItem.swift b/submodules/LocationUI/Sources/LocationActionListItem.swift index a2cf5664d9..c605ebfd52 100644 --- a/submodules/LocationUI/Sources/LocationActionListItem.swift +++ b/submodules/LocationUI/Sources/LocationActionListItem.swift @@ -8,7 +8,6 @@ import TelegramCore import SyncCore import TelegramPresentationData import ItemListUI -import PresentationDataUtils import LocationResources import AppBundle @@ -58,7 +57,7 @@ private func generateLocationIcon(theme: PresentationTheme) -> UIImage { context.scaleBy(x: 1.0, y: -1.0) context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0) - if let image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/LocationPinForeground"), color: theme.chat.inputPanel.actionControlForegroundColor) { + if let image = generateTintedImage(image: UIImage(bundleImageName: "Location/SendLocationIcon"), color: theme.chat.inputPanel.actionControlForegroundColor) { context.draw(image.cgImage!, in: CGRect(origin: CGPoint(x: floor((size.width - image.size.width) / 2.0), y: floor((size.height - image.size.height) / 2.0)), size: image.size)) } }! @@ -74,7 +73,7 @@ private func generateLiveLocationIcon(theme: PresentationTheme) -> UIImage { context.scaleBy(x: 1.0, y: -1.0) context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0) - if let image = generateTintedImage(image: UIImage(bundleImageName: "Location/LiveLocationIcon"), color: theme.chat.inputPanel.actionControlForegroundColor) { + if let image = generateTintedImage(image: UIImage(bundleImageName: "Location/SendLiveLocationIcon"), color: theme.chat.inputPanel.actionControlForegroundColor) { context.draw(image.cgImage!, in: CGRect(origin: CGPoint(x: floor((size.width - image.size.width) / 2.0), y: floor((size.height - image.size.height) / 2.0)), size: image.size)) } }! @@ -87,14 +86,16 @@ public class LocationActionListItem: ListViewItem { let subtitle: String let icon: LocationActionListItemIcon let action: () -> Void + let highlighted: (Bool) -> Void - public init(presentationData: ItemListPresentationData, account: Account, title: String, subtitle: String, icon: LocationActionListItemIcon, action: @escaping () -> Void) { + public init(presentationData: ItemListPresentationData, account: Account, title: String, subtitle: String, icon: LocationActionListItemIcon, action: @escaping () -> Void, highlighted: @escaping (Bool) -> Void = { _ in }) { self.presentationData = presentationData self.account = account self.title = title self.subtitle = subtitle self.icon = icon self.action = action + self.highlighted = highlighted } public func nodeConfiguredForParams(async: @escaping (@escaping () -> Void) -> Void, params: ListViewItemLayoutParams, synchronousLoads: Bool, previousItem: ListViewItem?, nextItem: ListViewItem?, completion: @escaping (ListViewItemNode, @escaping () -> (Signal?, (ListViewItemApply) -> Void)) -> Void) { @@ -130,7 +131,7 @@ public class LocationActionListItem: ListViewItem { } public func selected(listView: ListView) { - listView.clearHighlightAnimated(true) + listView.clearHighlightAnimated(false) self.action() } } @@ -184,6 +185,8 @@ class LocationActionListItemNode: ListViewItemNode { override func setHighlighted(_ highlighted: Bool, at point: CGPoint, animated: Bool) { super.setHighlighted(highlighted, at: point, animated: animated) + self.item?.highlighted(highlighted) + if highlighted { self.highlightedBackgroundNode.alpha = 1.0 if self.highlightedBackgroundNode.supernode == nil { diff --git a/submodules/LocationUI/Sources/LocationMapHeaderNode.swift b/submodules/LocationUI/Sources/LocationMapHeaderNode.swift index fd525773a6..30123cce26 100644 --- a/submodules/LocationUI/Sources/LocationMapHeaderNode.swift +++ b/submodules/LocationUI/Sources/LocationMapHeaderNode.swift @@ -22,12 +22,12 @@ private func generateBackgroundImage(theme: PresentationTheme) -> UIImage? { } } -private func generateShadowImage(theme: PresentationTheme) -> UIImage? { +private func generateShadowImage(theme: PresentationTheme, highlighted: Bool) -> UIImage? { return generateImage(CGSize(width: 26.0, height: 14.0)) { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) context.setShadow(offset: CGSize(), blur: 10.0, color: UIColor(rgb: 0x000000, alpha: 0.2).cgColor) - context.setFillColor(theme.list.plainBackgroundColor.cgColor) + context.setFillColor(highlighted ? theme.list.itemHighlightedBackgroundColor.cgColor : theme.list.plainBackgroundColor.cgColor) let path = UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: 0.0, y: 4.0), size: CGSize(width: 26.0, height: 20.0)), cornerRadius: 9.0) context.addPath(path.cgPath) context.fillPath() @@ -35,6 +35,7 @@ private func generateShadowImage(theme: PresentationTheme) -> UIImage? { } final class LocationMapHeaderNode: ASDisplayNode { + private var presentationData: PresentationData private let interaction: LocationPickerInteraction let mapNode: LocationMapNode @@ -44,6 +45,7 @@ final class LocationMapHeaderNode: ASDisplayNode { private let shadowNode: ASImageNode init(presentationData: PresentationData, interaction: LocationPickerInteraction) { + self.presentationData = presentationData self.interaction = interaction self.mapNode = LocationMapNode() @@ -66,7 +68,7 @@ final class LocationMapHeaderNode: ASDisplayNode { self.shadowNode.contentMode = .scaleToFill self.shadowNode.displaysAsynchronously = false self.shadowNode.displayWithoutProcessing = true - self.shadowNode.image = generateShadowImage(theme: presentationData.theme) + self.shadowNode.image = generateShadowImage(theme: presentationData.theme, highlighted: false) super.init() @@ -88,12 +90,14 @@ final class LocationMapHeaderNode: ASDisplayNode { } func updatePresentationData(_ presentationData: PresentationData) { + self.presentationData = presentationData + self.optionsBackgroundNode.image = generateBackgroundImage(theme: presentationData.theme) self.infoButtonNode.setImage(generateTintedImage(image: UIImage(bundleImageName: "Location/InfoIcon"), color: presentationData.theme.rootController.navigationBar.buttonColor), for: .normal) self.infoButtonNode.setImage(generateTintedImage(image: UIImage(bundleImageName: "Location/InfoActiveIcon"), color: presentationData.theme.rootController.navigationBar.buttonColor), for: .selected) self.infoButtonNode.setImage(generateTintedImage(image: UIImage(bundleImageName: "Location/InfoActiveIcon"), color: presentationData.theme.rootController.navigationBar.buttonColor), for: [.selected, .highlighted]) self.locationButtonNode.setImage(generateTintedImage(image: UIImage(bundleImageName: "Location/TrackIcon"), color: presentationData.theme.rootController.navigationBar.buttonColor), for: .normal) - self.shadowNode.image = generateShadowImage(theme: presentationData.theme) + self.shadowNode.image = generateShadowImage(theme: presentationData.theme, highlighted: false) } func updateLayout(layout: ContainerViewLayout, navigationBarHeight: CGFloat, padding: CGFloat, size: CGSize, transition: ContainedViewLayoutTransition) { @@ -112,6 +116,10 @@ final class LocationMapHeaderNode: ASDisplayNode { alphaTransition.updateAlpha(node: self.optionsBackgroundNode, alpha: optionsAlpha) } + func updateHighlight(_ highlighted: Bool) { + self.shadowNode.image = generateShadowImage(theme: self.presentationData.theme, highlighted: highlighted) + } + @objc private func infoPressed() { self.interaction.toggleMapModeSelection() } diff --git a/submodules/LocationUI/Sources/LocationPickerController.swift b/submodules/LocationUI/Sources/LocationPickerController.swift index 640ac42f8c..563664517a 100644 --- a/submodules/LocationUI/Sources/LocationPickerController.swift +++ b/submodules/LocationUI/Sources/LocationPickerController.swift @@ -31,7 +31,9 @@ class LocationPickerInteraction { let dismissInput: () -> Void - init(sendLocation: @escaping (CLLocationCoordinate2D) -> Void, sendLiveLocation: @escaping (CLLocationCoordinate2D) -> Void, sendVenue: @escaping (TelegramMediaMap) -> Void, toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, goToUserLocation: @escaping () -> Void, openSearch: @escaping () -> Void, updateSearchQuery: @escaping (String) -> Void, dismissSearch: @escaping () -> Void, dismissInput: @escaping () -> Void) { + let updateSendActionHighlight: (Bool) -> Void + + init(sendLocation: @escaping (CLLocationCoordinate2D) -> Void, sendLiveLocation: @escaping (CLLocationCoordinate2D) -> Void, sendVenue: @escaping (TelegramMediaMap) -> Void, toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, goToUserLocation: @escaping () -> Void, openSearch: @escaping () -> Void, updateSearchQuery: @escaping (String) -> Void, dismissSearch: @escaping () -> Void, dismissInput: @escaping () -> Void, updateSendActionHighlight: @escaping (Bool) -> Void) { self.sendLocation = sendLocation self.sendLiveLocation = sendLiveLocation self.sendVenue = sendVenue @@ -42,6 +44,7 @@ class LocationPickerInteraction { self.updateSearchQuery = updateSearchQuery self.dismissSearch = dismissSearch self.dismissInput = dismissInput + self.updateSendActionHighlight = updateSendActionHighlight } } @@ -212,6 +215,11 @@ public final class LocationPickerController: ViewController { return } strongSelf.searchNavigationContentNode?.deactivate() + }, updateSendActionHighlight: { [weak self] highlighted in + guard let strongSelf = self else { + return + } + strongSelf.controllerNode.updateSendActionHighlight(highlighted) }) self.scrollToTop = { [weak self] in @@ -235,9 +243,6 @@ public final class LocationPickerController: ViewController { } self.displayNode = LocationPickerControllerNode(context: self.context, presentationData: self.presentationData, mode: self.mode, interaction: interaction) - self.controllerNode.present = { [weak self] c, a in - self?.present(c, in: .window(.root), with: a) - } self.displayNodeDidLoad() self._ready.set(.single(true)) diff --git a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift index 9a6338f9d3..583f33e044 100644 --- a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift @@ -138,6 +138,8 @@ private enum LocationPickerEntry: Comparable, Identifiable { if let coordinate = coordinate { interaction?.sendLocation(coordinate) } + }, highlighted: { highlighted in + interaction?.updateSendActionHighlight(highlighted) }) case let .liveLocation(theme, title, subtitle, coordinate): return LocationActionListItem(presentationData: ItemListPresentationData(presentationData), account: account, title: title, subtitle: subtitle, icon: .liveLocation, action: { @@ -218,9 +220,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode { private var validLayout: (layout: ContainerViewLayout, navigationHeight: CGFloat)? private var listOffset: CGFloat? - - var present: ((ViewController, Any?) -> Void)? - + init(context: AccountContext, presentationData: PresentationData, mode: LocationPickerMode, interaction: LocationPickerInteraction) { self.context = context self.presentationData = presentationData @@ -606,4 +606,8 @@ final class LocationPickerControllerNode: ViewControllerTracingNode { searchContainerNode.containerLayoutUpdated(ContainerViewLayout(size: layout.size, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: layout.intrinsicInsets, safeInsets: layout.safeInsets, statusBarHeight: nil, inputHeight: layout.inputHeight, inputHeightIsInteractivellyChanging: layout.inputHeightIsInteractivellyChanging, inVoiceOver: layout.inVoiceOver), navigationBarHeight: navigationHeight, transition: transition) } } + + func updateSendActionHighlight(_ highlighted: Bool) { + self.headerNode.updateHighlight(highlighted) + } } diff --git a/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/Contents.json deleted file mode 100644 index 3afe81c36f..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/Contents.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "LocationMessageLiveIcon@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "filename" : "LocationMessageLiveIcon@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/LocationMessageLiveIcon@2x.png b/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/LocationMessageLiveIcon@2x.png deleted file mode 100644 index 92170e69ac..0000000000 Binary files a/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/LocationMessageLiveIcon@2x.png and /dev/null differ diff --git a/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/LocationMessageLiveIcon@3x.png b/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/LocationMessageLiveIcon@3x.png deleted file mode 100644 index 40f071a3b0..0000000000 Binary files a/submodules/TelegramUI/Images.xcassets/Location/LiveLocationIcon.imageset/LocationMessageLiveIcon@3x.png and /dev/null differ diff --git a/submodules/TelegramUI/Images.xcassets/Location/SendLiveLocationIcon.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Location/SendLiveLocationIcon.imageset/Contents.json new file mode 100644 index 0000000000..57e11d6b79 --- /dev/null +++ b/submodules/TelegramUI/Images.xcassets/Location/SendLiveLocationIcon.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_mappinlive.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/submodules/TelegramUI/Images.xcassets/Location/SendLiveLocationIcon.imageset/ic_mappinlive.pdf b/submodules/TelegramUI/Images.xcassets/Location/SendLiveLocationIcon.imageset/ic_mappinlive.pdf new file mode 100644 index 0000000000..acaa40c811 Binary files /dev/null and b/submodules/TelegramUI/Images.xcassets/Location/SendLiveLocationIcon.imageset/ic_mappinlive.pdf differ diff --git a/submodules/TelegramUI/Images.xcassets/Location/SendLocationIcon.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Location/SendLocationIcon.imageset/Contents.json new file mode 100644 index 0000000000..82b9aa1e74 --- /dev/null +++ b/submodules/TelegramUI/Images.xcassets/Location/SendLocationIcon.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_mappin.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/submodules/TelegramUI/Images.xcassets/Location/SendLocationIcon.imageset/ic_mappin.pdf b/submodules/TelegramUI/Images.xcassets/Location/SendLocationIcon.imageset/ic_mappin.pdf new file mode 100644 index 0000000000..d2291b336f Binary files /dev/null and b/submodules/TelegramUI/Images.xcassets/Location/SendLocationIcon.imageset/ic_mappin.pdf differ