Post

Replies

Boosts

Views

Activity

Reordering SwiftUI Sidebar Items Crashes on Big Sur
I'd like to make the items in my sidebar rearrangeable, like Finder, but when I apply the SidebarListStyle it breaks and causes a crash (tested on Big Sur). By removing the style, reordering works as expected. Is there another modifier I should be using? Thanks! @main struct MyApp: App { 	var body: some Scene { 		WindowGroup { 			ContentView() 		} 		} 	} struct ContentView: View { 	@State var strings: [String] = ["A", "B", "C"] 	@State var selection: String? 	var body: some View { 		NavigationView { 			List(selection: $selection) { 				ForEach(strings, id: \.self) { string in 					Text(string) 				} 				.onMove { (indexes, dest) in 					withAnimation { 						self.strings.move(fromOffsets: indexes, toOffset: dest) 					} 				} 			} 			.listStyle(SidebarListStyle()) 			VStack { 				Spacer() 				Text(selection ?? "<none>") 					.frame(idealWidth: 100, maxWidth: .infinity, alignment: .center) 				Spacer() 			} 		} 	} } I opened Feedback FB7520923 to track the issue too.
0
0
536
Jun ’20
Full Screen Sidebar with SwiftUI on Big Sur
Adopt the new look of macOS covered how to create a full screen sidebar in AppKit, but I'm not able to figure out how to accomplish this with SwiftUI. Any ideas as to what I'm missing? @main struct MyApp: App {   var body: some Scene { 		WindowGroup {       ContentView() 		}   } } struct ContentView: View {   @State var strings: [String] = ["A", "B", "C"]   @State var selection: String?   var body: some View { 	  HSplitView {       List(selection: $selection) {         ForEach(strings, id: \.self) { string in           Text(string)      	} 	    } 			.listStyle(SidebarListStyle()) 	    VStack {         Spacer()         Text(selection ?? "<none>")           .frame(idealWidth: 100, maxWidth: .infinity, alignment: .center)    		  Spacer() 			}     }   } } I already filed FB7776520 in case it's not possible, but I'm assuming I'm missing something since it's a marquee feature. Thanks! Update: If I replace HSplitView with NavigationView it works as expected. 🤦‍♂️
2
0
2.2k
Jun ’20