mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-01 18:33:10 +00:00
Add non-premium story tooltip
This commit is contained in:
parent
3d597b95a5
commit
b45e9fe24e
@ -198,10 +198,7 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
|
|||||||
}
|
}
|
||||||
let buttonSize = buttonNode.update(key: spec.key, presentationData: presentationData, height: size.height)
|
let buttonSize = buttonNode.update(key: spec.key, presentationData: presentationData, height: size.height)
|
||||||
var nextButtonOrigin = spec.isForExpandedView ? nextExpandedButtonOrigin : nextRegularButtonOrigin
|
var nextButtonOrigin = spec.isForExpandedView ? nextExpandedButtonOrigin : nextRegularButtonOrigin
|
||||||
var buttonFrame = CGRect(origin: CGPoint(x: nextButtonOrigin - buttonSize.width, y: expandOffset + (spec.isForExpandedView ? maximumExpandOffset : 0.0)), size: buttonSize)
|
let buttonFrame = CGRect(origin: CGPoint(x: nextButtonOrigin - buttonSize.width, y: expandOffset + (spec.isForExpandedView ? maximumExpandOffset : 0.0)), size: buttonSize)
|
||||||
if case .postStory = spec.key {
|
|
||||||
buttonFrame.origin.x -= 12.0
|
|
||||||
}
|
|
||||||
nextButtonOrigin -= buttonSize.width + 15.0
|
nextButtonOrigin -= buttonSize.width + 15.0
|
||||||
if spec.isForExpandedView {
|
if spec.isForExpandedView {
|
||||||
nextExpandedButtonOrigin = nextButtonOrigin
|
nextExpandedButtonOrigin = nextButtonOrigin
|
||||||
@ -263,10 +260,7 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
|
|||||||
if let buttonNode = self.rightButtonNodes[key] {
|
if let buttonNode = self.rightButtonNodes[key] {
|
||||||
let buttonSize = buttonNode.bounds.size
|
let buttonSize = buttonNode.bounds.size
|
||||||
var nextButtonOrigin = spec.isForExpandedView ? nextExpandedButtonOrigin : nextRegularButtonOrigin
|
var nextButtonOrigin = spec.isForExpandedView ? nextExpandedButtonOrigin : nextRegularButtonOrigin
|
||||||
var buttonFrame = CGRect(origin: CGPoint(x: nextButtonOrigin - buttonSize.width, y: expandOffset + (spec.isForExpandedView ? maximumExpandOffset : 0.0)), size: buttonSize)
|
let buttonFrame = CGRect(origin: CGPoint(x: nextButtonOrigin - buttonSize.width, y: expandOffset + (spec.isForExpandedView ? maximumExpandOffset : 0.0)), size: buttonSize)
|
||||||
if case .postStory = spec.key {
|
|
||||||
buttonFrame.origin.x -= 12.0
|
|
||||||
}
|
|
||||||
nextButtonOrigin -= buttonSize.width + 15.0
|
nextButtonOrigin -= buttonSize.width + 15.0
|
||||||
if spec.isForExpandedView {
|
if spec.isForExpandedView {
|
||||||
nextExpandedButtonOrigin = nextButtonOrigin
|
nextExpandedButtonOrigin = nextButtonOrigin
|
||||||
|
@ -4122,7 +4122,11 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
case .qrCode:
|
case .qrCode:
|
||||||
strongSelf.openQrCode()
|
strongSelf.openQrCode()
|
||||||
case .postStory:
|
case .postStory:
|
||||||
strongSelf.openPostStory()
|
var sourceFrame: CGRect?
|
||||||
|
if let source {
|
||||||
|
sourceFrame = source.view.convert(source.bounds, to: strongSelf.view)
|
||||||
|
}
|
||||||
|
strongSelf.openPostStory(sourceFrame: sourceFrame)
|
||||||
case .editPhoto, .editVideo, .moreToSearch:
|
case .editPhoto, .editVideo, .moreToSearch:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -9542,12 +9546,12 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
self.controller?.push(controller)
|
self.controller?.push(controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func openPostStory() {
|
private func openPostStory(sourceFrame: CGRect?) {
|
||||||
self.postingAvailabilityDisposable?.dispose()
|
self.postingAvailabilityDisposable?.dispose()
|
||||||
|
|
||||||
let canPostStatus: Signal<StoriesUploadAvailability, NoError>
|
let canPostStatus: Signal<StoriesUploadAvailability, NoError>
|
||||||
#if DEBUG && false
|
#if DEBUG && false
|
||||||
canPostStatus = .single(.available)
|
canPostStatus = .single(StoriesUploadAvailability.premiumRequired)
|
||||||
#else
|
#else
|
||||||
canPostStatus = self.context.engine.messages.checkStoriesUploadAvailability(target: .peer(self.peerId))
|
canPostStatus = self.context.engine.messages.checkStoriesUploadAvailability(target: .peer(self.peerId))
|
||||||
#endif
|
#endif
|
||||||
@ -9599,6 +9603,34 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
|
|
||||||
self.hapticFeedback.impact(.light)
|
self.hapticFeedback.impact(.light)
|
||||||
}).strict()
|
}).strict()
|
||||||
|
case .premiumRequired, .monthlyLimit, .weeklyLimit, .expiringLimit:
|
||||||
|
if let sourceFrame {
|
||||||
|
let context = self.context
|
||||||
|
let location = CGRect(origin: CGPoint(x: sourceFrame.midX, y: sourceFrame.maxY), size: CGSize())
|
||||||
|
|
||||||
|
let text: String
|
||||||
|
text = self.presentationData.strings.StoryFeed_TooltipPremiumPostingLimited
|
||||||
|
|
||||||
|
let tooltipController = TooltipScreen(
|
||||||
|
context: context,
|
||||||
|
account: context.account,
|
||||||
|
sharedContext: context.sharedContext,
|
||||||
|
text: .markdown(text: text),
|
||||||
|
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, forceDark: false, dismissed: nil)
|
||||||
|
self?.controller?.push(controller)
|
||||||
|
return .dismiss(consume: true)
|
||||||
|
} else {
|
||||||
|
return .dismiss(consume: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.controller?.present(tooltipController, in: .current)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user