mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various fixes
This commit is contained in:
@@ -791,9 +791,9 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
|
||||
let badgeCount: Int32
|
||||
switch state.mode {
|
||||
case .giveaway:
|
||||
badgeCount = state.subscriptions
|
||||
badgeCount = state.subscriptions * 4
|
||||
case .gift:
|
||||
badgeCount = Int32(state.peers.count)
|
||||
badgeCount = Int32(state.peers.count) * 4
|
||||
}
|
||||
let footerItem = CreateGiveawayFooterItem(theme: presentationData.theme, title: state.mode == .gift ? presentationData.strings.BoostGift_GiftPremium : presentationData.strings.BoostGift_StartGiveaway, badgeCount: badgeCount, isLoading: state.updating, action: {
|
||||
buyActionImpl?()
|
||||
|
||||
@@ -303,7 +303,10 @@ class GiftOptionItemNode: ItemListRevealOptionsItemNode {
|
||||
|
||||
let (labelLayout, labelApply) = makeLabelLayout(TextNodeLayoutArguments(attributedString: labelAttributedString, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: .greatestFiniteMagnitude)))
|
||||
|
||||
let textConstrainedWidth = params.width - leftInset - 8.0 - editingOffset - rightInset - labelLayout.size.width - avatarInset
|
||||
var textConstrainedWidth = params.width - leftInset - 8.0 - editingOffset - rightInset - labelLayout.size.width - avatarInset
|
||||
if let label = item.label, case .semitransparent = label {
|
||||
textConstrainedWidth -= 54.0
|
||||
}
|
||||
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: textConstrainedWidth, height: .greatestFiniteMagnitude)))
|
||||
let (statusLayout, statusApply) = makeStatusLayout(TextNodeLayoutArguments(attributedString: statusAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: textConstrainedWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
@@ -10,9 +10,29 @@ import TelegramPresentationData
|
||||
import Markdown
|
||||
import AlertUI
|
||||
|
||||
public func giveawayInfoController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, message: EngineMessage, giveawayInfo: PremiumGiveawayInfo, openLink: @escaping (String) -> Void) -> ViewController? {
|
||||
public func presentGiveawayInfoController(
|
||||
context: AccountContext,
|
||||
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil,
|
||||
messageId: EngineMessage.Id,
|
||||
giveawayInfo: PremiumGiveawayInfo,
|
||||
present: @escaping (ViewController) -> Void,
|
||||
openLink: @escaping (String) -> Void
|
||||
) {
|
||||
var peerIds: [EnginePeer.Id] = [context.account.peerId]
|
||||
if case let .ongoing(_, status) = giveawayInfo, case let .notAllowed(reason) = status, case let .channelAdmin(adminId) = reason {
|
||||
peerIds.append(adminId)
|
||||
}
|
||||
|
||||
let _ = (context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Messages.Message(id: messageId),
|
||||
EngineDataMap(peerIds.map(TelegramEngine.EngineData.Item.Peer.Peer.init))
|
||||
)
|
||||
|> deliverOnMainQueue).startStandalone(next: { message, peerMap in
|
||||
guard let message else {
|
||||
return
|
||||
}
|
||||
guard let giveaway = message.media.first(where: { $0 is TelegramMediaGiveaway }) as? TelegramMediaGiveaway else {
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
@@ -22,7 +42,8 @@ public func giveawayInfoController(context: AccountContext, updatedPresentationD
|
||||
peerName = EnginePeer(peer).compactDisplayTitle
|
||||
}
|
||||
|
||||
let untilDate = stringForDate(timestamp: giveaway.untilDate, strings: presentationData.strings)
|
||||
let timeZone = TimeZone.current
|
||||
let untilDate = stringForDate(timestamp: giveaway.untilDate, timeZone: timeZone, strings: presentationData.strings)
|
||||
|
||||
let title: String
|
||||
let text: String
|
||||
@@ -36,7 +57,7 @@ public func giveawayInfoController(context: AccountContext, updatedPresentationD
|
||||
|
||||
switch giveawayInfo {
|
||||
case let .ongoing(start, status):
|
||||
let startDate = stringForDate(timestamp: start, strings: presentationData.strings)
|
||||
let startDate = stringForDate(timestamp: start, timeZone: timeZone, strings: presentationData.strings)
|
||||
|
||||
title = presentationData.strings.Chat_Giveaway_Info_Title
|
||||
|
||||
@@ -78,8 +99,11 @@ public func giveawayInfoController(context: AccountContext, updatedPresentationD
|
||||
let joinDate = stringForDate(timestamp: joinedOn, strings: presentationData.strings)
|
||||
participation = presentationData.strings.Chat_Giveaway_Info_NotAllowedJoinedEarly(joinDate).string
|
||||
case let .channelAdmin(adminId):
|
||||
let _ = adminId
|
||||
participation = presentationData.strings.Chat_Giveaway_Info_NotAllowedAdmin(peerName).string
|
||||
var channelName = peerName
|
||||
if let maybePeer = peerMap[adminId], let peer = maybePeer {
|
||||
channelName = peer.compactDisplayTitle
|
||||
}
|
||||
participation = presentationData.strings.Chat_Giveaway_Info_NotAllowedAdmin(channelName).string
|
||||
case .disallowedCountry:
|
||||
participation = presentationData.strings.Chat_Giveaway_Info_NotAllowedCountry
|
||||
}
|
||||
@@ -99,8 +123,8 @@ public func giveawayInfoController(context: AccountContext, updatedPresentationD
|
||||
|
||||
text = "\(intro)\n\n\(ending)\(participation)"
|
||||
case let .finished(status, start, finish, _, activatedCount):
|
||||
let startDate = stringForDate(timestamp: start, strings: presentationData.strings)
|
||||
let finishDate = stringForDate(timestamp: finish, strings: presentationData.strings)
|
||||
let startDate = stringForDate(timestamp: start, timeZone: timeZone, strings: presentationData.strings)
|
||||
let finishDate = stringForDate(timestamp: finish, timeZone: timeZone, strings: presentationData.strings)
|
||||
title = presentationData.strings.Chat_Giveaway_Info_EndedTitle
|
||||
|
||||
let intro = presentationData.strings.Chat_Giveaway_Info_EndedIntro(peerName, presentationData.strings.Chat_Giveaway_Info_Subscriptions(giveaway.quantity), presentationData.strings.Chat_Giveaway_Info_Months(giveaway.months)).string
|
||||
@@ -160,7 +184,8 @@ public func giveawayInfoController(context: AccountContext, updatedPresentationD
|
||||
dismissImpl = { [weak alertController] in
|
||||
alertController?.dismissAnimated()
|
||||
}
|
||||
return alertController
|
||||
present(alertController)
|
||||
})
|
||||
}
|
||||
|
||||
private final class GiveawayInfoAlertContentNode: AlertContentNode {
|
||||
|
||||
@@ -1077,7 +1077,7 @@ public func channelStatsController(context: AccountContext, updatedPresentationD
|
||||
}
|
||||
controller.visibleBottomContentOffsetChanged = { offset in
|
||||
let state = stateValue.with { $0 }
|
||||
if case let .known(value) = offset, value < 100.0, case .boosts = state.section, state.boostersExpanded {
|
||||
if case let .known(value) = offset, value < 510.0, case .boosts = state.section, state.boostersExpanded {
|
||||
boostsContext.loadMore()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ public func stringForFullDate(timestamp: Int32, strings: PresentationStrings, da
|
||||
return monthFormat(dayString, yearString, timeString).string
|
||||
}
|
||||
|
||||
public func stringForDate(timestamp: Int32, strings: PresentationStrings) -> String {
|
||||
public func stringForDate(timestamp: Int32, timeZone: TimeZone? = TimeZone(secondsFromGMT: 0), strings: PresentationStrings) -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.timeStyle = .none
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
formatter.timeZone = timeZone
|
||||
formatter.locale = localeWithStrings(strings)
|
||||
return formatter.string(from: Date(timeIntervalSince1970: Double(timestamp)))
|
||||
}
|
||||
|
||||
@@ -535,6 +535,7 @@ public func PeerNameColorScreen(
|
||||
}
|
||||
|
||||
let controller = ItemListController(context: context, state: signal)
|
||||
controller.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||
presentImpl = { [weak controller] c in
|
||||
guard let controller else {
|
||||
return
|
||||
|
||||
@@ -19177,19 +19177,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
|
||||
func displayGiveawayStatusInfo(messageId: EngineMessage.Id, giveawayInfo: PremiumGiveawayInfo) {
|
||||
let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Messages.Message(id: messageId))
|
||||
|> deliverOnMainQueue).startStandalone(next: { [weak self] message in
|
||||
guard let self, let message else {
|
||||
presentGiveawayInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, messageId: messageId, giveawayInfo: giveawayInfo, present: { [weak self] c in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let controller = giveawayInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, message: message, giveawayInfo: giveawayInfo, openLink: { [weak self] slug in
|
||||
self.present(c, in: .window(.root))
|
||||
}, openLink: { [weak self] slug in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.openResolved(result: .premiumGiftCode(slug: slug), sourceMessageId: messageId)
|
||||
}) {
|
||||
self.present(controller, in: .window(.root))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,6 +913,9 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
|
||||
openPeer: { peer in
|
||||
if peer.id != context.account.peerId {
|
||||
openPeer(peer, .chat(textInputState: nil, subject: nil, peekData: nil))
|
||||
if case let .chat(peerId, _) = urlContext, peerId == peer.id {
|
||||
dismissImpl?()
|
||||
}
|
||||
}
|
||||
},
|
||||
openMessage: { messageId in
|
||||
@@ -922,6 +925,9 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
|
||||
return
|
||||
}
|
||||
openPeer(peer, .chat(textInputState: nil, subject: .message(id: .id(messageId), highlight: ChatControllerSubject.MessageHighlight(quote: nil), timecode: nil), peekData: nil))
|
||||
if case let .chat(peerId, _) = urlContext, peerId == messageId.peerId {
|
||||
dismissImpl?()
|
||||
}
|
||||
})
|
||||
},
|
||||
shareLink: { link in
|
||||
|
||||
Reference in New Issue
Block a user