From 4317ba43e4e417ab136da72dad41a0287882efb1 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 10 Aug 2023 22:01:12 +0400 Subject: [PATCH 1/3] Fix editing panel --- .../Sources/PeerListItemComponent.swift | 2 ++ .../Sources/StoryItemSetContainerComponent.swift | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift b/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift index 4ef92c455c..d8d8cdab6d 100644 --- a/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift @@ -499,6 +499,8 @@ public final class PeerListItemComponent: Component { } else { clipStyle = .round } + let _ = clipStyle + let _ = synchronousLoad self.avatarNode.setPeer(context: component.context, theme: component.theme, peer: peer, clipStyle: clipStyle, synchronousLoad: synchronousLoad, displayDimensions: CGSize(width: avatarSize, height: avatarSize)) self.avatarNode.setStoryStats(storyStats: component.storyStats.flatMap { storyStats -> AvatarNode.StoryStats in return AvatarNode.StoryStats( diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 34704727eb..48cffd2a36 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -1163,7 +1163,7 @@ public final class StoryItemSetContainerComponent: Component { if let currentIndex = component.slice.allItems.firstIndex(where: { $0.storyItem.id == component.slice.item.storyItem.id }) { if index != currentIndex { let nextId = component.slice.allItems[index].storyItem.id - self.awaitingSwitchToId = (component.slice.allItems[currentIndex].storyItem.id, nextId) + //self.awaitingSwitchToId = (component.slice.allItems[currentIndex].storyItem.id, nextId) component.navigate(.id(nextId)) } } @@ -1603,7 +1603,13 @@ public final class StoryItemSetContainerComponent: Component { let footerPanelFrame = CGRect(origin: CGPoint(x: itemPositionX - footerSize.width * 0.5, y: footerPanelY), size: footerSize) itemTransition.setFrame(view: footerPanelView, frame: footerPanelFrame) - itemTransition.setAlpha(view: footerPanelView, alpha: 1.0 - itemLayout.contentOverflowFraction) + + var footerAlpha: CGFloat = 1.0 - itemLayout.contentOverflowFraction + if component.hideUI || self.isEditingStory { + footerAlpha = 0.0 + } + + itemTransition.setAlpha(view: footerPanelView, alpha: footerAlpha) } } else if let footerPanel = visibleItem.footerPanel { visibleItem.footerPanel = nil From 2b254b508ddeb69418fb12c48850e5367f1c226d Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 10 Aug 2023 22:29:15 +0400 Subject: [PATCH 2/3] Scale view stats --- .../Sources/StoryItemSetContainerComponent.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 48cffd2a36..24933807b6 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -1598,11 +1598,18 @@ public final class StoryItemSetContainerComponent: Component { } var footerPanelY: CGFloat = self.itemsContainerView.frame.minY + itemLayout.contentFrame.center.y + itemLayout.contentFrame.height * 0.5 * itemScale - footerPanelY += (1.0 - footerExpandFraction) * 4.0 + footerExpandFraction * (-41.0) + let footerPanelMinScale: CGFloat = (1.0 - scaleFraction) + (itemLayout.sideVisibleItemScale / itemLayout.contentMinScale) * scaleFraction + let footerPanelScale = itemLayout.contentScaleFraction * footerPanelMinScale + 1.0 * (1.0 - itemLayout.contentScaleFraction) + + footerPanelY += (footerSize.height - footerSize.height * footerPanelScale) * 0.5 + let footerPanelFrame = CGRect(origin: CGPoint(x: itemPositionX - footerSize.width * 0.5, y: footerPanelY), size: footerSize) - itemTransition.setFrame(view: footerPanelView, frame: footerPanelFrame) + + itemTransition.setPosition(view: footerPanelView, position: footerPanelFrame.center) + itemTransition.setBounds(view: footerPanelView, bounds: CGRect(origin: CGPoint(), size: footerPanelFrame.size)) + itemTransition.setScale(view: footerPanelView, scale: footerPanelScale) var footerAlpha: CGFloat = 1.0 - itemLayout.contentOverflowFraction if component.hideUI || self.isEditingStory { From a46c372d68734d9d4bd352ef47a2d653fd2a36cd Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 10 Aug 2023 22:57:19 +0400 Subject: [PATCH 3/3] Story premium metadata --- .../Sources/AccountContext.swift | 5 +++ .../Sources/PremiumIntroScreen.swift | 45 +++++++++++++++++++ .../StoryItemSetContainerComponent.swift | 10 ++--- .../Sources/SharedAccountContext.swift | 10 +++++ 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 89ae9dd065..6216b18e93 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -947,6 +947,11 @@ public enum PremiumIntroSource { case fasterDownload case translation case stories + case storiesDownload + case storiesStealthMode + case storiesPermanentViews + case storiesFormatting + case storiesExpirationDurations } public enum PremiumDemoSubject { diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index cb9f6def4f..cd18d081b3 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -190,6 +190,36 @@ public enum PremiumSource: Equatable { } else { return false } + case .storiesDownload: + if case .storiesDownload = rhs { + return true + } else { + return false + } + case .storiesStealthMode: + if case .storiesStealthMode = rhs { + return true + } else { + return false + } + case .storiesPermanentViews: + if case .storiesPermanentViews = rhs { + return true + } else { + return false + } + case .storiesFormatting: + if case .storiesFormatting = rhs { + return true + } else { + return false + } + case .storiesExpirationDurations: + if case .storiesExpirationDurations = rhs { + return true + } else { + return false + } } } @@ -220,6 +250,11 @@ public enum PremiumSource: Equatable { case linksPerSharedFolder case membershipInSharedFolders case stories + case storiesDownload + case storiesStealthMode + case storiesPermanentViews + case storiesFormatting + case storiesExpirationDurations var identifier: String? { switch self { @@ -279,6 +314,16 @@ public enum PremiumSource: Equatable { return "double_limits__communities_joined" case .stories: return "stories" + case .storiesDownload: + return "stories__save_stories_to_gallery" + case .storiesStealthMode: + return "stories__stealth_mode" + case .storiesPermanentViews: + return "stories__permanent_views_history" + case .storiesFormatting: + return "stories__links_and_formatting" + case .storiesExpirationDurations: + return "stories__expiration_durations" } } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 24933807b6..309f3ef272 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -3047,7 +3047,7 @@ public final class StoryItemSetContainerComponent: Component { guard let self else { return } - self.presentStoriesUpgradeScreen() + self.presentStoriesUpgradeScreen(source: .storiesPermanentViews) }, setIsSearchActive: { [weak self] value in guard let self else { @@ -4728,7 +4728,7 @@ public final class StoryItemSetContainerComponent: Component { } switch action { case .info: - self.presentStoriesUpgradeScreen() + self.presentStoriesUpgradeScreen(source: .storiesDownload) return true default: break @@ -4743,11 +4743,11 @@ public final class StoryItemSetContainerComponent: Component { guard let self else { return } - self.presentStoriesUpgradeScreen() + self.presentStoriesUpgradeScreen(source: .storiesStealthMode) }) } - private func presentStoriesUpgradeScreen() { + private func presentStoriesUpgradeScreen(source: PremiumSource) { guard let component = self.component else { return } @@ -4761,7 +4761,7 @@ public final class StoryItemSetContainerComponent: Component { return } - let controller = PremiumIntroScreen(context: context, source: .stories, forceDark: true) + let controller = PremiumIntroScreen(context: context, source: source, forceDark: true) self.sendMessageContext.actionSheet = controller controller.wasDismissed = { [weak self, weak controller]in guard let self else { diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index ac26e9c94a..8e00f675a8 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -1779,6 +1779,16 @@ public final class SharedAccountContextImpl: SharedAccountContext { mappedSource = .translation case .stories: mappedSource = .stories + case .storiesDownload: + mappedSource = .storiesDownload + case .storiesStealthMode: + mappedSource = .storiesStealthMode + case .storiesPermanentViews: + mappedSource = .storiesPermanentViews + case .storiesFormatting: + mappedSource = .storiesFormatting + case .storiesExpirationDurations: + mappedSource = .storiesExpirationDurations } return PremiumIntroScreen(context: context, source: mappedSource, forceDark: forceDark) }