It's good to see that Game Center got some love in WWDC 2020. Still I was silently hoping they would introduce a GK Game Session 2.0. It's still not possible to easily share a Game Center game with a link or through the share sheet to other Messenger apps like WhatsApp or Telegram.
Post
Replies
Boosts
Views
Activity
First avoid using Data as this type already exists.
Second, like @heckj already described, you need to have a data structure that has a property children. Which holds an (optional) array of the same type.
I rewrote your code to show a working version:
struct ContentView: View {
let testData = [
SomeData(name: "Parent One", children: [
SomeData(name: "Child One", children: nil),
SomeData(name: "Child Two", children: nil),
SomeData(name: "Child Three", children: nil),
]),
SomeData(name: "Parent Two", children: nil)
]
var body: some View {
List(testData, children: \.children) { data in
Text(data.name)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct SomeData: Identifiable {
var id: String = UUID().uuidString
var name: String
let children: [SomeData]?
}
Maybe an update from the Apple engineers on the sample code?
This is a duplicate of Where to find ShapeEdit sample code? - https://developer.apple.com/forums/thread/651193
This is a duplicate of Where to find ShapeEdit sample code? - https://developer.apple.com/forums/thread/651193
To get a more extensive description with images and code I also posted this question on StackOverflow: How to build a collapsible sidebar as shown in the Files app? - https://stackoverflow.com/questions/62742011/how-to-build-a-collapsible-sidebar-as-shown-in-the-files-app
They still have improvements to do on the forum.
Removing and Editing a post are the basics for keeping any forum clean and tidy.
They should also allow for images and video's, feels like basics.
I copied your code and removed the Detail-part.
struct ContentView: View {
var body: some View {
NavigationView {
SidebarView()
Text("Main")
}
}
}
On iPad portrait mode I have a full screen for Main with a Back-button in the top left corner to let the sidebar come in as a fly-over. If I put the iPad in landscape mode. I get about 1 third sidebar and 2 third main. I can click the sidebar icon in the top left to dismiss the sidebar and get a full screen Main view. From your story this is the expected behavior is it not?
Build on xCode Version 12.0 beta (12A6159)
Simulator iPad Pro (11-inch) (2nd generation)
It seems like they solved the issue in iOS 14 beta 2. Not in Simulator but on the hardware device itself.
Altho the behavior is still very buggy.
1) When I press on a section header it get's a highlighted effect, which isn't there in the sidebar of the Files app.
2) When I collaps and expand the items, for instance the 'Version 2' section, the style of the first item get's styled two with bold and increased font, but when I collaps and expand again the last item get's styled and this swaps constantly.
The code should work.
Please note that the WebView has a different rendering system than UIKit.
So you don't get the dynamic font size advantage for free.
import SwiftUI
import WebKit
struct ContentView: View {
@State var text = "<html><body><h1>Hello World</h1></body></html>"
var body: some View {
WebView(text: $text)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
}
}
struct WebView: UIViewRepresentable {
@Binding var text: String
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.loadHTMLString(text, baseURL: nil)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Apple Feedback
The client code is recreating the Model every time the view is rendered. The model generates the new ID for every item every time. Without consistent IDs, the system cannot maintain a consistent UI.
The client code should be using @StateObject on the model property in ContentView.
UISearchController works when attached to a List. It becomes buggy when you use something other like a ScrollView or VStack. I have reported this in Apple's Feedback app and I hope others will do the same.
Never the less if you like to include a UISearchController in your App.
I created a Swift Package at Github named NavigationSearchBar. - https://github.com/markvanwijnen/NavigationSearchBar
I also submitted feedback. Apple we need this .listSeparatorStyle(.none).
Radar #FB8654253
I don't really understand your question, but I wrote an article about everything you should about @AppStorage and @SceneStorage on Medium, which might answer your question better.
Perhaps you don't realize that with defining @AppStorage you defined a source-of-truth. If you need to access it "outside" the views perhaps its better to place the @AppStorage somewhere higher in the view hierarchy and pass it with bindings.
Links: Introducing @AppStorage in SwiftUI (medium.com/swlh/introducing-appstorage-in-swiftui-470a56f5ba9e)
Introducing @SceneStorage in SwiftUI: (medium.com/@crystalminds/introducing-scenestorage-in-swiftui-5a4ec1a90ca3)
I fourth that.
I love that Apple exposed Group Activity as an API. Would only make sense to make DrawTogether available as sample code.