kiwix-apple/Views/BuildingBlocks/Attribute.swift
Balazs Perlaki-Horvath 442093126d Show server details
2025-07-07 00:13:01 +02:00

65 lines
1.8 KiB
Swift

// This file is part of Kiwix for iOS & macOS.
//
// Kiwix is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// any later version.
//
// Kiwix is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kiwix; If not, see https://www.gnu.org/licenses/.
import SwiftUI
struct Attribute: View {
let title: String
let detail: String?
var body: some View {
HStack {
Text(title)
Spacer()
Text(detail ?? LocalString.attribute_detail_unknown).foregroundColor(.secondary)
}
}
}
struct AttributeLink: View {
let title: String
let destination: URL
var body: some View {
HStack {
Text(title)
Spacer()
Link(destination.absoluteString, destination: destination)
.foregroundColor(.accentColor)
}
}
}
struct AttributeBool: View {
let title: String
let detail: Bool
var body: some View {
HStack {
Text(title)
Spacer()
#if os(macOS)
Text(detail ? LocalString.common_button_yes : LocalString.common_button_no).foregroundColor(.secondary)
#elseif os(iOS)
if detail {
Image(systemName: "checkmark.circle.fill").foregroundColor(.green)
} else {
Image(systemName: "multiply.circle.fill").foregroundColor(.orange)
}
#endif
}
}
}