2022-06-05 17:44:23 +00:00
|
|
|
//
|
|
|
|
|
// File.swift
|
2022-06-05 18:53:11 +00:00
|
|
|
//
|
2022-06-05 17:44:23 +00:00
|
|
|
//
|
|
|
|
|
// Created by Jackson Harper on 6/5/22.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
2022-06-05 18:53:11 +00:00
|
|
|
import Models
|
|
|
|
|
import SwiftUI
|
|
|
|
|
import Utils
|
|
|
|
|
|
|
|
|
|
public struct SyncStatusIcon: View {
|
|
|
|
|
let status: ServerSyncStatus
|
|
|
|
|
|
2023-10-27 01:56:41 +00:00
|
|
|
public init(status: ServerSyncStatus) {
|
2022-06-05 18:53:11 +00:00
|
|
|
self.status = status
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private var cloudIconName: String {
|
|
|
|
|
switch status {
|
|
|
|
|
case .isNSync:
|
|
|
|
|
return "exclamationmark.icloud"
|
2023-12-28 07:46:57 +00:00
|
|
|
case .isSyncing, .needsCreation, .needsDeletion, .needsUpdate:
|
2022-06-05 18:53:11 +00:00
|
|
|
return "icloud"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private var cloudIconColor: Color {
|
|
|
|
|
switch status {
|
|
|
|
|
case .isNSync:
|
|
|
|
|
return .red
|
2023-12-28 07:46:57 +00:00
|
|
|
case .isSyncing, .needsCreation, .needsDeletion, .needsUpdate:
|
2022-06-05 18:53:11 +00:00
|
|
|
return .appGrayText
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public var body: some View {
|
|
|
|
|
Image(systemName: cloudIconName)
|
|
|
|
|
.resizable()
|
|
|
|
|
.aspectRatio(contentMode: .fill)
|
|
|
|
|
.frame(width: 12, height: 12, alignment: .trailing)
|
|
|
|
|
.foregroundColor(cloudIconColor)
|
|
|
|
|
.padding(EdgeInsets(top: 0, leading: 0, bottom: 8, trailing: 8))
|
|
|
|
|
}
|
|
|
|
|
}
|