mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Group boosts
This commit is contained in:
@@ -11304,3 +11304,5 @@ Sorry for the inconvenience.";
|
||||
"Channel.AdminLog.MessageRemovedGroupEmojiPack" = "%@ removed group emoji pack";
|
||||
|
||||
"Group.Appearance.EmojiPackUpdated" = "Group emoji pack updated.";
|
||||
|
||||
"Attachment.BoostToUnlock" = "Boost to Unlock";
|
||||
|
||||
@@ -26,6 +26,7 @@ final class MediaPickerPlaceholderNode: ASDisplayNode {
|
||||
private var cameraTextNode: ImmediateTextNode
|
||||
private var cameraIconNode: ASImageNode
|
||||
|
||||
var boostPressed: () -> Void = {}
|
||||
var settingsPressed: () -> Void = {}
|
||||
var cameraPressed: () -> Void = {}
|
||||
|
||||
@@ -76,7 +77,13 @@ final class MediaPickerPlaceholderNode: ASDisplayNode {
|
||||
self.addSubnode(self.animationNode)
|
||||
self.addSubnode(self.textNode)
|
||||
|
||||
if case .intro = self.content {
|
||||
switch self.content {
|
||||
case .bannedSendMedia(_, true):
|
||||
self.addSubnode(self.buttonNode)
|
||||
self.buttonNode.pressed = { [weak self] in
|
||||
self?.boostPressed()
|
||||
}
|
||||
case .intro:
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.buttonNode)
|
||||
|
||||
@@ -104,6 +111,8 @@ final class MediaPickerPlaceholderNode: ASDisplayNode {
|
||||
self.buttonNode.pressed = { [weak self] in
|
||||
self?.settingsPressed()
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +137,7 @@ final class MediaPickerPlaceholderNode: ASDisplayNode {
|
||||
|
||||
let imageSpacing: CGFloat = 12.0
|
||||
let textSpacing: CGFloat = 12.0
|
||||
let buttonSpacing: CGFloat = 15.0
|
||||
let buttonSpacing: CGFloat = 20.0
|
||||
let cameraSpacing: CGFloat = 13.0
|
||||
|
||||
let imageHeight = layout.size.width < layout.size.height ? imageSize.height + imageSpacing : 0.0
|
||||
@@ -137,7 +146,13 @@ final class MediaPickerPlaceholderNode: ASDisplayNode {
|
||||
self.buttonNode.updateTheme(SolidRoundedButtonTheme(theme: theme))
|
||||
self.cameraIconNode.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Attach Menu/OpenCamera"), color: theme.list.itemAccentColor)
|
||||
}
|
||||
switch self.content {
|
||||
case .intro:
|
||||
self.buttonNode.title = strings.Attachment_OpenSettings
|
||||
case .bannedSendMedia:
|
||||
self.buttonNode.title = strings.Attachment_BoostToUnlock
|
||||
}
|
||||
|
||||
let buttonWidth: CGFloat = 248.0
|
||||
let buttonHeight = self.buttonNode.updateLayout(width: buttonWidth, transition: transition)
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
private let chatLocation: ChatLocation?
|
||||
private let bannedSendPhotos: (Int32, Bool)?
|
||||
private let bannedSendVideos: (Int32, Bool)?
|
||||
private let canBoostToUnrestrict: Bool
|
||||
private let subject: Subject
|
||||
private let saveEditedPhotos: Bool
|
||||
|
||||
@@ -187,6 +188,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
public var presentTimerPicker: (@escaping (Int32) -> Void) -> Void = { _ in }
|
||||
public var presentWebSearch: (MediaGroupsScreen, Bool) -> Void = { _, _ in }
|
||||
public var getCaptionPanelView: () -> TGCaptionPanelView? = { return nil }
|
||||
public var openBoost: () -> Void = { }
|
||||
|
||||
public var customSelection: ((MediaPickerScreen, Any) -> Void)? = nil
|
||||
|
||||
@@ -1324,7 +1326,10 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
if let current = self.placeholderNode {
|
||||
placeholderNode = current
|
||||
} else {
|
||||
placeholderNode = MediaPickerPlaceholderNode(content: .bannedSendMedia(text: banDescription, canBoost: false))
|
||||
placeholderNode = MediaPickerPlaceholderNode(content: .bannedSendMedia(text: banDescription, canBoost: controller.canBoostToUnrestrict))
|
||||
placeholderNode.boostPressed = { [weak controller] in
|
||||
controller?.openBoost()
|
||||
}
|
||||
self.containerNode.insertSubnode(placeholderNode, aboveSubnode: self.gridNode)
|
||||
self.placeholderNode = placeholderNode
|
||||
|
||||
@@ -1525,8 +1530,9 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
threadTitle: String?,
|
||||
chatLocation: ChatLocation?,
|
||||
isScheduledMessages: Bool = false,
|
||||
bannedSendPhotos: (Int32, Bool)?,
|
||||
bannedSendVideos: (Int32, Bool)?,
|
||||
bannedSendPhotos: (Int32, Bool)? = nil,
|
||||
bannedSendVideos: (Int32, Bool)? = nil,
|
||||
canBoostToUnrestrict: Bool = false,
|
||||
subject: Subject,
|
||||
editingContext: TGMediaEditingContext? = nil,
|
||||
selectionContext: TGMediaSelectionContext? = nil,
|
||||
@@ -1545,6 +1551,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
self.isScheduledMessages = isScheduledMessages
|
||||
self.bannedSendPhotos = bannedSendPhotos
|
||||
self.bannedSendVideos = bannedSendVideos
|
||||
self.canBoostToUnrestrict = canBoostToUnrestrict
|
||||
self.subject = subject
|
||||
self.saveEditedPhotos = saveEditedPhotos
|
||||
self.mainButtonState = mainButtonState
|
||||
|
||||
@@ -1070,7 +1070,25 @@ extension ChatControllerImpl {
|
||||
if case .scheduledMessages = self.presentationInterfaceState.subject {
|
||||
isScheduledMessages = true
|
||||
}
|
||||
let controller = MediaPickerScreen(context: self.context, updatedPresentationData: self.updatedPresentationData, peer: EnginePeer(peer), threadTitle: self.threadInfo?.title, chatLocation: self.chatLocation, isScheduledMessages: isScheduledMessages, bannedSendPhotos: bannedSendPhotos, bannedSendVideos: bannedSendVideos, subject: subject, saveEditedPhotos: saveEditedPhotos)
|
||||
let controller = MediaPickerScreen(
|
||||
context: self.context,
|
||||
updatedPresentationData: self.updatedPresentationData,
|
||||
peer: EnginePeer(peer),
|
||||
threadTitle: self.threadInfo?.title,
|
||||
chatLocation: self.chatLocation,
|
||||
isScheduledMessages: isScheduledMessages,
|
||||
bannedSendPhotos: bannedSendPhotos,
|
||||
bannedSendVideos: bannedSendVideos,
|
||||
canBoostToUnrestrict: (self.presentationInterfaceState.boostsToUnrestrict ?? 0) > 0 && bannedSendPhotos?.1 != true && bannedSendVideos?.1 != true,
|
||||
subject: subject,
|
||||
saveEditedPhotos: saveEditedPhotos
|
||||
)
|
||||
controller.openBoost = { [weak self, weak controller] in
|
||||
if let self {
|
||||
controller?.dismiss()
|
||||
self.interfaceInteraction?.openBoostToUnrestrict()
|
||||
}
|
||||
}
|
||||
let mediaPickerContext = controller.mediaPickerContext
|
||||
controller.openCamera = { [weak self] cameraView in
|
||||
self?.openCamera(cameraView: cameraView)
|
||||
|
||||
Reference in New Issue
Block a user