Advertisement
dartmeadow

SwiftUI grid popover buttons

Jan 6th, 2023
1,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 11.29 KB | Science | 0 0
  1. struct DETEView: View {
  2.     @Environment(\.dismiss) var dismiss
  3.     var body: some View {
  4.        
  5.        
  6.             GeometryReader { bounds in
  7.                 ScrollView([.horizontal, .vertical], showsIndicators: true) {
  8.                    
  9.                     HStack(alignment: .center) {
  10.                         Button(action: {
  11.                             dismiss()
  12.                            
  13.                         },   label: {
  14.                             Image("Crystalline")
  15.                                 .resizable()
  16.                                 .aspectRatio(contentMode: .fit)
  17.                         }  )//.frame(
  18.                             //maxWidth: .infinity,
  19.                            // maxHeight: 40, alignment: .top)
  20.                        
  21.                             Button(action: {
  22.                                 dismiss()
  23.                                
  24.                             },   label: {
  25.                                 Text("DART Edge Table of Elements")
  26.                                     .font(.largeTitle)
  27.                                     .bold()
  28.                                     .foregroundColor(.white)
  29.                                 //.colorInvert()
  30.                                     .padding(.top, 20)
  31.                                     .shadow(radius: 3)
  32.                             })
  33.                     }.frame(width: 600, height: 60, alignment: .topLeading)
  34.                    
  35.                     VStack(alignment: .center){
  36.                         HStack(alignment: .center){
  37.                             VStack(alignment: .center){
  38.                                 ZStack(alignment: .topLeading) {
  39.                                     VStack(alignment: .leading){
  40.                                         HStack(alignment: .center){
  41.                                             VStack(alignment: .center){
  42.                                                 ZStack{
  43.                                                     HStack(alignment: .center) {
  44.                                                        
  45.                                                         ZStack {
  46.                                                             HStack{
  47.                                                                 HStack{
  48.                                                                     Image("C2LogoHum")
  49.                                                                         .resizable()
  50.                                                                         .aspectRatio(contentMode: .fit)
  51.                                                                 }.frame(width: 120, height: 120, alignment: .topLeading)
  52.                                                                 HStack{
  53.                                                                     Image("rdfull")
  54.                                                                         .resizable()
  55.                                                                         .aspectRatio(contentMode: .fit)
  56.                                                                 }.frame(width: 300, height: 120, alignment: .topLeading)
  57.                                                                
  58.                                                             }
  59.                                                         }.padding(.leading, 200).padding(.bottom, 20)
  60.                                                        
  61.                                                        
  62.                                                        
  63.                                                     }
  64.                                                    
  65.                                                 }
  66.                                             }
  67.                                         }
  68.                                     }
  69. HStack(alignment: .top){
  70.                                         VStack(alignment: .center){
  71.                                             GridStack(rows: 7, columns: 18) { row, column in
  72.                                                 ZStack{
  73.                                                    
  74.                                                     if let element = tableOfElements[ElementCoordinate(row: row + 1, column: column + 1)] {
  75.                                                         //Image("detecell3")
  76.                                                        
  77.                                                         //RoundedRectangle(cornerRadius: 5)
  78.                                                         //.fill(Color.brown)
  79.                                                        
  80.                                                         //Image("DETECell")//.opacity(0.4)
  81.                                                        
  82.                                                         RoundedRectangle(cornerRadius: 4.0)
  83.                                                        
  84.                                                             .aspectRatio(1, contentMode: ContentMode.fit)
  85.                                                             .foregroundColor(.blue)
  86.                                                             .shadow(radius: 3)
  87.                                                        
  88.                                                         VStack(alignment: .leading){
  89.                                                             Text(element.atomicNumber)
  90.                                                                 .font(.system(size: 8))
  91.                                                            
  92.                                                         }.frame(width: 30, height: 20, alignment: .topLeading).padding(.bottom, 20)
  93.                                                         HStack(alignment: .center){
  94.                                                             VStack(alignment: .center){
  95.                                                                 Text(element.namesymbol)
  96.                                                                     .font(.system(size: 12))
  97.                                                                     .bold()
  98.                                                                     .shadow(radius: 3)
  99.                                                                
  100.                                                                 Text(element.name)
  101.                                                                     .font(.system(size: 6))
  102.                                                             }
  103.                                                         }
  104.                                                        
  105.                                                        
  106.                                                     }
  107.                                                    
  108.                                                 }
  109.                                                 .frame(width: 45, height: 55)
  110.                                                
  111.                                                
  112.                                             }//.frame(width: 900, height: 380, alignment: .top).padding(.top, 10).padding(5)
  113.                                         }
  114.                                     }
  115.                                 }
  116.  
  117. //*****************************************************************************************************************
  118. // I need both these sections below to display popover buttons unique to each individual grid of the table I’m not really //sure how to populate buttons since I’m already populating a grid of the table.
  119. //*****************************************************************************************************************
  120.  
  121.                                 HStack(alignment: .top){
  122.                                     VStack(alignment: .center){
  123.                                         GridStack2(rows2: 2, columns2: 15) { row2, column2 in
  124.                                             ZStack{
  125.                                                 if let element2 = tableOfElementsbottom[ElementCoordinate2(row2: row2 + 1, column2: column2 + 1)] {
  126.                                                     //Image("DETECell")
  127.                                                     //RoundedRectangle(cornerRadius: 5)
  128.                                                     //.fill(Color.brown)
  129.                                                    
  130.                                                     //Image("DETECell")//.opacity(0.4)
  131.                                                    
  132.                                                     RoundedRectangle(cornerRadius: 4.0)
  133.                                                    
  134.                                                         .aspectRatio(1, contentMode: ContentMode.fit)
  135.                                                         .foregroundColor(.blue)
  136.                                                         .shadow(radius: 3)
  137.                                                    
  138.                                                     VStack(alignment: .leading){
  139.                                                         Text(element2.atomicNumber2)
  140.                                                             .font(.system(size: 8))
  141.                                                        
  142.                                                     }.frame(width: 30, height: 20, alignment: .topLeading).padding(.bottom, 20)
  143.                                                     HStack(alignment: .top){
  144.                                                         VStack(alignment: .center){
  145.                                                             Text(element2.namesymbol2)
  146.                                                                 .font(.system(size: 12))
  147.                                                                 .bold()
  148.                                                                 .shadow(radius: 3)
  149.                                                            
  150.                                                             Text(element2.name2)
  151.                                                                 .font(.system(size: 6))
  152.                                                         }
  153.                                                     }
  154.                                                    
  155.                                                 }
  156.                                             }
  157.                                             .frame(width: 45, height: 55)
  158.                                            
  159.                                            
  160.                                         }.frame(
  161.                                             maxWidth: .infinity,
  162.                                             maxHeight: .infinity, alignment: .center
  163.                                            
  164.                                         ).padding(.top, 60).padding(5)
  165.                                        
  166.                                     }
  167.                                 }
  168.                             }
  169.                         }
  170.                     }
  171.                  
  172.                 }.background(LinearGradient(gradient: Gradient(colors: [.brown, .black]), startPoint: .topTrailing, endPoint: .bottomLeading))
  173.                     .frame(width: bounds.size.width, height: bounds.size.height)
  174.                
  175.                
  176.             }
  177.        
  178.     }
  179. }
  180.  
Tags: Swiftui
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement