sending again since the previous entry was poor.
Here is code that replicates issue without frills o iPhone Xs with iOS 15.1
//
// AppInfoView.swift
// TestApp
//
import SwiftUI
struct AppInfoView: View {
var body: some View {
Text("Application Info")
}
}
//
// ContentView.swift
// TestApp
//
import SwiftUI
struct ContentView: View {
@EnvironmentObject var gameView: GameViewController
@State private var selection: String? = nil
@State private var showSettingsAlert = false
@State private var showInfoAlert = false
init() {
UINavigationBar.appearance().backgroundColor = .clear
}
var body: some View {
NavigationView {
// ZStack{
// NavigationLink(destination: SettingsView(), tag: "Settings", selection: $selection) { EmptyView() }
// NavigationLink(destination: AppInfoView(), tag: "Info", selection: $selection) { EmptyView() }
VStack{
GameUIView()
ZStack{
NavigationLink(destination: SettingsView(), tag: "Settings", selection: $selection) { EmptyView() }
NavigationLink(destination: AppInfoView(), tag: "Info", selection: $selection) { EmptyView() }
HStack{
Button( action: {
self.selection = "Settings"
if gameView.gameStarted && !gameView.gamePaused {
self.showSettingsAlert = true
}
}) {
Text("Game Settings")
.font(.system(size: (CGFloat(16)), weight: .bold, design: .serif))
.foregroundColor(.blue)
Image(systemName: (showSettingsAlert ? "gearshape.fill" : "gearshape"))
.font(.system(size: (CGFloat(16)), weight: .bold, design: .serif))
}
.alert(isPresented: $showSettingsAlert) {
Alert(title: Text("Cannot View or Change Settings!"), message: Text("Game is Running or Game is NOT Paused!! Must not be running or else in Pause State to view Game Settings!"), dismissButton: .default(Text("Got it!")))
}
Spacer()
Button( action: {
self.selection = "Info"
if gameView.gameStarted && !gameView.gamePaused {
self.showInfoAlert = true
}
}) {
Text("Game Info")
.font(.system(size: (CGFloat(16)), weight: .bold, design: .serif))
.foregroundColor(.blue)
Image(systemName: (showInfoAlert ? "questionmark.diamond.fill" : "questionmark.diamond"))
.font(.system(size: (CGFloat(16)), weight: .bold, design: .serif))
}
.alert(isPresented: $showInfoAlert) {
Alert(title: Text("Cannot View Application Info!"), message: Text("Game is Running or Game is NOT Paused!! Must not be running or else in Pause State to view Game Information!"), dismissButton: .default(Text("Got it!")))
}
.navigationBarHidden(true)
.navigationBarTitle("Back To Game", displayMode: .inline)
}
}
}
// }
.navigationViewStyle(StackNavigationViewStyle())
.alert(isPresented: $gameView.gameEnded, content: {
Alert(title: Text("Game Has Ended"), message: Text("To play game again you MUST close app and restart!"), dismissButton: .default(Text("Got it!")))
})
}
}
}
//
// GameUIView.swift
// TestApp
//
import SwiftUI
struct GameUIView: View {
var body: some View {
Spacer()
Text("Game View Area")
Spacer()
}
}
//
// GameViewController.swift
// TestApp
//
import Foundation
import UIKit
class GameViewController: UIViewController, ObservableObject {
@Published var gameStarted = Bool(false)
@Published var gamePaused = Bool(false)
@Published var gameEnded = Bool(false)
}
//
// SettingsView.swift
// TestApp
//
import SwiftUI
struct SettingsView: View {
var body: some View {
Text("Settings")
}
}
Post
Replies
Boosts
Views
Activity
Here you go.