This file contains hidden or 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
| protocol RGBColorProtocol: ColorProtocol { | |
| var red: Double { get set } | |
| var green: Double { get set } | |
| var blue: Double { get set } | |
| } | |
| extension RGBColorProtocol { | |
| func new() -> Color { | |
| Color(red: red, green: green, blue: blue) | |
| } |
This file contains hidden or 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
| MusicRowView(song: song) | |
| .swipeActions(edge: .leading) { | |
| Button { | |
| withAnimation { | |
| // Mark the song favorite | |
| } | |
| } label: { | |
| Label("Favorite", systemImage: "star") | |
| } | |
| .tint(.brand) |
This file contains hidden or 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
| struct SearchView: View { | |
| @StateObject private var viewModel = SearchSongsViewModel() | |
| @State private var searchText = "" | |
| // 1 | |
| @State private var selectedHint = "" | |
| var body: some View { | |
| NavigationView { | |
| VStack { | |
| if searchText.isEmpty { |
This file contains hidden or 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
| struct SearchView: View { | |
| @State private var searchText = "" | |
| @StateObject private var viewModel = SearchSongsViewModel() | |
| var body: some View { | |
| NavigationView { | |
| VStack { | |
| if searchText.isEmpty { | |
| Image("empty_search") | |
| .resizable() |
This file contains hidden or 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
| struct MusicRowView: View { | |
| var song: SongData | |
| var body: some View { | |
| ZStack { | |
| // 1 | |
| ArtworkImage(url: url) { image in | |
| image | |
| .scaledToFill() |
This file contains hidden or 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
| struct MusicCardView: View { | |
| var song: SongData | |
| var body: some View { | |
| HStack { | |
| ArtworkImage(url: url) { image in | |
| image | |
| .scaledToFit() | |
| .transition(.opacity.combined(with: .scale)) | |
| } |
This file contains hidden or 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
| List { | |
| LazyVGrid(columns: items, spacing: 4) { | |
| ForEach(viewModel.songs.shuffled(), id: \.id) { song in | |
| // Content. Shuffling the songs after every refresh. | |
| } | |
| } | |
| .listRowSeparator(.hidden) | |
| } | |
| .listStyle(.plain) |
This file contains hidden or 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
| ArtworkImage(url: url) { image in | |
| image | |
| .scaledToFit() | |
| .transition(.opacity.combined(with: .scale)) | |
| } |
This file contains hidden or 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
| struct ArtworkImage: View { | |
| var url: URL? | |
| var body: some View { | |
| AsyncImage(url: url) | |
| } | |
| } |