mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Merge commit '60815f9fb55b8bf509193d24056d97546a47099e'
This commit is contained in:
commit
53634ad77a
@ -10405,3 +10405,4 @@ Sorry for the inconvenience.";
|
||||
|
||||
"ChannelBoost.EnableColors" = "Enable Colors";
|
||||
"ChannelBoost.EnableColorsText" = "Your channel needs %1$@ to change channel color.\n\nAsk your **Premium** subscribers to boost your channel with this link:";
|
||||
"ChannelBoost.BoostAgain" = "Boost Again";
|
||||
|
@ -1000,7 +1000,7 @@ public enum PremiumLimitSubject {
|
||||
case expiringStories
|
||||
case storiesWeekly
|
||||
case storiesMonthly
|
||||
case storiesChannelBoost(peer: EnginePeer, isCurrent: Bool, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, myBoostCount: Int32)
|
||||
case storiesChannelBoost(peer: EnginePeer, isCurrent: Bool, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, myBoostCount: Int32, canBoostAgain: Bool)
|
||||
}
|
||||
|
||||
public protocol ComposeController: ViewController {
|
||||
|
@ -14,7 +14,7 @@ private struct BoostState {
|
||||
let nextLevelBoosts: Int32?
|
||||
let boosts: Int32
|
||||
|
||||
func displayData(peer: EnginePeer, isCurrent: Bool, myBoostCount: Int32, currentMyBoostCount: Int32, replacedBoosts: Int32? = nil) -> (subject: PremiumLimitScreen.Subject, count: Int32) {
|
||||
func displayData(peer: EnginePeer, isCurrent: Bool, canBoostAgain: Bool, myBoostCount: Int32, currentMyBoostCount: Int32, replacedBoosts: Int32? = nil) -> (subject: PremiumLimitScreen.Subject, count: Int32) {
|
||||
var currentLevel = self.level
|
||||
var nextLevelBoosts = self.nextLevelBoosts
|
||||
var currentLevelBoosts = self.currentLevelBoosts
|
||||
@ -30,7 +30,7 @@ private struct BoostState {
|
||||
}
|
||||
|
||||
return (
|
||||
.storiesChannelBoost(peer: peer, boostSubject: .stories, isCurrent: isCurrent, level: currentLevel, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: nil, myBoostCount: myBoostCount),
|
||||
.storiesChannelBoost(peer: peer, boostSubject: .stories, isCurrent: isCurrent, level: currentLevel, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: nil, myBoostCount: myBoostCount, canBoostAgain: canBoostAgain),
|
||||
boosts
|
||||
)
|
||||
}
|
||||
@ -86,7 +86,10 @@ public func PremiumBoostScreen(
|
||||
var updateImpl: (() -> Void)?
|
||||
var dismissImpl: (() -> Void)?
|
||||
|
||||
let (initialSubject, initialCount) = initialState.displayData(peer: peer, isCurrent: isCurrent, myBoostCount: myBoostCount, currentMyBoostCount: 0, replacedBoosts: replacedBoosts?.0)
|
||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with({ $0 }))
|
||||
let canBoostAgain = premiumConfiguration.boostsPerGiftCount > 0
|
||||
|
||||
let (initialSubject, initialCount) = initialState.displayData(peer: peer, isCurrent: isCurrent, canBoostAgain: canBoostAgain, myBoostCount: myBoostCount, currentMyBoostCount: 0, replacedBoosts: replacedBoosts?.0)
|
||||
let controller = PremiumLimitScreen(context: context, subject: initialSubject, count: initialCount, forceDark: forceDark, action: {
|
||||
let dismiss = false
|
||||
updateImpl?()
|
||||
@ -99,7 +102,7 @@ public func PremiumBoostScreen(
|
||||
|
||||
if let (replacedBoosts, inChannels) = replacedBoosts {
|
||||
currentMyBoostCount += 1
|
||||
let (subject, count) = initialState.displayData(peer: peer, isCurrent: isCurrent, myBoostCount: myBoostCount, currentMyBoostCount: 1, replacedBoosts: nil)
|
||||
let (subject, count) = initialState.displayData(peer: peer, isCurrent: isCurrent, canBoostAgain: canBoostAgain, myBoostCount: myBoostCount, currentMyBoostCount: 1, replacedBoosts: nil)
|
||||
controller.updateSubject(subject, count: count)
|
||||
|
||||
Queue.mainQueue().after(0.3) {
|
||||
@ -138,7 +141,7 @@ public func PremiumBoostScreen(
|
||||
guard let state else {
|
||||
return
|
||||
}
|
||||
let (subject, count) = state.displayData(peer: peer, isCurrent: isCurrent, myBoostCount: myBoostCount, currentMyBoostCount: currentMyBoostCount)
|
||||
let (subject, count) = state.displayData(peer: peer, isCurrent: isCurrent, canBoostAgain: canBoostAgain, myBoostCount: myBoostCount, currentMyBoostCount: currentMyBoostCount)
|
||||
controller?.updateSubject(subject, count: count)
|
||||
})
|
||||
|
||||
@ -172,18 +175,21 @@ public func PremiumBoostScreen(
|
||||
}
|
||||
} else {
|
||||
if isPremium {
|
||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with({ $0 }))
|
||||
let controller = textAlertController(
|
||||
sharedContext: context.sharedContext,
|
||||
updatedPresentationData: nil,
|
||||
title: presentationData.strings.ChannelBoost_MoreBoosts_Title,
|
||||
text: presentationData.strings.ChannelBoost_MoreBoosts_Text(peer.compactDisplayTitle, "\(premiumConfiguration.boostsPerGiftCount)").string,
|
||||
actions: [
|
||||
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})
|
||||
],
|
||||
parseMarkdown: true
|
||||
)
|
||||
presentController(controller)
|
||||
if !canBoostAgain {
|
||||
dismissImpl?()
|
||||
} else {
|
||||
let controller = textAlertController(
|
||||
sharedContext: context.sharedContext,
|
||||
updatedPresentationData: nil,
|
||||
title: presentationData.strings.ChannelBoost_MoreBoosts_Title,
|
||||
text: presentationData.strings.ChannelBoost_MoreBoosts_Text(peer.compactDisplayTitle, "\(premiumConfiguration.boostsPerGiftCount)").string,
|
||||
actions: [
|
||||
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})
|
||||
],
|
||||
parseMarkdown: true
|
||||
)
|
||||
presentController(controller)
|
||||
}
|
||||
} else {
|
||||
let controller = textAlertController(
|
||||
sharedContext: context.sharedContext,
|
||||
|
@ -1105,7 +1105,7 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
string = strings.Premium_MaxStoriesMonthlyNoPremiumText("\(limit)").string
|
||||
}
|
||||
buttonAnimationName = nil
|
||||
case let .storiesChannelBoost(peer, boostSubject, isCurrent, level, currentLevelBoosts, nextLevelBoosts, link, myBoostCount):
|
||||
case let .storiesChannelBoost(peer, boostSubject, isCurrent, level, currentLevelBoosts, nextLevelBoosts, link, myBoostCount, canBoostAgain):
|
||||
if link == nil, !isCurrent, state.initialized {
|
||||
peerShortcutChild = peerShortcut.update(
|
||||
component: Button(
|
||||
@ -1231,8 +1231,8 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
alternateBadge = "X\(myBoostCount)"
|
||||
}
|
||||
let storiesString = strings.ChannelBoost_StoriesPerDay(level + 1)
|
||||
if let _ = remaining {
|
||||
actionButtonText = "Boost Again"
|
||||
if let _ = remaining, canBoostAgain {
|
||||
actionButtonText = strings.ChannelBoost_BoostAgain
|
||||
} else {
|
||||
buttonIconName = nil
|
||||
actionButtonText = environment.strings.Common_OK
|
||||
@ -1428,7 +1428,7 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
var buttonOffset: CGFloat = 0.0
|
||||
var textOffset: CGFloat = 184.0 + topOffset
|
||||
|
||||
if case let .storiesChannelBoost(_, _, _, _, _, _, link, _) = component.subject {
|
||||
if case let .storiesChannelBoost(_, _, _, _, _, _, link, _, _) = component.subject {
|
||||
if let link {
|
||||
let linkButton = linkButton.update(
|
||||
component: SolidRoundedButtonComponent(
|
||||
@ -1539,7 +1539,7 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
)
|
||||
|
||||
var additionalContentHeight: CGFloat = 0.0
|
||||
if case let .storiesChannelBoost(_, _, _, _, _, _, link, _) = component.subject, link != nil, let openGift = component.openGift {
|
||||
if case let .storiesChannelBoost(_, _, _, _, _, _, link, _, _) = component.subject, link != nil, let openGift = component.openGift {
|
||||
let orText = orText.update(
|
||||
component: MultilineTextComponent(text: .plain(NSAttributedString(string: "or", font: Font.regular(15.0), textColor: textColor.withAlphaComponent(0.8), paragraphAlignment: .center))),
|
||||
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: context.availableSize.height),
|
||||
@ -1608,7 +1608,7 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
height -= 78.0
|
||||
}
|
||||
|
||||
if case let .storiesChannelBoost(_, _, isCurrent, _, _, _, link, _) = component.subject {
|
||||
if case let .storiesChannelBoost(_, _, isCurrent, _, _, _, link, _, _) = component.subject {
|
||||
if link != nil {
|
||||
height += 66.0
|
||||
|
||||
@ -1774,7 +1774,7 @@ public class PremiumLimitScreen: ViewControllerComponentContainer {
|
||||
case stories
|
||||
case nameColors
|
||||
}
|
||||
case storiesChannelBoost(peer: EnginePeer, boostSubject: BoostSubject, isCurrent: Bool, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, myBoostCount: Int32)
|
||||
case storiesChannelBoost(peer: EnginePeer, boostSubject: BoostSubject, isCurrent: Bool, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, myBoostCount: Int32, canBoostAgain: Bool)
|
||||
}
|
||||
|
||||
private let context: AccountContext
|
||||
|
@ -968,6 +968,12 @@ public func channelStatsController(context: AccountContext, updatedPresentationD
|
||||
},
|
||||
openBoost: { boost in
|
||||
dismissAllTooltipsImpl?()
|
||||
|
||||
if let peer = boost.peer, !boost.flags.contains(.isGiveaway) && !boost.flags.contains(.isGift) {
|
||||
navigateToChatImpl?(peer)
|
||||
return
|
||||
}
|
||||
|
||||
if boost.peer == nil, boost.flags.contains(.isGiveaway) && !boost.flags.contains(.isUnclaimed) {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
presentImpl?(UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.Stats_Boosts_TooltipToBeDistributed, timeout: nil, customUndoText: nil), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }))
|
||||
|
@ -430,7 +430,7 @@ public func PeerNameColorScreen(
|
||||
}
|
||||
|
||||
let link = status.url
|
||||
let controller = PremiumLimitScreen(context: context, subject: .storiesChannelBoost(peer: peer, boostSubject: .nameColors, isCurrent: true, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, myBoostCount: 0), count: Int32(status.boosts), action: {
|
||||
let controller = PremiumLimitScreen(context: context, subject: .storiesChannelBoost(peer: peer, boostSubject: .nameColors, isCurrent: true, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, myBoostCount: 0, canBoostAgain: false), count: Int32(status.boosts), action: {
|
||||
UIPasteboard.general.string = link
|
||||
presentImpl?(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.ChannelBoost_BoostLinkCopied), elevatedLayout: false, position: .bottom, animateInAsReplacement: false, action: { _ in return false }))
|
||||
return true
|
||||
|
@ -1106,7 +1106,7 @@ final class ShareWithPeersScreenComponent: Component {
|
||||
previousController.dismiss()
|
||||
}
|
||||
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = component.context.sharedContext.makePremiumLimitController(context: component.context, subject: .storiesChannelBoost(peer: peer, isCurrent: true, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, myBoostCount: 0), count: Int32(status.boosts), forceDark: true, cancel: {}, action: { [weak navigationController] in
|
||||
let controller = component.context.sharedContext.makePremiumLimitController(context: component.context, subject: .storiesChannelBoost(peer: peer, isCurrent: true, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, myBoostCount: 0, canBoostAgain: false), count: Int32(status.boosts), forceDark: true, cancel: {}, action: { [weak navigationController] in
|
||||
UIPasteboard.general.string = link
|
||||
|
||||
if let previousController = navigationController?.viewControllers.reversed().first(where: { $0 is ShareWithPeersScreen}) as? ShareWithPeersScreen {
|
||||
|
@ -8382,7 +8382,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
if let previousController = navigationController.viewControllers.last as? ShareWithPeersScreen {
|
||||
previousController.dismiss()
|
||||
}
|
||||
let controller = PremiumLimitScreen(context: self.context, subject: .storiesChannelBoost(peer: peer, boostSubject: .stories, isCurrent: true, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, myBoostCount: 0), count: Int32(status.boosts), action: { [weak self] in
|
||||
let controller = PremiumLimitScreen(context: self.context, subject: .storiesChannelBoost(peer: peer, boostSubject: .stories, isCurrent: true, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, myBoostCount: 0, canBoostAgain: false), count: Int32(status.boosts), action: { [weak self] in
|
||||
UIPasteboard.general.string = link
|
||||
|
||||
if let self {
|
||||
|
@ -1812,8 +1812,8 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
mappedSubject = .storiesWeekly
|
||||
case .storiesMonthly:
|
||||
mappedSubject = .storiesMonthly
|
||||
case let .storiesChannelBoost(peer, isCurrent, level, currentLevelBoosts, nextLevelBoosts, link, myBoostCount):
|
||||
mappedSubject = .storiesChannelBoost(peer: peer, boostSubject: .stories, isCurrent: isCurrent, level: level, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: link, myBoostCount: myBoostCount)
|
||||
case let .storiesChannelBoost(peer, isCurrent, level, currentLevelBoosts, nextLevelBoosts, link, myBoostCount, canBoostAgain):
|
||||
mappedSubject = .storiesChannelBoost(peer: peer, boostSubject: .stories, isCurrent: isCurrent, level: level, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: link, myBoostCount: myBoostCount, canBoostAgain: canBoostAgain)
|
||||
}
|
||||
return PremiumLimitScreen(context: context, subject: mappedSubject, count: count, forceDark: forceDark, cancel: cancel, action: action)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user