Fix build

This commit is contained in:
Ilya Laktyushin
2019-11-25 14:33:30 +04:00
parent 6e3969cd46
commit 4ca3b5c6fb
12 changed files with 61 additions and 38 deletions

View File

@@ -30,5 +30,6 @@ static_library(
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/UIKit.framework", "$SDKROOT/System/Library/Frameworks/UIKit.framework",
"$SDKROOT/System/Library/Frameworks/CoreLocation.framework", "$SDKROOT/System/Library/Frameworks/CoreLocation.framework",
"$SDKROOT/System/Library/Frameworks/MapKit.framework",
], ],
) )

View File

@@ -8,7 +8,6 @@ import TelegramCore
import SyncCore import SyncCore
import TelegramPresentationData import TelegramPresentationData
import ItemListUI import ItemListUI
import PresentationDataUtils
import LocationResources import LocationResources
import AppBundle import AppBundle
@@ -58,7 +57,7 @@ private func generateLocationIcon(theme: PresentationTheme) -> UIImage {
context.scaleBy(x: 1.0, y: -1.0) context.scaleBy(x: 1.0, y: -1.0)
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.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)) 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.scaleBy(x: 1.0, y: -1.0)
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.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)) 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 subtitle: String
let icon: LocationActionListItemIcon let icon: LocationActionListItemIcon
let action: () -> Void 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.presentationData = presentationData
self.account = account self.account = account
self.title = title self.title = title
self.subtitle = subtitle self.subtitle = subtitle
self.icon = icon self.icon = icon
self.action = action 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<Void, NoError>?, (ListViewItemApply) -> Void)) -> Void) { public func nodeConfiguredForParams(async: @escaping (@escaping () -> Void) -> Void, params: ListViewItemLayoutParams, synchronousLoads: Bool, previousItem: ListViewItem?, nextItem: ListViewItem?, completion: @escaping (ListViewItemNode, @escaping () -> (Signal<Void, NoError>?, (ListViewItemApply) -> Void)) -> Void) {
@@ -130,7 +131,7 @@ public class LocationActionListItem: ListViewItem {
} }
public func selected(listView: ListView) { public func selected(listView: ListView) {
listView.clearHighlightAnimated(true) listView.clearHighlightAnimated(false)
self.action() self.action()
} }
} }
@@ -184,6 +185,8 @@ class LocationActionListItemNode: ListViewItemNode {
override func setHighlighted(_ highlighted: Bool, at point: CGPoint, animated: Bool) { override func setHighlighted(_ highlighted: Bool, at point: CGPoint, animated: Bool) {
super.setHighlighted(highlighted, at: point, animated: animated) super.setHighlighted(highlighted, at: point, animated: animated)
self.item?.highlighted(highlighted)
if highlighted { if highlighted {
self.highlightedBackgroundNode.alpha = 1.0 self.highlightedBackgroundNode.alpha = 1.0
if self.highlightedBackgroundNode.supernode == nil { if self.highlightedBackgroundNode.supernode == nil {

View File

@@ -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 return generateImage(CGSize(width: 26.0, height: 14.0)) { size, context in
context.clear(CGRect(origin: CGPoint(), size: size)) context.clear(CGRect(origin: CGPoint(), size: size))
context.setShadow(offset: CGSize(), blur: 10.0, color: UIColor(rgb: 0x000000, alpha: 0.2).cgColor) 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) 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.addPath(path.cgPath)
context.fillPath() context.fillPath()
@@ -35,6 +35,7 @@ private func generateShadowImage(theme: PresentationTheme) -> UIImage? {
} }
final class LocationMapHeaderNode: ASDisplayNode { final class LocationMapHeaderNode: ASDisplayNode {
private var presentationData: PresentationData
private let interaction: LocationPickerInteraction private let interaction: LocationPickerInteraction
let mapNode: LocationMapNode let mapNode: LocationMapNode
@@ -44,6 +45,7 @@ final class LocationMapHeaderNode: ASDisplayNode {
private let shadowNode: ASImageNode private let shadowNode: ASImageNode
init(presentationData: PresentationData, interaction: LocationPickerInteraction) { init(presentationData: PresentationData, interaction: LocationPickerInteraction) {
self.presentationData = presentationData
self.interaction = interaction self.interaction = interaction
self.mapNode = LocationMapNode() self.mapNode = LocationMapNode()
@@ -66,7 +68,7 @@ final class LocationMapHeaderNode: ASDisplayNode {
self.shadowNode.contentMode = .scaleToFill self.shadowNode.contentMode = .scaleToFill
self.shadowNode.displaysAsynchronously = false self.shadowNode.displaysAsynchronously = false
self.shadowNode.displayWithoutProcessing = true self.shadowNode.displayWithoutProcessing = true
self.shadowNode.image = generateShadowImage(theme: presentationData.theme) self.shadowNode.image = generateShadowImage(theme: presentationData.theme, highlighted: false)
super.init() super.init()
@@ -88,12 +90,14 @@ final class LocationMapHeaderNode: ASDisplayNode {
} }
func updatePresentationData(_ presentationData: PresentationData) { func updatePresentationData(_ presentationData: PresentationData) {
self.presentationData = presentationData
self.optionsBackgroundNode.image = generateBackgroundImage(theme: presentationData.theme) 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/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)
self.infoButtonNode.setImage(generateTintedImage(image: UIImage(bundleImageName: "Location/InfoActiveIcon"), color: presentationData.theme.rootController.navigationBar.buttonColor), for: [.selected, .highlighted]) 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.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) { 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) 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() { @objc private func infoPressed() {
self.interaction.toggleMapModeSelection() self.interaction.toggleMapModeSelection()
} }

View File

@@ -31,7 +31,9 @@ class LocationPickerInteraction {
let dismissInput: () -> Void 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.sendLocation = sendLocation
self.sendLiveLocation = sendLiveLocation self.sendLiveLocation = sendLiveLocation
self.sendVenue = sendVenue self.sendVenue = sendVenue
@@ -42,6 +44,7 @@ class LocationPickerInteraction {
self.updateSearchQuery = updateSearchQuery self.updateSearchQuery = updateSearchQuery
self.dismissSearch = dismissSearch self.dismissSearch = dismissSearch
self.dismissInput = dismissInput self.dismissInput = dismissInput
self.updateSendActionHighlight = updateSendActionHighlight
} }
} }
@@ -212,6 +215,11 @@ public final class LocationPickerController: ViewController {
return return
} }
strongSelf.searchNavigationContentNode?.deactivate() strongSelf.searchNavigationContentNode?.deactivate()
}, updateSendActionHighlight: { [weak self] highlighted in
guard let strongSelf = self else {
return
}
strongSelf.controllerNode.updateSendActionHighlight(highlighted)
}) })
self.scrollToTop = { [weak self] in 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.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.displayNodeDidLoad()
self._ready.set(.single(true)) self._ready.set(.single(true))

View File

@@ -138,6 +138,8 @@ private enum LocationPickerEntry: Comparable, Identifiable {
if let coordinate = coordinate { if let coordinate = coordinate {
interaction?.sendLocation(coordinate) interaction?.sendLocation(coordinate)
} }
}, highlighted: { highlighted in
interaction?.updateSendActionHighlight(highlighted)
}) })
case let .liveLocation(theme, title, subtitle, coordinate): case let .liveLocation(theme, title, subtitle, coordinate):
return LocationActionListItem(presentationData: ItemListPresentationData(presentationData), account: account, title: title, subtitle: subtitle, icon: .liveLocation, action: { return LocationActionListItem(presentationData: ItemListPresentationData(presentationData), account: account, title: title, subtitle: subtitle, icon: .liveLocation, action: {
@@ -219,8 +221,6 @@ final class LocationPickerControllerNode: ViewControllerTracingNode {
private var validLayout: (layout: ContainerViewLayout, navigationHeight: CGFloat)? private var validLayout: (layout: ContainerViewLayout, navigationHeight: CGFloat)?
private var listOffset: CGFloat? private var listOffset: CGFloat?
var present: ((ViewController, Any?) -> Void)?
init(context: AccountContext, presentationData: PresentationData, mode: LocationPickerMode, interaction: LocationPickerInteraction) { init(context: AccountContext, presentationData: PresentationData, mode: LocationPickerMode, interaction: LocationPickerInteraction) {
self.context = context self.context = context
self.presentationData = presentationData 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) 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)
}
} }

View File

@@ -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"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

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

View File

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