Advertisement
dartmeadow

Menu cycle from any given menu foward,backward?

Sep 16th, 2021
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 7.50 KB | None | 0 0
  1. import Foundation
  2. import SwiftUI
  3. import CoreData
  4. import Combine
  5. import PDFKit
  6. import SceneKit
  7. import WebKit
  8.  
  9.  
  10. struct Cotharticren: App {
  11.   var body: some Scene {
  12.         WindowGroup {
  13.             ContentView()
  14.         }
  15.   }
  16. }
  17.  
  18.      struct Option: Hashable {
  19.        
  20.          let title: String
  21.        
  22.          let imageName: String
  23.      }
  24.  
  25. struct ContentView: View {
  26.  
  27.     @State var currentOption = 0
  28.    
  29.     let options: [Option] = [
  30.         .init(title: "DART Meadow", imageName: "sun.max.fill"),
  31.         .init(title: "Research", imageName: "flame"),
  32.         .init(title: "Navigation", imageName: "moon.stars.fill"),
  33.         .init(title: "Shelf", imageName: "archivebox"),
  34.         .init(title: "Chest" ,imageName: "shippingbox"),
  35.         .init(title: "Crate" ,imageName: "bonjour"),
  36.         .init(title: "Manufactoring", imageName: "gear"),
  37.         .init(title: "Warehouse", imageName: "archivebox.fill"),
  38.         .init(title: "Journal", imageName: "note.text"),
  39.        
  40.     ]
  41.    
  42.     var body: some View {
  43.         VStack(alignment: .leading) {
  44.         HStack(alignment: .top) {
  45.         ScrollView( .vertical) {
  46.         NavigationView{
  47.             /*
  48.             List(1..<9)
  49.             {
  50.                      Text("\($0)")
  51.                 }
  52.             .listStyle(SidebarListStyle())
  53.             }
  54.  */
  55.             ListView(options: options, currentSelection: $currentOption)
  56.          
  57.             //Text(systemName: myItem.selectedImageName) + Text(myItem.whateverText)
  58.            
  59.             switch (currentOption) {
  60.             case 1:
  61.                 OrbitNodeView()
  62.             case 2:
  63.                 ATM26NodeView()
  64.             case 3:
  65.                 NozzleNodeView()
  66.             case 4:
  67.                 EmptyView()
  68.                 VStack(alignment: .center) {
  69.                 Text("Chest")
  70.                     .font(.largeTitle)
  71.                     .bold()
  72.                     .colorInvert()
  73.                 }
  74.             case 5:
  75.                 EmptyView()
  76.                 VStack(alignment: .center) {
  77.                 Text("Crate")
  78.                
  79.                     .font(.largeTitle)
  80.                     .bold()
  81.                     .colorInvert()
  82.                 }
  83.             case 6:
  84.                 EmptyView()
  85.                     VStack(alignment: .center) {
  86.                     Text("Manufactoring")
  87.                     .font(.largeTitle)
  88.                     .bold()
  89.                     .colorInvert()
  90.                     }
  91.             case 7:
  92.                 EmptyView()
  93.                         VStack(alignment: .center) {
  94.                         Text("Warehouse")
  95.                     .font(.largeTitle)
  96.                     .bold()
  97.                     .colorInvert()
  98.                         }
  99.             case 8:
  100.                    VStack(alignment: .center) {
  101.                     Text("Journal")
  102.                     .font(.largeTitle)
  103.                     .bold()
  104.                     .colorInvert()
  105.                     .padding(.top, 60)
  106.                        
  107.                        Image("articrenmeadowopacity")
  108.                            .shadow(radius: 3)
  109.                     WebView()
  110.                    
  111.             }
  112.             default:
  113.                 MainView()
  114.            
  115.             }
  116.            
  117.        }.background(Color.white)
  118.        
  119.         }
  120.        
  121.     }
  122.        
  123.        
  124.         }
  125.         Spacer()
  126.     }
  127. }
  128.  
  129.  
  130. struct MainView: View {
  131.  
  132.     var body: some View{
  133.         VStack(alignment: .leading) {
  134.         HStack(alignment: .bottom) {
  135.          
  136.              
  137.                 Image("CotharticrenMainView")
  138.                     .shadow(radius: 3)
  139.    
  140.         }
  141.             }
  142.        
  143.         .frame(width: 900, height: 800, alignment: .center)
  144.  
  145.         Spacer()
  146.         }
  147.        
  148.     }
  149.  
  150.  
  151.  
  152.  
  153. struct ListView: View {
  154.     let options: [Option]
  155.     @Binding var currentSelection: Int
  156.     var body: some View{
  157.        
  158.        
  159.         VStack(alignment: .leading) {
  160.         HStack(alignment: .top) {
  161.             HStack(alignment: .top) {
  162.                 VStack(alignment: .trailing) {
  163.             Circle()
  164.                 .stroke(Color.init(red: 0.9, green: 0.95, blue: 0.2, opacity: 1), lineWidth: 2)
  165.                 .alignmentGuide(HorizontalAlignment.myAlignment)
  166.                                    { d in d[.leading] }
  167.                 .alignmentGuide(VerticalAlignment.myAlignment)
  168.                                    { d in d[.bottom] }
  169.                 .frame(width: 50, height: 50)
  170.                
  171.                         Circle()
  172.                             .stroke(Color.init(red: 0.25, green: 0.9, blue: 0.2, opacity: 1), lineWidth: 2)
  173.                             .alignmentGuide(HorizontalAlignment.myAlignment)
  174.                                                { d in d[.leading] }
  175.                             .alignmentGuide(VerticalAlignment.myAlignment)
  176.                                                { d in d[.bottom] }
  177.                             .frame(width: 25, height: 25)
  178.                             VStack(alignment: .leading) {
  179.             Circle()
  180.                 .stroke(Color.init(red: 0.1, green: 0.1, blue: 1, opacity: 1), lineWidth: 2)
  181.                 .alignmentGuide(HorizontalAlignment.myAlignment)
  182.                                    { d in d[.leading] }
  183.                 .alignmentGuide(VerticalAlignment.myAlignment)
  184.                                    { d in d[.bottom] }
  185.                 .frame(width: 75, height: 75)
  186.                 }
  187.                 }
  188.             }
  189.            
  190.             HStack(alignment: .top) {
  191.         Image("DARTMeadowCSMwidthArtemis2by1")
  192.                
  193.             .shadow(radius: 3)
  194.             .padding(.top, 10)
  195.             }
  196.                
  197.            
  198.             .padding(.top, 20)
  199.  
  200.        
  201.         .padding(.trailing, 10)
  202.         }.padding(.top, 20).padding(.leading, 10)
  203.          
  204.             HStack(alignment: .center) {
  205.             VStack(alignment: .center) {
  206.            
  207.             Image("arrow300")
  208.                 HStack(alignment: .center) {
  209.                 Text("You've never plotted an Edge?")
  210.                 }
  211.             }
  212.             }.shadow(radius: 3)
  213.  
  214.         VStack(alignment: .leading) {
  215.             let current = options[currentSelection]
  216.             ForEach(options, id: \.self) {option in
  217.                 HStack {
  218.                    
  219.                     Image(systemName: option.imageName)
  220.                         //.resizable()
  221.                         //.aspectRatio(contentMode: .fit)
  222.                         .frame(width: 20)
  223.                    
  224.                     Text(option.title)
  225.                         .foregroundColor(current == option ? Color.blue : Color.white)
  226.                    
  227.                 }
  228.                 .padding(8)
  229.                
  230.  
  231.                 .onTapGesture {
  232.                    
  233.                     currentSelection += 1
  234.                    
  235.                     if currentSelection == 9 {
  236.                     currentSelection = 0
  237.                     }
  238.               }
  239.             }
  240.             Spacer()
  241.         }.frame(width: 300, height: 800, alignment: .leading)
  242.            
  243.     }
  244.         Spacer()
  245.     }
  246.        
  247. }
  248.  
  249.  
  250.  
  251.  
  252. struct WebView: View {
  253.  
  254.     var body: some View{
  255.         VStack(alignment: .leading) {
  256.         HStack(alignment: .bottom) {
  257.          
  258.              
  259.                
  260.    
  261.                    
  262.             }
  263.         }
  264.         .frame(width: 900, height: 800, alignment: .center)
  265.  
  266.         Spacer()
  267.         }
  268.        
  269.     }
  270.  
  271.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement