Skip to content

Commit

Permalink
BAL-195-GP-STATS
Browse files Browse the repository at this point in the history
  • Loading branch information
gperissetcelteeka committed May 24, 2024
1 parent df4b80c commit 694dd5a
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 33 deletions.
6 changes: 5 additions & 1 deletion Balance.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
6CB5181A29E45678007AADB4 /* ImageCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB5181929E45678007AADB4 /* ImageCollectionView.swift */; };
6CB5181C29E45C0C007AADB4 /* BalanceExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB5181B29E45C0B007AADB4 /* BalanceExtensions.swift */; };
6CB5181E29E6F395007AADB4 /* ImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB5181D29E6F395007AADB4 /* ImageView.swift */; };
6CB845572BFD208200059FFA /* StatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB845562BFD208200059FFA /* StatsView.swift */; };
6CB8F7322AC61BCF0074FDD9 /* BalanceWatchApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB8F72F2AC61BCE0074FDD9 /* BalanceWatchApp.swift */; };
6CB8F7332AC61BCF0074FDD9 /* ComplicationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB8F7302AC61BCE0074FDD9 /* ComplicationController.swift */; };
6CB8F73B2AC61F340074FDD9 /* WorkoutManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB8F73A2AC61F340074FDD9 /* WorkoutManager.swift */; };
Expand Down Expand Up @@ -378,6 +379,7 @@
6CB5181929E45678007AADB4 /* ImageCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCollectionView.swift; sourceTree = "<group>"; };
6CB5181B29E45C0B007AADB4 /* BalanceExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BalanceExtensions.swift; sourceTree = "<group>"; };
6CB5181D29E6F395007AADB4 /* ImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageView.swift; sourceTree = "<group>"; };
6CB845562BFD208200059FFA /* StatsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatsView.swift; sourceTree = "<group>"; };
6CB8F72F2AC61BCE0074FDD9 /* BalanceWatchApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BalanceWatchApp.swift; sourceTree = "<group>"; };
6CB8F7302AC61BCE0074FDD9 /* ComplicationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComplicationController.swift; sourceTree = "<group>"; };
6CB8F73A2AC61F340074FDD9 /* WorkoutManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WorkoutManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -663,6 +665,7 @@
6C5523F629F80E8800F802D9 /* ShowHideSecureField.swift */,
6C5523F829F8126000F802D9 /* ProfileCellView.swift */,
6C47339029FC5C7D00DC72D0 /* PersonalDataView.swift */,
6CB845562BFD208200059FFA /* StatsView.swift */,
6CF978982A65EC970046E90A /* EmailHelper.swift */,
);
path = Profile;
Expand Down Expand Up @@ -1199,6 +1202,7 @@
6C55243129F86DD800F802D9 /* OnboardingFlow.swift in Sources */,
6CFB02412A438AFA000045E1 /* Photo.swift in Sources */,
6CFB02552A449C2A000045E1 /* ImageReviewRepository.swift in Sources */,
6CB845572BFD208200059FFA /* StatsView.swift in Sources */,
6C8868AD2A3A011A00000647 /* LoginViewLocal.swift in Sources */,
6C55243029F86DD800F802D9 /* InterestingModules.swift in Sources */,
6C47339129FC5C7D00DC72D0 /* PersonalDataView.swift in Sources */,
Expand Down Expand Up @@ -1809,7 +1813,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SvenTiigi/YouTubePlayerKit.git";
requirement = {
kind = upToNextMajorVersion;
kind = upToNextMinorVersion;
minimumVersion = 1.0.0;
};
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"originHash" : "1c0f91032eceeb1ee5fdc9ba2c0f310e642edbda05c506be04c51ea181c42cf8",
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c",
"version" : "1.2022062300.0"
"revision" : "748c7837511d0e6a507737353af268484e1745e2",
"version" : "1.2024011601.1"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/app-check.git",
"state" : {
"revision" : "076b241a625e25eac22f8849be256dfb960fcdfe",
"version" : "10.19.1"
}
},
{
Expand All @@ -32,62 +42,62 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk.git",
"state" : {
"revision" : "8a8ec57a272e0d31480fb0893dda0cf4f769b57e",
"version" : "10.15.0"
"revision" : "9d17b500cd98d9a7009751ad62f802e152e97021",
"version" : "10.26.0"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "03b9beee1a61f62d32c521e172e192a1663a5e8b",
"version" : "10.13.0"
"revision" : "16244d177c4e989f87b25e9db1012b382cfedc55",
"version" : "10.25.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "aae45a320fd0d11811820335b1eabc8753902a40",
"version" : "9.2.5"
"revision" : "a637d318ae7ae246b02d7305121275bc75ed5565",
"version" : "9.4.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "c38ce365d77b04a9a300c31061c5227589e5597b",
"version" : "7.11.5"
"revision" : "57a1d307f42df690fdef2637f3e5b776da02aad6",
"version" : "7.13.3"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "f1b366129d1125be7db83247e003fc333104b569",
"version" : "1.50.2"
"revision" : "e9fad491d0673bdda7063a0341fb6b47a30c5359",
"version" : "1.62.2"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "d415594121c9e8a4f9d79cecee0965cf35e74dbd",
"version" : "3.1.1"
"revision" : "0382ca27f22fb3494cf657d8dc356dc282cd1193",
"version" : "3.4.1"
}
},
{
"identity" : "healthkitonfhir",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR",
"state" : {
"revision" : "fdf8e4543718a940643598e4bd5e750e9c4c5540",
"version" : "0.2.4"
"revision" : "418929f315f37e6d9c8f30f40030bc65b9cc47c9",
"version" : "0.2.8"
}
},
{
Expand All @@ -105,43 +115,43 @@
"location" : "https://github.com/spotify/ios-sdk.git",
"state" : {
"branch" : "master",
"revision" : "cdbdcb341ace5defa863cf323749376f7e4888e9"
"revision" : "9a46112bbf8ca7cb42fb28ede0a3fe9a85ab006c"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
"version" : "1.22.2"
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
"version" : "1.22.5"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
"version" : "2.30909.0"
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
"version" : "2.30910.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e",
"version" : "2.3.1"
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
"version" : "2.4.0"
}
},
{
"identity" : "researchkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/ResearchKit",
"state" : {
"revision" : "9530fadc9d09c0b783388c752b0dbe841974b6af",
"version" : "2.2.18"
"revision" : "3f70adf898b5985ba15e25d5074d86a9c657d305",
"version" : "2.2.30"
}
},
{
Expand All @@ -158,8 +168,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "3c54ab05249f59f2c6641dd2920b8358ea9ed127",
"version" : "1.24.0"
"revision" : "9f0c76544701845ad98716f3f6a774a892152bcb",
"version" : "1.26.0"
}
},
{
Expand All @@ -185,10 +195,10 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SvenTiigi/YouTubePlayerKit.git",
"state" : {
"revision" : "6bbba75c8a8927e8073765849e22707d96b55205",
"version" : "1.5.2"
"revision" : "7f5e23ef5948041bc2acba9f47b8f2128f93adca",
"version" : "1.0.0"
}
}
],
"version" : 2
"version" : 3
}
60 changes: 58 additions & 2 deletions Balance/Profile/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI

// swiftlint:disable type_body_length
// swiftlint:disable file_length
struct ProfileView: View {
@Environment(\.dismiss)
private var dismiss
Expand All @@ -34,7 +35,9 @@ struct ProfileView: View {
@State private var sliderValue: Float = 0.0
@State private var isEditing = false
@State private var sliderStringValue: String = ""

// @State private var postData = [PostCount]()
@State private var valuesData = [Double]()
@State private var namesData = [String]()
var body: some View {
ZStack {
VStack(alignment: .center, spacing: 0) {
Expand Down Expand Up @@ -121,11 +124,12 @@ struct ProfileView: View {
infoOption
updateOption
#else
resetOption
statsView
if logsIsEmpty == false {
shareOption
shareLink
}
resetOption
#endif
logoutOption
}
Expand All @@ -134,6 +138,28 @@ struct ProfileView: View {
}
}

var statsView: some View {
NavigationLink(
destination: ActivityLogBaseView(
viewName: "Stats View",
isDirectChildToContainer: true,
content: {
StatsView(valuesData: valuesData, namesData: namesData)
}
)
) {
ProfileCellView(image: "chart.pie", text: "How I used the App")
}.simultaneousGesture(TapGesture().onEnded {
// self.postData = topActions()
//
// for val in postData {
// self.valuesData.append(Double(val.count))
// self.namesData.append(val.eventName)
// }
topActions()
})
}

var avatarChangeView: some View {
Button(action: {
showingAvatarSheet.toggle()
Expand Down Expand Up @@ -473,4 +499,34 @@ struct ProfileView: View {
}
return noteAsCSV
}

func topActions() {
var byEvent: [PostCount] = []
var logActions = [String]()
var counts: [String: Int] = [:]

for log in logs {
for action in log.actions {
logActions.append(action.description)
}
}
for item in logActions {
counts[item] = (counts[item] ?? 0) + 1
}

for (key, value) in counts {
byEvent.append(PostCount(eventName: key, count: value))
}

let sortedEvents = byEvent.sorted {
$0.count > $1.count
}

for val in sortedEvents.first(elementCount: 5) {
self.valuesData.append(Double(val.count))
self.namesData.append(val.eventName)
}
return
// return sortedEvents.first(elementCount: 5)
}
}
Loading

0 comments on commit 694dd5a

Please sign in to comment.