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()
}
}
Post
Replies
Boosts
Views
Activity
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.
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)
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.
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
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
Maybe an update from the Apple engineers on the sample code?
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]?
}
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.