137 lines
3.2 KiB
Swift
137 lines
3.2 KiB
Swift
|
|
import SwiftUI
|
||
|
|
|
||
|
|
public enum SIO {
|
||
|
|
public static let tint = Color("SIOTint")
|
||
|
|
public static let laneFeed = Color("LaneFeed")
|
||
|
|
public static let lanePaper = Color("LanePaper")
|
||
|
|
public static let lanePeople = Color("LanePeople")
|
||
|
|
public static let cardRadius: CGFloat = 14
|
||
|
|
public static let controlRadius: CGFloat = 10
|
||
|
|
public static let chipRadius: CGFloat = 6
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum Lane: String, CaseIterable, Codable, Identifiable {
|
||
|
|
case feed
|
||
|
|
case paper
|
||
|
|
case people
|
||
|
|
|
||
|
|
public var id: String { rawValue }
|
||
|
|
|
||
|
|
public var label: String {
|
||
|
|
switch self {
|
||
|
|
case .feed: "Feed"
|
||
|
|
case .paper: "Paper"
|
||
|
|
case .people: "People"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public var color: Color {
|
||
|
|
switch self {
|
||
|
|
case .feed: SIO.laneFeed
|
||
|
|
case .paper: SIO.lanePaper
|
||
|
|
case .people: SIO.lanePeople
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum ThreadRowDensity: String, CaseIterable, Identifiable {
|
||
|
|
case compact
|
||
|
|
case cozy
|
||
|
|
case comfortable
|
||
|
|
|
||
|
|
public var id: String { rawValue }
|
||
|
|
|
||
|
|
public var avatarSize: CGFloat {
|
||
|
|
switch self {
|
||
|
|
case .compact: 24
|
||
|
|
case .cozy: 30
|
||
|
|
case .comfortable: 30
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public var previewLineLimit: Int {
|
||
|
|
switch self {
|
||
|
|
case .compact, .cozy: 1
|
||
|
|
case .comfortable: 2
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public var rowPadding: CGFloat {
|
||
|
|
switch self {
|
||
|
|
case .compact: 10
|
||
|
|
case .cozy: 12
|
||
|
|
case .comfortable: 14
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public var showsMetaChips: Bool {
|
||
|
|
self == .comfortable
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum ThemePreference: String, CaseIterable, Identifiable {
|
||
|
|
case system
|
||
|
|
case light
|
||
|
|
case dark
|
||
|
|
|
||
|
|
public var id: String { rawValue }
|
||
|
|
|
||
|
|
public var label: String {
|
||
|
|
switch self {
|
||
|
|
case .system: "System"
|
||
|
|
case .light: "Light"
|
||
|
|
case .dark: "Dark"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public var colorScheme: ColorScheme? {
|
||
|
|
switch self {
|
||
|
|
case .system: nil
|
||
|
|
case .light: .light
|
||
|
|
case .dark: .dark
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum ReadingPanePreference: String, CaseIterable, Identifiable {
|
||
|
|
case right
|
||
|
|
case bottom
|
||
|
|
case off
|
||
|
|
|
||
|
|
public var id: String { rawValue }
|
||
|
|
|
||
|
|
public var label: String {
|
||
|
|
switch self {
|
||
|
|
case .right: "Right"
|
||
|
|
case .bottom: "Bottom"
|
||
|
|
case .off: "Off"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public extension View {
|
||
|
|
func sioCardBackground(tint: Color? = nil, cornerRadius: CGFloat = SIO.cardRadius) -> some View {
|
||
|
|
background(.regularMaterial, in: RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
|
||
|
|
.overlay(
|
||
|
|
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
|
||
|
|
.fill((tint ?? Color.clear).opacity(0.08))
|
||
|
|
)
|
||
|
|
.overlay(
|
||
|
|
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
|
||
|
|
.strokeBorder(Color.primary.opacity(0.08), lineWidth: 1)
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
func sioSoftSelection(_ isSelected: Bool) -> some View {
|
||
|
|
background(
|
||
|
|
RoundedRectangle(cornerRadius: SIO.cardRadius, style: .continuous)
|
||
|
|
.fill(isSelected ? SIO.tint.opacity(0.12) : Color.clear)
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
func sioProse() -> some View {
|
||
|
|
font(.system(size: 15.5))
|
||
|
|
.lineSpacing(6)
|
||
|
|
}
|
||
|
|
}
|