Yattee v2 rewrite

This commit is contained in:
Arkadiusz Fal
2026-02-08 18:31:16 +01:00
parent 20d0cfc0c7
commit 05f921d605
1043 changed files with 163875 additions and 68430 deletions

View File

@@ -0,0 +1,106 @@
//
// TranslationContributorsView.swift
// Yattee
//
// Displays Weblate translation contributors.
//
import NukeUI
import SwiftUI
struct TranslationContributorsView: View {
@State private var contributors: [TranslationContributor] = []
var body: some View {
content
.navigationTitle(String(localized: "settings.translators.title"))
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
.task {
contributors = TranslationContributorsLoader.load()
}
}
// MARK: - Content
@ViewBuilder
private var content: some View {
if contributors.isEmpty {
ContentUnavailableView {
Label(String(localized: "settings.translators.empty"), systemImage: "globe")
}
} else {
contributorsList
}
}
private var contributorsList: some View {
Form {
Section {
ForEach(contributors) { contributor in
contributorRow(contributor)
}
} footer: {
Text(String(localized: "settings.translators.section.footer"))
}
}
}
private func contributorRow(_ contributor: TranslationContributor) -> some View {
HStack(spacing: 12) {
// Avatar
LazyImage(url: contributor.gravatarURL) { state in
ZStack {
Circle()
.fill(.quaternary)
.overlay {
if state.image == nil {
Text(String(contributor.displayName.prefix(1).uppercased()))
.font(.subheadline)
.fontWeight(.medium)
.foregroundStyle(.secondary)
}
}
if let image = state.image {
image
.resizable()
.aspectRatio(contentMode: .fill)
}
}
}
.frame(width: 40, height: 40)
.clipShape(Circle())
// Name and languages
VStack(alignment: .leading, spacing: 2) {
Text(contributor.displayName)
.font(.body)
.fontWeight(.semibold)
Text(contributor.languageSummary())
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(2)
}
Spacer()
// Total contributions badge
Text("\(contributor.totalContributions)")
.font(.caption)
.fontWeight(.medium)
.foregroundStyle(.secondary)
.padding(.horizontal, 8)
.padding(.vertical, 4)
.background(.quaternary, in: Capsule())
}
}
}
#Preview {
NavigationStack {
TranslationContributorsView()
}
}