Advertisement
dartmeadow

Variable passing, the modifier file, File2

Dec 15th, 2022 (edited)
1,581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 7.73 KB | Science | 0 0
  1. /*
  2. I want this file(file2) to revvieve edge input results of file1, modify them as desired then send them along to file 3 (charts) for realtime feedback. how do I pass variables into other variables as well across files while keeping the information live and modifiable?
  3. */
  4. import PlaygroundSupport
  5. import Foundation
  6. import SwiftUI
  7.  
  8.  
  9. import UniformTypeIdentifiers
  10.  
  11. struct sliderHalf: View {
  12.     @State private var showingPopover = false
  13.     @State private var edge = 50.0
  14.     @State private var math = 50.0
  15.     @State private var physics = 50.0
  16.     @State private var isEditing = false
  17.     var body: some View {
  18.        
  19.             VStack(alignment: .leading) {
  20.                 Divider()
  21.                
  22.                 VStack(alignment: .leading) {
  23.                     Button {
  24.                         showingPopover = true
  25.                     } label: {
  26.                         ZStack(alignment: .leading){
  27.                             RoundedRectangle(cornerRadius: 4.0)
  28.                                 .aspectRatio(4.5, contentMode: ContentMode.fit)
  29.                                 .shadow(radius: 3)
  30.                                 .foregroundColor(.blue)
  31.                             HStack(alignment: .center){
  32.                                 Image("Hornet").resizable()
  33.                                     .aspectRatio(contentMode: .fit).padding(.leading, 2).padding(.trailing, 2)
  34.                                     .frame(
  35.                                         maxWidth: 50,
  36.                                         maxHeight: 50, alignment: .leading).shadow(radius: 3)
  37.                                 Text("Lab Math")
  38.                             }.foregroundColor(.white)    
  39.                            
  40.                             //  Label("Overlay HUD", systemimage: "cloud")
  41.                             //        .foregroundColor(.white)
  42.                                 .padding(.leading, 2)
  43.                            
  44.                            
  45.                            
  46.                            
  47.                         }
  48.                         .buttonStyle(.plain)
  49.                         .popover(isPresented: $showingPopover) {
  50.                             VStack(alignment: .leading){
  51.                                 Text("Crystalline")
  52.                                     .font(.subheadline)
  53.                                
  54.                                 Text("Proportional")
  55.                                     .font(.subheadline)
  56.                                
  57.                                 Text("Congruent")
  58.                                     .font(.subheadline)
  59.                                
  60.                                 Divider()
  61.                                 Text("Edge")
  62.                                     .font(.subheadline)
  63.                                
  64.                                 VStack(alignment: .center){
  65.                                     Slider(
  66.                                         value: $edge,
  67.                                         in: 0...100,
  68.                                         onEditingChanged: { editing in
  69.                                             isEditing = editing
  70.                                         }
  71.                                     )
  72.                                     Text("\(edge)")
  73.                                         .foregroundColor(isEditing ? .yellow : .white)
  74.                                 }
  75.                                
  76.                                
  77.                                 Text("Math")
  78.                                     .font(.subheadline)
  79.                                
  80.                                 VStack(alignment: .center){
  81.                                     Slider(
  82.                                         value: $math,
  83.                                         in: 0...100,
  84.                                         onEditingChanged: { editing in
  85.                                             isEditing = editing
  86.                                         }
  87.                                     )
  88.                                     Text("\(math)")
  89.                                         .foregroundColor(isEditing ? .yellow : .white)
  90.                                 }
  91.                                 Text("Physics")
  92.                                     .font(.subheadline)
  93.                                
  94.                                 VStack(alignment: .center){
  95.                                     Slider(
  96.                                         value: $physics,
  97.                                         in: 0...100,
  98.                                         onEditingChanged: { editing in
  99.                                             isEditing = editing
  100.                                         }
  101.                                     )
  102.                                     Text("\(physics)")
  103.                                         .foregroundColor(isEditing ? .yellow : .white)
  104.                                 }
  105.                             } .frame(width: 300, height: 400) .shadow(radius: 3)
  106.                                 .padding(5)
  107.                                 .background(Color.blue.opacity(1.0))
  108.                             //  .padding()
  109.                         } .foregroundColor(.white)
  110.                     } .frame(
  111.                         maxWidth: 200,
  112.                         maxHeight: .infinity, alignment: .topLeading).padding(8)
  113.                 }
  114.                 HStack(alignment: .top){
  115.                     VStack(alignment: .leading){
  116.                         Text("Legend")
  117.                             .italic()
  118.                        
  119.                         Divider().frame(width:100)
  120.                             VStack(alignment: .leading){
  121.                                 Text("File 1")
  122.                                     .font(.subheadline)
  123.                                 VStack(alignment: .leading){
  124.                                 RoundedRectangle(cornerRadius: 2.0)
  125.                                     .aspectRatio(1, contentMode: ContentMode.fill)
  126.                                     .shadow(radius: 3)
  127.                                     .shadow(radius: 3)
  128.                                     .foregroundColor(.indigo)
  129.                             }.frame(maxWidth: 10, maxHeight: 10, alignment: .topLeading)
  130.                         }
  131.                         Text("File 2")
  132.                             .font(.subheadline)
  133.                         VStack(alignment: .leading){
  134.                             VStack(alignment: .leading){
  135.                                 RoundedRectangle(cornerRadius: 2.0)
  136.                                     .aspectRatio(1, contentMode: ContentMode.fill)
  137.                                     .shadow(radius: 3)
  138.                                 .shadow(radius: 3)
  139.                                     .foregroundColor(.brown)
  140.                             }.frame(maxWidth: 10, maxHeight: 10, alignment: .topLeading)
  141.                         }
  142.                         Text("File 3")
  143.                             .font(.subheadline)
  144.                         VStack(alignment: .leading){
  145.                             VStack(alignment: .leading){
  146.                                 RoundedRectangle(cornerRadius: 2.0)
  147.                                     .aspectRatio(1, contentMode: ContentMode.fill)
  148.                                     .shadow(radius: 3)
  149.                                 .shadow(radius: 3)
  150.                                     .foregroundColor(.black)
  151.                             }.frame(maxWidth: 10, maxHeight: 10, alignment: .topLeading)
  152.                         }
  153.                     }
  154.                 }.padding()
  155.             }.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading).background(Color.brown)
  156.     }
  157. }
  158.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement