Hello all,
I am struggling hiding the navigationbar on a navigationview. Navigationlink does work, but I want to remove the navigationbar on my Mainview. Here is my code:
//
// ContentView.swift
// Nuvora
//
// Created by Pohl, Kay on 23.12.21.
//
import SwiftUI
//########################################################################
//Landing Page ###########################################################
//########################################################################
struct ContentView: View {
var body: some View {
NavigationView{
ZStack{
VStack(spacing: 0.0) {
Header() //Header View
Spacer ()
Main() //Main View
Spacer()
Spacer()
Bottom() //Bottom View
}
}
}
.navigationTitle("")
.navigationBarHidden(true)
}
}
//########################################################################
//Extensions #############################################################
//########################################################################
extension Color {
init(_ hex: UInt, alpha: Double = 1) {
self.init(
.sRGB,
red: Double((hex >> 16) & 0xFF) / 255,
green: Double((hex >> 8) & 0xFF) / 255,
blue: Double(hex & 0xFF) / 255,
opacity: alpha
)
}
}
//########################################################################
//Previews ###############################################################
//########################################################################
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
//########################################################################
//Header View ############################################################
//########################################################################
struct Header: View {
let pallette_mint = Color(0x219EBC)
var body: some View {
VStack(alignment: .leading, spacing: 0) {
HStack {
Text("Nuvora")
.bold()
.foregroundColor(.white)
.font(.system(size:45))
Spacer()
NavigationLink(destination: Settings()){
Image(systemName: "gearshape.fill")
.resizable()
.frame(width: 28.0, height: 28.0)
.foregroundColor(.white)
}
}
Text("Take care of your working time")
.font(.subheadline)
.fontWeight(.light)
.bold()
.foregroundColor(.black)
}
//.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(pallette_mint)
.shadow(radius: 20)
}
}
//########################################################################
//Main View ##############################################################
//########################################################################
struct Main: View {
let pallette_orange_light = Color(0xFFB703)
let palette_mint_light = Color(0x8ecae6)
let palette_mint_dark = Color(0x023047)
let palette_orange_dark = Color(0xfb8500)
let pallette_mint = Color(0x219EBC)
var body: some View {
//Configure Circle gradient
let gradient = Gradient(colors: [palette_mint_light, pallette_mint])
let linearGradient = LinearGradient(gradient: gradient, startPoint: .top, endPoint: .bottom)
let style = StrokeStyle(lineWidth: 20,
lineCap: .round,
lineJoin: .round,
miterLimit: 1,
dash: [],
dashPhase: 0)
//Circle and Time
VStack {
ZStack{
Circle()
.stroke(Color.gray.opacity(0.08), style: StrokeStyle(lineWidth: 20, lineCap: .round))
.frame(width: 320, height: 320)
Circle()
.trim(from: 0, to: 0.8 )
.stroke(linearGradient, style: style)
.rotationEffect(.degrees(-90))
.frame(width: 320, height: 320)
.animation(.easeInOut, value: 1)
.shadow(radius: 5)
VStack {
Text("492")
.bold().font(.system(size: 80))
.foregroundColor(palette_mint_dark)
.padding(-19)
Text("minutes left")
.fontWeight(.light)
Text("Go Time: 15:02")
.fontWeight(.light)
.foregroundColor(.gray)
.padding(1)
}
}.padding(40)
//Buttons
HStack {
//Play & Pause
HStack(spacing: 20){
Image(systemName: "play.fill")
.foregroundColor(.white)
Text("Start")
.foregroundColor(.white)
}
.padding(.vertical)
.frame(width: (UIScreen.main.bounds.width / 2) - 55)
.background(pallette_orange_light)
.clipShape(Capsule())
.shadow(radius: 6)
Spacer()
//Restart
HStack(spacing: 20){
Image(systemName: "arrow.clockwise")
.foregroundColor(pallette_orange_light)
Text("Restart")
.foregroundColor(pallette_orange_light)
}
.padding(.vertical)
.frame(width: (UIScreen.main.bounds.width / 2) - 55)
.background(
Capsule()
.stroke(pallette_orange_light, lineWidth: 2)
)
.shadow(radius: 6)
}
.padding(.horizontal, 40)
}
}
}
//########################################################################
//Bottom View ############################################################
//########################################################################
struct Bottom: View {
var body: some View {
let pallette_mint = Color(0x219EBC)
Text("Made with ")
.foregroundColor(.secondary)
+ Text(Image(systemName: "heart.fill"))
.foregroundColor(pallette_mint)
+ Text(" by myself")
.foregroundColor(.secondary)
}
}
I've put the header, main and bottom in subviews just to organize it a bit for me. I am a beginner and tried to find a solution in the internet without success. May I ask someone to help me here?
Thanks in advance
Kay