Skip to content

Commit

Permalink
feat(charts): init segmented picker
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan committed Jun 15, 2021
1 parent 8b70d4c commit ebdb4c2
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions firstfm/Views/CharList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,41 @@ import SwiftUI
struct ChartList: View {
@ObservedObject var charts = ChartViewModel()
@State var loaded = false
@State private var selectedChartsIndex = 0

var body: some View {
NavigationView {
ZStack {
List(charts.artists) { artist in
NavigationLink(
destination: ArtistView(artist: artist),
label: {
ArtistRow(artist: artist)
})
}.navigationTitle("Artist charts").onAppear {
if !loaded {
self.charts.getChartingArtists()
// Prevent loading artits again when navigating
self.loaded = true
VStack {
Picker("Favorite Color",
selection: $selectedChartsIndex,
content: {
Text("Artists").tag(0)
Text("Tracks").tag(1)
}).padding(.horizontal, 20)
.padding(.vertical, 5)
.pickerStyle(SegmentedPickerStyle())

List(charts.artists) { artist in
NavigationLink(
destination: ArtistView(artist: artist),
label: {
ArtistRow(artist: artist)
})
}.navigationTitle("Global charts").onAppear {
if !loaded {
self.charts.getChartingArtists()
// Prevent loading artits again when navigating
self.loaded = true
}
}
}
// Show loader above the rest of the ZStack
if charts.isLoading {
ProgressView()
}
}

}
}
}
Expand Down

0 comments on commit ebdb4c2

Please sign in to comment.