mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Various Improvements
This commit is contained in:
@@ -17,19 +17,27 @@ final class LocationInfoListItem: ListViewItem {
|
||||
let location: TelegramMediaMap
|
||||
let address: String?
|
||||
let distance: String?
|
||||
let eta: String?
|
||||
let drivingTime: Double?
|
||||
let transitTime: Double?
|
||||
let walkingTime: Double?
|
||||
let action: () -> Void
|
||||
let getDirections: () -> Void
|
||||
let drivingAction: () -> Void
|
||||
let transitAction: () -> Void
|
||||
let walkingAction: () -> Void
|
||||
|
||||
public init(presentationData: ItemListPresentationData, engine: TelegramEngine, location: TelegramMediaMap, address: String?, distance: String?, eta: String?, action: @escaping () -> Void, getDirections: @escaping () -> Void) {
|
||||
public init(presentationData: ItemListPresentationData, engine: TelegramEngine, location: TelegramMediaMap, address: String?, distance: String?, drivingTime: Double?, transitTime: Double?, walkingTime: Double?, action: @escaping () -> Void, drivingAction: @escaping () -> Void, transitAction: @escaping () -> Void, walkingAction: @escaping () -> Void) {
|
||||
self.presentationData = presentationData
|
||||
self.engine = engine
|
||||
self.location = location
|
||||
self.address = address
|
||||
self.distance = distance
|
||||
self.eta = eta
|
||||
self.drivingTime = drivingTime
|
||||
self.transitTime = transitTime
|
||||
self.walkingTime = walkingTime
|
||||
self.action = action
|
||||
self.getDirections = getDirections
|
||||
self.drivingAction = drivingAction
|
||||
self.transitAction = transitAction
|
||||
self.walkingAction = walkingAction
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -71,7 +79,10 @@ final class LocationInfoListItemNode: ListViewItemNode {
|
||||
private var subtitleNode: TextNode?
|
||||
private let venueIconNode: TransformImageNode
|
||||
private let buttonNode: HighlightableButtonNode
|
||||
private var directionsButtonNode: SolidRoundedButtonNode?
|
||||
|
||||
private var drivingButtonNode: SolidRoundedButtonNode?
|
||||
private var transitButtonNode: SolidRoundedButtonNode?
|
||||
private var walkingButtonNode: SolidRoundedButtonNode?
|
||||
|
||||
private var item: LocationInfoListItem?
|
||||
private var layoutParams: ListViewItemLayoutParams?
|
||||
@@ -166,7 +177,7 @@ final class LocationInfoListItemNode: ListViewItemNode {
|
||||
|
||||
let titleSpacing: CGFloat = 1.0
|
||||
let bottomInset: CGFloat = 4.0
|
||||
let contentSize = CGSize(width: params.width, height: max(126.0, verticalInset * 2.0 + titleLayout.size.height + titleSpacing + subtitleLayout.size.height + bottomInset))
|
||||
let contentSize = CGSize(width: params.width, height: max(100.0, verticalInset * 2.0 + titleLayout.size.height + titleSpacing + subtitleLayout.size.height + bottomInset))
|
||||
let nodeLayout = ListViewItemNodeLayout(contentSize: contentSize, insets: UIEdgeInsets())
|
||||
|
||||
return (nodeLayout, { [weak self] in
|
||||
@@ -187,7 +198,6 @@ final class LocationInfoListItemNode: ListViewItemNode {
|
||||
|
||||
if let _ = updatedTheme {
|
||||
strongSelf.backgroundNode.backgroundColor = item.presentationData.theme.list.plainBackgroundColor
|
||||
strongSelf.directionsButtonNode?.updateTheme(SolidRoundedButtonTheme(theme: item.presentationData.theme))
|
||||
}
|
||||
|
||||
let arguments = VenueIconArguments(defaultBackgroundColor: item.presentationData.theme.chat.inputPanel.actionControlFillColor, defaultForegroundColor: item.presentationData.theme.chat.inputPanel.actionControlForegroundColor)
|
||||
@@ -212,19 +222,50 @@ final class LocationInfoListItemNode: ListViewItemNode {
|
||||
strongSelf.addSubnode(subtitleNode)
|
||||
}
|
||||
|
||||
let directionsButtonNode: SolidRoundedButtonNode
|
||||
if let currentDirectionsButtonNode = strongSelf.directionsButtonNode {
|
||||
directionsButtonNode = currentDirectionsButtonNode
|
||||
} else {
|
||||
directionsButtonNode = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(theme: item.presentationData.theme), height: 50.0, cornerRadius: 10.0)
|
||||
directionsButtonNode.title = item.presentationData.strings.Map_Directions
|
||||
directionsButtonNode.pressed = {
|
||||
item.getDirections()
|
||||
let buttonTheme = SolidRoundedButtonTheme(theme: item.presentationData.theme)
|
||||
if strongSelf.drivingButtonNode == nil {
|
||||
strongSelf.drivingButtonNode = SolidRoundedButtonNode(icon: generateTintedImage(image: UIImage(bundleImageName: "Location/DirectionsDriving"), color: item.presentationData.theme.list.itemCheckColors.foregroundColor), theme: buttonTheme, fontSize: 15.0, height: 32.0, cornerRadius: 16.0)
|
||||
strongSelf.drivingButtonNode?.iconSpacing = 5.0
|
||||
strongSelf.drivingButtonNode?.alpha = 0.0
|
||||
strongSelf.drivingButtonNode?.allowsGroupOpacity = true
|
||||
strongSelf.drivingButtonNode?.pressed = { [weak self] in
|
||||
if let item = self?.item {
|
||||
item.drivingAction()
|
||||
}
|
||||
}
|
||||
strongSelf.addSubnode(directionsButtonNode)
|
||||
strongSelf.directionsButtonNode = directionsButtonNode
|
||||
strongSelf.drivingButtonNode.flatMap { strongSelf.addSubnode($0) }
|
||||
|
||||
strongSelf.transitButtonNode = SolidRoundedButtonNode(icon: generateTintedImage(image: UIImage(bundleImageName: "Location/DirectionsTransit"), color: item.presentationData.theme.list.itemCheckColors.foregroundColor), theme: buttonTheme, fontSize: 15.0, height: 32.0, cornerRadius: 16.0)
|
||||
strongSelf.transitButtonNode?.iconSpacing = 2.0
|
||||
strongSelf.transitButtonNode?.alpha = 0.0
|
||||
strongSelf.transitButtonNode?.allowsGroupOpacity = true
|
||||
strongSelf.transitButtonNode?.pressed = { [weak self] in
|
||||
if let item = self?.item {
|
||||
item.transitAction()
|
||||
}
|
||||
}
|
||||
strongSelf.transitButtonNode.flatMap { strongSelf.addSubnode($0) }
|
||||
|
||||
strongSelf.walkingButtonNode = SolidRoundedButtonNode(icon: generateTintedImage(image: UIImage(bundleImageName: "Location/DirectionsWalking"), color: item.presentationData.theme.list.itemCheckColors.foregroundColor), theme: buttonTheme, fontSize: 15.0, height: 32.0, cornerRadius: 16.0)
|
||||
strongSelf.walkingButtonNode?.iconSpacing = 2.0
|
||||
strongSelf.walkingButtonNode?.alpha = 0.0
|
||||
strongSelf.walkingButtonNode?.allowsGroupOpacity = true
|
||||
strongSelf.walkingButtonNode?.pressed = { [weak self] in
|
||||
if let item = self?.item {
|
||||
item.walkingAction()
|
||||
}
|
||||
}
|
||||
strongSelf.walkingButtonNode.flatMap { strongSelf.addSubnode($0) }
|
||||
} else if let _ = updatedTheme {
|
||||
strongSelf.drivingButtonNode?.updateTheme(buttonTheme)
|
||||
strongSelf.drivingButtonNode?.icon = generateTintedImage(image: UIImage(bundleImageName: "Location/DirectionsDriving"), color: item.presentationData.theme.list.itemCheckColors.foregroundColor)
|
||||
|
||||
strongSelf.transitButtonNode?.updateTheme(buttonTheme)
|
||||
strongSelf.transitButtonNode?.icon = generateTintedImage(image: UIImage(bundleImageName: "Location/DirectionsTransit"), color: item.presentationData.theme.list.itemCheckColors.foregroundColor)
|
||||
|
||||
strongSelf.walkingButtonNode?.updateTheme(buttonTheme)
|
||||
strongSelf.walkingButtonNode?.icon = generateTintedImage(image: UIImage(bundleImageName: "Location/DirectionsWalking"), color: item.presentationData.theme.list.itemCheckColors.foregroundColor)
|
||||
}
|
||||
directionsButtonNode.subtitle = item.eta
|
||||
|
||||
let titleFrame = CGRect(origin: CGPoint(x: leftInset, y: verticalInset), size: titleLayout.size)
|
||||
titleNode.frame = titleFrame
|
||||
@@ -235,9 +276,42 @@ final class LocationInfoListItemNode: ListViewItemNode {
|
||||
let iconNodeFrame = CGRect(origin: CGPoint(x: params.leftInset + inset, y: 10.0), size: CGSize(width: iconSize, height: iconSize))
|
||||
strongSelf.venueIconNode.frame = iconNodeFrame
|
||||
|
||||
let directionsWidth = contentSize.width - inset * 2.0
|
||||
let directionsHeight = directionsButtonNode.updateLayout(width: directionsWidth, transition: .immediate)
|
||||
directionsButtonNode.frame = CGRect(x: inset, y: iconNodeFrame.maxY + 14.0, width: directionsWidth, height: directionsHeight)
|
||||
if let drivingTime = item.drivingTime {
|
||||
strongSelf.drivingButtonNode?.title = stringForEstimatedDuration(strings: item.presentationData.strings, time: drivingTime, format: { $0 })
|
||||
|
||||
if currentItem?.drivingTime == nil {
|
||||
strongSelf.drivingButtonNode?.alpha = 1.0
|
||||
strongSelf.drivingButtonNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
}
|
||||
|
||||
if let transitTime = item.transitTime {
|
||||
strongSelf.transitButtonNode?.title = stringForEstimatedDuration(strings: item.presentationData.strings, time: transitTime, format: { $0 })
|
||||
|
||||
if currentItem?.transitTime == nil {
|
||||
strongSelf.transitButtonNode?.alpha = 1.0
|
||||
strongSelf.transitButtonNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
}
|
||||
|
||||
if let walkingTime = item.walkingTime {
|
||||
strongSelf.walkingButtonNode?.title = stringForEstimatedDuration(strings: item.presentationData.strings, time: walkingTime, format: { $0 })
|
||||
|
||||
if currentItem?.walkingTime == nil {
|
||||
strongSelf.walkingButtonNode?.alpha = 1.0
|
||||
strongSelf.walkingButtonNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
}
|
||||
|
||||
let directionsWidth: CGFloat = 93.0
|
||||
let directionsSpacing: CGFloat = 8.0
|
||||
let drivingHeight = strongSelf.drivingButtonNode?.updateLayout(width: directionsWidth, transition: .immediate) ?? 0.0
|
||||
let transitHeight = strongSelf.transitButtonNode?.updateLayout(width: directionsWidth, transition: .immediate) ?? 0.0
|
||||
let walkingHeight = strongSelf.walkingButtonNode?.updateLayout(width: directionsWidth, transition: .immediate) ?? 0.0
|
||||
|
||||
strongSelf.drivingButtonNode?.frame = CGRect(origin: CGPoint(x: leftInset, y: subtitleFrame.maxY + 12.0), size: CGSize(width: directionsWidth, height: drivingHeight))
|
||||
strongSelf.transitButtonNode?.frame = CGRect(origin: CGPoint(x: leftInset + directionsWidth + directionsSpacing, y: subtitleFrame.maxY + 12.0), size: CGSize(width: directionsWidth, height: transitHeight))
|
||||
strongSelf.walkingButtonNode?.frame = CGRect(origin: CGPoint(x: leftInset + directionsWidth + directionsSpacing + directionsWidth + directionsSpacing, y: subtitleFrame.maxY + 12.0), size: CGSize(width: directionsWidth, height: walkingHeight))
|
||||
|
||||
strongSelf.buttonNode.frame = CGRect(x: 0.0, y: 0.0, width: contentSize.width, height: 72.0)
|
||||
strongSelf.backgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: contentSize.width, height: contentSize.height))
|
||||
|
||||
Reference in New Issue
Block a user