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
19007dfbcb
commit
5b6f79e6f5
@ -773,6 +773,8 @@ public final class DatePickerNode: ASDisplayNode {
|
|||||||
public func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
|
public func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||||
self.validLayout = size
|
self.validLayout = size
|
||||||
|
|
||||||
|
let constrainedSize = CGSize(width: min(390.0, size.width), height: size.height)
|
||||||
|
|
||||||
let timeHeight: CGFloat = 50.0
|
let timeHeight: CGFloat = 50.0
|
||||||
let topInset: CGFloat = 78.0 + timeHeight
|
let topInset: CGFloat = 78.0 + timeHeight
|
||||||
let sideInset: CGFloat = 16.0
|
let sideInset: CGFloat = 16.0
|
||||||
@ -783,8 +785,8 @@ public final class DatePickerNode: ASDisplayNode {
|
|||||||
let timeTitleSize = self.timeTitleNode.updateLayout(size)
|
let timeTitleSize = self.timeTitleNode.updateLayout(size)
|
||||||
self.timeTitleNode.frame = CGRect(origin: CGPoint(x: 16.0, y: 12.0), size: timeTitleSize)
|
self.timeTitleNode.frame = CGRect(origin: CGPoint(x: 16.0, y: 12.0), size: timeTitleSize)
|
||||||
|
|
||||||
let timePickerSize = CGSize(width: size.width, height: 180.0)
|
let timePickerSize = CGSize(width: constrainedSize.width, height: 180.0)
|
||||||
self.timePickerNode.frame = CGRect(origin: CGPoint(x: 0.0, y: timeHeight + 11.0), size: timePickerSize)
|
self.timePickerNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - constrainedSize.width) / 2.0), y: timeHeight + 11.0), size: timePickerSize)
|
||||||
|
|
||||||
self.monthTextNode.attributedText = NSAttributedString(string: stringForMonth(strings: self.strings, month: components.month.flatMap { Int32($0) - 1 } ?? 0, ofYear: components.year.flatMap { Int32($0) - 1900 } ?? 100), font: controlFont, textColor: self.state.displayingMonthSelection ? self.theme.accentColor : self.theme.textColor)
|
self.monthTextNode.attributedText = NSAttributedString(string: stringForMonth(strings: self.strings, month: components.month.flatMap { Int32($0) - 1 } ?? 0, ofYear: components.year.flatMap { Int32($0) - 1900 } ?? 100), font: controlFont, textColor: self.state.displayingMonthSelection ? self.theme.accentColor : self.theme.textColor)
|
||||||
let monthSize = self.monthTextNode.updateLayout(size)
|
let monthSize = self.monthTextNode.updateLayout(size)
|
||||||
@ -827,14 +829,14 @@ public final class DatePickerNode: ASDisplayNode {
|
|||||||
self.dateButtonNode.frame = CGRect(x: size.width - timeSize.width - 4.0 - 4.0 - dateSize.width, y: 4.0, width: dateSize.width, height: dateSize.height)
|
self.dateButtonNode.frame = CGRect(x: size.width - timeSize.width - 4.0 - 4.0 - dateSize.width, y: 4.0, width: dateSize.width, height: dateSize.height)
|
||||||
|
|
||||||
let daysSideInset: CGFloat = 12.0
|
let daysSideInset: CGFloat = 12.0
|
||||||
let cellSize: CGFloat = floor((size.width - daysSideInset * 2.0) / 7.0)
|
let cellSize: CGFloat = floor((constrainedSize.width - daysSideInset * 2.0) / 7.0)
|
||||||
|
|
||||||
var dayIndex: Int32 = Int32(calendar.firstWeekday) - 1
|
var dayIndex: Int32 = Int32(calendar.firstWeekday) - 1
|
||||||
for i in 0 ..< self.dayNodes.count {
|
for i in 0 ..< self.dayNodes.count {
|
||||||
let dayNode = self.dayNodes[i]
|
let dayNode = self.dayNodes[i]
|
||||||
dayNode.attributedText = NSAttributedString(string: shortStringForDayOfWeek(strings: self.strings, day: dayIndex % 7).uppercased(), font: dayFont, textColor: theme.secondaryTextColor)
|
dayNode.attributedText = NSAttributedString(string: shortStringForDayOfWeek(strings: self.strings, day: dayIndex % 7).uppercased(), font: dayFont, textColor: theme.secondaryTextColor)
|
||||||
|
|
||||||
let textSize = dayNode.updateLayout(size)
|
let textSize = dayNode.updateLayout(constrainedSize)
|
||||||
let cellFrame = CGRect(x: daysSideInset + CGFloat(i) * cellSize, y: topInset - 38.0, width: cellSize, height: cellSize)
|
let cellFrame = CGRect(x: daysSideInset + CGFloat(i) * cellSize, y: topInset - 38.0, width: cellSize, height: cellSize)
|
||||||
let textFrame = CGRect(origin: CGPoint(x: cellFrame.minX + floor((cellFrame.width - textSize.width) / 2.0), y: cellFrame.minY + floor((cellFrame.height - textSize.height) / 2.0)), size: textSize)
|
let textFrame = CGRect(origin: CGPoint(x: cellFrame.minX + floor((cellFrame.width - textSize.width) / 2.0), y: cellFrame.minY + floor((cellFrame.height - textSize.height) / 2.0)), size: textSize)
|
||||||
|
|
||||||
@ -842,8 +844,8 @@ public final class DatePickerNode: ASDisplayNode {
|
|||||||
dayIndex += 1
|
dayIndex += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
let containerSize = CGSize(width: size.width, height: size.height - topInset)
|
let containerSize = CGSize(width: constrainedSize.width, height: size.height - topInset)
|
||||||
self.contentNode.frame = CGRect(origin: CGPoint(x: 0.0, y: topInset), size: containerSize)
|
self.contentNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - constrainedSize.width) / 2.0), y: topInset), size: containerSize)
|
||||||
|
|
||||||
self.updateItems(size: containerSize, transition: transition)
|
self.updateItems(size: containerSize, transition: transition)
|
||||||
|
|
||||||
|
@ -904,8 +904,15 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
|
|||||||
|
|
||||||
var selectedProduct: PremiumGiftProduct?
|
var selectedProduct: PremiumGiftProduct?
|
||||||
let selectedMonths = state.selectedMonths ?? 12
|
let selectedMonths = state.selectedMonths ?? 12
|
||||||
if let product = products.first(where: { $0.months == selectedMonths && $0.giftOption.users == state.subscriptions }) {
|
switch state.mode {
|
||||||
selectedProduct = product
|
case .giveaway:
|
||||||
|
if let product = products.first(where: { $0.months == selectedMonths && $0.giftOption.users == state.subscriptions }) {
|
||||||
|
selectedProduct = product
|
||||||
|
}
|
||||||
|
case .gift:
|
||||||
|
if let product = products.first(where: { $0.months == selectedMonths && $0.giftOption.users == 1 }) {
|
||||||
|
selectedProduct = product
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let selectedProduct else {
|
guard let selectedProduct else {
|
||||||
|
@ -155,8 +155,9 @@ public class ItemListDatePickerItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
|
|
||||||
let leftInset = 16.0 + params.leftInset
|
let leftInset = 16.0 + params.leftInset
|
||||||
|
|
||||||
let width = min(390.0, params.width - params.leftInset - params.rightInset)
|
let width = params.width - params.leftInset - params.rightInset
|
||||||
let cellSize = floor((width - 12.0 * 2.0) / 7.0)
|
let constrainedWidth = min(390.0, width)
|
||||||
|
let cellSize = floor((constrainedWidth - 12.0 * 2.0) / 7.0)
|
||||||
let pickerHeight = 122.0 + cellSize * 6.0
|
let pickerHeight = 122.0 + cellSize * 6.0
|
||||||
let height: CGFloat
|
let height: CGFloat
|
||||||
if item.displayingDateSelection {
|
if item.displayingDateSelection {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"app": "10.2.2",
|
"app": "10.2.3",
|
||||||
"bazel": "6.4.0",
|
"bazel": "6.4.0",
|
||||||
"xcode": "15.0"
|
"xcode": "15.0"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user