Created
September 13, 2021 23:12
-
-
Save rudrankriyam/a4943cd31ff9ae5ef4f4dff86d3bd58b to your computer and use it in GitHub Desktop.
ContentView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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