Demonstration.swift 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * SwiftUIVisualEffects
  3. * Copyright © 2020 Lucas Brown
  4. */
  5. import SwiftUI
  6. public struct SwiftUIVisualEffects_Demonstration: View {
  7. public init() {}
  8. public var body: some View {
  9. ZStack {
  10. linearGradient
  11. .blurEffect()
  12. VStack(spacing: 8) {
  13. image
  14. .vibrancyEffect()
  15. largeTitleText
  16. .vibrancyEffect()
  17. .vibrancyEffectStyle(.label)
  18. titleText
  19. .vibrancyEffect()
  20. .vibrancyEffectStyle(.secondaryLabel)
  21. }
  22. }
  23. .blurEffectStyle(.systemUltraThinMaterial)
  24. .edgesIgnoringSafeArea(.all)
  25. }
  26. }
  27. private extension SwiftUIVisualEffects_Demonstration {
  28. var linearGradient: LinearGradient {
  29. LinearGradient(gradient: Gradient(colors: [.blue, .red]), startPoint: .topLeading, endPoint: .bottomTrailing)
  30. }
  31. var image: some View {
  32. Image(systemName: "hexagon.fill")
  33. .resizable()
  34. .scaledToFit()
  35. .frame(width: 150, height: 150)
  36. }
  37. var largeTitleText: Text {
  38. Text("Hello, world.")
  39. .font(.largeTitle)
  40. }
  41. var titleText: Text {
  42. Text("The world says, \"Hey.\"")
  43. .font(.title)
  44. }
  45. }