diff --git a/Music Tools.xcodeproj/project.pbxproj b/Music Tools.xcodeproj/project.pbxproj index fbb97bf..f369bbf 100644 --- a/Music Tools.xcodeproj/project.pbxproj +++ b/Music Tools.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ E906F7F42414019C004E1E31 /* NetworkPersister.swift in Sources */ = {isa = PBXBuildFile; fileRef = E906F7F32414019C004E1E31 /* NetworkPersister.swift */; }; + E906F7F724143AA7004E1E31 /* SwiftUICharts in Frameworks */ = {isa = PBXBuildFile; productRef = E906F7F624143AA7004E1E31 /* SwiftUICharts */; }; E92F94822401412100B6B721 /* SwiftUIRefresh in Frameworks */ = {isa = PBXBuildFile; productRef = E92F94812401412100B6B721 /* SwiftUIRefresh */; }; E934AC99240DD0E4009869F4 /* AddTagSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = E934AC98240DD0E4009869F4 /* AddTagSheet.swift */; }; E97AF45623FC4E7800635494 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF45523FC4E7800635494 /* User.swift */; }; @@ -106,6 +107,7 @@ E97AF45923FC50EC00635494 /* SwiftyJSON in Frameworks */, E98254D923FB53780056D9D3 /* Alamofire in Frameworks */, E97AF45E23FC83AF00635494 /* KeychainAccess in Frameworks */, + E906F7F724143AA7004E1E31 /* SwiftUICharts in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -292,6 +294,7 @@ E97AF45823FC50EC00635494 /* SwiftyJSON */, E97AF45D23FC83AF00635494 /* KeychainAccess */, E92F94812401412100B6B721 /* SwiftUIRefresh */, + E906F7F624143AA7004E1E31 /* SwiftUICharts */, ); productName = "Music Tools"; productReference = E9EA690723F9A5430012C3E8 /* Music Tools.app */; @@ -370,6 +373,7 @@ E97AF45723FC50EC00635494 /* XCRemoteSwiftPackageReference "swiftyjson" */, E97AF45C23FC83AF00635494 /* XCRemoteSwiftPackageReference "keychainaccess" */, E92F94802401412100B6B721 /* XCRemoteSwiftPackageReference "swiftuirefresh" */, + E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */, ); productRefGroup = E9EA690823F9A5430012C3E8 /* Products */; projectDirPath = ""; @@ -764,6 +768,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apppear/chartview"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.4.9; + }; + }; E92F94802401412100B6B721 /* XCRemoteSwiftPackageReference "swiftuirefresh" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/siteline/swiftuirefresh"; @@ -799,6 +811,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + E906F7F624143AA7004E1E31 /* SwiftUICharts */ = { + isa = XCSwiftPackageProductDependency; + package = E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */; + productName = SwiftUICharts; + }; E92F94812401412100B6B721 /* SwiftUIRefresh */ = { isa = XCSwiftPackageProductDependency; package = E92F94802401412100B6B721 /* XCRemoteSwiftPackageReference "swiftuirefresh" */; diff --git a/Music Tools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Music Tools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f4daac5..1b9aa59 100644 --- a/Music Tools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Music Tools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -10,6 +10,15 @@ "version": "5.0.0" } }, + { + "package": "SwiftUICharts", + "repositoryURL": "https://github.com/apppear/chartview", + "state": { + "branch": null, + "revision": "04989ad159380290a74729dbce1d39d64b893ab2", + "version": "1.4.9" + } + }, { "package": "KeychainAccess", "repositoryURL": "https://github.com/kishikawakatsumi/keychainaccess", diff --git a/Music Tools/Model/Tag.swift b/Music Tools/Model/Tag.swift index a0ccca9..fbeb398 100644 --- a/Music Tools/Model/Tag.swift +++ b/Music Tools/Model/Tag.swift @@ -21,6 +21,12 @@ class Tag: Identifiable, Equatable, Decodable { var albums: [JSON] var artists: [JSON] + var all: [JSON] { + get { + return tracks + albums + artists + } + } + var count: Int var proportion: Double var total_user_scrobbles: Int diff --git a/Music Tools/Views/Tag/TagView.swift b/Music Tools/Views/Tag/TagView.swift index e575ed4..6119276 100644 --- a/Music Tools/Views/Tag/TagView.swift +++ b/Music Tools/Views/Tag/TagView.swift @@ -9,6 +9,7 @@ import SwiftUI import SwiftUIRefresh import SwiftyJSON +import SwiftUICharts struct TagView: View { @@ -16,6 +17,14 @@ struct TagView: View { @State private var isRefreshing = false + var chartStyle: ChartStyle { + get { + let _style = Styles.barChartStyleNeonBlueLight + _style.darkModeStyle = Styles.barChartStyleNeonBlueDark + return _style + } + } + var body: some View { List { Section(header: Text("Stats")){ @@ -72,7 +81,28 @@ struct TagView: View { } } } - Section(header: Text("Actions")){ + HStack { + Spacer() + BarChartView( + data: ChartData(values: + self.tag.all + .filter { + $0["count"].intValue > 0 + } + .map { + ($0["name"].stringValue, $0["count"].intValue) + }), + title: "Scrobbles", + style: chartStyle, + form: ChartForm.medium, + cornerImage: Image(systemName: "music.note") + ) + .padding() +// .frame(width: 100, height: 400) + Spacer() + } + Section(header: Text("Actions"), + footer: Text("Last Updated \(self.tag.last_updated)")){ Button(action: { self.runTag() }) { Text("Update") }