2021-09-28 20:33:12 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
2021-10-23 11:51:02 +00:00
|
|
|
struct AccountValidationStatus: View {
|
2022-07-01 21:28:32 +00:00
|
|
|
@Binding var app: VideosApp?
|
2021-09-28 20:33:12 +00:00
|
|
|
@Binding var isValid: Bool
|
|
|
|
@Binding var isValidated: Bool
|
|
|
|
@Binding var isValidating: Bool
|
|
|
|
@Binding var error: String?
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
HStack(spacing: 4) {
|
|
|
|
Image(systemName: validationStatusSystemImage)
|
|
|
|
.foregroundColor(validationStatusColor)
|
|
|
|
|
|
|
|
.frame(minWidth: 35, minHeight: 35)
|
|
|
|
.opacity(isValidating ? 1 : (isValidated ? 1 : 0))
|
|
|
|
|
|
|
|
VStack(alignment: .leading) {
|
2022-07-01 21:28:32 +00:00
|
|
|
Text(isValid ? "Connected successfully (\(app?.name ?? "Unknown"))" : "Connection failed")
|
2022-09-28 14:27:01 +00:00
|
|
|
if let error, !isValid {
|
2021-11-14 23:06:01 +00:00
|
|
|
Text(error)
|
2021-09-28 20:33:12 +00:00
|
|
|
.font(.caption2)
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.truncationMode(.tail)
|
|
|
|
.lineLimit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.frame(minHeight: 35)
|
|
|
|
.opacity(isValidating ? 0 : (isValidated ? 1 : 0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var validationStatusSystemImage: String {
|
|
|
|
if isValidating {
|
|
|
|
return "bolt.horizontal.fill"
|
|
|
|
} else {
|
|
|
|
return isValid ? "checkmark.circle.fill" : "xmark.circle.fill"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var validationStatusColor: Color {
|
|
|
|
if isValidating {
|
|
|
|
return .accentColor
|
|
|
|
} else {
|
|
|
|
return isValid ? .green : .red
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|