NCCapabilitiesView.swift 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: 10, 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. .font(.system(size: 12))
  57. .padding(EdgeInsets(top: 7, leading: 12, bottom: 7, trailing: 12))
  58. .foregroundColor(.primary)
  59. .background(
  60. RoundedRectangle(cornerRadius: 20)
  61. .stroke(Color(UIColor.systemGray), lineWidth: 0.5)
  62. .background(
  63. RoundedRectangle(cornerRadius: 20)
  64. .fill(Color(UIColor.secondarySystemBackground))
  65. )
  66. )
  67. .frame(maxWidth: .infinity, alignment: .trailing)
  68. }
  69. }
  70. struct NCCapabilitiesView_Previews: PreviewProvider {
  71. static var previews: some View {
  72. NCCapabilitiesView()
  73. }
  74. }