LoadingButtonView.swift 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // LoopFollow
  2. // LoadingButtonView.swift
  3. import SwiftUI
  4. struct LoadingButtonView: View {
  5. var buttonText: String
  6. var progressText: String
  7. var isLoading: Bool
  8. var action: () -> Void
  9. var isDisabled: Bool = false
  10. var body: some View {
  11. Section {
  12. VStack {
  13. if isLoading {
  14. HStack {
  15. ProgressView()
  16. .padding(.trailing, 10)
  17. Text(progressText)
  18. }
  19. .padding()
  20. } else {
  21. Button(action: {
  22. action()
  23. }) {
  24. Text(buttonText)
  25. .frame(maxWidth: .infinity)
  26. }
  27. .buttonStyle(.borderedProminent)
  28. .controlSize(.large)
  29. .disabled(isDisabled)
  30. }
  31. }
  32. .frame(maxWidth: .infinity, alignment: .center)
  33. .listRowInsets(EdgeInsets())
  34. }
  35. }
  36. }