Various improvements

This commit is contained in:
Ilya Laktyushin 2024-09-02 17:19:08 +04:00
parent e27bb3a220
commit 32e6629538
5 changed files with 54 additions and 8 deletions

View File

@ -10292,6 +10292,9 @@ Sorry for the inconvenience.";
"BoostGift.GiveawayCreated.Text" = "Check your channel's [Statistics]() to see how this giveaway boosted your channel."; "BoostGift.GiveawayCreated.Text" = "Check your channel's [Statistics]() to see how this giveaway boosted your channel.";
"BoostGift.PremiumGifted.Title" = "Premium Subscriptions Gifted"; "BoostGift.PremiumGifted.Title" = "Premium Subscriptions Gifted";
"BoostGift.PremiumGifted.Text" = "Check your channel's [Statistics]() to see how gifts boosted your channel."; "BoostGift.PremiumGifted.Text" = "Check your channel's [Statistics]() to see how gifts boosted your channel.";
"BoostGift.StarsGiveawayCreated.Title" = "Stars Giveaway Created";
"BoostGift.StarsGiveawayCreated.Text" = "Check your channel's [Statistics]() to see how this giveaway boosted your channel.";
"BoostGift.Group.StarsGiveawayCreated.Text" = "Check your group's [Boosts]() to see how this giveaway boosted your group.";
"BoostGift.Subscribers.Title" = "Gift Premium"; "BoostGift.Subscribers.Title" = "Gift Premium";
"BoostGift.Subscribers.Subtitle" = "select up to %@ subscribers"; "BoostGift.Subscribers.Subtitle" = "select up to %@ subscribers";
@ -12904,3 +12907,11 @@ Sorry for the inconvenience.";
"Stars.Transaction.Giveaway.Boost.Subscriber_any" = "%@ Subscribers"; "Stars.Transaction.Giveaway.Boost.Subscriber_any" = "%@ Subscribers";
"Conversation.ContextMenuCopyEmail" = "Copy Email"; "Conversation.ContextMenuCopyEmail" = "Copy Email";
"Chat.Giveaway.Message.WinnersInfo.Stars_1" = "**%@ Star**";
"Chat.Giveaway.Message.WinnersInfo.Stars_any" = "**%@ Stars**";
"Chat.Giveaway.Message.WinnersInfo.Stars.One" = "The winner received %@.";
"Chat.Giveaway.Message.WinnersInfo.Stars.Many" = "All winners received a total of %@.";
"Premium.BoostByGiveawayDescription" = "Get more boosts and subscribers for your channel by giving away prizes. [Get boosts >]()";
"Premium.Group.BoostByGiveawayDescription" = "Get more boosts and members for your group by giving away prizes. [Get boosts >]()";

View File

@ -1383,18 +1383,40 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
let title: String let title: String
let text: String let text: String
switch state.mode { switch state.mode {
case .giveaway, .starsGiveaway: case .giveaway:
title = presentationData.strings.BoostGift_GiveawayCreated_Title title = presentationData.strings.BoostGift_GiveawayCreated_Title
text = isGroup ? presentationData.strings.BoostGift_Group_GiveawayCreated_Text : presentationData.strings.BoostGift_GiveawayCreated_Text text = isGroup ? presentationData.strings.BoostGift_Group_GiveawayCreated_Text : presentationData.strings.BoostGift_GiveawayCreated_Text
case .starsGiveaway:
title = presentationData.strings.BoostGift_StarsGiveawayCreated_Title
text = isGroup ? presentationData.strings.BoostGift_Group_StarsGiveawayCreated_Text : presentationData.strings.BoostGift_StarsGiveawayCreated_Text
case .gift: case .gift:
title = presentationData.strings.BoostGift_PremiumGifted_Title title = presentationData.strings.BoostGift_PremiumGifted_Title
text = isGroup ? presentationData.strings.BoostGift_Group_PremiumGifted_Text : presentationData.strings.BoostGift_PremiumGifted_Text text = isGroup ? presentationData.strings.BoostGift_Group_PremiumGifted_Text : presentationData.strings.BoostGift_PremiumGifted_Text
} }
let tooltipController = UndoOverlayController(presentationData: presentationData, content: .premiumPaywall(title: title, text: text, customUndoText: nil, timeout: nil, linkAction: { [weak navigationController] _ in var content: UndoOverlayContent
let statsController = context.sharedContext.makeChannelStatsController(context: context, updatedPresentationData: updatedPresentationData, peerId: peerId, boosts: true, boostStatus: nil) if case .starsGiveaway = state.mode {
navigationController?.pushViewController(statsController) content = .universal(
}), elevatedLayout: false, action: { _ in animation: "StarsBuy",
scale: 0.066,
colors: [:],
title: title,
text: text,
customUndoText: nil,
timeout: nil
)
} else {
content = .premiumPaywall(title: title, text: text, customUndoText: nil, timeout: nil, linkAction: { [weak navigationController] _ in
let statsController = context.sharedContext.makeChannelStatsController(context: context, updatedPresentationData: updatedPresentationData, peerId: peerId, boosts: true, boostStatus: nil)
navigationController?.pushViewController(statsController)
})
}
let tooltipController = UndoOverlayController(presentationData: presentationData, content: content, elevatedLayout: false, action: { [weak navigationController] action in
if case .info = action {
let statsController = context.sharedContext.makeChannelStatsController(context: context, updatedPresentationData: updatedPresentationData, peerId: peerId, boosts: true, boostStatus: nil)
navigationController?.pushViewController(statsController)
}
return true return true
}) })
(controllers.last as? ViewController)?.present(tooltipController, in: .current) (controllers.last as? ViewController)?.present(tooltipController, in: .current)

