NCCapabilitiesView.swift 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // NCCapabilitiesView.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 19/05/23.
  6. // Copyright © 2023 Marino Faggiana. All rights reserved.
  7. //
  8. import SwiftUI
  9. struct NCCapabilitiesView: View {
  10. var body: some View {
  11. ScrollView {
  12. VStack {
  13. HStack {
  14. Capability(text: "File sharing", image: Image("share"))
  15. CapabilityAvailable(available: true)
  16. }
  17. HStack {
  18. Capability(text: "Externa site", image: Image(systemName: "network"))
  19. CapabilityAvailable(available: false)
  20. }
  21. }
  22. .frame(maxWidth: .infinity, alignment: .top)
  23. .padding(EdgeInsets(top: 20, leading: 10, bottom: 0, trailing: 10))
  24. }
  25. }
  26. }
  27. struct Capability: View {
  28. @State var text: String = ""
  29. @State var image: Image
  30. var body: some View {
  31. Label {
  32. Text(text)
  33. .font(.system(size: 15))
  34. .foregroundColor(Color(UIColor.systemGray))
  35. } icon: {
  36. image
  37. .renderingMode(.template)
  38. .resizable()
  39. .frame(width: 25.0, height: 25.0)
  40. .foregroundColor(Color(UIColor.systemGray))
  41. }
  42. .frame(maxWidth: .infinity, alignment: .leading)
  43. }
  44. }
  45. struct CapabilityAvailable: View {
  46. @State private var text: String
  47. init(available: Bool) {
  48. if available {
  49. _text = State(initialValue: NSLocalizedString("_available_", comment: ""))
  50. } else {
  51. _text = State(initialValue: NSLocalizedString("_not_available_", comment: ""))
  52. }
  53. }
  54. var body: some View {
  55. Text(text)
  56. .frame(width: 100)
  57. .font(.system(size: 12))
  58. .padding(EdgeInsets(top: 7, leading: 12, bottom: 7, trailing: 12))
  59. .foregroundColor(.primary)
  60. .background(
  61. RoundedRectangle(cornerRadius: 20)
  62. .stroke(Color(UIColor.systemGray), lineWidth: 0.5)
  63. .background(
  64. RoundedRectangle(cornerRadius: 20)
  65. .fill(Color(UIColor.secondarySystemBackground))
  66. )
  67. )
  68. .frame(maxWidth: .infinity, alignment: .trailing)
  69. }
  70. }
  71. struct NCCapabilitiesView_Previews: PreviewProvider {
  72. static var previews: some View {
  73. NCCapabilitiesView()
  74. }
  75. }