|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
import SwiftUI
|
|
|
import NextcloudKit
|
|
|
+import PreviewSnapshots
|
|
|
|
|
|
@objc class NCHostingCapabilitiesView: NSObject {
|
|
|
|
|
@@ -35,70 +36,62 @@ class NCCapabilitiesViewOO: ObservableObject {
|
|
|
@Published var homeServer = ""
|
|
|
|
|
|
init() {
|
|
|
+ guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
|
|
|
+ var textEditor = false
|
|
|
+ var onlyofficeEditors = false
|
|
|
|
|
|
- if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
|
|
|
- capabililies = [Capability(text: "Collabora", image: UIImage(named: "collabora")!, resize: true, available: true),
|
|
|
- Capability(text: "XXX site", image: UIImage(systemName: "lock.shield")!, resize: false, available: false)
|
|
|
- ]
|
|
|
- homeServer = "https://cloud.nextcloud.com/remote.php.dav/files/marino/"
|
|
|
- } else {
|
|
|
- guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
|
|
|
- var textEditor = false
|
|
|
- var onlyofficeEditors = false
|
|
|
-
|
|
|
- if let image = UIImage(named: "share") {
|
|
|
- capabililies.append(Capability(text: "File sharing", image: image, resize: true, available: NCGlobal.shared.capabilityFileSharingApiEnabled))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "network") {
|
|
|
- capabililies.append(Capability(text: "External site", image: image, resize: false, available: NCGlobal.shared.capabilityExternalSites))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "lock") {
|
|
|
- capabililies.append(Capability(text: "End-to-End Encryption", image: image, resize: false, available: NCGlobal.shared.capabilityE2EEEnabled))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "bolt") {
|
|
|
- capabililies.append(Capability(text: "Activity", image: image, resize: false, available: !NCGlobal.shared.capabilityActivity.isEmpty))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "bell") {
|
|
|
- capabililies.append(Capability(text: "Notification", image: image, resize: false, available: !NCGlobal.shared.capabilityNotification.isEmpty))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "trash") {
|
|
|
- capabililies.append(Capability(text: "Deleted files", image: image, resize: false, available: NCGlobal.shared.capabilityFilesUndelete))
|
|
|
- }
|
|
|
+ if let image = UIImage(named: "share") {
|
|
|
+ capabililies.append(Capability(text: "File sharing", image: image, resize: true, available: NCGlobal.shared.capabilityFileSharingApiEnabled))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "network") {
|
|
|
+ capabililies.append(Capability(text: "External site", image: image, resize: false, available: NCGlobal.shared.capabilityExternalSites))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "lock") {
|
|
|
+ capabililies.append(Capability(text: "End-to-End Encryption", image: image, resize: false, available: NCGlobal.shared.capabilityE2EEEnabled))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "bolt") {
|
|
|
+ capabililies.append(Capability(text: "Activity", image: image, resize: false, available: !NCGlobal.shared.capabilityActivity.isEmpty))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "bell") {
|
|
|
+ capabililies.append(Capability(text: "Notification", image: image, resize: false, available: !NCGlobal.shared.capabilityNotification.isEmpty))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "trash") {
|
|
|
+ capabililies.append(Capability(text: "Deleted files", image: image, resize: false, available: NCGlobal.shared.capabilityFilesUndelete))
|
|
|
+ }
|
|
|
|
|
|
- if let editors = NCManageDatabase.shared.getDirectEditingEditors(account: activeAccount.account) {
|
|
|
- for editor in editors {
|
|
|
- if editor.editor == NCGlobal.shared.editorText {
|
|
|
- textEditor = true
|
|
|
- } else if editor.editor == NCGlobal.shared.editorOnlyoffice {
|
|
|
- onlyofficeEditors = true
|
|
|
- }
|
|
|
+ if let editors = NCManageDatabase.shared.getDirectEditingEditors(account: activeAccount.account) {
|
|
|
+ for editor in editors {
|
|
|
+ if editor.editor == NCGlobal.shared.editorText {
|
|
|
+ textEditor = true
|
|
|
+ } else if editor.editor == NCGlobal.shared.editorOnlyoffice {
|
|
|
+ onlyofficeEditors = true
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if let image = UIImage(systemName: "doc.text") {
|
|
|
- capabililies.append(Capability(text: "Text", image: image, resize: false, available: textEditor))
|
|
|
- }
|
|
|
- if let image = UIImage(named: "onlyoffice") {
|
|
|
- capabililies.append(Capability(text: "ONLYOFFICE", image: image, resize: true, available: onlyofficeEditors))
|
|
|
- }
|
|
|
- if let image = UIImage(named: "collabora") {
|
|
|
- capabililies.append(Capability(text: "Collabora", image: image, resize: true, available: !NCGlobal.shared.capabilityRichdocumentsMimetypes.isEmpty))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "moon") {
|
|
|
- capabililies.append(Capability(text: "User Status", image: image, resize: false, available: NCGlobal.shared.capabilityUserStatusEnabled))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "ellipsis.bubble") {
|
|
|
- capabililies.append(Capability(text: "Comments", image: image, resize: false, available: NCGlobal.shared.capabilityFilesComments))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "lock") {
|
|
|
- capabililies.append(Capability(text: "Lock file", image: image, resize: false, available: !NCGlobal.shared.capabilityFilesLockVersion.isEmpty))
|
|
|
- }
|
|
|
- if let image = UIImage(systemName: "person.2") {
|
|
|
- capabililies.append(Capability(text: "Group folders", image: image, resize: false, available: NCGlobal.shared.capabilityGroupfoldersEnabled))
|
|
|
- }
|
|
|
-
|
|
|
- homeServer = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId) + "/"
|
|
|
+ if let image = UIImage(systemName: "doc.text") {
|
|
|
+ capabililies.append(Capability(text: "Text", image: image, resize: false, available: textEditor))
|
|
|
+ }
|
|
|
+ if let image = UIImage(named: "onlyoffice") {
|
|
|
+ capabililies.append(Capability(text: "ONLYOFFICE", image: image, resize: true, available: onlyofficeEditors))
|
|
|
+ }
|
|
|
+ if let image = UIImage(named: "collabora") {
|
|
|
+ capabililies.append(Capability(text: "Collabora", image: image, resize: true, available: !NCGlobal.shared.capabilityRichdocumentsMimetypes.isEmpty))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "moon") {
|
|
|
+ capabililies.append(Capability(text: "User Status", image: image, resize: false, available: NCGlobal.shared.capabilityUserStatusEnabled))
|
|
|
}
|
|
|
+ if let image = UIImage(systemName: "ellipsis.bubble") {
|
|
|
+ capabililies.append(Capability(text: "Comments", image: image, resize: false, available: NCGlobal.shared.capabilityFilesComments))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "lock") {
|
|
|
+ capabililies.append(Capability(text: "Lock file", image: image, resize: false, available: !NCGlobal.shared.capabilityFilesLockVersion.isEmpty))
|
|
|
+ }
|
|
|
+ if let image = UIImage(systemName: "person.2") {
|
|
|
+ capabililies.append(Capability(text: "Group folders", image: image, resize: false, available: NCGlobal.shared.capabilityGroupfoldersEnabled))
|
|
|
+ }
|
|
|
+
|
|
|
+ homeServer = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId) + "/"
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -175,6 +168,26 @@ struct NCCapabilitiesView: View {
|
|
|
|
|
|
struct NCCapabilitiesView_Previews: PreviewProvider {
|
|
|
static var previews: some View {
|
|
|
- NCCapabilitiesView(capabilitiesStatus: NCCapabilitiesViewOO())
|
|
|
+ snapshots.previews.previewLayout(.device)
|
|
|
}
|
|
|
+
|
|
|
+ static var snapshots: PreviewSnapshots<String> {
|
|
|
+ PreviewSnapshots(
|
|
|
+ configurations: [
|
|
|
+ .init(name: NCGlobal.shared.defaultSnapshotConfiguration, state: "")
|
|
|
+ ],
|
|
|
+ configure: { _ in
|
|
|
+ NCCapabilitiesView(capabilitiesStatus: getCapabilitiesViewOOForPreview()).padding(.top, 20).frameForPreview()
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func getCapabilitiesViewOOForPreview() -> NCCapabilitiesViewOO {
|
|
|
+ let capabilitiesViewOO = NCCapabilitiesViewOO()
|
|
|
+ capabilitiesViewOO.capabililies = [
|
|
|
+ NCCapabilitiesViewOO.Capability(text: "Collabora", image: UIImage(named: "collabora")!, resize: true, available: true),
|
|
|
+ NCCapabilitiesViewOO.Capability(text: "XXX site", image: UIImage(systemName: "lock.shield")!, resize: false, available: false)
|
|
|
+ ]
|
|
|
+ capabilitiesViewOO.homeServer = "https://cloud.nextcloud.com/remote.php.dav/files/marino/"
|
|
|
+ return capabilitiesViewOO
|
|
|
}
|