fixed weird crash bug on half drag back on playlist view

This commit is contained in:
aj 2020-04-27 21:33:26 +01:00
parent fced8c9fc3
commit 228fdb3991

View File

@ -13,8 +13,6 @@ import SwiftUICharts
struct PlaylistView: View { struct PlaylistView: View {
@EnvironmentObject var liveUser: LiveUser
@Binding var playlist: Playlist @Binding var playlist: Playlist
@State private var this_month: Bool = false @State private var this_month: Bool = false
@ -194,11 +192,19 @@ struct PlaylistView: View {
Text("Open") Text("Open")
} }
} }
}.listStyle(GroupedListStyle())
// alert seems to need to be within list root element
// else weird crash on half drag back
.alert(isPresented: $showingNetworkError) {
Alert(title: Text("Network Error"),
message: Text("Could not refresh playlist"))
}
}.listStyle(GroupedListStyle())
.pullToRefresh(isShowing: $isRefreshing) { .pullToRefresh(isShowing: $isRefreshing) {
self.refreshPlaylist() self.refreshPlaylist()
} }
.navigationBarTitle(playlist.name) .navigationBarTitle(Text(playlist.name))
.onAppear { .onAppear {
// TODO are these binding properly? // TODO are these binding properly?
@ -206,16 +212,12 @@ struct PlaylistView: View {
self.$this_month.wrappedValue = playlist.add_this_month self.$this_month.wrappedValue = playlist.add_this_month
self.$last_month.wrappedValue = playlist.add_last_month self.$last_month.wrappedValue = playlist.add_last_month
} }
if let playlist = self.playlist as? LastFMChartPlaylist { if let playlist = self.playlist as? LastFMChartPlaylist {
self.$chart_range.wrappedValue = playlist.chart_range self.$chart_range.wrappedValue = playlist.chart_range
self.$chart_limit.wrappedValue = playlist.chart_limit self.$chart_limit.wrappedValue = playlist.chart_limit
} }
} }
.alert(isPresented: $showingNetworkError) {
Alert(title: Text("Network Error"),
message: Text("Could not refresh playlist"))
}
} }
func changeChartRange(newRange: LastFmRange) { func changeChartRange(newRange: LastFmRange) {