mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-31 15:37:01 +00:00
Merge commit 'fc5c2ad154095a3dd7573c21ed7bc17de017b775'
This commit is contained in:
commit
485d7c45dd
@ -952,7 +952,7 @@ private final class DemoSheetContent: CombinedComponent {
|
||||
content: AnyComponent(PhoneDemoComponent(
|
||||
context: component.context,
|
||||
position: .top,
|
||||
videoFile: configuration.videos["colors"],
|
||||
videoFile: configuration.videos["peer_colors"],
|
||||
decoration: .badgeStars
|
||||
)),
|
||||
title: strings.Premium_Colors,
|
||||
|
@ -458,7 +458,7 @@ public enum PremiumPerk: CaseIterable {
|
||||
case .stories:
|
||||
return "stories"
|
||||
case .colors:
|
||||
return "colors"
|
||||
return "peer_colors"
|
||||
case .wallpapers:
|
||||
return "wallpapers"
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ public class PremiumLimitsListScreen: ViewController {
|
||||
content: AnyComponent(PhoneDemoComponent(
|
||||
context: context,
|
||||
position: .top,
|
||||
videoFile: configuration.videos["colors"],
|
||||
videoFile: configuration.videos["peer_colors"],
|
||||
decoration: .badgeStars
|
||||
)),
|
||||
title: strings.Premium_Colors,
|
||||
|
@ -420,16 +420,6 @@ final class VideoFinishPass: RenderPass {
|
||||
}
|
||||
|
||||
var isVisible = true
|
||||
if let additionalVideoRemovalStartTimestamp {
|
||||
let disappearingPosition = VideoPosition(position: foregroundPosition.position, size: foregroundPosition.size, scale: 0.01, rotation: foregroundPosition.rotation, baseScale: foregroundPosition.baseScale)
|
||||
|
||||
let visibilityFraction = max(0.0, min(1.0, 1.0 - (CACurrentMediaTime() - additionalVideoRemovalStartTimestamp) / videoRemovalDuration))
|
||||
if visibilityFraction.isZero {
|
||||
isVisible = false
|
||||
}
|
||||
foregroundAlpha = Float(visibilityFraction)
|
||||
foregroundPosition = disappearingPosition.mixed(with: foregroundPosition, fraction: visibilityFraction)
|
||||
} else {
|
||||
var trimRangeLowerBound: Double?
|
||||
var trimRangeUpperBound: Double?
|
||||
if let additionalVideoRange = self.additionalVideoRange {
|
||||
@ -468,9 +458,18 @@ final class VideoFinishPass: RenderPass {
|
||||
foregroundPosition = disappearingPosition.mixed(with: foregroundPosition, fraction: visibilityFraction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isVisible {
|
||||
if let additionalVideoRemovalStartTimestamp {
|
||||
let disappearingPosition = VideoPosition(position: foregroundPosition.position, size: foregroundPosition.size, scale: 0.01, rotation: foregroundPosition.rotation, baseScale: foregroundPosition.baseScale)
|
||||
|
||||
let visibilityFraction = max(0.0, min(1.0, 1.0 - (CACurrentMediaTime() - additionalVideoRemovalStartTimestamp) / videoRemovalDuration))
|
||||
if visibilityFraction.isZero {
|
||||
isVisible = false
|
||||
}
|
||||
foregroundAlpha = Float(visibilityFraction)
|
||||
foregroundPosition = disappearingPosition.mixed(with: foregroundPosition, fraction: visibilityFraction)
|
||||
}
|
||||
foregroundVideoState = VideoState(texture: foregroundTexture, textureRotation: foregroundTextureRotation, position: foregroundPosition, roundness: 1.0, alpha: foregroundAlpha)
|
||||
}
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ private final class StoryContainerScreenComponent: Component {
|
||||
}
|
||||
}
|
||||
longPressRecognizer.updatePanMove = { [weak self] initialLocation, translation in
|
||||
guard let self else {
|
||||
guard let self, self.itemSetPanState?.didBegin == false else {
|
||||
return
|
||||
}
|
||||
guard let stateValue = self.stateValue, let slice = stateValue.slice, let itemSetView = self.visibleItemSetViews[slice.peer.id], let itemSetComponentView = itemSetView.view.view as? StoryItemSetContainerComponent.View else {
|
||||
@ -538,11 +538,7 @@ private final class StoryContainerScreenComponent: Component {
|
||||
let fraction = translation.x / (self.bounds.width / 2.0)
|
||||
timestamp = initialSeekTimestamp + duration * fraction
|
||||
}
|
||||
if translation.y < 64.0 {
|
||||
visibleItemView.seekTo(max(0.0, min(duration, timestamp)), apply: apply)
|
||||
} else {
|
||||
visibleItemView.seekTo(initialSeekTimestamp, apply: apply)
|
||||
}
|
||||
}
|
||||
longPressRecognizer.updatePanEnded = { [weak self] in
|
||||
guard let self else {
|
||||
@ -1124,15 +1120,16 @@ private final class StoryContainerScreenComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
private var previousBackNavigationTime: Double?
|
||||
private func navigate(direction: StoryItemSetContainerComponent.NavigationDirection) {
|
||||
guard let component = self.component, let environment = self.environment else {
|
||||
guard let component = self.component, let environment = self.environment, let controller = environment.controller() as? StoryContainerScreen else {
|
||||
return
|
||||
}
|
||||
|
||||
if let stateValue = self.stateValue, let slice = stateValue.slice {
|
||||
if case .next = direction, slice.nextItemId == nil, (slice.item.position == nil || slice.item.position == slice.totalCount - 1) {
|
||||
if stateValue.nextSlice == nil {
|
||||
environment.controller()?.dismiss()
|
||||
controller.dismiss()
|
||||
} else {
|
||||
self.beginHorizontalPan(translation: CGPoint())
|
||||
self.updateHorizontalPan(translation: CGPoint())
|
||||
@ -1142,8 +1139,18 @@ private final class StoryContainerScreenComponent: Component {
|
||||
if stateValue.previousSlice == nil {
|
||||
if let itemSetView = self.visibleItemSetViews[slice.peer.id] {
|
||||
if let componentView = itemSetView.view.view as? StoryItemSetContainerComponent.View {
|
||||
if let customBackAction = controller.customBackAction {
|
||||
let currentTime = CACurrentMediaTime()
|
||||
if let previousBackNavigationTime = self.previousBackNavigationTime, currentTime - previousBackNavigationTime < 1.0 {
|
||||
customBackAction()
|
||||
} else {
|
||||
self.previousBackNavigationTime = CACurrentMediaTime()
|
||||
componentView.rewindCurrentItem()
|
||||
}
|
||||
} else {
|
||||
componentView.rewindCurrentItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.beginHorizontalPan(translation: CGPoint())
|
||||
@ -1943,6 +1950,8 @@ public class StoryContainerScreen: ViewControllerComponentContainer {
|
||||
return self.focusedItemPromise.get()
|
||||
}
|
||||
|
||||
public var customBackAction: (() -> Void)?
|
||||
|
||||
public init(
|
||||
context: AccountContext,
|
||||
content: StoryContentContext,
|
||||
|
@ -1220,6 +1220,9 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
} else {
|
||||
if let visibleItemView = self.visibleItems[component.slice.item.storyItem.id]?.view.view as? StoryItemContentComponent.View {
|
||||
visibleItemView.seekEnded()
|
||||
}
|
||||
if translation.y > 200.0 || (translation.y > 5.0 && velocity.y > 200.0) {
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring)))
|
||||
self.component?.controller()?.dismiss()
|
||||
@ -4218,13 +4221,45 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
return component.controller()
|
||||
},
|
||||
openStory: { [weak self] peer, story in
|
||||
guard let self else {
|
||||
guard let self, let component = self.component else {
|
||||
return
|
||||
}
|
||||
let context = component.context
|
||||
let peerId = component.slice.peer.id
|
||||
let currentResult: ResolvedUrl = .story(peerId: peerId, id: component.slice.item.storyItem.id)
|
||||
|
||||
self.sendMessageContext.openResolved(view: self, result: .story(peerId: peer.id, id: story.id), completion: { [weak self] in
|
||||
guard let self, let controller = self.component?.controller() as? StoryContainerScreen else {
|
||||
return
|
||||
}
|
||||
if let nextController = controller.navigationController?.viewControllers.last as? StoryContainerScreen {
|
||||
nextController.customBackAction = { [weak nextController] in
|
||||
context.sharedContext.openResolvedUrl(
|
||||
currentResult,
|
||||
context: context,
|
||||
urlContext: .generic,
|
||||
navigationController: nextController?.navigationController as? NavigationController,
|
||||
forceExternal: false,
|
||||
openPeer: { _, _ in
|
||||
},
|
||||
sendFile: nil,
|
||||
sendSticker: nil,
|
||||
requestMessageActionUrlAuth: nil,
|
||||
joinVoiceChat: nil,
|
||||
present: { _, _ in
|
||||
},
|
||||
dismissInput: {
|
||||
},
|
||||
contentContext: nil,
|
||||
progress: nil,
|
||||
completion: { [weak nextController] in
|
||||
Queue.mainQueue().after(0.5) {
|
||||
nextController?.dismissWithoutTransitionOut()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
Queue.mainQueue().after(0.5) {
|
||||
controller.dismissWithoutTransitionOut()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user