mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Web app improvements
This commit is contained in:
parent
f5092b8d8d
commit
ec79dd27ed
@ -455,13 +455,13 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
case .changed:
|
case .changed:
|
||||||
guard let _ = self.dismissingItemId else { return }
|
guard let _ = self.dismissingItemId else { return }
|
||||||
|
|
||||||
var delta = gestureRecognizer.translation(in: scrollView)
|
var translation = gestureRecognizer.translation(in: scrollView)
|
||||||
delta.y = 0
|
translation.y = 0
|
||||||
|
|
||||||
if let offset = self.dismissingItemOffset {
|
if let offset = self.dismissingItemOffset {
|
||||||
self.dismissingItemOffset = offset + delta.x
|
self.dismissingItemOffset = offset + translation.x
|
||||||
} else {
|
} else {
|
||||||
self.dismissingItemOffset = delta.x
|
self.dismissingItemOffset = translation.x
|
||||||
}
|
}
|
||||||
|
|
||||||
gestureRecognizer.setTranslation(.zero, in: scrollView)
|
gestureRecognizer.setTranslation(.zero, in: scrollView)
|
||||||
@ -473,6 +473,7 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
if let offset = self.dismissingItemOffset {
|
if let offset = self.dismissingItemOffset {
|
||||||
let velocity = gestureRecognizer.velocity(in: self.view)
|
let velocity = gestureRecognizer.velocity(in: self.view)
|
||||||
if offset < -self.frame.width / 3.0 || velocity.x < -300.0 {
|
if offset < -self.frame.width / 3.0 || velocity.x < -300.0 {
|
||||||
|
let proceed = {
|
||||||
self.currentTransition = .dismiss(itemId: itemId)
|
self.currentTransition = .dismiss(itemId: itemId)
|
||||||
|
|
||||||
self.items.removeAll(where: { $0.id == itemId })
|
self.items.removeAll(where: { $0.id == itemId })
|
||||||
@ -482,8 +483,25 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
needsLayout = false
|
needsLayout = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let item = self.items.first(where: { $0.id == itemId }), !item.controller.shouldDismissImmediately() {
|
||||||
|
self.displayDismissConfirmation(completion: { commit in
|
||||||
self.dismissingItemOffset = nil
|
self.dismissingItemOffset = nil
|
||||||
self.dismissingItemId = nil
|
self.dismissingItemId = nil
|
||||||
|
if commit {
|
||||||
|
proceed()
|
||||||
|
} else {
|
||||||
|
self.requestUpdate(transition: .animated(duration: 0.4, curve: .spring))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
proceed()
|
||||||
|
self.dismissingItemOffset = nil
|
||||||
|
self.dismissingItemId = nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.dismissingItemOffset = nil
|
||||||
|
self.dismissingItemId = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if needsLayout {
|
if needsLayout {
|
||||||
@ -613,6 +631,26 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func displayDismissConfirmation(completion: @escaping (Bool) -> Void) {
|
||||||
|
let actionSheet = ActionSheetController(presentationData: self.presentationData)
|
||||||
|
actionSheet.setItemGroups([
|
||||||
|
ActionSheetItemGroup(items: [
|
||||||
|
ActionSheetTextItem(title: self.presentationData.strings.WebApp_CloseConfirmation),
|
||||||
|
ActionSheetButtonItem(title: self.presentationData.strings.WebApp_CloseAnyway, color: .destructive, action: { [weak actionSheet] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
completion(true)
|
||||||
|
})
|
||||||
|
]),
|
||||||
|
ActionSheetItemGroup(items: [
|
||||||
|
ActionSheetButtonItem(title: self.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
completion(false)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
])
|
||||||
|
self.navigationController?.presentOverlay(controller: actionSheet, inGlobal: false, blockInteraction: false)
|
||||||
|
}
|
||||||
|
|
||||||
private func requestUpdate(transition: ContainedViewLayoutTransition, completion: @escaping (Transition) -> Void = { _ in }) {
|
private func requestUpdate(transition: ContainedViewLayoutTransition, completion: @escaping (Transition) -> Void = { _ in }) {
|
||||||
guard let layout = self.validLayout else {
|
guard let layout = self.validLayout else {
|
||||||
return
|
return
|
||||||
@ -720,23 +758,11 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let item = itemNode?.item, !item.controller.shouldDismissImmediately() {
|
if let item = itemNode?.item, !item.controller.shouldDismissImmediately() {
|
||||||
let actionSheet = ActionSheetController(presentationData: self.presentationData)
|
self.displayDismissConfirmation(completion: { commit in
|
||||||
actionSheet.setItemGroups([
|
if commit {
|
||||||
ActionSheetItemGroup(items: [
|
|
||||||
ActionSheetTextItem(title: self.presentationData.strings.WebApp_CloseConfirmation),
|
|
||||||
ActionSheetButtonItem(title: self.presentationData.strings.WebApp_CloseAnyway, color: .destructive, action: { [weak actionSheet] in
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
|
|
||||||
proceed()
|
proceed()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
]),
|
|
||||||
ActionSheetItemGroup(items: [
|
|
||||||
ActionSheetButtonItem(title: self.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
})
|
|
||||||
])
|
|
||||||
])
|
|
||||||
self.navigationController?.presentOverlay(controller: actionSheet, inGlobal: false, blockInteraction: false)
|
|
||||||
} else {
|
} else {
|
||||||
proceed()
|
proceed()
|
||||||
}
|
}
|
||||||
@ -761,23 +787,11 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
|||||||
self.navigationController?.presentOverlay(controller: actionSheet, inGlobal: false, blockInteraction: false)
|
self.navigationController?.presentOverlay(controller: actionSheet, inGlobal: false, blockInteraction: false)
|
||||||
} else if let item = self.items.first {
|
} else if let item = self.items.first {
|
||||||
if !item.controller.shouldDismissImmediately() {
|
if !item.controller.shouldDismissImmediately() {
|
||||||
let actionSheet = ActionSheetController(presentationData: self.presentationData)
|
self.displayDismissConfirmation(completion: { [weak self] commit in
|
||||||
actionSheet.setItemGroups([
|
if commit {
|
||||||
ActionSheetItemGroup(items: [
|
|
||||||
ActionSheetTextItem(title: self.presentationData.strings.WebApp_CloseConfirmation),
|
|
||||||
ActionSheetButtonItem(title: self.presentationData.strings.WebApp_CloseAnyway, color: .destructive, action: { [weak self, weak actionSheet] in
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
|
|
||||||
self?.navigationController?.dismissMinimizedControllers(animated: true)
|
self?.navigationController?.dismissMinimizedControllers(animated: true)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
]),
|
|
||||||
ActionSheetItemGroup(items: [
|
|
||||||
ActionSheetButtonItem(title: self.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
})
|
|
||||||
])
|
|
||||||
])
|
|
||||||
self.navigationController?.presentOverlay(controller: actionSheet, inGlobal: false, blockInteraction: false)
|
|
||||||
} else {
|
} else {
|
||||||
self.navigationController?.dismissMinimizedControllers(animated: true)
|
self.navigationController?.dismissMinimizedControllers(animated: true)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user