Paid media improvements

This commit is contained in:
Ilya Laktyushin 2024-06-24 14:29:56 +04:00
parent 829174356f
commit 837de5b1c2
3 changed files with 13 additions and 6 deletions

View File

@ -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";

View File

@ -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<TGMediaSelectableItem>);

View File

@ -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)
}