Advertisement
dartmeadow

passing variables into another across files, File 1

Dec 15th, 2022 (edited)
1,032
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 5.56 KB | Science | 0 0
  1. import PlaygroundSupport
  2. import Foundation
  3. import SwiftUI
  4. import UniformTypeIdentifiers
  5.  
  6.  
  7.  
  8. struct Edge: View {
  9.     @State var glove = Double()
  10.     @State var edgenum = Double()
  11.     @State var vrglove = Double()
  12.     @State var vredgenum = Double()
  13.     @State var vr1glove = Double()
  14.     @State var vr1edgenum = Double()
  15.    
  16.     let formatter: NumberFormatter = {
  17.         let formatter = NumberFormatter()
  18.         formatter.numberStyle = .scientific
  19.         formatter.positiveFormat = "0.###E+0"
  20.         formatter.exponentSymbol = "e"
  21.         return formatter
  22.     }()
  23.    
  24.     func glove(gloveresult: Double) -> Double {  sqrt(2+pow(edgenum, cbrt(4))) }
  25.     func vrglove(vrgloveresult: Double) -> Double {  sqrt(2+pow(vredgenum, cbrt(4))) }
  26.     func vr1glove(vr1gloveresult: Double) -> Double {  sqrt(2+pow(vr1edgenum, cbrt(4))) }
  27.     var body: some View {
  28.         HStack(alignment: .center) {
  29.            
  30.             VStack(alignment: .leading) {
  31.                 Text("Edge Variance 1")
  32.                     .italic()
  33.                 Divider()
  34.                 Text("DART Edge Measure (Limit | 100):")
  35.                     .font(.callout)
  36.                     .bold()
  37.                 // .colorInvert()
  38.                 TextField("#", value: self.$edgenum, formatter: formatter)
  39.                 //.colorInvert()
  40.                
  41.                     .textFieldStyle(RoundedBorderTextFieldStyle())
  42.                     .overlay(
  43.                         RoundedRectangle(cornerRadius: 6)
  44.                             .stroke(Color.blue, lineWidth: 2)
  45.                     )
  46.                
  47.                 Text("DART Edge: \(glove(gloveresult: edgenum))")
  48.                     .font(.callout)
  49.                     .bold()
  50.                     .frame(width: 150, height: 60, alignment: .leading)
  51.                 //.colorInvert()
  52.             }.padding()
  53.             VStack(alignment: .leading) {
  54.                 Text("Edge Variance 2")
  55.                     .italic()
  56.                 Divider()
  57.                 Text("DART Edge Measure (Limit | 100):")
  58.                     .font(.callout)
  59.                     .bold()
  60.                 // .colorInvert()
  61.                 TextField("#", value: self.$vredgenum, formatter: formatter)
  62.                 //.colorInvert()
  63.                
  64.                     .textFieldStyle(RoundedBorderTextFieldStyle())
  65.                     .overlay(
  66.                         RoundedRectangle(cornerRadius: 6)
  67.                             .stroke(Color.blue, lineWidth: 2)
  68.                     )
  69.                
  70.                 Text("DART Edge: \(vrglove(vrgloveresult: vredgenum))")
  71.                     .font(.callout)
  72.                     .bold()
  73.                     .frame(width: 150, height: 60, alignment: .leading)
  74.                 //.colorInvert()
  75.             }.padding()
  76.             VStack(alignment: .leading) {
  77.                 Text("Edge Variance 3")
  78.                     .italic()
  79.                 Divider()
  80.                 Text("DART Edge Measure (Limit | 100):")
  81.                     .font(.callout)
  82.                     .bold()
  83.                 // .colorInvert()
  84.                 TextField("#", value: self.$vr1edgenum, formatter: formatter)
  85.                 //.colorInvert()
  86.                
  87.                     .textFieldStyle(RoundedBorderTextFieldStyle())
  88.                     .overlay(
  89.                         RoundedRectangle(cornerRadius: 6)
  90.                             .stroke(Color.blue, lineWidth: 2)
  91.                     )
  92.                
  93.                 Text("DART Edge: \(vr1glove(vr1gloveresult: vr1edgenum))")
  94.                     .font(.callout)
  95.                     .bold()
  96.                     .frame(width: 150, height: 60, alignment: .leading)
  97.                 //.colorInvert()
  98.             }.padding()
  99.             Divider()
  100.             HStack(alignment: .top) {
  101.                 VStack(alignment: .leading) {
  102.                    
  103.                     HStack(alignment: .center) {
  104.                         Image(systemName: "minus")
  105.                         Slider(value: $edgenum, in: 0...100, step: 1)
  106.                             .accentColor(Color.blue)
  107.                         Image(systemName: "plus")
  108.                        
  109.                     }.foregroundColor(Color.blue).padding(10)
  110.                         .overlay(
  111.                             RoundedRectangle(cornerRadius: 6)
  112.                                 .stroke(Color.blue, lineWidth: 2)
  113.                         ).shadow(radius: 3)
  114.                    
  115.                     Text("Edge Scale Plus:")
  116.                         .font(.callout)
  117.                         .bold()
  118.                     //  .colorInvert()
  119.                     TextField("#", value: self.$edgenum, formatter: formatter)
  120.                     //  .colorInvert()
  121.                    
  122.                         .textFieldStyle(RoundedBorderTextFieldStyle())
  123.                         .overlay(
  124.                             RoundedRectangle(cornerRadius: 6)
  125.                                 .stroke(Color.blue, lineWidth: 2)
  126.                         )
  127.                    
  128.                     Text("Edge Scale : \(glove(gloveresult: edgenum))")
  129.                         .font(.callout)
  130.                         .bold()
  131.                         .frame(width: 150, height: 60, alignment: .leading)
  132.                     //    .colorInvert()
  133.                     Divider()
  134.                     Text("Edge Variance 1 Only")
  135.                         .italic()
  136.                    
  137.                 }.padding()
  138.                 Divider()
  139.                
  140.                
  141.             }
  142.         }.background(Color.indigo)
  143.     }
  144. }
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement