// // rocketView.swift // spacex // // Created by Charlie Kingsland on 23/01/2021. // import SwiftUI import SDWebImage import HalfModal import Foundation struct rocketView: View { @State var rockets: [Rocket] = [] @State private var showingHalfModal2: Bool = false var body: some View { ZStack { NavigationView { VStack { Spacer() .frame(height: 1) .navigationBarTitle("Rockets") List { ForEach(rockets, id: \.id) { rocket in Button(action: { withAnimation { self.showingHalfModal2 = true } }) { rHStack(rocket) } .buttonStyle(PlainButtonStyle()) } } }.onAppear { rocketApiCall().getUsers{ (rockets) in rockets = rockets} }.listStyle(SidebarListStyle()) .frame(alignment: .center) } } if showingHalfModal2 { HalfModalView(content: AnyView(HStack { VStack { Text("test123") .padding() } }), header: AnyView(HStack { VStack(alignment: .leading) { Text("test") Text("test") .font(.system(size: 10)) .foregroundColor(Color.gray) }}), isPresented: $showingHalfModal2) } } func rHStack(_ rocket: Rocket) -> some View { HStack { Group { Text(rocket.name) .font(.system(size: 23)) .frame(maxWidth: .infinity, alignment: .leading) .fixedSize(horizontal: false, vertical: true) Text("Active: " + String(rocket.active)) .font(.system(size: 15)) .foregroundColor(Color.gray) Spacer() } } } } struct rocketView_Previews: PreviewProvider { static var previews: some View { rocketView() } }