View File

@ -1021,7 +1021,8 @@ private final class SheetContent: CombinedComponent {
state.cachedChevronImage = (generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: linkColor)!, theme) state.cachedChevronImage = (generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: linkColor)!, theme)
} }
let giftString = isGroup ? strings.Premium_Group_BoostByGiftDescription : strings.Premium_BoostByGiftDescription2
let giftString = isGroup ? strings.Premium_Group_BoostByGiveawayDescription : strings.Premium_BoostByGiveawayDescription
let giftAttributedString = parseMarkdownIntoAttributedString(giftString, attributes: markdownAttributes).mutableCopy() as! NSMutableAttributedString let giftAttributedString = parseMarkdownIntoAttributedString(giftString, attributes: markdownAttributes).mutableCopy() as! NSMutableAttributedString
if let range = giftAttributedString.string.range(of: ">"), let chevronImage = state.cachedChevronImage?.0 { if let range = giftAttributedString.string.range(of: ">"), let chevronImage = state.cachedChevronImage?.0 {

View File

@ -1609,7 +1609,7 @@ private final class LimitSheetContent: CombinedComponent {
state.cachedChevronImage = (generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: linkColor)!, environment.theme) state.cachedChevronImage = (generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: linkColor)!, environment.theme)
} }
let giftString = environment.strings.Premium_BoostByGiftDescription2 let giftString = environment.strings.Premium_BoostByGiveawayDescription
let giftAttributedString = parseMarkdownIntoAttributedString(giftString, attributes: markdownAttributes).mutableCopy() as! NSMutableAttributedString let giftAttributedString = parseMarkdownIntoAttributedString(giftString, attributes: markdownAttributes).mutableCopy() as! NSMutableAttributedString
if let range = giftAttributedString.string.range(of: ">"), let chevronImage = state.cachedChevronImage?.0 { if let range = giftAttributedString.string.range(of: ">"), let chevronImage = state.cachedChevronImage?.0 {

View File

@ -466,7 +466,19 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode,
if let giveaway { if let giveaway {
dateTextString = NSAttributedString(string: stringForFullDate(timestamp: giveaway.untilDate, strings: item.presentationData.strings, dateTimeFormat: item.presentationData.dateTimeFormat), font: textFont, textColor: textColor) dateTextString = NSAttributedString(string: stringForFullDate(timestamp: giveaway.untilDate, strings: item.presentationData.strings, dateTimeFormat: item.presentationData.dateTimeFormat), font: textFont, textColor: textColor)
} else if let giveawayResults { } else if let giveawayResults {
dateTextString = NSAttributedString(string: giveawayResults.winnersCount > 1 ? item.presentationData.strings.Chat_Giveaway_Message_WinnersInfo_Many : item.presentationData.strings.Chat_Giveaway_Message_WinnersInfo_One, font: textFont, textColor: textColor) if case let .stars(stars) = giveawayResults.prize {
let starsString = item.presentationData.strings.Chat_Giveaway_Message_WinnersInfo_Stars(Int32(stars))
dateTextString = parseMarkdownIntoAttributedString(giveawayResults.winnersCount > 1 ? item.presentationData.strings.Chat_Giveaway_Message_WinnersInfo_Stars_Many(starsString).string : item.presentationData.strings.Chat_Giveaway_Message_WinnersInfo_Stars_One(starsString).string, attributes: MarkdownAttributes(
body: MarkdownAttributeSet(font: textFont, textColor: textColor),
bold: MarkdownAttributeSet(font: boldTextFont, textColor: textColor),
link: MarkdownAttributeSet(font: textFont, textColor: accentColor),
linkAttribute: { url in
return ("URL", url)
}
), textAlignment: .center)
} else {
dateTextString = NSAttributedString(string: giveawayResults.winnersCount > 1 ? item.presentationData.strings.Chat_Giveaway_Message_WinnersInfo_Many : item.presentationData.strings.Chat_Giveaway_Message_WinnersInfo_One, font: textFont, textColor: textColor)
}
} }
let hideHeaders = item.message.forwardInfo == nil let hideHeaders = item.message.forwardInfo == nil
let contentProperties = ChatMessageBubbleContentProperties(hidesSimpleAuthorHeader: hideHeaders, headerSpacing: 0.0, hidesBackground: .never, forceFullCorners: false, forceAlignment: .none, hidesHeaders: hideHeaders) let contentProperties = ChatMessageBubbleContentProperties(hidesSimpleAuthorHeader: hideHeaders, headerSpacing: 0.0, hidesBackground: .never, forceFullCorners: false, forceAlignment: .none, hidesHeaders: hideHeaders)