瀏覽代碼

Improved code

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 年之前
父節點
當前提交
f9ba059b97
共有 1 個文件被更改,包括 13 次插入5 次删除
  1. 13 5
      iOSClient/Main/Create cloud/NCUploadScanDocument.swift

+ 13 - 5
iOSClient/Main/Create cloud/NCUploadScanDocument.swift

@@ -475,11 +475,7 @@ struct UploadScanDocumentView: View {
                                 }
                             }
                         }
-                        .padding(.horizontal, 40)
-                        .padding(.vertical, 10)
-                        .background(fileName.isEmpty ? Color(UIColor.systemGray4) : Color(NCBrandColor.shared.brand))
-                        .foregroundColor(.white)
-                        .clipShape(Capsule())
+                        .buttonStyle(ButtonUploadScanDocumenStyle(disabled: fileName.isEmpty))
                     }
                     // .listRowBackground(Color(UIColor.systemGroupedBackground))
                 }
@@ -504,6 +500,18 @@ struct UploadScanDocumentView: View {
     }
 }
 
+struct ButtonUploadScanDocumenStyle: ButtonStyle {
+    var disabled = false
+    func makeBody(configuration: Configuration) -> some View {
+        configuration.label
+            .padding(.horizontal, 40)
+            .padding(.vertical, 10)
+            .background(disabled ? Color(UIColor.systemGray4) : Color(NCBrandColor.shared.brand))
+            .foregroundColor(.white)
+            .clipShape(Capsule())
+    }
+}
+
 // MARK: - UIViewControllerRepresentable
 
 struct NCSelectRepresentedView: UIViewControllerRepresentable {