mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-06 05:02:54 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -109,7 +109,11 @@ final class MediaNavigationStripComponent: Component {
|
||||
itemWidth = idealItemWidth
|
||||
}
|
||||
|
||||
let globalWidth: CGFloat = CGFloat(component.count) * itemWidth + CGFloat(component.count - 1) * spacing
|
||||
var globalWidth: CGFloat = CGFloat(component.count) * itemWidth + CGFloat(component.count - 1) * spacing
|
||||
if globalWidth > availableSize.width && globalWidth <= availableSize.width + 1.0 {
|
||||
globalWidth = availableSize.width
|
||||
}
|
||||
|
||||
let globalFocusedFrame = CGRect(origin: CGPoint(x: CGFloat(component.index) * (itemWidth + spacing), y: 0.0), size: CGSize(width: itemWidth, height: itemHeight))
|
||||
var globalOffset: CGFloat = floor(globalFocusedFrame.midX - availableSize.width * 0.5)
|
||||
if globalOffset > globalWidth - availableSize.width {
|
||||
|
||||
@@ -190,6 +190,9 @@ private final class StoryContainerScreenComponent: Component {
|
||||
if !itemSetComponentView.isPointInsideContentArea(point: self.convert(point, to: itemSetComponentView)) {
|
||||
return []
|
||||
}
|
||||
if !itemSetComponentView.allowsInteractiveGestures() {
|
||||
return []
|
||||
}
|
||||
return [.left, .right]
|
||||
})
|
||||
self.addGestureRecognizer(horizontalPanRecognizer)
|
||||
@@ -201,6 +204,9 @@ private final class StoryContainerScreenComponent: Component {
|
||||
if !itemSetComponentView.isPointInsideContentArea(point: self.convert(point, to: itemSetComponentView)) {
|
||||
return []
|
||||
}
|
||||
if !itemSetComponentView.allowsInteractiveGestures() {
|
||||
return []
|
||||
}
|
||||
|
||||
return [.down]
|
||||
})
|
||||
|
||||
@@ -6,12 +6,24 @@ import MultilineTextComponent
|
||||
|
||||
final class StoryContentCaptionComponent: Component {
|
||||
final class ExternalState {
|
||||
fileprivate(set) var expandFraction: CGFloat = 0.0
|
||||
fileprivate(set) var isExpanded: Bool = false
|
||||
|
||||
init() {
|
||||
}
|
||||
}
|
||||
|
||||
final class TransitionHint {
|
||||
enum Kind {
|
||||
case isExpandedUpdated
|
||||
}
|
||||
|
||||
let kind: Kind
|
||||
|
||||
init(kind: Kind) {
|
||||
self.kind = kind
|
||||
}
|
||||
}
|
||||
|
||||
let externalState: ExternalState
|
||||
let text: String
|
||||
|
||||
@@ -81,6 +93,9 @@ final class StoryContentCaptionComponent: Component {
|
||||
self.addSubview(self.scrollViewContainer)
|
||||
|
||||
self.scrollViewContainer.mask = self.scrollMaskContainer
|
||||
|
||||
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))
|
||||
self.addGestureRecognizer(tapRecognizer)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -101,12 +116,26 @@ final class StoryContentCaptionComponent: Component {
|
||||
return nil
|
||||
}
|
||||
|
||||
@objc private func tapGesture(_ recognizer: UITapGestureRecognizer) {
|
||||
if case .ended = recognizer.state {
|
||||
self.expand(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
}
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if !self.ignoreScrolling {
|
||||
self.updateScrolling(transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
func expand(transition: Transition) {
|
||||
self.ignoreScrolling = true
|
||||
transition.setBounds(view: self.scrollView, bounds: CGRect(origin: CGPoint(x: 0.0, y: max(0.0, self.scrollView.contentSize.height - self.scrollView.bounds.height)), size: self.scrollView.bounds.size))
|
||||
self.ignoreScrolling = false
|
||||
|
||||
self.updateScrolling(transition: transition)
|
||||
}
|
||||
|
||||
func collapse(transition: Transition) {
|
||||
self.ignoreScrolling = true
|
||||
transition.setBounds(view: self.scrollView, bounds: CGRect(origin: CGPoint(), size: self.scrollView.bounds.size))
|
||||
@@ -132,11 +161,14 @@ final class StoryContentCaptionComponent: Component {
|
||||
if self.scrollView.contentSize.height < self.scrollView.bounds.height + expandDistance {
|
||||
expandFraction = 0.0
|
||||
}
|
||||
if component.externalState.expandFraction != expandFraction {
|
||||
component.externalState.expandFraction = expandFraction
|
||||
|
||||
let isExpanded = expandFraction > 0.0
|
||||
|
||||
if component.externalState.isExpanded != isExpanded {
|
||||
component.externalState.isExpanded = isExpanded
|
||||
|
||||
if !self.ignoreExternalState {
|
||||
self.state?.updated(transition: transition)
|
||||
self.state?.updated(transition: transition.withUserData(TransitionHint(kind: .isExpandedUpdated)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,6 +405,13 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
return false
|
||||
}
|
||||
|
||||
func allowsInteractiveGestures() -> Bool {
|
||||
if self.displayViewList {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func rewindCurrentItem() {
|
||||
guard let component = self.component else {
|
||||
return
|
||||
@@ -431,7 +438,7 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
} else if self.displayViewList {
|
||||
self.displayViewList = false
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
} else if let captionItem = self.captionItem, captionItem.externalState.expandFraction > 0.0 {
|
||||
} else if let captionItem = self.captionItem, captionItem.externalState.isExpanded {
|
||||
if let captionItemView = captionItem.view.view as? StoryContentCaptionComponent.View {
|
||||
captionItemView.collapse(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
@@ -479,7 +486,13 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
if self.inputPanelExternalState.isEditing || component.isProgressPaused || self.actionSheet != nil || self.contextController != nil || self.sendMessageContext.audioRecorderValue != nil || self.sendMessageContext.videoRecorderValue != nil || self.displayViewList {
|
||||
return true
|
||||
}
|
||||
if let captionItem = self.captionItem, captionItem.externalState.expandFraction > 0.0 {
|
||||
if self.sendMessageContext.attachmentController != nil {
|
||||
return true
|
||||
}
|
||||
if self.sendMessageContext.shareController != nil {
|
||||
return true
|
||||
}
|
||||
if let captionItem = self.captionItem, captionItem.externalState.isExpanded {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -1727,8 +1740,12 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
transition.setAlpha(layer: self.bottomContentGradientLayer, alpha: 0.0)
|
||||
|
||||
var normalDimAlpha: CGFloat = 0.0
|
||||
var forceDimAnimation = false
|
||||
if let captionItem = self.captionItem {
|
||||
normalDimAlpha = captionItem.externalState.expandFraction
|
||||
normalDimAlpha = captionItem.externalState.isExpanded ? 1.0 : 0.0
|
||||
if transition.animation.isImmediate && transition.userData(StoryContentCaptionComponent.TransitionHint.self)?.kind == .isExpandedUpdated {
|
||||
forceDimAnimation = true
|
||||
}
|
||||
}
|
||||
var dimAlpha: CGFloat = (inputPanelIsOverlay || self.inputPanelExternalState.isEditing) ? 1.0 : normalDimAlpha
|
||||
if component.hideUI || self.displayViewList {
|
||||
@@ -1736,7 +1753,12 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
}
|
||||
|
||||
transition.setFrame(layer: self.contentDimLayer, frame: CGRect(origin: CGPoint(), size: contentFrame.size))
|
||||
transition.setAlpha(layer: self.contentDimLayer, alpha: dimAlpha)
|
||||
|
||||
if transition.animation.isImmediate && forceDimAnimation && self.contentDimLayer.opacity != Float(dimAlpha) {
|
||||
Transition(animation: .curve(duration: 0.25, curve: .easeInOut)).setAlpha(layer: self.contentDimLayer, alpha: dimAlpha)
|
||||
} else {
|
||||
transition.setAlpha(layer: self.contentDimLayer, alpha: dimAlpha)
|
||||
}
|
||||
|
||||
self.ignoreScrolling = true
|
||||
transition.setFrame(view: self.scrollView, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: availableSize.width, height: availableSize.height)))
|
||||
|
||||
@@ -35,6 +35,7 @@ import Postbox
|
||||
|
||||
final class StoryItemSetContainerSendMessage {
|
||||
weak var attachmentController: AttachmentController?
|
||||
weak var shareController: ShareController?
|
||||
|
||||
var audioRecorderValue: ManagedAudioRecorder?
|
||||
var audioRecorder = Promise<ManagedAudioRecorder?>()
|
||||
@@ -295,6 +296,18 @@ final class StoryItemSetContainerSendMessage {
|
||||
updatedPresentationData: (component.context.sharedContext.currentPresentationData.with({ $0 }),
|
||||
component.context.sharedContext.presentationData)
|
||||
)
|
||||
|
||||
self.shareController = shareController
|
||||
view.updateIsProgressPaused()
|
||||
|
||||
shareController.dismissed = { [weak self, weak view] _ in
|
||||
guard let self, let view else {
|
||||
return
|
||||
}
|
||||
self.shareController = nil
|
||||
view.updateIsProgressPaused()
|
||||
}
|
||||
|
||||
controller.present(shareController, in: .window(.root))
|
||||
}
|
||||
|
||||
@@ -436,23 +449,25 @@ final class StoryItemSetContainerSendMessage {
|
||||
initialButton = .gift*/
|
||||
}
|
||||
|
||||
for bot in attachMenuBots.reversed() {
|
||||
var peerType = peerType
|
||||
if bot.peer.id == peer.id {
|
||||
peerType.insert(.sameBot)
|
||||
peerType.remove(.bot)
|
||||
if !"".isEmpty {
|
||||
for bot in attachMenuBots.reversed() {
|
||||
var peerType = peerType
|
||||
if bot.peer.id == peer.id {
|
||||
peerType.insert(.sameBot)
|
||||
peerType.remove(.bot)
|
||||
}
|
||||
let button: AttachmentButtonType = .app(bot.peer, bot.shortName, bot.icons)
|
||||
if !bot.peerTypes.intersection(peerType).isEmpty {
|
||||
buttons.insert(button, at: 1)
|
||||
|
||||
/*if case let .bot(botId, _, _) = subject {
|
||||
if initialButton == nil && bot.peer.id == botId {
|
||||
initialButton = button
|
||||
}
|
||||
}*/
|
||||
}
|
||||
allButtons.insert(button, at: 1)
|
||||
}
|
||||
let button: AttachmentButtonType = .app(bot.peer, bot.shortName, bot.icons)
|
||||
if !bot.peerTypes.intersection(peerType).isEmpty {
|
||||
buttons.insert(button, at: 1)
|
||||
|
||||
/*if case let .bot(botId, _, _) = subject {
|
||||
if initialButton == nil && bot.peer.id == botId {
|
||||
initialButton = button
|
||||
}
|
||||
}*/
|
||||
}
|
||||
allButtons.insert(button, at: 1)
|
||||
}
|
||||
|
||||
return (buttons, allButtons, initialButton)
|
||||
|
||||
@@ -21,6 +21,7 @@ swift_library(
|
||||
"//submodules/AvatarNode",
|
||||
"//submodules/ContextUI",
|
||||
"//submodules/TelegramUI/Components/Stories/StoryContainerScreen",
|
||||
"//submodules/Components/MultilineTextComponent",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
||||
@@ -12,6 +12,7 @@ import AvatarNode
|
||||
import ContextUI
|
||||
import AsyncDisplayKit
|
||||
import StoryContainerScreen
|
||||
import MultilineTextComponent
|
||||
|
||||
private func calculateCircleIntersection(center: CGPoint, otherCenter: CGPoint, radius: CGFloat) -> (point1Angle: CGFloat, point2Angle: CGFloat)? {
|
||||
let distanceVector = CGPoint(x: otherCenter.x - center.x, y: otherCenter.y - center.y)
|
||||
@@ -704,7 +705,10 @@ public final class StoryPeerListItemComponent: Component {
|
||||
|
||||
let titleSize = self.title.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(Text(text: titleString, font: Font.regular(11.0), color: component.theme.list.itemPrimaryTextColor)),
|
||||
component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: titleString, font: Font.regular(11.0), textColor: component.theme.list.itemPrimaryTextColor)),
|
||||
maximumNumberOfLines: 1
|
||||
)),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width + 4.0, height: 100.0)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user