Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/4.5.0 swift UI #419

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions iOS/APIExample-SwiftUI/APIExample-SwiftUI/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,7 @@ struct ContentView: View {
ForEach(menus) { section in
Section(header: Text(section.name)) {
ForEach(section.rows) { item in
if item.name == "Picture In Picture".localized {
if #available(iOS 15.0, *) {
NavigationLink(destination: {
item.view.navigationTitle(item.name)
}) {
Text(item.name)
}
} else {
Button(action: {
showAlert()
}) {
Text(item.name)
}
}
} else {
NavigationLink(destination: {
item.view.navigationTitle(item.name)
}) {
Text(item.name)
}
}
MenuItemView(item: item)
}
}
}
Expand All @@ -131,6 +111,33 @@ struct ContentView: View {
.navigationBarTitleDisplayMode(.inline)
}
}
}

struct MenuItemView: View {
var item: MenuItem
var body: some View {
if item.name == "Picture In Picture".localized {
if #available(iOS 15.0, *) {
NavigationLink(destination: {
item.view.navigationTitle(item.name)
}) {
Text(item.name)
}
} else {
Button(action: {
showAlert()
}) {
Text(item.name)
}
}
} else {
NavigationLink(destination: {
item.view.navigationTitle(item.name)
}) {
Text(item.name)
}
}
}

func showAlert() {
let alert = UIAlertController(title: "Unsupported", message: "Picture in Picture is not supported on this version of iOS.", preferredStyle: .alert)
Expand Down
Loading