mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-09 22:20:41 +00:00
Merge commit 'e23c7f2e2bbe800fb2e68a7b96fdf9b629a10573'
This commit is contained in:
commit
d65df43cb5
@ -28,6 +28,29 @@ public enum AttachmentButtonType: Equatable {
|
|||||||
case gift
|
case gift
|
||||||
case standalone
|
case standalone
|
||||||
|
|
||||||
|
public var key: String {
|
||||||
|
switch self {
|
||||||
|
case .gallery:
|
||||||
|
return "gallery"
|
||||||
|
case .file:
|
||||||
|
return "file"
|
||||||
|
case .location:
|
||||||
|
return "location"
|
||||||
|
case .quickReply:
|
||||||
|
return "quickReply"
|
||||||
|
case .contact:
|
||||||
|
return "contact"
|
||||||
|
case .poll:
|
||||||
|
return "poll"
|
||||||
|
case let .app(bot):
|
||||||
|
return "app_\(bot.shortName)"
|
||||||
|
case .gift:
|
||||||
|
return "gift"
|
||||||
|
case .standalone:
|
||||||
|
return "standalone"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static func ==(lhs: AttachmentButtonType, rhs: AttachmentButtonType) -> Bool {
|
public static func ==(lhs: AttachmentButtonType, rhs: AttachmentButtonType) -> Bool {
|
||||||
switch lhs {
|
switch lhs {
|
||||||
case .gallery:
|
case .gallery:
|
||||||
@ -207,10 +230,10 @@ public class AttachmentController: ViewController {
|
|||||||
private let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?
|
private let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?
|
||||||
private let chatLocation: ChatLocation?
|
private let chatLocation: ChatLocation?
|
||||||
private let isScheduledMessages: Bool
|
private let isScheduledMessages: Bool
|
||||||
private let buttons: [AttachmentButtonType]
|
private var buttons: [AttachmentButtonType]
|
||||||
private let initialButton: AttachmentButtonType
|
private let initialButton: AttachmentButtonType
|
||||||
private let fromMenu: Bool
|
private let fromMenu: Bool
|
||||||
private let hasTextInput: Bool
|
private var hasTextInput: Bool
|
||||||
private let makeEntityInputView: () -> AttachmentTextInputPanelInputView?
|
private let makeEntityInputView: () -> AttachmentTextInputPanelInputView?
|
||||||
public var animateAppearance: Bool = false
|
public var animateAppearance: Bool = false
|
||||||
|
|
||||||
@ -239,7 +262,7 @@ public class AttachmentController: ViewController {
|
|||||||
private let makeEntityInputView: () -> AttachmentTextInputPanelInputView?
|
private let makeEntityInputView: () -> AttachmentTextInputPanelInputView?
|
||||||
let panel: AttachmentPanel
|
let panel: AttachmentPanel
|
||||||
|
|
||||||
private var currentType: AttachmentButtonType?
|
fileprivate var currentType: AttachmentButtonType?
|
||||||
private var currentControllers: [AttachmentContainable] = []
|
private var currentControllers: [AttachmentContainable] = []
|
||||||
|
|
||||||
private var validLayout: ContainerViewLayout?
|
private var validLayout: ContainerViewLayout?
|
||||||
@ -368,7 +391,7 @@ public class AttachmentController: ViewController {
|
|||||||
|
|
||||||
self.container.interactivelyDismissed = { [weak self] velocity in
|
self.container.interactivelyDismissed = { [weak self] velocity in
|
||||||
if let strongSelf = self, let layout = strongSelf.validLayout {
|
if let strongSelf = self, let layout = strongSelf.validLayout {
|
||||||
if let controller = strongSelf.controller, controller.shouldMinimizeOnSwipe?() == true, let navigationController = controller.navigationController as? NavigationController {
|
if let controller = strongSelf.controller, controller.shouldMinimizeOnSwipe?(strongSelf.currentType) == true, let navigationController = controller.navigationController as? NavigationController {
|
||||||
|
|
||||||
let delta = layout.size.height - controller.minimizedTopEdgeOffset
|
let delta = layout.size.height - controller.minimizedTopEdgeOffset
|
||||||
let damping: CGFloat = 180
|
let damping: CGFloat = 180
|
||||||
@ -390,7 +413,6 @@ public class AttachmentController: ViewController {
|
|||||||
|
|
||||||
strongSelf.isMinimizing = true
|
strongSelf.isMinimizing = true
|
||||||
strongSelf.container.update(isExpanded: true, force: true, transition: .immediate)
|
strongSelf.container.update(isExpanded: true, force: true, transition: .immediate)
|
||||||
// strongSelf.container.update(isExpanded: true, force: true, transition: .animated(duration: 0.4, curve: .customSpring(damping: 180.0, initialVelocity: initialVelocity)))
|
|
||||||
strongSelf.isMinimizing = false
|
strongSelf.isMinimizing = false
|
||||||
|
|
||||||
Queue.mainQueue().after(0.45, {
|
Queue.mainQueue().after(0.45, {
|
||||||
@ -1025,7 +1047,7 @@ public class AttachmentController: ViewController {
|
|||||||
|
|
||||||
public var getSourceRect: (() -> CGRect?)?
|
public var getSourceRect: (() -> CGRect?)?
|
||||||
|
|
||||||
public var shouldMinimizeOnSwipe: (() -> Bool)?
|
public var shouldMinimizeOnSwipe: ((AttachmentButtonType?) -> Bool)?
|
||||||
|
|
||||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, chatLocation: ChatLocation?, isScheduledMessages: Bool = false, buttons: [AttachmentButtonType], initialButton: AttachmentButtonType = .gallery, fromMenu: Bool = false, hasTextInput: Bool = true, makeEntityInputView: @escaping () -> AttachmentTextInputPanelInputView? = { return nil}) {
|
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, chatLocation: ChatLocation?, isScheduledMessages: Bool = false, buttons: [AttachmentButtonType], initialButton: AttachmentButtonType = .gallery, fromMenu: Bool = false, hasTextInput: Bool = true, makeEntityInputView: @escaping () -> AttachmentTextInputPanelInputView? = { return nil}) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@ -1061,31 +1083,18 @@ public class AttachmentController: ViewController {
|
|||||||
return self.buttons.contains(.standalone)
|
return self.buttons.contains(.standalone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// private var snapshotView: UIView?
|
public func convertToStandalone() {
|
||||||
// public override var isMinimized: Bool {
|
guard self.buttons != [.standalone] else {
|
||||||
// didSet {
|
return
|
||||||
// guard self.isMinimized != oldValue else {
|
}
|
||||||
// return
|
if case let .app(bot) = self.node.currentType {
|
||||||
// }
|
self.title = bot.peer.compactDisplayTitle
|
||||||
// if self.isMinimized {
|
}
|
||||||
// if self.snapshotView == nil, let lastController = self.node.container.container.controllers.last, let snapshotView = lastController.view.snapshotView(afterScreenUpdates: false) {
|
self.buttons = [.standalone]
|
||||||
// snapshotView.isUserInteractionEnabled = false
|
self.hasTextInput = false
|
||||||
// self.snapshotView = snapshotView
|
self.requestLayout(transition: .immediate)
|
||||||
// lastController.view.addSubview(snapshotView)
|
}
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if let snapshotView = self.snapshotView {
|
|
||||||
// self.snapshotView = nil
|
|
||||||
// Queue.mainQueue().after(0.15) {
|
|
||||||
// snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, removeOnCompletion: false, completion: { _ in
|
|
||||||
// snapshotView.removeFromSuperview()
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public func updateSelectionCount(_ count: Int) {
|
public func updateSelectionCount(_ count: Int) {
|
||||||
self.node.updateSelectionCount(count, animated: false)
|
self.node.updateSelectionCount(count, animated: false)
|
||||||
}
|
}
|
||||||
|
@ -701,7 +701,7 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate {
|
|||||||
private let backgroundNode: NavigationBackgroundNode
|
private let backgroundNode: NavigationBackgroundNode
|
||||||
private let scrollNode: ASScrollNode
|
private let scrollNode: ASScrollNode
|
||||||
private let separatorNode: ASDisplayNode
|
private let separatorNode: ASDisplayNode
|
||||||
private var buttonViews: [Int: ComponentHostView<Empty>] = [:]
|
private var buttonViews: [AnyHashable: ComponentHostView<Empty>] = [:]
|
||||||
|
|
||||||
private var textInputPanelNode: AttachmentTextInputPanelNode?
|
private var textInputPanelNode: AttachmentTextInputPanelNode?
|
||||||
private var progressNode: LoadingProgressNode?
|
private var progressNode: LoadingProgressNode?
|
||||||
@ -1169,7 +1169,6 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let visibleRect = self.scrollNode.bounds.insetBy(dx: -180.0, dy: 0.0)
|
let visibleRect = self.scrollNode.bounds.insetBy(dx: -180.0, dy: 0.0)
|
||||||
var validButtons = Set<Int>()
|
|
||||||
|
|
||||||
var distanceBetweenNodes = layout.size.width / CGFloat(self.buttons.count)
|
var distanceBetweenNodes = layout.size.width / CGFloat(self.buttons.count)
|
||||||
let internalWidth = distanceBetweenNodes * CGFloat(self.buttons.count - 1)
|
let internalWidth = distanceBetweenNodes * CGFloat(self.buttons.count - 1)
|
||||||
@ -1182,26 +1181,29 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate {
|
|||||||
leftNodeOriginX = layout.safeInsets.left + sideInset + buttonWidth / 2.0
|
leftNodeOriginX = layout.safeInsets.left + sideInset + buttonWidth / 2.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var validIds = Set<AnyHashable>()
|
||||||
|
|
||||||
for i in 0 ..< self.buttons.count {
|
for i in 0 ..< self.buttons.count {
|
||||||
let originX = floor(leftNodeOriginX + CGFloat(i) * distanceBetweenNodes - buttonWidth / 2.0)
|
let originX = floor(leftNodeOriginX + CGFloat(i) * distanceBetweenNodes - buttonWidth / 2.0)
|
||||||
let buttonFrame = CGRect(origin: CGPoint(x: originX, y: 0.0), size: CGSize(width: buttonWidth, height: buttonSize.height))
|
let buttonFrame = CGRect(origin: CGPoint(x: originX, y: 0.0), size: CGSize(width: buttonWidth, height: buttonSize.height))
|
||||||
if !visibleRect.intersects(buttonFrame) {
|
if !visibleRect.intersects(buttonFrame) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
validButtons.insert(i)
|
|
||||||
|
let type = self.buttons[i]
|
||||||
|
let _ = validIds.insert(type.key)
|
||||||
|
|
||||||
var buttonTransition = transition
|
var buttonTransition = transition
|
||||||
let buttonView: ComponentHostView<Empty>
|
let buttonView: ComponentHostView<Empty>
|
||||||
if let current = self.buttonViews[i] {
|
if let current = self.buttonViews[type.key] {
|
||||||
buttonView = current
|
buttonView = current
|
||||||
} else {
|
} else {
|
||||||
buttonTransition = .immediate
|
buttonTransition = .immediate
|
||||||
buttonView = ComponentHostView<Empty>()
|
buttonView = ComponentHostView<Empty>()
|
||||||
self.buttonViews[i] = buttonView
|
self.buttonViews[type.key] = buttonView
|
||||||
self.scrollNode.view.addSubview(buttonView)
|
self.scrollNode.view.addSubview(buttonView)
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = self.buttons[i]
|
|
||||||
if case let .app(bot) = type {
|
if case let .app(bot) = type {
|
||||||
for (name, file) in bot.icons {
|
for (name, file) in bot.icons {
|
||||||
if [.default, .iOSAnimated, .iOSSettingsStatic, .placeholder].contains(name) {
|
if [.default, .iOSAnimated, .iOSSettingsStatic, .placeholder].contains(name) {
|
||||||
@ -1285,6 +1287,16 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate {
|
|||||||
buttonView.accessibilityLabel = accessibilityTitle
|
buttonView.accessibilityLabel = accessibilityTitle
|
||||||
buttonView.accessibilityTraits = [.button]
|
buttonView.accessibilityTraits = [.button]
|
||||||
}
|
}
|
||||||
|
var removeIds: [AnyHashable] = []
|
||||||
|
for (id, itemView) in self.buttonViews {
|
||||||
|
if !validIds.contains(id) {
|
||||||
|
removeIds.append(id)
|
||||||
|
itemView.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for id in removeIds {
|
||||||
|
self.buttonViews.removeValue(forKey: id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateScrollLayoutIfNeeded(force: Bool, transition: ContainedViewLayoutTransition) -> Bool {
|
private func updateScrollLayoutIfNeeded(force: Bool, transition: ContainedViewLayoutTransition) -> Bool {
|
||||||
|
@ -638,6 +638,7 @@ final class MediaPickerGridItemNode: GridItemNode {
|
|||||||
self.updateHiddenMedia()
|
self.updateHiddenMedia()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var currentPrice: Int64?
|
||||||
private var didSetupSpoiler = false
|
private var didSetupSpoiler = false
|
||||||
private func updateHasSpoiler(_ hasSpoiler: Bool, price: Int64?, isSingle: Bool) {
|
private func updateHasSpoiler(_ hasSpoiler: Bool, price: Int64?, isSingle: Bool) {
|
||||||
var animated = true
|
var animated = true
|
||||||
@ -645,7 +646,8 @@ final class MediaPickerGridItemNode: GridItemNode {
|
|||||||
animated = false
|
animated = false
|
||||||
self.didSetupSpoiler = true
|
self.didSetupSpoiler = true
|
||||||
}
|
}
|
||||||
|
self.currentPrice = isSingle ? price : nil
|
||||||
|
|
||||||
if hasSpoiler || price != nil {
|
if hasSpoiler || price != nil {
|
||||||
if self.spoilerNode == nil {
|
if self.spoilerNode == nil {
|
||||||
let spoilerNode = SpoilerOverlayNode(enableAnimations: self.enableAnimations)
|
let spoilerNode = SpoilerOverlayNode(enableAnimations: self.enableAnimations)
|
||||||
@ -724,6 +726,11 @@ final class MediaPickerGridItemNode: GridItemNode {
|
|||||||
spoilerNode.update(size: self.bounds.size, transition: .immediate)
|
spoilerNode.update(size: self.bounds.size, transition: .immediate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let priceNode = self.priceNode, self.bounds.width > 0.0 {
|
||||||
|
priceNode.frame = self.bounds
|
||||||
|
priceNode.update(size: self.bounds.size, price: self.currentPrice, small: true, transition: .immediate)
|
||||||
|
}
|
||||||
|
|
||||||
let statusSize = CGSize(width: 40.0, height: 40.0)
|
let statusSize = CGSize(width: 40.0, height: 40.0)
|
||||||
if let statusNode = self.statusNode {
|
if let statusNode = self.statusNode {
|
||||||
statusNode.view.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((self.bounds.width - statusSize.width) / 2.0), y: floorToScreenPixels((self.bounds.height - statusSize.height) / 2.0)), size: statusSize)
|
statusNode.view.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((self.bounds.width - statusSize.width) / 2.0), y: floorToScreenPixels((self.bounds.height - statusSize.height) / 2.0)), size: statusSize)
|
||||||
|
@ -2369,6 +2369,8 @@ public func channelStatsController(context: AccountContext, updatedPresentationD
|
|||||||
withdrawalDisposable.set((context.engine.peers.checkStarsRevenueWithdrawalAvailability()
|
withdrawalDisposable.set((context.engine.peers.checkStarsRevenueWithdrawalAvailability()
|
||||||
|> deliverOnMainQueue).start(error: { error in
|
|> deliverOnMainQueue).start(error: { error in
|
||||||
switch error {
|
switch error {
|
||||||
|
case .serverProvided:
|
||||||
|
return
|
||||||
case .requestPassword:
|
case .requestPassword:
|
||||||
let _ = (starsContext.state
|
let _ = (starsContext.state
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|
@ -234,6 +234,7 @@ public enum RequestStarsRevenueWithdrawalError : Equatable {
|
|||||||
case limitExceeded
|
case limitExceeded
|
||||||
case requestPassword
|
case requestPassword
|
||||||
case invalidPassword
|
case invalidPassword
|
||||||
|
case serverProvided(text: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _internal_checkStarsRevenueWithdrawalAvailability(account: Account) -> Signal<Never, RequestStarsRevenueWithdrawalError> {
|
func _internal_checkStarsRevenueWithdrawalAvailability(account: Account) -> Signal<Never, RequestStarsRevenueWithdrawalError> {
|
||||||
@ -292,7 +293,9 @@ func _internal_requestStarsRevenueWithdrawalUrl(account: Account, peerId: PeerId
|
|||||||
|> mapToSignal { password -> Signal<String, RequestStarsRevenueWithdrawalError> in
|
|> mapToSignal { password -> Signal<String, RequestStarsRevenueWithdrawalError> in
|
||||||
return account.network.request(Api.functions.payments.getStarsRevenueWithdrawalUrl(peer: inputPeer, stars: amount, password: password), automaticFloodWait: false)
|
return account.network.request(Api.functions.payments.getStarsRevenueWithdrawalUrl(peer: inputPeer, stars: amount, password: password), automaticFloodWait: false)
|
||||||
|> mapError { error -> RequestStarsRevenueWithdrawalError in
|
|> mapError { error -> RequestStarsRevenueWithdrawalError in
|
||||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
if error.errorCode == 406 {
|
||||||
|
return .serverProvided(text: error.errorDescription)
|
||||||
|
} else if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||||
return .limitExceeded
|
return .limitExceeded
|
||||||
} else if error.errorDescription == "PASSWORD_HASH_INVALID" {
|
} else if error.errorDescription == "PASSWORD_HASH_INVALID" {
|
||||||
return .invalidPassword
|
return .invalidPassword
|
||||||
|
@ -232,7 +232,6 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
|
|
||||||
private var highlightedItemId: AnyHashable?
|
private var highlightedItemId: AnyHashable?
|
||||||
|
|
||||||
private var dismissGestureRecognizer: UIPanGestureRecognizer?
|
|
||||||
private var dismissingItemId: AnyHashable?
|
private var dismissingItemId: AnyHashable?
|
||||||
private var dismissingItemOffset: CGFloat?
|
private var dismissingItemOffset: CGFloat?
|
||||||
|
|
||||||
@ -297,11 +296,10 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
self.scrollView.showsVerticalScrollIndicator = false
|
self.scrollView.showsVerticalScrollIndicator = false
|
||||||
self.scrollView.showsHorizontalScrollIndicator = false
|
self.scrollView.showsHorizontalScrollIndicator = false
|
||||||
|
|
||||||
let dismissGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.dismissPan(_:)))
|
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
|
||||||
dismissGestureRecognizer.delegate = self.wrappedGestureRecognizerDelegate
|
panGestureRecognizer.delegate = self.wrappedGestureRecognizerDelegate
|
||||||
dismissGestureRecognizer.delaysTouchesBegan = true
|
panGestureRecognizer.delaysTouchesBegan = true
|
||||||
self.scrollView.addGestureRecognizer(dismissGestureRecognizer)
|
self.scrollView.addGestureRecognizer(panGestureRecognizer)
|
||||||
self.dismissGestureRecognizer = dismissGestureRecognizer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func item(at y: CGFloat) -> Int? {
|
func item(at y: CGFloat) -> Int? {
|
||||||
@ -323,13 +321,35 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
let location = panGesture.location(in: gestureRecognizer.view)
|
let location = panGesture.location(in: gestureRecognizer.view)
|
||||||
let velocity = panGesture.velocity(in: gestureRecognizer.view)
|
let velocity = panGesture.velocity(in: gestureRecognizer.view)
|
||||||
|
|
||||||
if abs(velocity.x) > abs(velocity.y), let _ = self.item(at: location.y) {
|
if let _ = self.item(at: location.y) {
|
||||||
return true
|
if self.isExpanded {
|
||||||
|
return abs(velocity.x) > abs(velocity.y)
|
||||||
|
} else {
|
||||||
|
return abs(velocity.y) > abs(velocity.x)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func dismissPan(_ gestureRecognizer: UIPanGestureRecognizer) {
|
@objc func panGesture(_ gestureRecognizer: UIPanGestureRecognizer) {
|
||||||
|
if self.isExpanded {
|
||||||
|
self.dismissPanGesture(gestureRecognizer)
|
||||||
|
} else {
|
||||||
|
self.expandPanGesture(gestureRecognizer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func expandPanGesture(_ gestureRecognizer: UIPanGestureRecognizer) {
|
||||||
|
let translation = gestureRecognizer.translation(in: self.view)
|
||||||
|
if translation.y < -10.0 {
|
||||||
|
gestureRecognizer.isEnabled = false
|
||||||
|
gestureRecognizer.isEnabled = true
|
||||||
|
|
||||||
|
self.expand()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func dismissPanGesture(_ gestureRecognizer: UIPanGestureRecognizer) {
|
||||||
let scrollView = self.scrollView
|
let scrollView = self.scrollView
|
||||||
|
|
||||||
switch gestureRecognizer.state {
|
switch gestureRecognizer.state {
|
||||||
@ -357,7 +377,8 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
var needsLayout = true
|
var needsLayout = true
|
||||||
if let itemId = self.dismissingItemId {
|
if let itemId = self.dismissingItemId {
|
||||||
if let offset = self.dismissingItemOffset {
|
if let offset = self.dismissingItemOffset {
|
||||||
if offset < -self.frame.width / 4.0 {
|
let velocity = gestureRecognizer.velocity(in: self.view)
|
||||||
|
if offset < -self.frame.width / 3.0 || velocity.x < -300.0 {
|
||||||
self.currentTransition = .dismiss(itemId: itemId)
|
self.currentTransition = .dismiss(itemId: itemId)
|
||||||
|
|
||||||
self.items.removeAll(where: { $0.id == itemId })
|
self.items.removeAll(where: { $0.id == itemId })
|
||||||
@ -449,6 +470,18 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
completion()
|
completion()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func expand() {
|
||||||
|
guard !self.items.isEmpty && !self.isExpanded else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if self.items.count == 1, let item = self.items.first {
|
||||||
|
self.navigationController?.maximizeViewController(item.controller, animated: true)
|
||||||
|
} else {
|
||||||
|
self.isExpanded = true
|
||||||
|
self.requestUpdate(transition: .animated(duration: 0.4, curve: .spring))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
guard self.isExpanded else {
|
guard self.isExpanded else {
|
||||||
@ -569,12 +602,7 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
if self.isExpanded {
|
if self.isExpanded {
|
||||||
self.navigationController?.maximizeViewController(item.controller, animated: true)
|
self.navigationController?.maximizeViewController(item.controller, animated: true)
|
||||||
} else {
|
} else {
|
||||||
if self.items.count == 1 {
|
self.expand()
|
||||||
self.navigationController?.maximizeViewController(item.controller, animated: true)
|
|
||||||
} else {
|
|
||||||
self.isExpanded = true
|
|
||||||
self.requestUpdate(transition: .animated(duration: 0.4, curve: .spring))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,6 +679,8 @@ public final class StarsStatisticsScreen: ViewControllerComponentContainer {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch error {
|
switch error {
|
||||||
|
case .serverProvided:
|
||||||
|
return
|
||||||
case .requestPassword:
|
case .requestPassword:
|
||||||
let _ = (revenueContext.state
|
let _ = (revenueContext.state
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|
@ -3754,7 +3754,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let openWebView = {
|
let openWebView = {
|
||||||
if source == .menu {
|
if source == .menu {
|
||||||
strongSelf.updateChatPresentationInterfaceState(interactive: false) { state in
|
strongSelf.updateChatPresentationInterfaceState(interactive: false) { state in
|
||||||
return state.updatedShowWebView(true).updatedForceInputCommandsHidden(true)
|
return state.updatedForceInputCommandsHidden(true)
|
||||||
|
// return state.updatedShowWebView(true).updatedForceInputCommandsHidden(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
let context = strongSelf.context
|
let context = strongSelf.context
|
||||||
|
@ -1714,13 +1714,19 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
|||||||
transition.updateFrame(node: backgroundEffectNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
transition.updateFrame(node: backgroundEffectNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||||
}
|
}
|
||||||
|
|
||||||
let wallpaperBounds = CGRect(x: 0.0, y: 0.0, width: layout.size.width - wrappingInsets.left - wrappingInsets.right, height: layout.size.height)
|
var wallpaperBounds = CGRect(x: 0.0, y: 0.0, width: layout.size.width - wrappingInsets.left - wrappingInsets.right, height: layout.size.height)
|
||||||
|
|
||||||
transition.updateFrame(node: self.backgroundNode, frame: wallpaperBounds)
|
transition.updateFrame(node: self.backgroundNode, frame: wallpaperBounds)
|
||||||
|
|
||||||
var displayMode: WallpaperDisplayMode = .aspectFill
|
var displayMode: WallpaperDisplayMode = .aspectFill
|
||||||
if case .regular = layout.metrics.widthClass, layout.size.height == layout.deviceMetrics.screenSize.width {
|
if case .regular = layout.metrics.widthClass, layout.size.height == layout.deviceMetrics.screenSize.width {
|
||||||
displayMode = .aspectFit
|
displayMode = .aspectFit
|
||||||
|
} else if case .compact = layout.metrics.widthClass {
|
||||||
|
if layout.size.width < layout.size.height && layout.size.height < layout.deviceMetrics.screenSize.height {
|
||||||
|
wallpaperBounds.size.height = layout.deviceMetrics.screenSize.height
|
||||||
|
} else if layout.size.width > layout.size.height && layout.size.height < layout.deviceMetrics.screenSize.width {
|
||||||
|
wallpaperBounds.size.height = layout.deviceMetrics.screenSize.width
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.backgroundNode.updateLayout(size: wallpaperBounds.size, displayMode: displayMode, transition: transition)
|
self.backgroundNode.updateLayout(size: wallpaperBounds.size, displayMode: displayMode, transition: transition)
|
||||||
|
|
||||||
|
@ -277,6 +277,13 @@ extension ChatControllerImpl {
|
|||||||
}
|
}
|
||||||
return EntityInputView(context: strongSelf.context, isDark: false, areCustomEmojiEnabled: strongSelf.presentationInterfaceState.customEmojiAvailable)
|
return EntityInputView(context: strongSelf.context, isDark: false, areCustomEmojiEnabled: strongSelf.presentationInterfaceState.customEmojiAvailable)
|
||||||
})
|
})
|
||||||
|
attachmentController.shouldMinimizeOnSwipe = { [weak attachmentController] button in
|
||||||
|
if case .app = button {
|
||||||
|
attachmentController?.convertToStandalone()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
attachmentController.didDismiss = { [weak self] in
|
attachmentController.didDismiss = { [weak self] in
|
||||||
self?.attachmentController = nil
|
self?.attachmentController = nil
|
||||||
self?.canReadHistory.set(true)
|
self?.canReadHistory.set(true)
|
||||||
|
@ -1743,7 +1743,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
|||||||
self.menuButtonIconNode.enqueueState(.close, animated: false)
|
self.menuButtonIconNode.enqueueState(.close, animated: false)
|
||||||
} else if case .webView = interfaceState.botMenuButton, let previousShowWebView = previousState?.showWebView, previousShowWebView != interfaceState.showWebView {
|
} else if case .webView = interfaceState.botMenuButton, let previousShowWebView = previousState?.showWebView, previousShowWebView != interfaceState.showWebView {
|
||||||
if interfaceState.showWebView {
|
if interfaceState.showWebView {
|
||||||
self.menuButtonIconNode.enqueueState(.close, animated: true)
|
// self.menuButtonIconNode.enqueueState(.close, animated: true)
|
||||||
} else {
|
} else {
|
||||||
self.menuButtonIconNode.enqueueState(.app, animated: true)
|
self.menuButtonIconNode.enqueueState(.app, animated: true)
|
||||||
}
|
}
|
||||||
@ -4536,7 +4536,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
|||||||
}
|
}
|
||||||
} else if case let .webView(title, url) = presentationInterfaceState.botMenuButton {
|
} else if case let .webView(title, url) = presentationInterfaceState.botMenuButton {
|
||||||
let willShow = !(self.presentationInterfaceState?.showWebView ?? false)
|
let willShow = !(self.presentationInterfaceState?.showWebView ?? false)
|
||||||
if willShow {
|
if willShow || "".isEmpty {
|
||||||
self.interfaceInteraction?.openWebView(title, url, false, .menu)
|
self.interfaceInteraction?.openWebView(title, url, false, .menu)
|
||||||
} else {
|
} else {
|
||||||
self.interfaceInteraction?.updateShowWebView { _ in
|
self.interfaceInteraction?.updateShowWebView { _ in
|
||||||
|
@ -2182,7 +2182,7 @@ public func standaloneWebAppController(
|
|||||||
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.source == .menu, hasTextInput: false, makeEntityInputView: {
|
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.source == .menu, hasTextInput: false, makeEntityInputView: {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
controller.getInputContainerNode = getInputContainerNode
|
// controller.getInputContainerNode = getInputContainerNode
|
||||||
controller.requestController = { _, present in
|
controller.requestController = { _, present in
|
||||||
let webAppController = WebAppController(context: context, updatedPresentationData: updatedPresentationData, params: params, replyToMessageId: nil, threadId: threadId)
|
let webAppController = WebAppController(context: context, updatedPresentationData: updatedPresentationData, params: params, replyToMessageId: nil, threadId: threadId)
|
||||||
webAppController.openUrl = openUrl
|
webAppController.openUrl = openUrl
|
||||||
@ -2195,12 +2195,8 @@ public func standaloneWebAppController(
|
|||||||
controller.didDismiss = didDismiss
|
controller.didDismiss = didDismiss
|
||||||
controller.getSourceRect = getSourceRect
|
controller.getSourceRect = getSourceRect
|
||||||
controller.title = params.botName
|
controller.title = params.botName
|
||||||
controller.shouldMinimizeOnSwipe = {
|
controller.shouldMinimizeOnSwipe = { _ in
|
||||||
if params.source != .menu {
|
return true
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return controller
|
return controller
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user