Advertisement
Guest User

Untitled

a guest
Dec 10th, 2023
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. import SwiftUI
  2.  
  3. struct ContentView: View {
  4. @State private var rotation: Double = 0.0
  5. @State private var toggle1: Bool = false
  6. @State private var toggle2: Bool = false
  7.  
  8. var body: some View {
  9. TabView {
  10. NavigationView {
  11. VStack {
  12. Spacer()
  13. Image3D(image: "image", rotation: rotation)
  14. .frame(width: 200, height: 200)
  15. .onAppear() {
  16. withAnimation(Animation.linear(duration: 10).repeatForever(autoreverses: false)) {
  17. rotation = 360.0
  18. }
  19. }
  20. Spacer()
  21. }
  22. .navigationBarTitle("", displayMode: .inline)
  23. }
  24. .tabItem {
  25. Image(systemName: "house")
  26. }
  27.  
  28. NavigationView {
  29. VStack {
  30. Spacer()
  31. Text("Cennik Studyjny")
  32. .font(.title)
  33. .padding()
  34.  
  35. NeonPricingView(title: "Mix/Master", price: "XXXPLN")
  36. NeonPricingView(title: "Godzina nagrywek", price: "XXXPLN")
  37. NeonPricingView(title: "Realizacja", price: "XXXPLN")
  38.  
  39. Spacer()
  40. }
  41. .navigationBarTitle("", displayMode: .inline)
  42. }
  43. .tabItem {
  44. Image(systemName: "dollarsign.circle")
  45. }
  46.  
  47. NavigationView {
  48. Text("Treść strony trzeciej")
  49. .font(.title)
  50. .navigationBarTitle("", displayMode: .inline)
  51. }
  52. .tabItem {
  53. Image(systemName: "ellipsis")
  54. }
  55.  
  56. NavigationView {
  57. VStack {
  58. Text("Ustawienia")
  59. .font(.title)
  60. .padding()
  61.  
  62. SettingsOptionView(option: "Opcja 1", isOn: $toggle1)
  63. SettingsOptionView(option: "Opcja 2", isOn: $toggle2)
  64.  
  65. Spacer()
  66. }
  67. .navigationBarTitle("", displayMode: .inline)
  68. }
  69. .tabItem {
  70. Image(systemName: "gear")
  71. }
  72. }
  73. }
  74. }
  75.  
  76. struct ContentView_Previews: PreviewProvider {
  77. static var previews: some View {
  78. ContentView()
  79. }
  80. }
  81.  
  82. struct Image3D: UIViewRepresentable {
  83. var image: String
  84. var rotation: Double
  85.  
  86. func makeUIView(context: Context) -> UIView {
  87. let imageView = UIImageView(image: UIImage(named: image))
  88. return imageView
  89. }
  90.  
  91. func updateUIView(_ uiView: UIView, context: Context) {
  92. let angle = CGFloat(rotation * .pi / 180)
  93. uiView.layer.transform = CATransform3DMakeRotation(angle, 0, 1, 0)
  94. }
  95. }
  96.  
  97. struct NeonPricingView: View {
  98. var title: String
  99. var price: String
  100.  
  101. @State private var neonOn = false
  102.  
  103. var body: some View {
  104. HStack {
  105. Spacer()
  106. VStack {
  107. Text(title)
  108. .font(.headline)
  109. .foregroundColor(neonOn ? .blue : .white)
  110. .shadow(color: neonOn ? .blue : .clear, radius: 8)
  111. .animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true))
  112. Text(price)
  113. .font(.subheadline)
  114. }
  115. Spacer()
  116. }
  117. .onAppear {
  118. neonOn.toggle()
  119. }
  120. }
  121. }
  122.  
  123. struct SettingsOptionView: View {
  124. var option: String
  125. @Binding var isOn: Bool
  126.  
  127. var body: some View {
  128. HStack {
  129. Text(option)
  130. .font(.headline)
  131. .padding()
  132. Spacer()
  133. Toggle("", isOn: $isOn)
  134. .padding(.horizontal)
  135. }
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement