SwiftUIHUDView.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // SwiftUIHUDView.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 02/01/23.
  6. // Copyright © 2023 Marino Faggiana. All rights reserved.
  7. //
  8. import SwiftUI
  9. struct SwiftUIHUDView: View {
  10. var body: some View {
  11. Text("Saved image")
  12. .foregroundColor(.gray)
  13. .padding(.horizontal, 10)
  14. .padding(14)
  15. .background(
  16. Blur(style: .systemMaterial)
  17. .clipShape(Capsule())
  18. .shadow(color: Color(.black).opacity(0.22), radius: 12, x: 0, y: 5)
  19. )
  20. }
  21. }
  22. struct Blur: UIViewRepresentable {
  23. var style: UIBlurEffect.Style
  24. func makeUIView(context: Context) -> UIVisualEffectView {
  25. return UIVisualEffectView(effect: UIBlurEffect(style: style))
  26. }
  27. func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
  28. uiView.effect = UIBlurEffect(style: style)
  29. }
  30. }
  31. struct ContentView: View {
  32. @State private var showHUD = false
  33. @ViewBuilder var body: some View {
  34. ZStack {
  35. NavigationView {
  36. Button("Save image") {
  37. self.showHUD.toggle()
  38. }
  39. .navigationTitle("Content View")
  40. }
  41. SwiftUIHUDView()
  42. .offset(y: showHUD ? 0 : -100)
  43. .animation(.easeOut)
  44. }
  45. }
  46. }
  47. struct SwiftUIHUDView_Previews: PreviewProvider {
  48. static var previews: some View {
  49. ContentView()
  50. }
  51. }