another.im-ios/ConversationsClassic/View/SharedComponents/SharedListRow.swift
2024-08-07 21:07:39 +02:00

60 lines
1.8 KiB
Swift

import SwiftUI
enum SharedListRowIconType {
case charCircle(String)
case image(Image, Color)
}
struct SharedListRow: View {
let iconType: SharedListRowIconType
let text: String
var body: some View {
VStack(spacing: 0) {
HStack(spacing: 8) {
// Icon
switch iconType {
case .charCircle(let str):
let char = str.firstLetter
let color = str.firstLetterColor
ZStack {
Circle()
.frame(width: 44, height: 44)
.foregroundColor(color)
Text(char)
.foregroundColor(.white)
.font(.body1)
}
case .image(let image, let color):
ZStack {
Circle()
.frame(width: 44, height: 44)
.foregroundColor(.clearTappable)
.overlay {
image
.foregroundColor(color)
}
}
}
// Text
Text(text)
.foregroundColor(Color.Material.Text.main)
.font(.body2)
Spacer()
}
.padding(.horizontal, 16)
.padding(.vertical, 4)
Rectangle()
.frame(maxWidth: .infinity)
.frame(height: 1)
.foregroundColor(.Material.Background.dark)
}
.listRowInsets(.zero)
.listRowSeparator(.hidden)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.Material.Background.light)
}
}