Invite Links Improvements

This commit is contained in:
Ilya Laktyushin 2021-01-22 15:54:06 +03:00
parent cba5b9b5e1
commit c7e1d3762f
19 changed files with 3446 additions and 3325 deletions

View File

@ -5914,3 +5914,7 @@ Sorry for the inconvenience.";
"ChatList.HeaderImportIntoAnExistingGroup" = "OR IMPORT INTO AN EXISTING GROUP"; "ChatList.HeaderImportIntoAnExistingGroup" = "OR IMPORT INTO AN EXISTING GROUP";
"Group.ErrorAdminsTooMuch" = "Sorry, too many administrators in this group.";
"Channel.ErrorAdminsTooMuch" = "Sorry, too many administrators in this channel.";
"Conversation.AddMembers" = "Add Members";

View File

@ -10,6 +10,7 @@ swift_library(
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display", "//submodules/Display:Display",
"//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/TelegramPresentationData:TelegramPresentationData",
"//submodules/TelegramStringFormatting:TelegramStringFormatting",
], ],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",

View File

@ -1,425 +1,388 @@
//import Foundation import Foundation
//import Display import Display
//import UIKit import UIKit
//import AsyncDisplayKit import AsyncDisplayKit
//import TelegramPresentationData import TelegramPresentationData
// import TelegramStringFormatting
//private let textFont = Font.regular(13.0)
//private let selectedTextFont = Font.bold(13.0) private let textFont = Font.regular(13.0)
// private let selectedTextFont = Font.bold(13.0)
//public final class DatePickerTheme: Equatable {
// public let backgroundColor: UIColor public final class DatePickerTheme: Equatable {
// public let textColor: UIColor public let backgroundColor: UIColor
// public let secondaryTextColor: UIColor public let textColor: UIColor
// public let accentColor: UIColor public let secondaryTextColor: UIColor
// public let selectionColor: UIColor public let accentColor: UIColor
// public let selectedCurrentTextColor: UIColor public let disabledColor: UIColor
// public let secondarySelectionColor: UIColor public let selectionColor: UIColor
// public let selectedCurrentTextColor: UIColor
// public init(backgroundColor: UIColor, textColor: UIColor, secondaryTextColor: UIColor, accentColor: UIColor, selectionColor: UIColor, selectedCurrentTextColor: UIColor, secondarySelectionColor: UIColor) { public let secondarySelectionColor: UIColor
// self.backgroundColor = backgroundColor
// self.textColor = textColor public init(backgroundColor: UIColor, textColor: UIColor, secondaryTextColor: UIColor, accentColor: UIColor, disabledColor: UIColor, selectionColor: UIColor, selectedCurrentTextColor: UIColor, secondarySelectionColor: UIColor) {
// self.secondaryTextColor = secondaryTextColor self.backgroundColor = backgroundColor
// self.accentColor = accentColor self.textColor = textColor
// self.selectionColor = selectionColor self.secondaryTextColor = secondaryTextColor
// self.selectedCurrentTextColor = selectedCurrentTextColor self.accentColor = accentColor
// self.secondarySelectionColor = secondarySelectionColor self.disabledColor = disabledColor
// } self.selectionColor = selectionColor
// self.selectedCurrentTextColor = selectedCurrentTextColor
// public static func ==(lhs: DatePickerTheme, rhs: DatePickerTheme) -> Bool { self.secondarySelectionColor = secondarySelectionColor
// if lhs.backgroundColor != rhs.backgroundColor { }
// return false
// } public static func ==(lhs: DatePickerTheme, rhs: DatePickerTheme) -> Bool {
// if lhs.textColor != rhs.textColor { if lhs.backgroundColor != rhs.backgroundColor {
// return false return false
// } }
// if lhs.secondaryTextColor != rhs.secondaryTextColor { if lhs.textColor != rhs.textColor {
// return false return false
// } }
// if lhs.accentColor != rhs.accentColor { if lhs.secondaryTextColor != rhs.secondaryTextColor {
// return false return false
// } }
// if lhs.selectionColor != rhs.selectionColor { if lhs.accentColor != rhs.accentColor {
// return false return false
// } }
// if lhs.selectedCurrentTextColor != rhs.selectedCurrentTextColor { if lhs.selectionColor != rhs.selectionColor {
// return false return false
// } }
// if lhs.secondarySelectionColor != rhs.secondarySelectionColor { if lhs.selectedCurrentTextColor != rhs.selectedCurrentTextColor {
// return false return false
// } }
// return true if lhs.secondarySelectionColor != rhs.secondarySelectionColor {
// } return false
//} }
// return true
}
}
//public extension DatePickerTheme { //public extension DatePickerTheme {
// convenience init(theme: PresentationTheme) { // convenience init(theme: PresentationTheme) {
// self.init(backgroundColor: theme.rootController.navigationBar.segmentedBackgroundColor, foregroundColor: theme.rootController.navigationBar.segmentedForegroundColor, shadowColor: .black, textColor: theme.rootController.navigationBar.segmentedTextColor, dividerColor: theme.rootController.navigationBar.segmentedDividerColor) // self.init(backgroundColor: theme.rootController.navigationBar.segmentedBackgroundColor, foregroundColor: theme.rootController.navigationBar.segmentedForegroundColor, shadowColor: .black, textColor: theme.rootController.navigationBar.segmentedTextColor, dividerColor: theme.rootController.navigationBar.segmentedDividerColor)
// } // }
//} //}
//
//private class SegmentedControlItemNode: HighlightTrackingButtonNode { private class SegmentedControlItemNode: HighlightTrackingButtonNode {
//} }
//
//private let telegramReleaseDate = Date(timeIntervalSince1970: 1376438400.0) private let telegramReleaseDate = Date(timeIntervalSince1970: 1376438400.0)
// private let upperLimitDate = Date(timeIntervalSince1970: Double(Int32.max - 1))
//public final class DatePickerNode: ASDisplayNode, UIGestureRecognizerDelegate {
// private var theme: DatePickerTheme private let dayFont = Font.regular(13.0)
// private var _items: [SegmentedControlItem] private let dateFont = Font.with(size: 13.0, design: .regular, traits: .monospacedNumbers)
// private var _selectedIndex: Int = 0 private let selectedDateFont = Font.bold(13.0)
//
// private var validLayout: SegmentedControlLayout? private let calendar = Calendar(identifier: .gregorian)
//
// private let selectionNode: ASImageNode private func monthForDate(_ date: Date) -> Date {
// private var itemNodes: [SegmentedControlItemNode] var components = calendar.dateComponents([.year, .month], from: date)
// private var dividerNodes: [ASDisplayNode] components.hour = 0
// components.minute = 0
// private var gestureRecognizer: UIPanGestureRecognizer? components.second = 0
// private var gestureSelectedIndex: Int? return calendar.date(from: components)!
// }
// public var maximumDate: Date? {
// didSet { public final class DatePickerNode: ASDisplayNode, UIScrollViewDelegate {
// class MonthNode: ASDisplayNode {
// } private let month: Date
// }
// public var minimumDate: Date = telegramReleaseDate { var theme: DatePickerTheme {
// didSet { didSet {
// if let size = self.validSize {
// } self.updateLayout(size: size)
// } }
// public var date: Date = Date() { }
// didSet { }
//
// } var maximumDate: Date? {
// } didSet {
// if let size = self.validSize {
// self.updateLayout(size: size)
// public var items: [SegmentedControlItem] { }
// get { }
// return self._items }
// }
// set { var minimumDate: Date? {
// let previousItems = self._items didSet {
// self._items = newValue if let size = self.validSize {
// guard previousItems != newValue else { self.updateLayout(size: size)
// return }
// } }
// }
// self.itemNodes.forEach { $0.removeFromSupernode() }
// self.itemNodes = self._items.map { item in var date: Date? {
// let itemNode = SegmentedControlItemNode() didSet {
// itemNode.contentEdgeInsets = UIEdgeInsets(top: 0.0, left: 8.0, bottom: 0.0, right: 8.0) if let size = self.validSize {
// itemNode.titleNode.maximumNumberOfLines = 1 self.updateLayout(size: size)
// itemNode.titleNode.truncationMode = .byTruncatingTail }
// itemNode.setTitle(item.title, with: textFont, with: self.theme.textColor, for: .normal) }
// itemNode.setTitle(item.title, with: selectedTextFont, with: self.theme.textColor, for: .selected) }
// itemNode.setTitle(item.title, with: selectedTextFont, with: self.theme.textColor, for: [.selected, .highlighted])
// return itemNode private var validSize: CGSize?
// }
// self.setupButtons() private let selectionNode: ASImageNode
// self.itemNodes.forEach(self.addSubnode(_:)) private let dateNodes: [ImmediateTextNode]
//
// let dividersCount = self._items.count > 2 ? self._items.count - 1 : 0 private let firstWeekday: Int
// if self.dividerNodes.count != dividersCount { private let startWeekday: Int
// self.dividerNodes.forEach { $0.removeFromSupernode() } private let numberOfDays: Int
// self.dividerNodes = (0 ..< dividersCount).map { _ in ASDisplayNode() }
// } init(theme: DatePickerTheme, month: Date, minimumDate: Date?, maximumDate: Date?, date: Date?) {
// self.theme = theme
// if let layout = self.validLayout { self.month = month
// let _ = self.updateLayout(layout, transition: .immediate) self.minimumDate = minimumDate
// } self.maximumDate = maximumDate
// } self.date = date
// }
// self.selectionNode = ASImageNode()
// public var selectedIndex: Int { self.selectionNode.displaysAsynchronously = false
// get { self.selectionNode.displayWithoutProcessing = true
// return self._selectedIndex
// } self.dateNodes = (0..<42).map { _ in ImmediateTextNode() }
// set {
// guard newValue != self._selectedIndex else { let components = calendar.dateComponents([.year, .month], from: month)
// return let startDayDate = calendar.date(from: components)!
// }
// self._selectedIndex = newValue self.firstWeekday = calendar.firstWeekday
// if let layout = self.validLayout { self.startWeekday = calendar.dateComponents([.weekday], from: startDayDate).weekday!
// let _ = self.updateLayout(layout, transition: .immediate) self.numberOfDays = calendar.range(of: .day, in: .month, for: month)!.count
// }
// } super.init()
// }
// self.addSubnode(self.selectionNode)
// public func setSelectedIndex(_ index: Int, animated: Bool) { self.dateNodes.forEach { self.addSubnode($0) }
// guard index != self._selectedIndex else { }
// return
// } func updateLayout(size: CGSize) {
// self._selectedIndex = index var weekday = self.firstWeekday
// if let layout = self.validLayout { var started = false
// let _ = self.updateLayout(layout, transition: .animated(duration: 0.2, curve: .easeInOut)) var count = 0
// }
// } for i in 0 ..< 42 {
// let row: Int = Int(floor(Float(i) / 7.0))
// public var selectedIndexChanged: (Int) -> Void = { _ in } let col: Int = i % 7
// public var selectedIndexShouldChange: (Int, @escaping (Bool) -> Void) -> Void = { _, f in
// f(true) if !started && weekday == self.startWeekday {
// } started = true
// }
// public init(theme: SegmentedControlTheme, items: [SegmentedControlItem], selectedIndex: Int) { if started {
// self.theme = theme count += 1
// self._items = items
// self._selectedIndex = selectedIndex var isAvailableDate = true
// if let minimumDate = self.minimumDate {
// self.selectionNode = ASImageNode() var components = calendar.dateComponents([.year, .month], from: self.month)
// self.selectionNode.displaysAsynchronously = false components.day = count
// self.selectionNode.displayWithoutProcessing = true components.hour = 0
// components.minute = 0
// self.itemNodes = items.map { item in let date = calendar.date(from: components)!
// let itemNode = SegmentedControlItemNode() if date < minimumDate {
// itemNode.contentEdgeInsets = UIEdgeInsets(top: 0.0, left: 8.0, bottom: 0.0, right: 8.0) isAvailableDate = false
// itemNode.titleNode.maximumNumberOfLines = 1 }
// itemNode.titleNode.truncationMode = .byTruncatingTail }
// itemNode.setTitle(item.title, with: textFont, with: theme.textColor, for: .normal) if let maximumDate = self.maximumDate {
// itemNode.setTitle(item.title, with: selectedTextFont, with: theme.textColor, for: .selected) var components = calendar.dateComponents([.year, .month], from: self.month)
// itemNode.setTitle(item.title, with: selectedTextFont, with: theme.textColor, for: [.selected, .highlighted]) components.day = count
// return itemNode components.hour = 0
// } components.minute = 0
// let date = calendar.date(from: components)!
// let dividersCount = items.count > 2 ? items.count - 1 : 0 if date > maximumDate {
// self.dividerNodes = (0 ..< dividersCount).map { _ in isAvailableDate = false
// let node = ASDisplayNode() }
// node.backgroundColor = theme.dividerColor }
// return node var isSelectedDate = false
// } var isSelectedAndCurrentDate = false
//
// super.init() let color: UIColor
// if !isAvailableDate {
// self.clipsToBounds = true color = self.theme.disabledColor
// self.cornerRadius = 9.0 } else if isSelectedAndCurrentDate {
// color = .white
// self.addSubnode(self.selectionNode) } else if isSelectedDate {
// self.itemNodes.forEach(self.addSubnode(_:)) color = self.theme.accentColor
// self.setupButtons() } else {
// self.dividerNodes.forEach(self.addSubnode(_:)) color = self.theme.textColor
// }
// self.backgroundColor = self.theme.backgroundColor
// self.selectionNode.image = generateSelectionImage(theme: self.theme) let textNode = self.dateNodes[i]
// } textNode.attributedText = NSAttributedString(string: "\(count)", font: dateFont, textColor: color)
//
// override public func didLoad() { let textSize = textNode.updateLayout(size)
// super.didLoad() textNode.frame = CGRect(origin: CGPoint(x: CGFloat(col) * 20.0, y: CGFloat(row) * 20.0), size: textSize)
//
// self.view.disablesInteractiveTransitionGestureRecognizer = true if count == self.numberOfDays {
// break
// let gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:))) }
// gestureRecognizer.delegate = self }
// self.view.addGestureRecognizer(gestureRecognizer) }
// self.gestureRecognizer = gestureRecognizer }
// } }
//
// private func setupButtons() { struct State {
// for i in 0 ..< self.itemNodes.count { let minDate: Date
// let itemNode = self.itemNodes[i] let maxDate: Date
// itemNode.addTarget(self, action: #selector(self.buttonPressed(_:)), forControlEvents: .touchUpInside) let date: Date
// itemNode.highligthedChanged = { [weak self, weak itemNode] highlighted in
// if let strongSelf = self, let itemNode = itemNode { let displayingMonthSelection: Bool
// let transition = ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut) let selectedMonth: Date
// if strongSelf.selectedIndex == i { }
// if let gestureRecognizer = strongSelf.gestureRecognizer, case .began = gestureRecognizer.state {
// } else { private var state: State
// strongSelf.updateButtonsHighlights(highlightedIndex: highlighted ? i : nil, gestureSelectedIndex: strongSelf.gestureSelectedIndex)
// } private var theme: DatePickerTheme
// } else if highlighted { private let strings: PresentationStrings
// transition.updateAlpha(node: itemNode, alpha: 0.4)
// } private let timeTitleNode: ImmediateTextNode
// if !highlighted { private let timeFieldNode: ASImageNode
// transition.updateAlpha(node: itemNode, alpha: 1.0)
// } private let monthButtonNode: HighlightTrackingButtonNode
// } private let monthTextNode: ImmediateTextNode
// } private let monthArrowNode: ASImageNode
// }
// } private let previousButtonNode: HighlightableButtonNode
// private let nextButtonNode: HighlightableButtonNode
// private func updateButtonsHighlights(highlightedIndex: Int?, gestureSelectedIndex: Int?) {
// let transition = ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut) private let dayNodes: [ImmediateTextNode]
// if highlightedIndex == nil && gestureSelectedIndex == nil { private var previousMonthNode: MonthNode?
// transition.updateTransformScale(node: self.selectionNode, scale: 1.0) private var currentMonthNode: MonthNode?
// } else { private var nextMonthNode: MonthNode?
// transition.updateTransformScale(node: self.selectionNode, scale: 0.92) private let scrollNode: ASScrollNode
// }
// for i in 0 ..< self.itemNodes.count { private var gestureRecognizer: UIPanGestureRecognizer?
// let itemNode = self.itemNodes[i] private var gestureSelectedIndex: Int?
// if i == highlightedIndex || i == gestureSelectedIndex {
// transition.updateTransformScale(node: itemNode, scale: 0.92) private var validLayout: CGSize?
// } else {
// transition.updateTransformScale(node: itemNode, scale: 1.0) public var maximumDate: Date? {
// } didSet {
// }
// } }
// }
// private func updateButtonsHighlights() { public var minimumDate: Date = telegramReleaseDate {
// let transition = ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut) didSet {
// if let gestureSelectedIndex = self.gestureSelectedIndex {
// for i in 0 ..< self.itemNodes.count { }
// let itemNode = self.itemNodes[i] }
// transition.updateTransformScale(node: itemNode, scale: i == gestureSelectedIndex ? 0.92 : 1.0) public var date: Date = Date() {
// } didSet {
// } else { guard self.date != oldValue else {
// for itemNode in self.itemNodes { return
// transition.updateTransformScale(node: itemNode, scale: 1.0) }
// } if let size = self.validLayout {
// } let _ = self.updateLayout(size: size, transition: .immediate)
// } }
// }
// public func updateTheme(_ theme: SegmentedControlTheme) { }
// guard theme != self.theme else {
// return public init(theme: DatePickerTheme, strings: PresentationStrings) {
// } self.theme = theme
// self.theme = theme self.strings = strings
// self.state = State(minDate: telegramReleaseDate, maxDate: upperLimitDate, date: Date(), displayingMonthSelection: false, selectedMonth: monthForDate(Date()))
// self.backgroundColor = self.theme.backgroundColor
// self.selectionNode.image = generateSelectionImage(theme: self.theme) self.timeTitleNode = ImmediateTextNode()
// self.timeFieldNode = ASImageNode()
// for itemNode in self.itemNodes { self.timeFieldNode.displaysAsynchronously = false
// if let title = itemNode.attributedTitle(for: .normal)?.string { self.timeFieldNode.displayWithoutProcessing = true
// itemNode.setTitle(title, with: textFont, with: self.theme.textColor, for: .normal)
// itemNode.setTitle(title, with: selectedTextFont, with: self.theme.textColor, for: .selected) self.monthButtonNode = HighlightTrackingButtonNode()
// itemNode.setTitle(title, with: selectedTextFont, with: self.theme.textColor, for: [.selected, .highlighted])
// } self.monthTextNode = ImmediateTextNode()
// }
// self.monthArrowNode = ASImageNode()
// for dividerNode in self.dividerNodes { self.monthArrowNode.displaysAsynchronously = false
// dividerNode.backgroundColor = theme.dividerColor self.monthArrowNode.displayWithoutProcessing = true
// }
// } self.previousButtonNode = HighlightableButtonNode()
// self.nextButtonNode = HighlightableButtonNode()
// public func updateLayout(_ layout: SegmentedControlLayout, transition: ContainedViewLayoutTransition) -> CGSize {
// self.validLayout = layout self.dayNodes = (0..<7).map { _ in ImmediateTextNode() }
//
// let calculatedWidth: CGFloat = 0.0 self.scrollNode = ASScrollNode()
//
// let width: CGFloat super.init()
// switch layout {
// case let .stretchToFill(targetWidth): self.backgroundColor = theme.backgroundColor
// width = targetWidth
// case let .sizeToFit(maximumWidth, minimumWidth): self.addSubnode(self.monthTextNode)
// width = max(minimumWidth, min(maximumWidth, calculatedWidth)) self.addSubnode(self.monthArrowNode)
// } self.addSubnode(self.monthButtonNode)
//
// let selectedIndex: Int self.addSubnode(self.previousButtonNode)
// if let gestureSelectedIndex = self.gestureSelectedIndex { self.addSubnode(self.nextButtonNode)
// selectedIndex = gestureSelectedIndex
// } else { self.addSubnode(self.scrollNode)
// selectedIndex = self.selectedIndex }
// }
// override public func didLoad() {
// let size = CGSize(width: width, height: 32.0) super.didLoad()
// if !self.itemNodes.isEmpty {
// let itemSize = CGSize(width: floorToScreenPixels(size.width / CGFloat(self.itemNodes.count)), height: size.height) self.view.disablesInteractiveTransitionGestureRecognizer = true
//
// transition.updateBounds(node: self.selectionNode, bounds: CGRect(origin: CGPoint(), size: itemSize)) self.scrollNode.view.isPagingEnabled = true
// transition.updatePosition(node: self.selectionNode, position: CGPoint(x: itemSize.width / 2.0 + itemSize.width * CGFloat(selectedIndex), y: size.height / 2.0)) self.scrollNode.view.delegate = self
// }
// for i in 0 ..< self.itemNodes.count {
// let itemNode = self.itemNodes[i] private func updateState(_ state: State, animated: Bool) {
// let _ = itemNode.measure(itemSize) self.state = state
// transition.updateFrame(node: itemNode, frame: CGRect(origin: CGPoint(x: itemSize.width * CGFloat(i), y: (size.height - itemSize.height) / 2.0), size: itemSize)) if let size = self.validLayout {
// self.updateLayout(size: size, transition: animated ? .animated(duration: 0.3, curve: .easeInOut) : .immediate)
// let isSelected = selectedIndex == i }
// if itemNode.isSelected != isSelected { }
// if case .animated = transition {
// UIView.transition(with: itemNode.view, duration: 0.2, options: .transitionCrossDissolve, animations: { public func updateTheme(_ theme: DatePickerTheme) {
// itemNode.isSelected = isSelected guard theme != self.theme else {
// }, completion: nil) return
// } else { }
// itemNode.isSelected = isSelected self.theme = theme
// }
// if isSelected { self.backgroundColor = self.theme.backgroundColor
// itemNode.accessibilityTraits.insert(.selected) }
// } else {
// itemNode.accessibilityTraits.remove(.selected) public func scrollViewDidScroll(_ scrollView: UIScrollView) {
// } self.view.window?.endEditing(true)
// } }
// }
// } public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
// if !decelerate {
// if !self.dividerNodes.isEmpty { if let size = self.validLayout {
// let dividerSize = CGSize(width: 1.0, height: 16.0) self.updateLayout(size: size, transition: .immediate)
// let delta: CGFloat = size.width / CGFloat(self.dividerNodes.count + 1) }
// for i in 0 ..< self.dividerNodes.count { }
// let dividerNode = self.dividerNodes[i] }
// transition.updateFrame(node: dividerNode, frame: CGRect(origin: CGPoint(x: floorToScreenPixels(delta * CGFloat(i + 1) - dividerSize.width / 2.0), y: (size.height - dividerSize.height) / 2.0), size: dividerSize))
// public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
// let dividerAlpha: CGFloat if let size = self.validLayout {
// if (selectedIndex - 1 ... selectedIndex).contains(i) { self.updateLayout(size: size, transition: .immediate)
// dividerAlpha = 0.0 }
// } else { }
// dividerAlpha = 1.0
// } public func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
// transition.updateAlpha(node: dividerNode, alpha: dividerAlpha) self.validLayout = size
// }
// } let topInset: CGFloat = 60.0
//
// return size let scrollSize = CGSize(width: size.width, height: size.height - topInset)
// } self.scrollNode.frame = CGRect(origin: CGPoint(x: 0.0, y: topInset), size: scrollSize)
// self.scrollNode.view.contentSize = CGSize(width: scrollSize.width * 3.0, height: scrollSize.height)
// @objc private func buttonPressed(_ button: SegmentedControlItemNode) { self.scrollNode.view.contentOffset = CGPoint(x: scrollSize.width, y: 0.0)
// guard let index = self.itemNodes.firstIndex(of: button) else {
// return for i in 0 ..< self.dayNodes.count {
// } let dayNode = self.dayNodes[i]
//
// self.selectedIndexShouldChange(index, { [weak self] commit in let day = Int32(i)
// if let strongSelf = self, commit { dayNode.attributedText = NSAttributedString(string: shortStringForDayOfWeek(strings: self.strings, day: day), font: dayFont, textColor: theme.secondaryTextColor)
// strongSelf._selectedIndex = index let size = dayNode.updateLayout(size)
// strongSelf.selectedIndexChanged(index) dayNode.frame = CGRect(origin: CGPoint(x: CGFloat(i) * 20.0, y: 0.0), size: size)
// if let layout = strongSelf.validLayout { }
// let _ = strongSelf.updateLayout(layout, transition: .animated(duration: 0.2, curve: .slide)) }
// }
// } @objc private func monthButtonPressed(_ button: SegmentedControlItemNode) {
// })
// } }
//
// public override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { @objc private func previousButtonPressed(_ button: SegmentedControlItemNode) {
// return self.selectionNode.frame.contains(gestureRecognizer.location(in: self.view))
// } }
//
// @objc private func panGesture(_ recognizer: UIPanGestureRecognizer) { @objc private func nextButtonPressed(_ button: SegmentedControlItemNode) {
// let location = recognizer.location(in: self.view)
// switch recognizer.state { }
// case .changed: }
// if !self.selectionNode.frame.contains(location) {
// let point = CGPoint(x: max(0.0, min(self.bounds.width, location.x)), y: 1.0)
// for i in 0 ..< self.itemNodes.count {
// let itemNode = self.itemNodes[i]
// if itemNode.frame.contains(point) {
// if i != self.gestureSelectedIndex {
// self.gestureSelectedIndex = i
// self.updateButtonsHighlights(highlightedIndex: nil, gestureSelectedIndex: i)
// if let layout = self.validLayout {
// let _ = self.updateLayout(layout, transition: .animated(duration: 0.35, curve: .slide))
// }
// }
// break
// }
// }
// }
// case .ended:
// if let gestureSelectedIndex = self.gestureSelectedIndex {
// if gestureSelectedIndex != self.selectedIndex {
// self.selectedIndexShouldChange(gestureSelectedIndex, { [weak self] commit in
// if let strongSelf = self {
// if commit {
// strongSelf._selectedIndex = gestureSelectedIndex
// strongSelf.selectedIndexChanged(gestureSelectedIndex)
// } else {
// if let layout = strongSelf.validLayout {
// let _ = strongSelf.updateLayout(layout, transition: .animated(duration: 0.2, curve: .slide))
// }
// }
// }
// })
// }
// self.gestureSelectedIndex = nil
// }
// self.updateButtonsHighlights(highlightedIndex: nil, gestureSelectedIndex: nil)
// default:
// break
// }
// }
//}

