Various fixes

This commit is contained in:
Ilya Laktyushin
2023-07-11 06:48:28 +02:00
parent 0d69b86b92
commit 5ad9671d70
13 changed files with 820 additions and 378 deletions

View File

@@ -2568,16 +2568,41 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
switch self.storyPostingAvailability {
case .premium:
guard self.isPremium else {
let context = self.context
var replaceImpl: ((ViewController) -> Void)?
let controller = context.sharedContext.makePremiumDemoController(context: self.context, subject: .stories, action: {
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .stories)
replaceImpl?(controller)
})
replaceImpl = { [weak controller] c in
controller?.replace(with: c)
if let componentView = self.chatListHeaderView() {
var sourceFrame: CGRect?
if fromList {
if let (transitionView, _) = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
sourceFrame = transitionView.convert(transitionView.bounds, to: nil).offsetBy(dx: 18.0 - UIScreenPixel, dy: 1.0)
}
} else {
if let rightButtonView = componentView.rightButtonViews["story"] {
sourceFrame = rightButtonView.convert(rightButtonView.bounds, to: nil).offsetBy(dx: 5.0, dy: -8.0)
}
}
if let sourceFrame {
let context = self.context
let location = CGRect(origin: CGPoint(x: sourceFrame.midX, y: sourceFrame.maxY), size: CGSize())
let tooltipController = TooltipScreen(
context: context,
account: context.account,
sharedContext: context.sharedContext,
text: .markdown(text: "Posting stories is currently available only to subscribers of [Telegram Premium]()."),
style: .customBlur(UIColor(rgb: 0x2a2a2a), 2.0),
icon: .none,
location: .point(location, .top),
shouldDismissOnTouch: { [weak self] point, containerFrame in
if containerFrame.contains(point) {
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .stories)
self?.push(controller)
return .dismiss(consume: true)
} else {
return .dismiss(consume: false)
}
}
)
self.present(tooltipController, in: .window(.root))
}
}
self.push(controller)
return
}
case .disabled: