diff --git a/Examples/StressTest/StressTestApp.swift b/Examples/StressTest/StressTestApp.swift new file mode 100644 index 00000000..f4c8879c --- /dev/null +++ b/Examples/StressTest/StressTestApp.swift @@ -0,0 +1,67 @@ +import GtkBackend +import SwiftCrossUI + +class StressTestState: Observable { + @Observed + var tab = 0 + + @Observed + var values: [Int: [String]] = [:] + + let options: [String] = [ + "red", + "green", + "blue", + "tower", + "power", + "flower", + "one", + "two", + "three", + "foo", + "bar", + "baz", + ] +} + +@main +struct StressTestApp: App { + typealias Backend = GtkBackend + + let identifier = "dev.stackotter.StressTestApp" + + let state = StressTestState() + + let windowProperties = WindowProperties( + title: "StressTestApp", + defaultSize: WindowProperties.Size(400, 400), + resizable: true + ) + + var body: some View { + NavigationSplitView { + VStack { + Button("List 1") { state.tab = 0 } + Button("List 2") { state.tab = 1 } + }.padding(10) + } detail: { + VStack { + Button("Generate") { + var values: [String] = [] + for _ in 0..<1000 { + values.append(state.options.randomElement()!) + } + + state.values[state.tab] = values + } + if let values = state.values[state.tab] { + ScrollView { + ForEach(values) { value in + Text(value) + } + } + } + }.padding(10) + } + } +} diff --git a/Package.swift b/Package.swift index c2a465c5..9a9c0f45 100644 --- a/Package.swift +++ b/Package.swift @@ -244,6 +244,11 @@ let package = Package( dependencies: exampleDependencies, path: "Examples/Spreadsheet" ), + .executableTarget( + name: "StressTestExample", + dependencies: exampleDependencies, + path: "Examples/StressTest" + ), .testTarget( name: "SwiftCrossUITests",