View File

@ -208,6 +208,25 @@ private func preparedTransition(from fromEntries: [InviteLinkViewEntry], to toEn
return InviteLinkViewTransaction(deletions: deletions, insertions: insertions, updates: updates, isLoading: isLoading) return InviteLinkViewTransaction(deletions: deletions, insertions: insertions, updates: updates, isLoading: isLoading)
} }
private let titleFont = Font.bold(17.0)
private let subtitleFont = Font.with(size: 13, design: .regular, weight: .regular, traits: .monospacedNumbers)
private func textForTimeout(value: Int32) -> String {
if value < 3600 {
let minutes = value / 60
let seconds = value % 60
let secondsPadding = seconds < 10 ? "0" : ""
return "\(minutes):\(secondsPadding)\(seconds)"
} else {
let hours = value / 3600
let minutes = (value % 3600) / 60
let minutesPadding = minutes < 10 ? "0" : ""
let seconds = value % 60
let secondsPadding = seconds < 10 ? "0" : ""
return "\(hours):\(minutesPadding)\(minutes):\(secondsPadding)\(seconds)"
}
}
public final class InviteLinkViewController: ViewController { public final class InviteLinkViewController: ViewController {
private var controllerNode: Node { private var controllerNode: Node {
return self.displayNode as! Node return self.displayNode as! Node
@ -328,6 +347,8 @@ public final class InviteLinkViewController: ViewController {
private var enqueuedTransitions: [InviteLinkViewTransaction] = [] private var enqueuedTransitions: [InviteLinkViewTransaction] = []
private var countdownTimer: SwiftSignalKit.Timer?
private var validLayout: ContainerViewLayout? private var validLayout: ContainerViewLayout?
init(context: AccountContext, peerId: PeerId, invite: ExportedInvitation, importersContext: PeerInvitationImportersContext?, controller: InviteLinkViewController) { init(context: AccountContext, peerId: PeerId, invite: ExportedInvitation, importersContext: PeerInvitationImportersContext?, controller: InviteLinkViewController) {
@ -566,11 +587,13 @@ public final class InviteLinkViewController: ViewController {
self.controller?.dismiss() self.controller?.dismiss()
let invitationsContext = self.controller?.invitationsContext let invitationsContext = self.controller?.invitationsContext
let revokedInvitationsContext = self.controller?.revokedInvitationsContext
if let navigationController = navigationController { if let navigationController = navigationController {
let controller = inviteLinkEditController(context: self.context, peerId: self.peerId, invite: self.invite, completion: { [weak self] invite in let controller = inviteLinkEditController(context: self.context, peerId: self.peerId, invite: self.invite, completion: { invite in
if let invite = invite { if let invite = invite {
if invite.isRevoked { if invite.isRevoked {
invitationsContext?.remove(invite) invitationsContext?.remove(invite)
revokedInvitationsContext?.add(invite.withUpdated(isRevoked: true))
} else { } else {
invitationsContext?.update(invite) invitationsContext?.update(invite)
} }
@ -591,7 +614,8 @@ public final class InviteLinkViewController: ViewController {
self.historyBackgroundContentNode.backgroundColor = self.presentationData.theme.list.plainBackgroundColor self.historyBackgroundContentNode.backgroundColor = self.presentationData.theme.list.plainBackgroundColor
self.headerBackgroundNode.backgroundColor = self.presentationData.theme.list.plainBackgroundColor self.headerBackgroundNode.backgroundColor = self.presentationData.theme.list.plainBackgroundColor
self.titleNode.attributedText = NSAttributedString(string: self.presentationData.strings.InviteLink_InviteLink, font: Font.bold(17.0), textColor: self.presentationData.theme.actionSheet.primaryTextColor) self.titleNode.attributedText = NSAttributedString(string: self.presentationData.strings.InviteLink_InviteLink, font: titleFont, textColor: self.presentationData.theme.actionSheet.primaryTextColor)
self.subtitleNode.attributedText = NSAttributedString(string: self.subtitleNode.attributedText?.string ?? "", font: subtitleFont, textColor: self.presentationData.theme.list.itemSecondaryTextColor)
let buttonColor = color(for: invite) ?? self.presentationData.theme.actionSheet.controlAccentColor let buttonColor = color(for: invite) ?? self.presentationData.theme.actionSheet.controlAccentColor
self.editButton.setTitle(self.presentationData.strings.Common_Edit, with: Font.regular(17.0), with: buttonColor, for: .normal) self.editButton.setTitle(self.presentationData.strings.Common_Edit, with: Font.regular(17.0), with: buttonColor, for: .normal)
@ -679,8 +703,43 @@ public final class InviteLinkViewController: ViewController {
transition.updateFrame(node: self.headerBackgroundNode, frame: CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: 68.0)) transition.updateFrame(node: self.headerBackgroundNode, frame: CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: 68.0))
var subtitleText = ""
if self.invite.isRevoked {
subtitleText = self.presentationData.strings.InviteLink_Revoked
} else if let usageLimit = self.invite.usageLimit, let count = self.invite.count, count >= usageLimit {
subtitleText = self.presentationData.strings.InviteLink_UsageLimitReached
} else if let expireDate = self.invite.expireDate {
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
if currentTime >= expireDate {
subtitleText = self.presentationData.strings.InviteLink_Expired
self.countdownTimer?.invalidate()
self.countdownTimer = nil
} else {
let elapsedTime = expireDate - currentTime
if elapsedTime >= 86400 {
subtitleText = self.presentationData.strings.InviteLink_ExpiresIn(timeIntervalString(strings: self.presentationData.strings, value: elapsedTime)).0
} else {
subtitleText = self.presentationData.strings.InviteLink_ExpiresIn(textForTimeout(value: elapsedTime)).0
if self.countdownTimer == nil {
let countdownTimer = SwiftSignalKit.Timer(timeout: 1.0, repeat: true, completion: { [weak self] in
if let strongSelf = self, let layout = strongSelf.validLayout {
strongSelf.containerLayoutUpdated(layout, transition: .immediate)
}
}, queue: Queue.mainQueue())
self.countdownTimer = countdownTimer
countdownTimer.start()
}
}
}
}
self.subtitleNode.attributedText = NSAttributedString(string: subtitleText, font: subtitleFont, textColor: self.presentationData.theme.list.itemSecondaryTextColor)
let subtitleSize = self.subtitleNode.updateLayout(CGSize(width: layout.size.width, height: headerHeight))
let subtitleFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - subtitleSize.width) / 2.0), y: 30.0 - UIScreenPixel), size: subtitleSize)
transition.updateFrame(node: self.subtitleNode, frame: subtitleFrame)
let titleSize = self.titleNode.updateLayout(CGSize(width: layout.size.width, height: headerHeight)) let titleSize = self.titleNode.updateLayout(CGSize(width: layout.size.width, height: headerHeight))
let titleFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - titleSize.width) / 2.0), y: 18.0), size: titleSize) let titleFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - titleSize.width) / 2.0), y: subtitleSize.height.isZero ? 18.0 : 10.0 + UIScreenPixel), size: titleSize)
transition.updateFrame(node: self.titleNode, frame: titleFrame) transition.updateFrame(node: self.titleNode, frame: titleFrame)
let editSize = self.editButton.measure(CGSize(width: layout.size.width, height: headerHeight)) let editSize = self.editButton.measure(CGSize(width: layout.size.width, height: headerHeight))

View File

@ -206,12 +206,6 @@ NSString *const kYUVVideoRangeConversionForLAFragmentShaderString = SHADER_STRIN
#pragma mark - #pragma mark -
#pragma mark Movie processing #pragma mark Movie processing
//- (void)enableSynchronizedEncodingUsingMovieWriter:(GPUImageMovieWriter *)movieWriter;
//{
// synchronizedMovieWriter = movieWriter;
// movieWriter.encodingLiveVideo = NO;
//}
- (void)startProcessing { - (void)startProcessing {
dispatch_sync(dispatch_get_main_queue(), ^{ dispatch_sync(dispatch_get_main_queue(), ^{
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkCallback:)]; displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkCallback:)];

View File

@ -1052,6 +1052,12 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
default: default:
break break
} }
case .adminsTooMuch:
if case .broadcast = channel.info {
text = presentationData.strings.Channel_ErrorAdminsTooMuch
} else {
text = presentationData.strings.Group_ErrorAdminsTooMuch
}
} }
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
}, completed: { }, completed: {
@ -1119,6 +1125,14 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
let text = presentationData.strings.Invite_ChannelsTooMuch let text = presentationData.strings.Invite_ChannelsTooMuch
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
} }
} else if case .adminsTooMuch = error {
let text: String
if case .broadcast = channel.info {
text = presentationData.strings.Channel_ErrorAdminsTooMuch
} else {
text = presentationData.strings.Group_ErrorAdminsTooMuch
}
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
} }
dismissImpl?() dismissImpl?()
}, completed: { }, completed: {
@ -1164,6 +1178,8 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|> deliverOnMainQueue).start(error: { error in |> deliverOnMainQueue).start(error: { error in
if case let .addMemberError(error) = error, case .privacy = error, let admin = adminView.peers[adminView.peerId] { if case let .addMemberError(error) = error, case .privacy = error, let admin = adminView.peers[adminView.peerId] {
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
} else if case .adminsTooMuch = error {
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Group_ErrorAdminsTooMuch, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
} }
dismissImpl?() dismissImpl?()
@ -1226,6 +1242,8 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
text = presentationData.strings.Invite_ChannelsTooMuch text = presentationData.strings.Invite_ChannelsTooMuch
} }
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
} else if case .adminsTooMuch = error {
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Group_ErrorAdminsTooMuch, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
} }
case .conversionFailed, .conversionTooManyChannels: case .conversionFailed, .conversionTooManyChannels:
pushControllerImpl?(oldChannelsController(context: context, intent: .upgrade)) pushControllerImpl?(oldChannelsController(context: context, intent: .upgrade))

