import SwiftUI
struct UtilitySelectionView: View {
var body: some View {
NavigationView {
GeometryReader { geometry in
VStack(spacing: 0) {
// Black color for the safe area
Color.black
.frame(height: geometry.safeAreaInsets.top) // Background color for safe area
.edgesIgnoringSafeArea(.top)
// Header/Navbar
HStack {
Button(action: {
// Action for menu button
}) {
Image(systemName: "line.horizontal.3")
.resizable()
.frame(width: 25, height: 25)
.foregroundColor(.black)
.padding(10)
}
Spacer()
Button(action: {
// Action for search button
}) {
Image(systemName: "magnifyingglass")
.resizable()
.frame(width: 25, height: 25)
.foregroundColor(.black)
.padding(10)
}
}
.background(Color.yellow)
.frame(height: 50) // Set fixed height for the navbar
Spacer()
// Centered Content
VStack {
Text("Choose your Utility")
.font(.largeTitle)
.foregroundColor(.yellow)
.padding(.bottom, 20)
HStack {
NavigationLink(destination: ARSelectionView(utility: .sdge)) {
Image("s_logo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 80, height: 80)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: 15)) // Rounded edges
.padding(10)
}
NavigationLink(destination: ARSelectionView(utility: .sce)) {
Image("s_logo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 80, height: 80)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: 15)) // Rounded edges
.padding(10)
}
NavigationLink(destination: ARSelectionView(utility: .pge)) {
Image("p_logo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 80, height: 80)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: 15)) // Rounded edges
.padding(10)
}
}
}
.padding(.top, 10)
Spacer()
}
.background(Color.black.edgesIgnoringSafeArea(.all)) // Background color for the entire view
}
.navigationBarHidden(true) // Hide the default navigation bar
}
}
}
i tried padding, offsets, and other positioning technieques, i think maybe my layout is off? I am just looking to see how to move it up without stretching out the navbar, so the Hstack that has the image horizontal button and mangifying glass in it is the navbar that I’d like to modify and move upwards
New contributor
Brian Haack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.