From 837de5b1c2bc9af3d28f53e1fdec03a07bba5ee9 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 24 Jun 2024 14:29:56 +0400 Subject: [PATCH] Paid media improvements --- Telegram/Telegram-iOS/en.lproj/Localizable.strings | 6 ++++++ .../LegacyComponents/TGMediaSelectionContext.h | 2 +- .../MediaPickerUI/Sources/MediaPickerScreen.swift | 11 ++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 5fb20b0aef..bc3129ff72 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -12454,3 +12454,9 @@ Sorry for the inconvenience."; "Premium.MessageEffectsInfo" = "Add over 500 animated effects to private messages."; "Chat.UnlockMedia" = "Unlock for %@"; + +"Attachment.SendWithoutGrouping" = "Send Without Grouping"; +"Attachment.Paid.EditPrice" = "Edit Price"; +"Attachment.Paid.EditPrice.Stars_1" = "%@ Star"; +"Attachment.Paid.EditPrice.Stars_any" = "%@ Stars"; +"Attachment.Paid.Create" = "Make This Content Paid"; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaSelectionContext.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaSelectionContext.h index bc3c16874c..68bda51e98 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaSelectionContext.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaSelectionContext.h @@ -11,7 +11,7 @@ - (instancetype)initWithGroupingAllowed:(bool)allowGrouping selectionLimit:(int)selectionLimit; @property (nonatomic, readonly) bool allowGrouping; -@property (nonatomic, readonly) int selectionLimit; +@property (nonatomic, assign) int selectionLimit; @property (nonatomic, copy) void (^selectionLimitExceeded)(void); @property (nonatomic, copy) bool (^attemptSelectingItem)(id); diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 631704c86f..40be90ac32 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -2488,7 +2488,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { }))) } if selectionCount > 1, price == nil { - items.append(.action(ContextMenuActionItem(text: "Send Without Grouping", icon: { theme in + items.append(.action(ContextMenuActionItem(text: strings.Attachment_SendWithoutGrouping, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Media Grid/GroupingOff"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in f(.default) @@ -2499,7 +2499,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } var isPaidAvailable = false - if let peer = self.peer, case let .channel(channel) = peer, case .broadcast = channel.info { + if let peer = self.peer, case let .channel(channel) = peer, case .broadcast = channel.info, selectionCount <= 10 { isPaidAvailable = true } if isSpoilerAvailable || isPaidAvailable || (selectionCount > 0 && isCaptionAboveMediaAvailable) { @@ -2547,10 +2547,10 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { let title: String let titleLayout: ContextMenuActionItemTextLayout if let price { - title = "Edit Price" - titleLayout = .secondLineWithValue("\(price) Stars") + title = strings.Attachment_Paid_EditPrice + titleLayout = .secondLineWithValue(strings.Attachment_Paid_EditPrice_Stars(Int32(price))) } else { - title = "Make This Content Paid" + title = strings.Attachment_Paid_Create titleLayout = .singleLine } items.append(.action(ContextMenuActionItem(text: title, textLayout: titleLayout, icon: { theme in @@ -2566,6 +2566,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { return } if let selectionContext = strongSelf.interaction?.selectionState, let editingContext = strongSelf.interaction?.editingState { + selectionContext.selectionLimit = 10 for case let item as TGMediaEditableItem in selectionContext.selectedItems() { editingContext.setPrice(NSNumber(value: amount), for: item) }