View File

@ -215,6 +215,7 @@ swift_library(
"//Telegram:GeneratedSources", "//Telegram:GeneratedSources",
"//third-party/ZIPFoundation:ZIPFoundation", "//third-party/ZIPFoundation:ZIPFoundation",
"//submodules/ChatImportUI:ChatImportUI", "//submodules/ChatImportUI:ChatImportUI",
"//submodules/DatePickerNode:DatePickerNode",
], ],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",

View File

@ -2842,6 +2842,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
didDisplayActionsPanel = true didDisplayActionsPanel = true
} else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) { } else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) {
didDisplayActionsPanel = true didDisplayActionsPanel = true
} else if peerStatusSettings.contains(.suggestAddMembers) {
didDisplayActionsPanel = true
} }
} }
} }
@ -2857,6 +2859,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
displayActionsPanel = true displayActionsPanel = true
} else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) { } else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) {
displayActionsPanel = true displayActionsPanel = true
} else if peerStatusSettings.contains(.suggestAddMembers) {
displayActionsPanel = true
} }
} }
} }
@ -3046,6 +3050,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
didDisplayActionsPanel = true didDisplayActionsPanel = true
} else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) { } else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) {
didDisplayActionsPanel = true didDisplayActionsPanel = true
} else if peerStatusSettings.contains(.suggestAddMembers) {
didDisplayActionsPanel = true
} }
} }
} }
@ -3061,6 +3067,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
displayActionsPanel = true displayActionsPanel = true
} else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) { } else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) {
displayActionsPanel = true displayActionsPanel = true
} else if peerStatusSettings.contains(.suggestAddMembers) {
displayActionsPanel = true
} }
} }
} }
@ -6126,6 +6134,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let strongSelf = self { if let strongSelf = self {
strongSelf.controllerInteraction?.editMessageMedia(messageId, draw) strongSelf.controllerInteraction?.editMessageMedia(messageId, draw)
} }
}, presentAddMembers: {
}, statuses: ChatPanelInterfaceInteractionStatuses(editingMessage: self.editingMessage.get(), startingBot: self.startingBot.get(), unblockingPeer: self.unblockingPeer.get(), searching: self.searching.get(), loadingMessage: self.loadingMessage.get(), inlineSearch: self.performingInlineSearch.get())) }, statuses: ChatPanelInterfaceInteractionStatuses(editingMessage: self.editingMessage.get(), startingBot: self.startingBot.get(), unblockingPeer: self.unblockingPeer.get(), searching: self.searching.get(), loadingMessage: self.loadingMessage.get(), inlineSearch: self.performingInlineSearch.get()))
do { do {
@ -10468,7 +10478,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} else { } else {
dismissPeerId = peerId dismissPeerId = peerId
} }
self.editMessageDisposable.set((TelegramCore.dismissPeerStatusOptions(account: self.context.account, peerId: dismissPeerId) self.editMessageDisposable.set((dismissPeerStatusOptions(account: self.context.account, peerId: dismissPeerId)
|> afterDisposed({ |> afterDisposed({
Queue.mainQueue().async { Queue.mainQueue().async {
} }

View File

@ -50,6 +50,8 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
displayActionsPanel = true displayActionsPanel = true
} else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) { } else if contactStatus.canReportIrrelevantLocation && peerStatusSettings.contains(.canReportIrrelevantGeoLocation) {
displayActionsPanel = true displayActionsPanel = true
} else if peerStatusSettings.contains(.suggestAddMembers) {
displayActionsPanel = true
} }
} }
} }

View File

@ -126,8 +126,9 @@ final class ChatPanelInterfaceInteraction {
let scrollToTop: () -> Void let scrollToTop: () -> Void
let viewReplies: (MessageId?, ChatReplyThreadMessage) -> Void let viewReplies: (MessageId?, ChatReplyThreadMessage) -> Void
let activatePinnedListPreview: (ASDisplayNode, ContextGesture) -> Void let activatePinnedListPreview: (ASDisplayNode, ContextGesture) -> Void
let editMessageMedia: (MessageId, Bool) -> Void
let joinGroupCall: (CachedChannelData.ActiveCall) -> Void let joinGroupCall: (CachedChannelData.ActiveCall) -> Void
let editMessageMedia: (MessageId, Bool) -> Void
let presentAddMembers: () -> Void
let statuses: ChatPanelInterfaceInteractionStatuses? let statuses: ChatPanelInterfaceInteractionStatuses?
init( init(
@ -209,6 +210,7 @@ final class ChatPanelInterfaceInteraction {
activatePinnedListPreview: @escaping (ASDisplayNode, ContextGesture) -> Void, activatePinnedListPreview: @escaping (ASDisplayNode, ContextGesture) -> Void,
joinGroupCall: @escaping (CachedChannelData.ActiveCall) -> Void, joinGroupCall: @escaping (CachedChannelData.ActiveCall) -> Void,
editMessageMedia: @escaping (MessageId, Bool) -> Void, editMessageMedia: @escaping (MessageId, Bool) -> Void,
presentAddMembers: @escaping () -> Void,
statuses: ChatPanelInterfaceInteractionStatuses? statuses: ChatPanelInterfaceInteractionStatuses?
) { ) {
self.setupReplyMessage = setupReplyMessage self.setupReplyMessage = setupReplyMessage
@ -289,6 +291,7 @@ final class ChatPanelInterfaceInteraction {
self.activatePinnedListPreview = activatePinnedListPreview self.activatePinnedListPreview = activatePinnedListPreview
self.editMessageMedia = editMessageMedia self.editMessageMedia = editMessageMedia
self.joinGroupCall = joinGroupCall self.joinGroupCall = joinGroupCall
self.presentAddMembers = presentAddMembers
self.statuses = statuses self.statuses = statuses
} }
} }

View File

@ -134,6 +134,7 @@ final class ChatRecentActionsController: TelegramBaseController {
}, activatePinnedListPreview: { _, _ in }, activatePinnedListPreview: { _, _ in
}, joinGroupCall: { _ in }, joinGroupCall: { _ in
}, editMessageMedia: { _, _ in }, editMessageMedia: { _, _ in
}, presentAddMembers: {
}, statuses: nil) }, statuses: nil)
self.navigationItem.titleView = self.titleView self.navigationItem.titleView = self.titleView

