51 lines
1.3 KiB
Swift
51 lines
1.3 KiB
Swift
//
|
|
// PrefsAccountView.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 4/7/24.
|
|
// Copyright © 2024 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import UserAccounts
|
|
import WebURL
|
|
|
|
struct PrefsAccountView: View {
|
|
let account: UserAccountInfo
|
|
|
|
var body: some View {
|
|
HStack {
|
|
LocalAccountAvatarView(localAccountInfo: account)
|
|
VStack(alignment: .prefsAvatar) {
|
|
Text(verbatim: account.username)
|
|
.foregroundColor(.primary)
|
|
let instance = if let domain = WebURL.Domain(account.instanceURL.host!) {
|
|
domain.render(.uncheckedUnicodeString)
|
|
} else {
|
|
account.instanceURL.host!
|
|
}
|
|
Text(verbatim: instance)
|
|
.font(.caption)
|
|
.foregroundColor(.primary)
|
|
}
|
|
.alignmentGuide(.prefsAvatar, computeValue: { dimension in
|
|
dimension[.leading]
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct AvatarAlignment: AlignmentID {
|
|
static func defaultValue(in context: ViewDimensions) -> CGFloat {
|
|
0
|
|
}
|
|
}
|
|
|
|
extension HorizontalAlignment {
|
|
static let prefsAvatar = HorizontalAlignment(AvatarAlignment.self)
|
|
}
|
|
|
|
//#Preview {
|
|
// PrefsAccountView()
|
|
//}
|