Not being able to set maximum window size for Views under different tabs

On TikTok on Vision Pro, the home page has different minimum and maximum window heights and widths compared to the search page.

Now I am able to set minimum window size for different tab views but maximum size doesn't seem to work

Code:

//  WindowSizeModel.swift
import Foundation
import SwiftUI

enum TabType {
    case home
    case search
    case profile
}

@Observable
class WindowSizeModel {
    var minWidth: CGFloat = 400
    var maxWidth: CGFloat = 500
    var minHeight: CGFloat = 400
    var maxHeight: CGFloat = 500

    
    func setWindowSize(for tab: TabType) {
        switch tab {
        case .home:
            configureWindowSize(minWidth: 400, maxWidth: 500, minHeight: 400, maxHeight: 500)
        case .search:
            configureWindowSize(minWidth: 300, maxWidth: 800, minHeight: 300, maxHeight: 800)
        case .profile:
            configureWindowSize(minWidth: 800, maxWidth: 1000, minHeight: 800, maxHeight: 1000)
        }
    }
    
    private func configureWindowSize(minWidth: CGFloat, maxWidth: CGFloat, minHeight: CGFloat, maxHeight: CGFloat) {
        self.minWidth = minWidth
        self.maxWidth = maxWidth
        self.minHeight = minHeight
        self.maxHeight = maxHeight
    }
}

//  tiktokForSpacialModelingApp.swift
import SwiftUI

@main
struct tiktokForSpacialModelingApp: App {
    @State private var windowSizeModel: WindowSizeModel = WindowSizeModel()
    
    var body: some Scene {
        WindowGroup {
            MainView()
                .frame(
                    minWidth: windowSizeModel.minWidth, maxWidth: windowSizeModel.maxWidth,
                    minHeight: windowSizeModel.minHeight, maxHeight: windowSizeModel.maxHeight)
                .environment(windowSizeModel)
        }
        .windowResizability(.contentSize)
        
    }
}

//  MainView.swift
import SwiftUI
import RealityKit

struct MainView: View {
    @State private var selectedTab: TabType = TabType.home
    @Environment(WindowSizeModel.self) var windowSizeModel;
    
    
    var body: some View {
        @Bindable var windowSizeModel = windowSizeModel
        
        TabView(selection: $selectedTab) {
            Tab("Home", systemImage: "play.house", value: TabType.home) {
                HomeView()
            }
            Tab("Search", systemImage: "magnifyingglass", value: TabType.search) {
                SearchView()
            }
            Tab("Profile", systemImage: "person.crop.circle", value: TabType.profile) {
                ProfileView()
            }
        }
        .onAppear {
            windowSizeModel.setWindowSize(for: TabType.home)
        }
        .onChange(of: selectedTab) { oldTab, newTab in
            if oldTab == newTab {
                return
            }
            else if newTab == TabType.home {
                windowSizeModel.setWindowSize(for: TabType.home)
            }
            else if newTab == TabType.search {
                windowSizeModel.setWindowSize(for: TabType.search)
                
            }
            else if newTab == TabType.profile {
                windowSizeModel.setWindowSize(for: TabType.profile)
            }
        }
    }
    
}
Answered by Vision Pro Engineer in 796142022

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. I'd greatly appreciate it if you could open a bug report with a link to this forum post, and post the FB number here once you do.

Bug Reporting: How and Why? has tips on creating your bug report.

Accepted Answer

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. I'd greatly appreciate it if you could open a bug report with a link to this forum post, and post the FB number here once you do.

Bug Reporting: How and Why? has tips on creating your bug report.

Not being able to set maximum window size for Views under different tabs
 
 
Q