mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
c5f4cf179e
commit
d136aa683d
@ -37,11 +37,12 @@ public final class GiftOptionItem: ListViewItem, ItemListItem {
|
|||||||
|
|
||||||
public enum Label {
|
public enum Label {
|
||||||
case generic(String)
|
case generic(String)
|
||||||
|
case semitransparent(String)
|
||||||
case boosts(Int32)
|
case boosts(Int32)
|
||||||
|
|
||||||
var string: String {
|
var string: String {
|
||||||
switch self {
|
switch self {
|
||||||
case let .generic(value):
|
case let .generic(value), let .semitransparent(value):
|
||||||
return value
|
return value
|
||||||
case let .boosts(value):
|
case let .boosts(value):
|
||||||
return "\(value)"
|
return "\(value)"
|
||||||
@ -265,6 +266,9 @@ class GiftOptionItemNode: ItemListRevealOptionsItemNode {
|
|||||||
if let label = item.label, case .boosts = label {
|
if let label = item.label, case .boosts = label {
|
||||||
labelColor = item.presentationData.theme.list.itemAccentColor
|
labelColor = item.presentationData.theme.list.itemAccentColor
|
||||||
labelFont = Font.semibold(floor(item.presentationData.fontSize.itemListBaseFontSize * 15.0 / 17.0))
|
labelFont = Font.semibold(floor(item.presentationData.fontSize.itemListBaseFontSize * 15.0 / 17.0))
|
||||||
|
} else if let label = item.label, case .semitransparent = label {
|
||||||
|
labelColor = item.presentationData.theme.list.itemAccentColor
|
||||||
|
labelFont = Font.semibold(floor(item.presentationData.fontSize.itemListBaseFontSize * 14.0 / 17.0))
|
||||||
} else {
|
} else {
|
||||||
labelColor = item.presentationData.theme.list.itemSecondaryTextColor
|
labelColor = item.presentationData.theme.list.itemSecondaryTextColor
|
||||||
labelFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 17.0 / 17.0))
|
labelFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 17.0 / 17.0))
|
||||||
@ -539,6 +543,23 @@ class GiftOptionItemNode: ItemListRevealOptionsItemNode {
|
|||||||
transition.updateFrame(node: strongSelf.labelNode, frame: labelFrame)
|
transition.updateFrame(node: strongSelf.labelNode, frame: labelFrame)
|
||||||
transition.updateFrame(node: iconNode, frame: iconFrame)
|
transition.updateFrame(node: iconNode, frame: iconFrame)
|
||||||
}
|
}
|
||||||
|
} else if let label = item.label, case .semitransparent = label {
|
||||||
|
let backgroundNode: ASImageNode
|
||||||
|
if let currentBackground = strongSelf.labelBackgroundNode {
|
||||||
|
backgroundNode = currentBackground
|
||||||
|
} else {
|
||||||
|
backgroundNode = ASImageNode()
|
||||||
|
backgroundNode.displaysAsynchronously = false
|
||||||
|
backgroundNode.image = generateStretchableFilledCircleImage(radius: 13.0, color: item.presentationData.theme.list.itemAccentColor.withAlphaComponent(0.1))
|
||||||
|
strongSelf.containerNode.insertSubnode(backgroundNode, at: 1)
|
||||||
|
|
||||||
|
strongSelf.labelBackgroundNode = backgroundNode
|
||||||
|
}
|
||||||
|
|
||||||
|
let labelFrame = CGRect(origin: CGPoint(x: layoutSize.width - rightInset - labelLayout.size.width - 19.0, y: floorToScreenPixels((layout.contentSize.height - labelLayout.size.height) / 2.0)), size: labelLayout.size)
|
||||||
|
let totalFrame = CGRect(x: labelFrame.minX - 7.0, y: labelFrame.minY - 5.0, width: labelFrame.width + 14.0, height: 26.0)
|
||||||
|
transition.updateFrame(node: backgroundNode, frame: totalFrame)
|
||||||
|
transition.updateFrame(node: strongSelf.labelNode, frame: labelFrame)
|
||||||
} else {
|
} else {
|
||||||
transition.updateFrame(node: strongSelf.labelNode, frame: CGRect(origin: CGPoint(x: layoutSize.width - rightInset - labelLayout.size.width - 18.0, y: floorToScreenPixels((layout.contentSize.height - labelLayout.size.height) / 2.0)), size: labelLayout.size))
|
transition.updateFrame(node: strongSelf.labelNode, frame: CGRect(origin: CGPoint(x: layoutSize.width - rightInset - labelLayout.size.width - 18.0, y: floorToScreenPixels((layout.contentSize.height - labelLayout.size.height) / 2.0)), size: labelLayout.size))
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ private enum StatsEntry: ItemListNodeEntry {
|
|||||||
case boostersTitle(PresentationTheme, String)
|
case boostersTitle(PresentationTheme, String)
|
||||||
case boostersPlaceholder(PresentationTheme, String)
|
case boostersPlaceholder(PresentationTheme, String)
|
||||||
case boosterTabs(PresentationTheme, String, String, Bool)
|
case boosterTabs(PresentationTheme, String, String, Bool)
|
||||||
case booster(Int32, PresentationTheme, PresentationDateTimeFormat, EnginePeer?, Int32, ChannelBoostersContext.State.Boost.Flags, Int32)
|
case booster(Int32, PresentationTheme, PresentationDateTimeFormat, EnginePeer?, Int32, ChannelBoostersContext.State.Boost.Flags, Int32, Int32)
|
||||||
case boostersExpand(PresentationTheme, String)
|
case boostersExpand(PresentationTheme, String)
|
||||||
case boostersInfo(PresentationTheme, String)
|
case boostersInfo(PresentationTheme, String)
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ private enum StatsEntry: ItemListNodeEntry {
|
|||||||
return 2102
|
return 2102
|
||||||
case .boosterTabs:
|
case .boosterTabs:
|
||||||
return 2103
|
return 2103
|
||||||
case let .booster(index, _, _, _, _, _, _):
|
case let .booster(index, _, _, _, _, _, _, _):
|
||||||
return 2104 + index
|
return 2104 + index
|
||||||
case .boostersExpand:
|
case .boostersExpand:
|
||||||
return 10000
|
return 10000
|
||||||
@ -439,8 +439,8 @@ private enum StatsEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .booster(lhsIndex, lhsTheme, lhsDateTimeFormat, lhsPeer, lhsCount, lhsFlags, lhsExpires):
|
case let .booster(lhsIndex, lhsTheme, lhsDateTimeFormat, lhsPeer, lhsCount, lhsFlags, lhsDate, lhsExpires):
|
||||||
if case let .booster(rhsIndex, rhsTheme, rhsDateTimeFormat, rhsPeer, rhsCount, rhsFlags, rhsExpires) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsDateTimeFormat == rhsDateTimeFormat, lhsPeer == rhsPeer, lhsCount == rhsCount, lhsFlags == rhsFlags, lhsExpires == rhsExpires {
|
if case let .booster(rhsIndex, rhsTheme, rhsDateTimeFormat, rhsPeer, rhsCount, rhsFlags, rhsDate, rhsExpires) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsDateTimeFormat == rhsDateTimeFormat, lhsPeer == rhsPeer, lhsCount == rhsCount, lhsFlags == rhsFlags, lhsDate == rhsDate, lhsExpires == rhsExpires {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -548,28 +548,47 @@ private enum StatsEntry: ItemListNodeEntry {
|
|||||||
return BoostsTabsItem(theme: presentationData.theme, boostsText: boostText, giftsText: giftText, selectedTab: giftSelected ? .gifts : .boosts, sectionId: self.section, selectionUpdated: { tab in
|
return BoostsTabsItem(theme: presentationData.theme, boostsText: boostText, giftsText: giftText, selectedTab: giftSelected ? .gifts : .boosts, sectionId: self.section, selectionUpdated: { tab in
|
||||||
arguments.updateGiftsSelected(tab == .gifts)
|
arguments.updateGiftsSelected(tab == .gifts)
|
||||||
})
|
})
|
||||||
case let .booster(_, _, _, peer, count, flags, expires):
|
case let .booster(_, _, _, peer, count, flags, date, expires):
|
||||||
let expiresValue = stringForDate(timestamp: expires, strings: presentationData.strings)
|
let expiresValue = stringForDate(timestamp: expires, strings: presentationData.strings)
|
||||||
let expiresString = presentationData.strings.Stats_Boosts_ExpiresOn(expiresValue).string
|
let expiresString: String
|
||||||
|
|
||||||
|
let durationMonths = Int32(round(Float(expires - date) / (86400.0 * 30.0)))
|
||||||
|
let durationString = "\(durationMonths)m"
|
||||||
|
|
||||||
let title: String
|
let title: String
|
||||||
let icon: GiftOptionItem.Icon
|
let icon: GiftOptionItem.Icon
|
||||||
|
var label: String?
|
||||||
|
if flags.contains(.isGiveaway) {
|
||||||
|
label = "🏆 Giveaway"
|
||||||
|
} else if flags.contains(.isGift) {
|
||||||
|
label = "🎁 Gift"
|
||||||
|
}
|
||||||
if let peer {
|
if let peer {
|
||||||
title = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
title = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||||
icon = .peer(peer)
|
icon = .peer(peer)
|
||||||
|
expiresString = presentationData.strings.Stats_Boosts_ExpiresOn(expiresValue).string
|
||||||
} else {
|
} else {
|
||||||
|
let color: GiftOptionItem.Icon.Color
|
||||||
|
if durationMonths > 11 {
|
||||||
|
color = .red
|
||||||
|
} else if durationMonths > 5 {
|
||||||
|
color = .blue
|
||||||
|
} else {
|
||||||
|
color = .green
|
||||||
|
}
|
||||||
if flags.contains(.isUnclaimed) {
|
if flags.contains(.isUnclaimed) {
|
||||||
title = "Unclaimed"
|
title = "Unclaimed"
|
||||||
icon = .image(color: .red, name: "Premium/Unclaimed")
|
icon = .image(color: color, name: "Premium/Unclaimed")
|
||||||
} else if flags.contains(.isGiveaway) {
|
} else if flags.contains(.isGiveaway) {
|
||||||
title = "To be distributed"
|
title = "To be distributed"
|
||||||
icon = .image(color: .blue, name: "Premium/ToBeDistributed")
|
icon = .image(color: color, name: "Premium/ToBeDistributed")
|
||||||
} else {
|
} else {
|
||||||
title = "Unknown"
|
title = "Unknown"
|
||||||
icon = .image(color: .red, name: "Premium/ToBeDistributed")
|
icon = .image(color: color, name: "Premium/ToBeDistributed")
|
||||||
}
|
}
|
||||||
|
expiresString = "\(durationString) • \(expiresValue)"
|
||||||
}
|
}
|
||||||
return GiftOptionItem(presentationData: presentationData, context: arguments.context, icon: icon, title: title, titleFont: .bold, titleBadge: count > 1 ? "\(count)" : nil, subtitle: expiresString, sectionId: self.section, action: peer != nil && peer?.id != arguments.context.account.peerId ? {
|
return GiftOptionItem(presentationData: presentationData, context: arguments.context, icon: icon, title: title, titleFont: .bold, titleBadge: count > 1 ? "\(count)" : nil, subtitle: expiresString, label: label.flatMap { .semitransparent($0) }, sectionId: self.section, action: peer != nil && peer?.id != arguments.context.account.peerId ? {
|
||||||
arguments.openPeer(peer!)
|
arguments.openPeer(peer!)
|
||||||
} : nil)
|
} : nil)
|
||||||
case let .boostersExpand(theme, title):
|
case let .boostersExpand(theme, title):
|
||||||
@ -805,7 +824,7 @@ private func channelStatsControllerEntries(state: ChannelStatsControllerState, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
for booster in boosters {
|
for booster in boosters {
|
||||||
entries.append(.booster(boosterIndex, presentationData.theme, presentationData.dateTimeFormat, booster.peer, booster.multiplier, booster.flags, booster.expires))
|
entries.append(.booster(boosterIndex, presentationData.theme, presentationData.dateTimeFormat, booster.peer, booster.multiplier, booster.flags, booster.date, booster.expires))
|
||||||
boosterIndex += 1
|
boosterIndex += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user