From 228fdb39911933de523c326ed7e689135bc392a5 Mon Sep 17 00:00:00 2001 From: aj Date: Mon, 27 Apr 2020 21:33:26 +0100 Subject: [PATCH] fixed weird crash bug on half drag back on playlist view --- Music Tools/Views/Playlist/PlaylistView.swift | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Music Tools/Views/Playlist/PlaylistView.swift b/Music Tools/Views/Playlist/PlaylistView.swift index 22133ba..abfe80b 100644 --- a/Music Tools/Views/Playlist/PlaylistView.swift +++ b/Music Tools/Views/Playlist/PlaylistView.swift @@ -13,8 +13,6 @@ import SwiftUICharts struct PlaylistView: View { - @EnvironmentObject var liveUser: LiveUser - @Binding var playlist: Playlist @State private var this_month: Bool = false @@ -194,11 +192,19 @@ struct PlaylistView: View { 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) { self.refreshPlaylist() } - .navigationBarTitle(playlist.name) + .navigationBarTitle(Text(playlist.name)) .onAppear { // TODO are these binding properly? @@ -206,16 +212,12 @@ struct PlaylistView: View { self.$this_month.wrappedValue = playlist.add_this_month self.$last_month.wrappedValue = playlist.add_last_month } - + if let playlist = self.playlist as? LastFMChartPlaylist { self.$chart_range.wrappedValue = playlist.chart_range 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) {