A multiplatform SwiftUI project demonstrating various SwiftUI features, including creating a master-detail interface. It's a multiplatform version of the MacWikiDemo project. I use this project as a sample project in the following articles:
- Creating a Master-Detail Inteface in SwiftUI
- Passing Data to SwiftUI Views
- Using File Wrappers in a SwiftUI App
- Removing Items from SwiftUI Lists in Mac Apps
- Disable a Text Field in a SwiftUI List Until Tapping Edit Button
- Using a UIKit or AppKIt View in SwiftUI
The master view shows a list of pages. Select a page to show the page's contents in the detail view.
The detail view has two views: a text view where you type Markdown and a web view that shows HTML.
- Xcode 13.0+ for iOS version
- Xcode 13.1+ for Mac version
- iOS 14+
- macOS 11+
Click the Add button at the bottom of the list to add a new page.
Tap the Edit button. Tap on the name of a page to rename it.
Select the page from the sidebar and press the Return key to rename the page.
I find that with SwiftUI that all you have to do is select the page to change the page name. I consider it a bug.
Tap the Edit button. Tap the minus button next to the page you want to remove. Tap the Delete button to finish deleting.
Select the page and press the Delete key to delete a page.
You may have to press the Esc key afer selecting the page to select the page instead of renaming it.
- The
ContentView.swift
andPageListView.swift
files have the code for creating a master-detail interface. - The
Wiki.swift
andPage.swift
files have the code for working with file wrappers. - The
PageListView.swift
andWiki.swift
files have the code for list item removal. - The
PageListView.swift
file in the iOS folder has code for disabling the text fields in the page list until someone taps the Edit button on iOS. - The
WebView.swift
files in the iOS and Mac folders have code for wrapping UIKit and AppKit views to use in a SwiftUI app.
This project uses the Ink Markdown parser by John Sundell.