Files
Morgan Pretty 1b8d6ead1e Added in initial AppStore purchase logic, cleaned up some code
• Added in the actual Session Pro AppStore purchase call
• Cleaned up the SessionProManager interface
• Fixed an issue where enabling Session Pro wouldn't update the settings screen
• Fixed a few issues with performing UI actions on background threads (mentions "@You badge")
2025-12-02 16:22:11 +11:00

114 lines
5.1 KiB
Swift

// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
import SwiftUI
import DifferenceKit
// MARK: - ListItemCell
public struct ListItemCell: View {
public struct Info: Equatable, Hashable, Differentiable {
let leadingAccessory: SessionListScreenContent.ListItemAccessory?
let title: SessionListScreenContent.TextInfo?
let description: SessionListScreenContent.TextInfo?
let trailingAccessory: SessionListScreenContent.ListItemAccessory?
public init(
leadingAccessory: SessionListScreenContent.ListItemAccessory? = nil,
title: SessionListScreenContent.TextInfo? = nil,
description: SessionListScreenContent.TextInfo? = nil,
trailingAccessory: SessionListScreenContent.ListItemAccessory? = nil
) {
self.leadingAccessory = leadingAccessory
self.title = title
self.description = description
self.trailingAccessory = trailingAccessory
}
}
let info: Info
let height: CGFloat
public var body: some View {
HStack(spacing: Values.mediumSpacing) {
if let leadingAccessory = info.leadingAccessory {
leadingAccessory.accessoryView()
}
VStack(alignment: .leading, spacing: 0) {
if let title = info.title {
HStack(spacing: Values.verySmallSpacing) {
if case .proBadgeLeading(let size, let themeBackgroundColor) = title.accessory {
SessionProBadge_SwiftUI(size: size, themeBackgroundColor: themeBackgroundColor)
}
if let text = title.text {
Text(text)
.font(title.font)
.multilineTextAlignment(title.alignment)
.foregroundColor(themeColor: title.color)
.accessibility(title.accessibility)
.fixedSize()
} else if let attributedString = title.attributedString {
AttributedText(attributedString)
.font(title.font)
.multilineTextAlignment(title.alignment)
.foregroundColor(themeColor: title.color)
.accessibility(title.accessibility)
.fixedSize()
}
if case .proBadgeTrailing(let size, let themeBackgroundColor) = title.accessory {
SessionProBadge_SwiftUI(size: size, themeBackgroundColor: themeBackgroundColor)
}
}
}
if let description = info.description {
HStack(spacing: Values.verySmallSpacing) {
if case .proBadgeLeading(let size, let themeBackgroundColor) = description.accessory {
SessionProBadge_SwiftUI(size: size, themeBackgroundColor: themeBackgroundColor)
}
if let text = description.text {
Text(text)
.font(description.font)
.multilineTextAlignment(description.alignment)
.foregroundColor(themeColor: description.color)
.accessibility(description.accessibility)
.fixedSize(horizontal: false, vertical: true)
} else if let attributedString = description.attributedString {
AttributedText(attributedString)
.font(description.font)
.multilineTextAlignment(description.alignment)
.foregroundColor(themeColor: description.color)
.accessibility(description.accessibility)
.fixedSize(horizontal: false, vertical: true)
}
if case .proBadgeTrailing(let size, let themeBackgroundColor) = description.accessory {
SessionProBadge_SwiftUI(size: size, themeBackgroundColor: themeBackgroundColor)
}
}
}
}
.frame(
maxWidth: .infinity,
maxHeight: .infinity,
alignment: .leading
)
if let trailingAccessory = info.trailingAccessory {
Spacer(minLength: 0)
trailingAccessory.accessoryView()
}
}
.padding(.horizontal, Values.mediumSpacing)
.frame(
maxWidth: .infinity,
minHeight: height,
alignment: .leading
)
.contentShape(Rectangle())
}
}