mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +00:00
Attachment menu improvements
This commit is contained in:
parent
555c097d07
commit
8332b434a9
@ -7352,6 +7352,10 @@ Sorry for the inconvenience.";
|
||||
"Attachment.LocationAccessTitle" = "Access Your Location";
|
||||
"Attachment.LocationAccessText" = "Share places or your live location.";
|
||||
|
||||
"Attachment.CancelSelectionAlertText" = "Cancel selection?";
|
||||
"Attachment.CancelSelectionAlertYes" = "Yes";
|
||||
"Attachment.CancelSelectionAlertNo" = "No";
|
||||
|
||||
"ChannelInfo.CreateExternalStream" = "Stream With...";
|
||||
|
||||
"CreateExternalStream.Title" = "Stream With...";
|
||||
|
@ -207,18 +207,24 @@ final class AttachmentContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
if currentOffset > 0.0, let scrollView = scrollView {
|
||||
scrollView.panGestureRecognizer.setTranslation(CGPoint(), in: scrollView)
|
||||
}
|
||||
}
|
||||
|
||||
var bounds = self.bounds
|
||||
if self.isExpanded {
|
||||
bounds.origin.y = -max(0.0, translation - edgeTopInset)
|
||||
} else {
|
||||
bounds.origin.y = -translation
|
||||
}
|
||||
bounds.origin.y = min(0.0, bounds.origin.y)
|
||||
self.bounds = bounds
|
||||
}
|
||||
|
||||
self.update(layout: layout, controllers: controllers, coveredByModalTransition: coveredByModalTransition, transition: .immediate)
|
||||
case .ended:
|
||||
guard let (currentTopInset, panOffset, scrollView, listNode) = self.panGestureArguments else {
|
||||
return
|
||||
}
|
||||
self.panGestureArguments = nil
|
||||
|
||||
let visibleContentOffset = listNode?.visibleContentOffset()
|
||||
let contentOffset = scrollView?.contentOffset.y ?? 0.0
|
||||
|
||||
@ -236,15 +242,23 @@ final class AttachmentContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
var bounds = self.bounds
|
||||
if self.isExpanded {
|
||||
bounds.origin.y = -max(0.0, translation - edgeTopInset)
|
||||
} else {
|
||||
bounds.origin.y = -translation
|
||||
}
|
||||
bounds.origin.y = min(0.0, bounds.origin.y)
|
||||
|
||||
scrollView?.bounces = true
|
||||
|
||||
let offset = currentTopInset + panOffset
|
||||
let topInset: CGFloat = edgeTopInset
|
||||
if self.isExpanded {
|
||||
self.panGestureArguments = nil
|
||||
|
||||
var dismissing = false
|
||||
if bounds.minY < -60 || (bounds.minY < 0.0 && velocity.y > 300.0) || (self.isExpanded && bounds.minY.isZero && velocity.y > 600.0) {
|
||||
self.interactivelyDismissed?()
|
||||
dismissing = true
|
||||
} else if self.isExpanded {
|
||||
if velocity.y > 300.0 || offset > topInset / 2.0 {
|
||||
self.isExpanded = false
|
||||
if let listNode = listNode {
|
||||
@ -262,13 +276,6 @@ final class AttachmentContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
|
||||
self.update(layout: layout, controllers: controllers, coveredByModalTransition: coveredByModalTransition, transition: .animated(duration: 0.3, curve: .easeInOut))
|
||||
}
|
||||
} else {
|
||||
self.panGestureArguments = nil
|
||||
|
||||
var dismissing = false
|
||||
if bounds.minY < -60 || (bounds.minY < 0.0 && velocity.y > 300.0) {
|
||||
self.interactivelyDismissed?()
|
||||
dismissing = true
|
||||
} else if (velocity.y < -300.0 || offset < topInset / 2.0) {
|
||||
if velocity.y > -2200.0 && velocity.y < -300.0, let listNode = listNode {
|
||||
DispatchQueue.main.async {
|
||||
@ -298,7 +305,6 @@ final class AttachmentContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
self.bounds = bounds
|
||||
self.layer.animateBounds(from: previousBounds, to: self.bounds, duration: 0.3, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue)
|
||||
}
|
||||
}
|
||||
case .cancelled:
|
||||
self.panGestureArguments = nil
|
||||
|
||||
|
@ -28,6 +28,8 @@ public protocol AttachmentContainable: ViewController {
|
||||
|
||||
func resetForReuse()
|
||||
func prepareForReuse()
|
||||
|
||||
func requestDismiss(completion: @escaping () -> Void)
|
||||
}
|
||||
|
||||
public extension AttachmentContainable {
|
||||
@ -38,6 +40,10 @@ public extension AttachmentContainable {
|
||||
func prepareForReuse() {
|
||||
|
||||
}
|
||||
|
||||
func requestDismiss(completion: @escaping () -> Void) {
|
||||
completion()
|
||||
}
|
||||
}
|
||||
|
||||
public enum AttachmentMediaPickerSendMode {
|
||||
@ -274,9 +280,15 @@ public class AttachmentController: ViewController {
|
||||
|
||||
@objc func dimTapGesture(_ recognizer: UITapGestureRecognizer) {
|
||||
if case .ended = recognizer.state {
|
||||
if let controller = self.currentControllers.last {
|
||||
controller.requestDismiss(completion: { [weak self] in
|
||||
self?.controller?.dismiss(animated: true)
|
||||
})
|
||||
} else {
|
||||
self.controller?.dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func switchToController(_ type: AttachmentButtonType, _ ascending: Bool) -> Bool {
|
||||
guard self.currentType != type else {
|
||||
|
@ -140,6 +140,10 @@
|
||||
if (strongSelf == nil)
|
||||
return;
|
||||
|
||||
strongSelf->_ignoreSelectionUpdates = true;
|
||||
[strongSelf->_selectionChangedDisposable dispose];
|
||||
[strongSelf->_itemSelectedDisposable dispose];
|
||||
|
||||
[strongSelf.window endEditing:true];
|
||||
strongSelf->_portraitToolbarView.doneButton.userInteractionEnabled = false;
|
||||
strongSelf->_landscapeToolbarView.doneButton.userInteractionEnabled = false;
|
||||
|
@ -191,7 +191,6 @@
|
||||
UIView *contentView = [itemView transitionContentView];
|
||||
UIView *snapshotView = [contentView snapshotViewAfterScreenUpdates:true];
|
||||
snapshotView.frame = [contentView convertRect:contentView.bounds toView:nil];
|
||||
// snapshotView.frame = CGRectOffset([contentView convertRect:contentView.bounds toView:nil], 0.0, -self.view.frame.size.height);
|
||||
return snapshotView;
|
||||
}
|
||||
}
|
||||
|
@ -379,12 +379,11 @@ static const CGFloat swipeDistanceThreshold = 128.0f;
|
||||
completion();
|
||||
}];
|
||||
|
||||
[UIView animateWithDuration:ABS(distance / velocity) animations:^
|
||||
{
|
||||
[UIView animateWithDuration:0.15 animations:^{
|
||||
_interfaceView.alpha = 0.0f;
|
||||
_overlayContainerView.alpha = 0.0f;
|
||||
self.backgroundColor = UIColorRGBA(0x000000, 0.0f);
|
||||
} completion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)transitionInWithDuration:(NSTimeInterval)duration
|
||||
|
@ -19,6 +19,7 @@ import ContextUI
|
||||
import WebSearchUI
|
||||
import SparseItemGrid
|
||||
import UndoUI
|
||||
import PresentationDataUtils
|
||||
|
||||
let overflowInset: CGFloat = 0.0
|
||||
|
||||
@ -1282,8 +1283,22 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
self.undoOverlayController?.dismissWithCommitAction()
|
||||
}
|
||||
|
||||
public func requestDismiss(completion: @escaping () -> Void) {
|
||||
if let selectionState = self.interaction?.selectionState, selectionState.count() > 0 {
|
||||
let controller = textAlertController(context: self.context, title: nil, text: self.presentationData.strings.Attachment_CancelSelectionAlertText, actions: [TextAlertAction(type: .genericAction, title: self.presentationData.strings.Attachment_CancelSelectionAlertNo, action: {
|
||||
|
||||
}), TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Attachment_CancelSelectionAlertYes, action: {
|
||||
completion()
|
||||
})])
|
||||
self.present(controller, in: .window(.root))
|
||||
} else {
|
||||
completion()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
self.dismissAllTooltips()
|
||||
|
||||
self.dismiss()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user