View File

@ -17,6 +17,7 @@ private enum ChatReportPeerTitleButton: Equatable {
case reportUserSpam case reportUserSpam
case reportIrrelevantGeoLocation case reportIrrelevantGeoLocation
case unarchive case unarchive
case addMembers
func title(strings: PresentationStrings) -> String { func title(strings: PresentationStrings) -> String {
switch self { switch self {
@ -38,6 +39,8 @@ private enum ChatReportPeerTitleButton: Equatable {
return strings.Conversation_ReportGroupLocation return strings.Conversation_ReportGroupLocation
case .unarchive: case .unarchive:
return strings.Conversation_Unarchive return strings.Conversation_Unarchive
case .addMembers:
return strings.Conversation_AddMembers
} }
} }
} }
@ -85,7 +88,9 @@ private func peerButtons(_ state: ChatPresentationInterfaceState) -> [ChatReport
} }
} }
} else if let _ = state.renderedPeer?.chatMainPeer { } else if let _ = state.renderedPeer?.chatMainPeer {
if let contactStatus = state.contactStatus, contactStatus.canReportIrrelevantLocation, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.canReportIrrelevantGeoLocation) { if let contactStatus = state.contactStatus, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.suggestAddMembers) {
buttons.append(.addMembers)
} else if let contactStatus = state.contactStatus, contactStatus.canReportIrrelevantLocation, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.canReportIrrelevantGeoLocation) {
buttons.append(.reportIrrelevantGeoLocation) buttons.append(.reportIrrelevantGeoLocation)
} else if let contactStatus = state.contactStatus, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.autoArchived) { } else if let contactStatus = state.contactStatus, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.autoArchived) {
buttons.append(.reportUserSpam) buttons.append(.reportUserSpam)
@ -514,6 +519,8 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
self.interfaceInteraction?.presentPeerContact() self.interfaceInteraction?.presentPeerContact()
case .reportIrrelevantGeoLocation: case .reportIrrelevantGeoLocation:
self.interfaceInteraction?.reportPeerIrrelevantGeoLocation() self.interfaceInteraction?.reportPeerIrrelevantGeoLocation()
case .addMembers:
self.interfaceInteraction?.presentAddMembers()
} }
break break
} }

