diff --git a/firstfm.xcodeproj/project.pbxproj b/firstfm.xcodeproj/project.pbxproj index 66bcabf..ea9ea79 100644 --- a/firstfm.xcodeproj/project.pbxproj +++ b/firstfm.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ 82D5B4D22696DBD700716931 /* ScrobblesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D5B4D12696DBD700716931 /* ScrobblesViewModel.swift */; }; 82D5B4D42696DC7800716931 /* RecentTracks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D5B4D32696DC7800716931 /* RecentTracks.swift */; }; 82D5B4D62696E0E100716931 /* ScrobbledTrackRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D5B4D52696E0E100716931 /* ScrobbledTrackRowView.swift */; }; + 82E80C39269777C60098DC3C /* SwiftUIRefresh in Frameworks */ = {isa = PBXBuildFile; productRef = 82E80C38269777C60098DC3C /* SwiftUIRefresh */; }; 82FBAE472674B8FC000D8E29 /* Artist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82FBAE462674B8FC000D8E29 /* Artist.swift */; }; 82FBAE492674BB55000D8E29 /* ChartViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82FBAE482674BB55000D8E29 /* ChartViewModel.swift */; }; 82FBAE4C2674BCB7000D8E29 /* ArtistResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82FBAE4B2674BCB7000D8E29 /* ArtistResponse.swift */; }; @@ -86,6 +87,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 82E80C39269777C60098DC3C /* SwiftUIRefresh in Frameworks */, 82505CE42675178B00CCCB58 /* Kingfisher in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -233,6 +235,7 @@ name = firstfm; packageProductDependencies = ( 82505CE32675178B00CCCB58 /* Kingfisher */, + 82E80C38269777C60098DC3C /* SwiftUIRefresh */, ); productName = firstfm; productReference = 82844DFD2673991F00578DD4 /* firstfm.app */; @@ -263,6 +266,7 @@ mainGroup = 82844DF42673991F00578DD4; packageReferences = ( 82505CE22675178B00CCCB58 /* XCRemoteSwiftPackageReference "Kingfisher" */, + 82E80C37269777C50098DC3C /* XCRemoteSwiftPackageReference "SwiftUIRefresh" */, ); productRefGroup = 82844DFE2673991F00578DD4 /* Products */; projectDirPath = ""; @@ -523,6 +527,14 @@ minimumVersion = 6.3.0; }; }; + 82E80C37269777C50098DC3C /* XCRemoteSwiftPackageReference "SwiftUIRefresh" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/timbersoftware/SwiftUIRefresh.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 0.0.3; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -531,6 +543,11 @@ package = 82505CE22675178B00CCCB58 /* XCRemoteSwiftPackageReference "Kingfisher" */; productName = Kingfisher; }; + 82E80C38269777C60098DC3C /* SwiftUIRefresh */ = { + isa = XCSwiftPackageProductDependency; + package = 82E80C37269777C50098DC3C /* XCRemoteSwiftPackageReference "SwiftUIRefresh" */; + productName = SwiftUIRefresh; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 82844DF52673991F00578DD4 /* Project object */; diff --git a/firstfm.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/firstfm.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9c95f95..01a5f69 100644 --- a/firstfm.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/firstfm.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,6 +9,24 @@ "revision": "44450a8f564d7c0165f736ba2250649ff8d3e556", "version": "6.3.0" } + }, + { + "package": "Introspect", + "repositoryURL": "https://github.com/siteline/SwiftUI-Introspect.git", + "state": { + "branch": null, + "revision": "2e09be8af614401bc9f87d40093ec19ce56ccaf2", + "version": "0.1.3" + } + }, + { + "package": "SwiftUIRefresh", + "repositoryURL": "https://github.com/timbersoftware/SwiftUIRefresh.git", + "state": { + "branch": null, + "revision": "fa8fac7b5eb5c729983a8bef65f094b5e0d12014", + "version": "0.0.3" + } } ] }, diff --git a/firstfm/Views/ChartListView.swift b/firstfm/Views/ChartListView.swift index 6e879f6..7b6533e 100644 --- a/firstfm/Views/ChartListView.swift +++ b/firstfm/Views/ChartListView.swift @@ -12,6 +12,7 @@ struct ChartList: View { @State var artistsLoaded = false @State var tracksLoaded = false @State private var selectedChartsIndex = 0 + @State private var isPullLoaderShowing = false var body: some View { NavigationView { @@ -47,6 +48,10 @@ struct ChartList: View { self.artistsLoaded = true } } + .pullToRefresh(isShowing: $isPullLoaderShowing) { + self.charts.getChartingArtists() + self.isPullLoaderShowing = false + } } if selectedChartsIndex == 1 { List(charts.tracks) { track in @@ -62,6 +67,10 @@ struct ChartList: View { self.tracksLoaded = true } } + .pullToRefresh(isShowing: $isPullLoaderShowing) { + self.charts.getChartingTracks() + self.isPullLoaderShowing = false + } } diff --git a/firstfm/Views/ScrobblesView.swift b/firstfm/Views/ScrobblesView.swift index 3191f1f..c9b6258 100644 --- a/firstfm/Views/ScrobblesView.swift +++ b/firstfm/Views/ScrobblesView.swift @@ -6,11 +6,13 @@ // import SwiftUI +import SwiftUIRefresh struct Scrobbles: View { @ObservedObject var vm = ScrobblesViewModel() @State var scrobblesLoaded = false @State private var selectedChartsIndex = 0 + @State private var isPullLoaderShowing = false var body: some View { NavigationView { @@ -20,8 +22,8 @@ struct Scrobbles: View { NavigationLink( destination: Color(.blue), label: { - ScrobbledTrackRow(track: track) - }) + ScrobbledTrackRow(track: track) + }) }.navigationTitle("Scrobbles").onAppear { if !scrobblesLoaded { vm.getUserScrobbles() @@ -29,6 +31,10 @@ struct Scrobbles: View { scrobblesLoaded = true } } + .pullToRefresh(isShowing: $isPullLoaderShowing) { + vm.getUserScrobbles() + self.isPullLoaderShowing = false + } } // Show loader above the rest of the ZStack if vm.isLoading {