mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
a288c543f2
commit
ab0faf8073
@ -987,7 +987,7 @@ public enum PremiumLimitSubject {
|
||||
case expiringStories
|
||||
case storiesWeekly
|
||||
case storiesMonthly
|
||||
case storiesChannelBoost(peer: EnginePeer, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, boosted: Bool)
|
||||
case storiesChannelBoost(peer: EnginePeer, isCurrent: Bool, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, boosted: Bool)
|
||||
}
|
||||
|
||||
public protocol ComposeController: ViewController {
|
||||
|
@ -774,7 +774,12 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
let subject = component.subject
|
||||
|
||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: component.context.currentAppConfiguration.with { $0 })
|
||||
let isPremiumDisabled = premiumConfiguration.isPremiumDisabled
|
||||
let isPremiumDisabled: Bool
|
||||
if case .storiesChannelBoost = subject {
|
||||
isPremiumDisabled = false
|
||||
} else {
|
||||
isPremiumDisabled = premiumConfiguration.isPremiumDisabled
|
||||
}
|
||||
|
||||
let sideInset: CGFloat = 16.0 + environment.safeInsets.left
|
||||
let textSideInset: CGFloat = 32.0 + environment.safeInsets.left
|
||||
@ -1027,8 +1032,8 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
string = strings.Premium_MaxStoriesMonthlyNoPremiumText("\(limit)").string
|
||||
}
|
||||
buttonAnimationName = nil
|
||||
case let .storiesChannelBoost(peer, level, currentLevelBoosts, nextLevelBoosts, link, boosted):
|
||||
if link == nil, state.initialized {
|
||||
case let .storiesChannelBoost(peer, isCurrent, level, currentLevelBoosts, nextLevelBoosts, link, boosted):
|
||||
if link == nil, !isCurrent, state.initialized {
|
||||
peerShortcutChild = peerShortcut.update(
|
||||
component: Button(
|
||||
content: AnyComponent(
|
||||
@ -1246,7 +1251,7 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
|
||||
let limit = limit.update(
|
||||
component: PremiumLimitDisplayComponent(
|
||||
inactiveColor: theme.list.itemBlocksSeparatorColor.withAlphaComponent(0.5),
|
||||
inactiveColor: theme.list.itemBlocksSeparatorColor.withAlphaComponent(0.3),
|
||||
activeColors: gradientColors,
|
||||
inactiveTitle: defaultTitle,
|
||||
inactiveValue: defaultValue,
|
||||
@ -1302,7 +1307,7 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
var buttonOffset: CGFloat = 0.0
|
||||
var textOffset: CGFloat = 228.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(
|
||||
@ -1316,7 +1321,11 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
fontSize: 17.0,
|
||||
height: 50.0,
|
||||
cornerRadius: 10.0,
|
||||
action: {}
|
||||
action: {
|
||||
if component.action() {
|
||||
component.dismiss()
|
||||
}
|
||||
}
|
||||
),
|
||||
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: 50.0),
|
||||
transition: context.transition
|
||||
@ -1386,11 +1395,15 @@ private final class LimitSheetContent: CombinedComponent {
|
||||
height -= 78.0
|
||||
}
|
||||
|
||||
if case let .storiesChannelBoost(_, _, _, _, link, _) = component.subject {
|
||||
if case let .storiesChannelBoost(_, isCurrent, _, _, _, link, _) = component.subject {
|
||||
if link != nil {
|
||||
height += 66.0
|
||||
} else {
|
||||
height -= 53.0 - 32.0
|
||||
if isCurrent {
|
||||
height -= 53.0
|
||||
} else {
|
||||
height -= 53.0 - 32.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1510,7 +1523,7 @@ public class PremiumLimitScreen: ViewControllerComponentContainer {
|
||||
case storiesWeekly
|
||||
case storiesMonthly
|
||||
|
||||
case storiesChannelBoost(peer: EnginePeer, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, boosted: Bool)
|
||||
case storiesChannelBoost(peer: EnginePeer, isCurrent: Bool, level: Int32, currentLevelBoosts: Int32, nextLevelBoosts: Int32?, link: String?, boosted: Bool)
|
||||
}
|
||||
|
||||
private let context: AccountContext
|
||||
@ -1611,10 +1624,8 @@ private final class PeerShortcutComponent: Component {
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
self.backgroundColor = component.theme.list.itemBlocksSeparatorColor.withAlphaComponent(0.5)
|
||||
self.backgroundColor = component.theme.list.itemBlocksSeparatorColor.withAlphaComponent(0.3)
|
||||
|
||||
|
||||
|
||||
self.avatarNode.frame = CGRect(origin: CGPoint(x: 1.0, y: 1.0), size: CGSize(width: 30.0, height: 30.0))
|
||||
self.avatarNode.setPeer(
|
||||
context: component.context,
|
||||
|
@ -627,7 +627,7 @@ private func channelStatsControllerEntries(state: ChannelStatsControllerState, p
|
||||
if let addressName = peer.addressName, !addressName.isEmpty {
|
||||
link = "t.me/\(addressName)?boost"
|
||||
} else {
|
||||
link = "t.me/boost?=\(peer.id.id._internalGetInt64Value())"
|
||||
link = "t.me/c/\(peer.id.id._internalGetInt64Value())?boost"
|
||||
}
|
||||
entries.append(.boostLink(presentationData.theme, link))
|
||||
}
|
||||
|
@ -4463,10 +4463,10 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
if let addressName = peer.addressName, !addressName.isEmpty {
|
||||
link = "t.me/\(peer.addressName ?? "")?boost"
|
||||
} else {
|
||||
link = "t.me/boost?=\(peer.id.id._internalGetInt64Value())"
|
||||
link = "t.me/c/\(peer.id.id._internalGetInt64Value())?boost"
|
||||
}
|
||||
|
||||
let controller = self.context.sharedContext.makePremiumLimitController(context: self.context, subject: .storiesChannelBoost(peer: peer, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, boosted: false), count: Int32(status.boosts), forceDark: true, cancel: {}, action: { [weak self] in
|
||||
let controller = self.context.sharedContext.makePremiumLimitController(context: self.context, subject: .storiesChannelBoost(peer: peer, isCurrent: true, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: link, boosted: false), count: Int32(status.boosts), forceDark: true, cancel: {}, action: { [weak self] in
|
||||
guard let self else {
|
||||
return true
|
||||
}
|
||||
@ -4476,6 +4476,8 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
return true
|
||||
})
|
||||
self.push(controller)
|
||||
|
||||
self.hapticFeedback.impact(.light)
|
||||
})
|
||||
default:
|
||||
break
|
||||
|
@ -847,8 +847,13 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
|
||||
boosted = true
|
||||
}
|
||||
|
||||
let subject: PremiumLimitScreen.Subject = .storiesChannelBoost(peer: peer, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: nil, boosted: boosted)
|
||||
let nextSubject: PremiumLimitScreen.Subject = .storiesChannelBoost(peer: peer, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: nil, boosted: true)
|
||||
var isCurrent = false
|
||||
if case let .chat(chatPeerId, _) = urlContext, chatPeerId == peerId {
|
||||
isCurrent = true
|
||||
}
|
||||
|
||||
let subject: PremiumLimitScreen.Subject = .storiesChannelBoost(peer: peer, isCurrent: isCurrent, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: nil, boosted: boosted)
|
||||
let nextSubject: PremiumLimitScreen.Subject = .storiesChannelBoost(peer: peer, isCurrent: isCurrent, level: Int32(status.level), currentLevelBoosts: Int32(status.currentLevelBoosts), nextLevelBoosts: status.nextLevelBoosts.flatMap(Int32.init), link: nil, boosted: true)
|
||||
let nextCount = Int32(status.boosts + 1)
|
||||
|
||||
var updateImpl: (() -> Void)?
|
||||
|
@ -876,7 +876,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
if let domain {
|
||||
convertedUrl = "https://t.me/\(domain)?boost"
|
||||
} else if let channel {
|
||||
convertedUrl = "https://t.me/boost?channel=\(channel)"
|
||||
convertedUrl = "https://t.me/c/\(channel)?boost"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1782,8 +1782,8 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
mappedSubject = .storiesWeekly
|
||||
case .storiesMonthly:
|
||||
mappedSubject = .storiesMonthly
|
||||
case let .storiesChannelBoost(peer, level, currentLevelBoosts, nextLevelBoosts, link, boosted):
|
||||
mappedSubject = .storiesChannelBoost(peer: peer, level: level, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: link, boosted: boosted)
|
||||
case let .storiesChannelBoost(peer, isCurrent, level, currentLevelBoosts, nextLevelBoosts, link, boosted):
|
||||
mappedSubject = .storiesChannelBoost(peer: peer, isCurrent: isCurrent, level: level, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: link, boosted: boosted)
|
||||
}
|
||||
return PremiumLimitScreen(context: context, subject: mappedSubject, count: count, forceDark: forceDark, cancel: cancel, action: action)
|
||||
}
|
||||
|
@ -218,11 +218,6 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
|
||||
self.accountSettingsController = accountSettingsController
|
||||
self.rootTabController = tabBarController
|
||||
self.pushViewController(tabBarController, animated: false)
|
||||
|
||||
// Queue.mainQueue().after(0.5) {
|
||||
// let controller = self.context.sharedContext.makePremiumLimitController(context: self.context, subject: .storiesChannelBoost(title: "MYChannel", level: 0, currentLevelBoosts: 0, nextLevelBoosts: 1, link: "t.me/mychannel?boost"), count: 0, forceDark: true, cancel: {}, action: {})
|
||||
// chatListController.present(controller, in: .window(.root))
|
||||
// }
|
||||
}
|
||||
|
||||
public func updateRootControllers(showCallsTab: Bool) {
|
||||
|
@ -494,6 +494,7 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? {
|
||||
} else if pathComponents.count == 2 && pathComponents[0] == "c" {
|
||||
if let channelId = Int64(pathComponents[1]) {
|
||||
var threadId: Int32?
|
||||
var boost: Bool = false
|
||||
if let queryItems = components.queryItems {
|
||||
for queryItem in queryItems {
|
||||
if let value = queryItem.value {
|
||||
@ -502,12 +503,19 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? {
|
||||
threadId = intValue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if queryItem.name == "boost" {
|
||||
boost = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let threadId = threadId {
|
||||
return .peer(.id(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))), .replyThread(threadId, threadId))
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
if boost {
|
||||
return .peer(.id(peerId), .boost)
|
||||
} else if let threadId = threadId {
|
||||
return .peer(.id(peerId), .replyThread(threadId, threadId))
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user