mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Various fixes
This commit is contained in:
parent
064024514c
commit
2fc5a19f50
@ -528,29 +528,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
if case let .assets(_, mode) = controller.subject, [.wallpaper, .story, .addImage, .cover, .createSticker, .createAvatar].contains(mode) {
|
if case let .assets(_, mode) = controller.subject, [.wallpaper, .story, .addImage, .cover, .createSticker, .createAvatar].contains(mode) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
let selectionGesture = MediaPickerGridSelectionGesture<TGMediaSelectableItem>()
|
self.setupSelectionGesture()
|
||||||
selectionGesture.delegate = self.wrappedGestureRecognizerDelegate
|
|
||||||
selectionGesture.began = { [weak self] in
|
|
||||||
self?.controller?.cancelPanGesture()
|
|
||||||
}
|
|
||||||
selectionGesture.updateIsScrollEnabled = { [weak self] isEnabled in
|
|
||||||
self?.gridNode.scrollView.isScrollEnabled = isEnabled
|
|
||||||
}
|
|
||||||
selectionGesture.itemAt = { [weak self] point in
|
|
||||||
if let self, let itemNode = self.gridNode.itemNodeAtPoint(point) as? MediaPickerGridItemNode, let selectableItem = itemNode.selectableItem {
|
|
||||||
return (selectableItem, self.controller?.interaction?.selectionState?.isIdentifierSelected(selectableItem.uniqueIdentifier) ?? false)
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selectionGesture.updateSelection = { [weak self] asset, selected in
|
|
||||||
if let strongSelf = self {
|
|
||||||
strongSelf.controller?.interaction?.selectionState?.setItem(asset, selected: selected, animated: true, sender: nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selectionGesture.sideInset = 44.0
|
|
||||||
self.gridNode.view.addGestureRecognizer(selectionGesture)
|
|
||||||
self.selectionGesture = selectionGesture
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let controller = self.controller, case let .assets(collection, _) = controller.subject, collection != nil {
|
if let controller = self.controller, case let .assets(collection, _) = controller.subject, collection != nil {
|
||||||
@ -713,6 +691,35 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setupSelectionGesture() {
|
||||||
|
guard self.selectionGesture == nil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let selectionGesture = MediaPickerGridSelectionGesture<TGMediaSelectableItem>()
|
||||||
|
selectionGesture.delegate = self.wrappedGestureRecognizerDelegate
|
||||||
|
selectionGesture.began = { [weak self] in
|
||||||
|
self?.controller?.cancelPanGesture()
|
||||||
|
}
|
||||||
|
selectionGesture.updateIsScrollEnabled = { [weak self] isEnabled in
|
||||||
|
self?.gridNode.scrollView.isScrollEnabled = isEnabled
|
||||||
|
}
|
||||||
|
selectionGesture.itemAt = { [weak self] point in
|
||||||
|
if let self, let itemNode = self.gridNode.itemNodeAtPoint(point) as? MediaPickerGridItemNode, let selectableItem = itemNode.selectableItem {
|
||||||
|
return (selectableItem, self.controller?.interaction?.selectionState?.isIdentifierSelected(selectableItem.uniqueIdentifier) ?? false)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectionGesture.updateSelection = { [weak self] asset, selected in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.controller?.interaction?.selectionState?.setItem(asset, selected: selected, animated: true, sender: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectionGesture.sideInset = 44.0
|
||||||
|
self.gridNode.view.addGestureRecognizer(selectionGesture)
|
||||||
|
self.selectionGesture = selectionGesture
|
||||||
|
}
|
||||||
|
|
||||||
@objc private func cameraTapped() {
|
@objc private func cameraTapped() {
|
||||||
guard let camera = self.modernCamera, let previewView = self.modernCameraView else {
|
guard let camera = self.modernCamera, let previewView = self.modernCameraView else {
|
||||||
return
|
return
|
||||||
@ -2352,9 +2359,6 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
let transition = ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)
|
let transition = ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)
|
||||||
var moreIsVisible = false
|
var moreIsVisible = false
|
||||||
if case let .assets(_, mode) = self.subject, [.story, .createSticker].contains(mode) {
|
if case let .assets(_, mode) = self.subject, [.story, .createSticker].contains(mode) {
|
||||||
if count == 1 {
|
|
||||||
self.requestAttachmentMenuExpansion()
|
|
||||||
}
|
|
||||||
moreIsVisible = true
|
moreIsVisible = true
|
||||||
} else if case let .media(media) = self.subject {
|
} else if case let .media(media) = self.subject {
|
||||||
self.titleView.title = media.count == 1 ? self.presentationData.strings.Attachment_Pasteboard : self.presentationData.strings.Attachment_SelectedMedia(count)
|
self.titleView.title = media.count == 1 ? self.presentationData.strings.Attachment_Pasteboard : self.presentationData.strings.Attachment_SelectedMedia(count)
|
||||||
@ -2618,6 +2622,8 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
|
|
||||||
self.navigationItem.setRightBarButton(nil, animated: true)
|
self.navigationItem.setRightBarButton(nil, animated: true)
|
||||||
self.explicitMultipleSelection = true
|
self.explicitMultipleSelection = true
|
||||||
|
self.controllerNode.setupSelectionGesture()
|
||||||
|
self.requestAttachmentMenuExpansion()
|
||||||
|
|
||||||
if let state = self.controllerNode.state {
|
if let state = self.controllerNode.state {
|
||||||
self.controllerNode.updateState(state)
|
self.controllerNode.updateState(state)
|
||||||
|
@ -2553,6 +2553,8 @@ public class CameraScreenImpl: ViewController, CameraScreen {
|
|||||||
transitionCircleLayer.animateScale(from: sourceLocalFrame.width / 320.0, to: 6.0, duration: 0.6, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in
|
transitionCircleLayer.animateScale(from: sourceLocalFrame.width / 320.0, to: 6.0, duration: 0.6, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in
|
||||||
self.view.mask = nil
|
self.view.mask = nil
|
||||||
colorFillView.removeFromSuperview()
|
colorFillView.removeFromSuperview()
|
||||||
|
|
||||||
|
self.requestUpdateLayout(hasAppeared: true, transition: .immediate)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if case .story = controller.mode {
|
if case .story = controller.mode {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user