Skip to content

Instantly share code, notes, and snippets.

@rudrankriyam
Created September 13, 2021 23:12
Show Gist options
  • Save rudrankriyam/a4943cd31ff9ae5ef4f4dff86d3bd58b to your computer and use it in GitHub Desktop.
Save rudrankriyam/a4943cd31ff9ae5ef4f4dff86d3bd58b to your computer and use it in GitHub Desktop.
ContentView
import SwiftUI
struct ContentView: View {
@StateObject private var viewModel = HomeViewModel()
@Environment(\.openURL) var openURL
var body: some View {
NavigationView {
VStack {
List {
ForEach(viewModel.mediaItems, id: \.shazamID) { item in
Button(action: { openAppleMusic(with: item.appleMusicURL) }) {
ShazamMusicRow(item: item)
}
.buttonStyle(.plain)
.listRowSeparator(.hidden)
}
}
.listStyle(.plain)
HomeButtonsView(viewModel: viewModel)
}
.navigationTitle("Musadora")
}
.navigationViewStyle(.stack)
}
private func openAppleMusic(with url: URL?) {
if let url = url {
openURL(url)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment