Advertisement
dartmeadow

nth switch case item for menu

Sep 7th, 2021
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 6.22 KB | None | 0 0
  1. struct ContentView: View {
  2.     @State var currentOption = 0
  3.  
  4.     let options: [Option] = [
  5.         .init(title: "DART Meadow", imageName: "sun.min"),
  6.         .init(title: "Research", imageName: "bonjour"),
  7.         .init(title: "Navigation", imageName: "moon"),
  8.         .init(title: "Shelf", imageName: "archivebox"),
  9.         .init(title: "Chest" ,imageName: "shippingbox"),
  10.         .init(title: "Crate" ,imageName: "archivebox.circle.fill"),
  11.         .init(title: "Manufactoring", imageName: "gear"),
  12.         .init(title: "Warehouse", imageName: "archivebox.fill"),
  13.         .init(title: "Journal", imageName: "note"),
  14.        
  15.         ]
  16.    
  17.     var body: some View {
  18.        
  19.         NavigationView{
  20.             ListView(options: options, currentSelection: $currentOption)
  21.            
  22.             switch currentOption {
  23.             case 1:
  24.                 OrbitNodeView()
  25.             case 2:
  26.                 leafpondView()
  27.             case 3:
  28.                 OrbitNodeView()
  29.             case 4:
  30.                 leafpondView()
  31.             case 5:
  32.                 OrbitNodeView()
  33.             case 6:
  34.                 leafpondView()
  35.             case 7:
  36.                 OrbitNodeView()
  37.             case 8:
  38.                 leafpondView()
  39.             default:
  40.                
  41.             MainView()
  42.             }
  43.            
  44.         }.background(Color.white)
  45.         /*
  46.         .background(
  47.            LinearGradient(gradient: Gradient(colors: [.blue, .black, .blue, .white, .white]), startPoint: .leading, endPoint: .trailing)
  48.           )
  49.      
  50.         .background(
  51.                 RadialGradient(gradient: Gradient(colors: [.blue, .black, .blue, .white, .white]), center: .bottomLeading, startRadius: 66, endRadius: 1080)
  52.             )
  53.          */
  54.         //.background(Color.black)//init(red: 0.01, green: 0.01, blue: 1, opacity: 0.1))
  55.       // .frame(minWidth: 600, minHeight: 400)
  56.     }
  57. }
  58.  
  59. struct MainView: View {
  60.    
  61.  
  62.        
  63.     /*
  64.     let cols: [GridItem] = [
  65.         .init(.flexible()),
  66.         .init(.flexible()),
  67.         .init(.flexible())
  68.     ]
  69.    
  70.     let videoImages = Array(1...6).map { "video\($0)" }
  71.     */
  72.     var body: some View{
  73.      
  74.         VStack(alignment: .leading) {
  75.             HStack(alignment: .bottom) {
  76.            
  77.                 Image("articrenmeadowopacity")
  78.                     .shadow(radius: 3)
  79.                     //.padding(.top, 100)
  80.                     //.padding(.leading, 100)
  81.             /*
  82.             Circle()
  83.                 .stroke(Color.blue, lineWidth: 2)
  84.                 .frame(width: 60, height: 60)
  85.                 .shadow(radius: 3)
  86.                 .padding(20)
  87.             Circle()
  88.                 .stroke(Color.blue, lineWidth: 2)
  89.                 .frame(width: 100, height: 100)
  90.                 .shadow(radius: 3)
  91.                 .padding(20)
  92.                
  93.             */
  94.            
  95.                
  96.            
  97.                
  98.             /*
  99.             LazyVGrid(columns: cols) {
  100.                 ForEach(videoImages, id: \.self) { imageName in
  101.                     Image(imageName)
  102.                         .resizable()
  103.                         .aspectRatio(contentMode: .fit)
  104.                 }
  105.             }
  106.             */
  107.             }
  108.         }
  109.     }
  110. }
  111.  
  112.  
  113. struct ListView: View {
  114.     let options: [Option]
  115.     @Binding var currentSelection: Int
  116.     var body: some View{
  117.         HStack(alignment: .top) {
  118.         }.padding(.top, 10)
  119.  
  120.         HStack(alignment: .top) {
  121.         VStack(alignment: .leading) {
  122.             Circle()
  123.                 .stroke(Color.init(red: 0.25, green: 0.45, blue: 0.98, opacity: 1), lineWidth: 2)
  124.                 .alignmentGuide(HorizontalAlignment.myAlignment)
  125.                                    { d in d[.leading] }
  126.                 .alignmentGuide(VerticalAlignment.myAlignment)
  127.                                    { d in d[.top] }
  128.                 .frame(width: 35, height: 35)
  129.         }
  130.                 HStack(alignment: .center) {
  131.    
  132.             Circle()
  133.                 .stroke(Color.yellow, lineWidth: 2)
  134.                 .alignmentGuide(HorizontalAlignment.myAlignment)
  135.                                    { d in d[.leading] }
  136.                 .alignmentGuide(VerticalAlignment.myAlignment)
  137.                                    { d in d[.top] }
  138.                 .frame(width: 25, height: 25)
  139.        
  140.         VStack(alignment: .leading) {
  141.             Circle()
  142.                 .stroke(Color.init(red: 0, green: 0, blue: 1, opacity: 1), lineWidth: 2)
  143.                 .alignmentGuide(HorizontalAlignment.myAlignment)
  144.                                    { d in d[.trailing] }
  145.                 .alignmentGuide(VerticalAlignment.myAlignment)
  146.                                    { d in d[.bottom] }
  147.                 .frame(width: 75, height: 75)
  148.         Image("DARTMeadowCSMwidthArtemis2by1")
  149.             .shadow(radius: 3)
  150.             .padding(.top, 10)
  151.         }
  152.                
  153.             }
  154.         }.aspectRatio(contentMode: .fit).padding(.top, 30)
  155.         .padding(.leading, 10)
  156.         .padding(.trailing, 10)
  157.         VStack {
  158.             let current = options[currentSelection]
  159.             ForEach(options, id: \.self) {option in
  160.                 HStack {
  161.                    
  162.                     Image(systemName: option.imageName)
  163.                         .resizable()
  164.                         .aspectRatio(contentMode: .fit)
  165.                         .frame(width: 20)
  166.                    
  167.                     Text(option.title)
  168.                         .foregroundColor(current == option ? Color.blue : Color.white)
  169.                     Spacer()
  170.                 }
  171.                 .padding(8)
  172.                 .onTapGesture {
  173.                    // self.currentSelection = 0
  174.                    
  175.                  if currentSelection == 1 {
  176.                         currentSelection = 0
  177.                    } else {
  178.                    currentSelection = 1
  179.                  
  180.                     }
  181.                     /*
  182.                     let numbers = [1, 2, 3, 4, 5, 6]
  183.                     var sum = 0
  184.  
  185.                     for i in numbers {
  186.                         sum += i
  187.                     }
  188.  
  189.                     print(sum)
  190.  */
  191.               }
  192.             }
  193.        
  194.         }
  195.     }
  196. }
  197.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement