Skip to content

Commit

Permalink
Merge pull request #419 from AgoraIO/dev/4.5.0-SwiftUI
Browse files Browse the repository at this point in the history
Dev/4.5.0 swift UI
  • Loading branch information
tamworth authored Oct 18, 2024
2 parents 206e9e7 + bb38955 commit 8ade95e
Showing 1 changed file with 28 additions and 21 deletions.
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

0 comments on commit 8ade95e

Please sign in to comment.