When starting my app on iPadOS, there is a blank view/screen on the right side, so I need a solution to force the app to choose or to lunch with the firstDetailsView().
If there is no solution for this problem, how can I add a Text() View on the right side which tells the user something like that -> no DetailView is selected
Here is the sourcecode ContentView.swift
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
HomeView()
.tabItem {
Image(systemName: "house.fill")
Text("Home")
}
SettingsView()
.tabItem {
Image(systemName: "gear.circle")
Text("Settings")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
SettingsView.swift
import SwiftUI
struct SettingsView: View {
var body: some View {
Text("Settings")
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
}
}
HomeView.swift
import SwiftUI
struct HomeView: View {
var body: some View {
NavigationView {
ScrollView {
VStack (spacing: -15) {
NavigationLink(destination: firstDetailsView()) {
card(symbol: "1.square", color: Color.orange)
}
NavigationLink(destination: secondDetailsView()) {
card(symbol: "2.square", color: Color.green)
}
NavigationLink(destination: thirdDetailsView()) {
card(symbol: "3.square", color: Color.purple)
}
}
}
.navigationTitle("Title")
}
}
}
struct card: View {
var symbol: String
var color: Color
var body: some View {
HStack {
Text("Link to DetailView")
Image(systemName: symbol)
}
.frame(maxWidth: .infinity, minHeight: 100)
.bold()
.foregroundColor(Color.white)
.background(color)
.padding()
}
}
struct HomeView_Previews: PreviewProvider {
static var previews: some View {
HomeView()
}
}
firstDetailsView.swift
import SwiftUI
struct firstDetailsView: View {
var body: some View {
ZStack {
Color.orange
.ignoresSafeArea()
Text("firstDetailsView!")
}
}
}
struct firstDetailsView_Previews: PreviewProvider {
static var previews: some View {
firstDetailsView()
}
}
secondDetailsView.swift
struct secondDetailsView: View {
var body: some View {
ZStack {
Color.green
.ignoresSafeArea()
Text("secondDetailsView!")
}
}
}
struct secondDetailsView_Previews: PreviewProvider {
static var previews: some View {
secondDetailsView()
}
}