View File

@ -26,6 +26,7 @@ private struct ChatContextResultStableId: Hashable {
private struct HorizontalListContextResultsChatInputContextPanelEntry: Comparable, Identifiable { private struct HorizontalListContextResultsChatInputContextPanelEntry: Comparable, Identifiable {
let index: Int let index: Int
let theme: PresentationTheme
let result: ChatContextResult let result: ChatContextResult
var stableId: ChatContextResultStableId { var stableId: ChatContextResultStableId {
@ -33,7 +34,7 @@ private struct HorizontalListContextResultsChatInputContextPanelEntry: Comparabl
} }
static func ==(lhs: HorizontalListContextResultsChatInputContextPanelEntry, rhs: HorizontalListContextResultsChatInputContextPanelEntry) -> Bool { static func ==(lhs: HorizontalListContextResultsChatInputContextPanelEntry, rhs: HorizontalListContextResultsChatInputContextPanelEntry) -> Bool {
return lhs.index == rhs.index && lhs.result == rhs.result return lhs.index == rhs.index && lhs.theme === rhs.theme && lhs.result == rhs.result
} }
static func <(lhs: HorizontalListContextResultsChatInputContextPanelEntry, rhs: HorizontalListContextResultsChatInputContextPanelEntry) -> Bool { static func <(lhs: HorizontalListContextResultsChatInputContextPanelEntry, rhs: HorizontalListContextResultsChatInputContextPanelEntry) -> Bool {
@ -41,7 +42,7 @@ private struct HorizontalListContextResultsChatInputContextPanelEntry: Comparabl
} }
func item(account: Account, resultSelected: @escaping (ChatContextResult, ASDisplayNode, CGRect) -> Bool) -> ListViewItem { func item(account: Account, resultSelected: @escaping (ChatContextResult, ASDisplayNode, CGRect) -> Bool) -> ListViewItem {
return HorizontalListContextResultsChatInputPanelItem(account: account, result: self.result, resultSelected: resultSelected) return HorizontalListContextResultsChatInputPanelItem(account: account, theme: self.theme, result: self.result, resultSelected: resultSelected)
} }
} }
@ -248,7 +249,7 @@ final class HorizontalListContextResultsChatInputContextPanelNode: ChatInputCont
var index = 0 var index = 0
var resultIds = Set<ChatContextResultStableId>() var resultIds = Set<ChatContextResultStableId>()
for result in results.results { for result in results.results {
let entry = HorizontalListContextResultsChatInputContextPanelEntry(index: index, result: result) let entry = HorizontalListContextResultsChatInputContextPanelEntry(index: index, theme: self.theme, result: result)
if resultIds.contains(entry.stableId) { if resultIds.contains(entry.stableId) {
continue continue
} else { } else {

View File

@ -12,17 +12,21 @@ import StickerResources
import PhotoResources import PhotoResources
import AnimatedStickerNode import AnimatedStickerNode
import TelegramAnimatedStickerNode import TelegramAnimatedStickerNode
import TelegramPresentationData
import AccountContext import AccountContext
import ShimmerEffect
final class HorizontalListContextResultsChatInputPanelItem: ListViewItem { final class HorizontalListContextResultsChatInputPanelItem: ListViewItem {
let account: Account let account: Account
let theme: PresentationTheme
let result: ChatContextResult let result: ChatContextResult
let resultSelected: (ChatContextResult, ASDisplayNode, CGRect) -> Bool let resultSelected: (ChatContextResult, ASDisplayNode, CGRect) -> Bool
let selectable: Bool = true let selectable: Bool = true
public init(account: Account, result: ChatContextResult, resultSelected: @escaping (ChatContextResult, ASDisplayNode, CGRect) -> Bool) { public init(account: Account, theme: PresentationTheme, result: ChatContextResult, resultSelected: @escaping (ChatContextResult, ASDisplayNode, CGRect) -> Bool) {
self.account = account self.account = account
self.theme = theme
self.result = result self.result = result
self.resultSelected = resultSelected self.resultSelected = resultSelected
} }
@ -84,6 +88,7 @@ final class HorizontalListContextResultsChatInputPanelItemNode: ListViewItemNode
private let imageNodeBackground: ASDisplayNode private let imageNodeBackground: ASDisplayNode
private let imageNode: TransformImageNode private let imageNode: TransformImageNode
private var animationNode: AnimatedStickerNode? private var animationNode: AnimatedStickerNode?
private var placeholderNode: StickerShimmerEffectNode?
private var videoLayer: (SoftwareVideoThumbnailNode, SoftwareVideoLayerFrameManager, SampleBufferLayer)? private var videoLayer: (SoftwareVideoThumbnailNode, SoftwareVideoLayerFrameManager, SampleBufferLayer)?
private var currentImageResource: TelegramMediaResource? private var currentImageResource: TelegramMediaResource?
private var currentVideoFile: TelegramMediaFile? private var currentVideoFile: TelegramMediaFile?
@ -153,6 +158,8 @@ final class HorizontalListContextResultsChatInputPanelItemNode: ListViewItemNode
self.imageNodeBackground = ASDisplayNode() self.imageNodeBackground = ASDisplayNode()
self.imageNodeBackground.isLayerBacked = true self.imageNodeBackground.isLayerBacked = true
self.placeholderNode = StickerShimmerEffectNode()
self.imageNode = TransformImageNode() self.imageNode = TransformImageNode()
self.imageNode.contentAnimations = [.subsequentUpdates] self.imageNode.contentAnimations = [.subsequentUpdates]
self.imageNode.isLayerBacked = !smartInvertColorsEnabled() self.imageNode.isLayerBacked = !smartInvertColorsEnabled()
@ -170,6 +177,22 @@ final class HorizontalListContextResultsChatInputPanelItemNode: ListViewItemNode
self.imageNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0) self.imageNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
self.imageNode.contentAnimations = [.firstUpdate, .subsequentUpdates] self.imageNode.contentAnimations = [.firstUpdate, .subsequentUpdates]
self.addSubnode(self.imageNode) self.addSubnode(self.imageNode)
var firstTime = true
self.imageNode.imageUpdated = { [weak self] image in
guard let strongSelf = self else {
return
}
if image != nil {
strongSelf.removePlaceholder(animated: !firstTime)
}
firstTime = false
}
if let placeholderNode = self.placeholderNode {
placeholderNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
self.addSubnode(placeholderNode)
}
} }
deinit { deinit {
@ -181,6 +204,22 @@ final class HorizontalListContextResultsChatInputPanelItemNode: ListViewItemNode
self.fetchDisposable.dispose() self.fetchDisposable.dispose()
} }
private func removePlaceholder(animated: Bool) {
if let placeholderNode = self.placeholderNode {
self.placeholderNode = nil
if !animated {
placeholderNode.removeFromSupernode()
} else {
placeholderNode.allowsGroupOpacity = true
placeholderNode.alpha = 0.0
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
placeholderNode?.removeFromSupernode()
placeholderNode?.allowsGroupOpacity = false
})
}
}
}
override public func layoutForParams(_ params: ListViewItemLayoutParams, item: ListViewItem, previousItem: ListViewItem?, nextItem: ListViewItem?) { override public func layoutForParams(_ params: ListViewItemLayoutParams, item: ListViewItem, previousItem: ListViewItem?, nextItem: ListViewItem?) {
if let item = item as? HorizontalListContextResultsChatInputPanelItem { if let item = item as? HorizontalListContextResultsChatInputPanelItem {
let doLayout = self.asyncLayout() let doLayout = self.asyncLayout()
@ -385,7 +424,11 @@ final class HorizontalListContextResultsChatInputPanelItemNode: ListViewItemNode
animationNode = AnimatedStickerNode() animationNode = AnimatedStickerNode()
animationNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0) animationNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
animationNode.visibility = true animationNode.visibility = true
strongSelf.addSubnode(animationNode) if let placeholderNode = strongSelf.placeholderNode {
strongSelf.insertSubnode(animationNode, belowSubnode: placeholderNode)
} else {
strongSelf.addSubnode(animationNode)
}
strongSelf.animationNode = animationNode strongSelf.animationNode = animationNode
} }
animationNode.started = { [weak self] in animationNode.started = { [weak self] in
@ -406,7 +449,6 @@ final class HorizontalListContextResultsChatInputPanelItemNode: ListViewItemNode
strongSelf.statusNode.frame = progressFrame strongSelf.statusNode.frame = progressFrame
if let updatedStatusSignal = updatedStatusSignal { if let updatedStatusSignal = updatedStatusSignal {
strongSelf.statusDisposable.set((updatedStatusSignal |> deliverOnMainQueue).start(next: { [weak strongSelf] status in strongSelf.statusDisposable.set((updatedStatusSignal |> deliverOnMainQueue).start(next: { [weak strongSelf] status in
displayLinkDispatcher.dispatch { displayLinkDispatcher.dispatch {
@ -446,6 +488,18 @@ final class HorizontalListContextResultsChatInputPanelItemNode: ListViewItemNode
animationNode.position = CGPoint(x: height / 2.0, y: (nodeLayout.contentSize.height - sideInset) / 2.0 + sideInset) animationNode.position = CGPoint(x: height / 2.0, y: (nodeLayout.contentSize.height - sideInset) / 2.0 + sideInset)
animationNode.updateLayout(size: croppedImageDimensions) animationNode.updateLayout(size: croppedImageDimensions)
} }
var immediateThumbnailData: Data?
if case let .internalReference(internalReference) = item.result, internalReference.file?.isSticker == true {
immediateThumbnailData = internalReference.file?.immediateThumbnailData
}
if let placeholderNode = strongSelf.placeholderNode {
placeholderNode.bounds = CGRect(origin: CGPoint(), size: CGSize(width: croppedImageDimensions.width, height: croppedImageDimensions.height))
placeholderNode.position = CGPoint(x: height / 2.0, y: (nodeLayout.contentSize.height - sideInset) / 2.0 + sideInset)
placeholderNode.update(backgroundColor: item.theme.list.plainBackgroundColor, foregroundColor: item.theme.list.mediaPlaceholderColor.mixedWith(item.theme.list.plainBackgroundColor, alpha: 0.4), shimmeringColor: item.theme.list.mediaPlaceholderColor.withAlphaComponent(0.3), data: immediateThumbnailData, size: CGSize(width: croppedImageDimensions.width, height: croppedImageDimensions.height))
}
} }
}) })
} }

View File

@ -187,7 +187,6 @@ final class HorizontalStickerGridItemNode: GridItemNode {
let boundingSize = bounds.insetBy(dx: 2.0, dy: 2.0).size let boundingSize = bounds.insetBy(dx: 2.0, dy: 2.0).size
if let placeholderNode = self.placeholderNode { if let placeholderNode = self.placeholderNode {
let placeholderFrame = CGRect(origin: CGPoint(x: floor((bounds.width - boundingSize.width) / 2.0), y: floor((bounds.height - boundingSize.height) / 2.0)), size: boundingSize)
placeholderNode.frame = bounds placeholderNode.frame = bounds
if let theme = self.currentState?.1.theme, let file = self.currentState?.1.file { if let theme = self.currentState?.1.theme, let file = self.currentState?.1.file {

View File

@ -445,6 +445,7 @@ final class PeerInfoSelectionPanelNode: ASDisplayNode {
}, activatePinnedListPreview: { _, _ in }, activatePinnedListPreview: { _, _ in
}, joinGroupCall: { _ in }, joinGroupCall: { _ in
}, editMessageMedia: { _, _ in }, editMessageMedia: { _, _ in
}, presentAddMembers: {
}, statuses: nil) }, statuses: nil)
self.selectionPanel.interfaceInteraction = interfaceInteraction self.selectionPanel.interfaceInteraction = interfaceInteraction

View File

@ -195,7 +195,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
self.textNode.attributedText = attributedText self.textNode.attributedText = attributedText
self.textNode.maximumNumberOfLines = 2 self.textNode.maximumNumberOfLines = 2
displayUndo = false displayUndo = false
self.originalRemainingSeconds = 5 self.originalRemainingSeconds = 4
case let .banned(text): case let .banned(text):
self.avatarNode = nil self.avatarNode = nil
self.iconNode = nil self.iconNode = nil