Skip to content

Commit

Permalink
Merge pull request #190 from Capstone-Projects-2024-Spring/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
SlowMiata authored Apr 25, 2024
2 parents aff5097 + 4d0f625 commit e300639
Show file tree
Hide file tree
Showing 59 changed files with 1,635 additions and 638 deletions.
32 changes: 24 additions & 8 deletions SmartWeights/SmartWeights.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E45BCCAE-A4B4-4641-A260-415EDC2C1BBE"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SmartWeightsTests/PetPageTest.swift"
Expand Down Expand Up @@ -36,5 +36,21 @@
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "18B14073-9A1D-46E2-8340-73D171592111"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SmartWeights/pet-customize-page/PetPageViewModel.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "98"
endingLineNumber = "98"
landmarkName = "init()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "connection.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "dumbbellPlacement.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "dumbbellSensor.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "dumbbellSensorOn.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "dumbbellVelcro.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "elbow.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "elbowSensor.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "elbowVelcro.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "sensorOnElbow.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 7 additions & 30 deletions SmartWeights/SmartWeights/ChallengesTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,11 @@ import SwiftUI
import GameKit

struct ChallengesTab: View {
@State var challenges: [Challenge] = [
Challenge(title: "1st Workout", description: "Complete your first workout.", coinReward: "+ 50 PC", xpReward: "+ 10 XP", image: Image("C-1stWorkout"), achievementIdentifier: "SmartWeights.Achievement.1stWorkout", currentProgress: 0, isCompleted: false),
Challenge(title: "New Shopper", description: "Purchase your first item in the pet store.", coinReward: "+ 50 PC", xpReward: "+ 10 XP", image: Image("C-1stItemBought"), achievementIdentifier: "SmartWeights.Achievement.NewShopper", currentProgress: 0, isCompleted: false),
Challenge(title: "Outfit Change", description: "Customize your pet for the first time.", coinReward: "+ 50 PC", xpReward: "+ 10 XP", image: Image("C-1stOutfitChange"), achievementIdentifier: "SmartWeights.Achievement.OutfitChange", currentProgress: 0, isCompleted: false),
Challenge(title: "Sharing Companion", description: "Interact with the share button on the profile tab.", coinReward: "+ 50 PC", xpReward: "+ 10 XP", image: Image("SharingCompanion"), achievementIdentifier: "SmartWeights.Achievement.SharingCompanion", currentProgress: 0, isCompleted: false),
Challenge(title: "New Best Friends", description: "Level up your pet to level 2.", coinReward: "+ 100 PC", xpReward: "+ 20 XP", image: Image("NewBestFriends"), achievementIdentifier: "SmartWeights.Achievement.NewBestFriends", currentProgress: 0, isCompleted: false),
Challenge(title: "Dinner Time", description: "Feed your pet 50 times.", coinReward: "+ 250 PC", xpReward: "+ 50 XP", image: Image("DinnerTime"), achievementIdentifier: "SmartWeights.Achievement.DinnerTime", currentProgress: 0, isCompleted: false),
Challenge(title: "Loyal Customer", description: "Purchase 50 items in the pet store.", coinReward: "+ 500 PC", xpReward: "+ 75 XP", image: Image("LoyalCustomer"), achievementIdentifier: "SmartWeights.Achievement.LoyalCustomer", currentProgress: 0, isCompleted: false),
Challenge(title: "Workout Machine", description: "Complete 50 workouts.", coinReward: "+ 500 PC", xpReward: "+ 50 XP", image: Image("WorkoutMachine"), achievementIdentifier: "SmartWeights.Achievement.WorkoutMachine", currentProgress: 0, isCompleted: false),
Challenge(title: "Perfect Form", description: "Complete 100 workouts.", coinReward: "+ 1000 PC", xpReward: "+ 100 XP", image: Image("PerfectForm"), achievementIdentifier: "SmartWeights.Achievement.PerfectForm", currentProgress: 0, isCompleted: false),
Challenge(title: "Dynamic Duo", description: "Level up your pet to level 10.", coinReward: "+ 1500 PC", xpReward: "+ 100 XP", image: Image("DynamicDuo"), achievementIdentifier: "SmartWeights.Achievement.DynamicDuo", currentProgress: 0, isCompleted: false)
]
@ObservedObject var challengesViewModel = ChallengesViewModel()

var body: some View {
NavigationView {
ChallengesList(challenges: challenges, fetchGameCenterProgress: fetchGameCenterProgress)
ChallengesList(challenges: challengesViewModel.challenges, fetchGameCenterProgress: fetchGameCenterProgress)
.navigationBarTitle("Achievements", displayMode: .inline)
.preferredColorScheme(.light) // force light mode
}
Expand All @@ -36,12 +25,12 @@ struct ChallengesTab: View {
print("Error fetching achievements: \(error.localizedDescription)")
} else if let progressDict = progressDict {
DispatchQueue.main.async {
for i in self.challenges.indices {
if let percentComplete = progressDict[self.challenges[i].achievementIdentifier] {
for i in self.challengesViewModel.challenges.indices {
if let percentComplete = progressDict[self.challengesViewModel.challenges[i].achievementIdentifier] {
// Update the current progress with the fetched percent complete directly
self.challenges[i].currentProgress = Int(percentComplete)
self.challengesViewModel.challenges[i].currentProgress = Int(percentComplete)
// Determine if the challenge is completed based on whether the percent complete is 100
self.challenges[i].isCompleted = percentComplete == 100.0
self.challengesViewModel.challenges[i].isCompleted = percentComplete == 100.0
}
}
}
Expand All @@ -54,18 +43,14 @@ class Challenge: Identifiable, ObservableObject {
var id = UUID()
var title: String
var description: String
var coinReward: String
var xpReward: String
var image: Image // added for custom images
var achievementIdentifier: String
@Published var currentProgress: Int
@Published var isCompleted: Bool

init(title: String, description: String, coinReward: String, xpReward: String, image: Image, achievementIdentifier: String, currentProgress: Int, isCompleted: Bool) {
init(title: String, description: String, image: Image, achievementIdentifier: String, currentProgress: Int, isCompleted: Bool) {
self.title = title
self.description = description
self.coinReward = coinReward
self.xpReward = xpReward
self.image = image
self.achievementIdentifier = achievementIdentifier
self.currentProgress = currentProgress
Expand Down Expand Up @@ -130,14 +115,6 @@ struct ChallengesList: View {
.foregroundColor(.gray)
}
Spacer()
VStack(alignment: .trailing) {
Text(challenge.coinReward)
.font(.subheadline)
.foregroundColor(.green)
Text(challenge.xpReward)
.font(.subheadline)
.foregroundColor(.green)
}
}
ProgressView(value: Double(challenge.currentProgress), total: 100)
.progressViewStyle(LinearProgressViewStyle())
Expand Down
24 changes: 24 additions & 0 deletions SmartWeights/SmartWeights/ChallengesViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ChallengesViewModel.swift
// SmartWeights
//
// Created by Timothy Bui on 4/23/24.
//

import SwiftUI
import Foundation

class ChallengesViewModel: ObservableObject {
@Published var challenges: [Challenge] = [
Challenge(title: "1st Workout", description: "Complete your first workout.", image: Image("C-1stWorkout"), achievementIdentifier: "SmartWeights.Achievement.1stWorkout", currentProgress: 0, isCompleted: false),
Challenge(title: "New Shopper", description: "Purchase your first item in the pet store.", image: Image("C-1stItemBought"), achievementIdentifier: "SmartWeights.Achievement.NewShopper", currentProgress: 0, isCompleted: false),
Challenge(title: "Outfit Change", description: "Customize your pet for the first time.", image: Image("C-1stOutfitChange"), achievementIdentifier: "SmartWeights.Achievement.OutfitChange", currentProgress: 0, isCompleted: false),
Challenge(title: "Sharing Companion", description: "Interact with the share button on the profile tab.", image: Image("SharingCompanion"), achievementIdentifier: "SmartWeights.Achievement.SharingCompanion", currentProgress: 0, isCompleted: false),
Challenge(title: "New Best Friends", description: "Level up your pet to level 2.", image: Image("NewBestFriends"), achievementIdentifier: "SmartWeights.Achievement.NewBestFriends", currentProgress: 0, isCompleted: false),
Challenge(title: "Dinner Time", description: "Feed your pet 50 times.", image: Image("DinnerTime"), achievementIdentifier: "SmartWeights.Achievement.DinnerTime", currentProgress: 0, isCompleted: false),
Challenge(title: "Loyal Customer", description: "Purchase 50 items in the pet store.", image: Image("LoyalCustomer"), achievementIdentifier: "SmartWeights.Achievement.LoyalCustomer", currentProgress: 0, isCompleted: false),
Challenge(title: "Workout Machine", description: "Complete 50 workouts.", image: Image("WorkoutMachine"), achievementIdentifier: "SmartWeights.Achievement.WorkoutMachine", currentProgress: 0, isCompleted: false),
Challenge(title: "Perfect Form", description: "Complete 100 workouts.", image: Image("PerfectForm"), achievementIdentifier: "SmartWeights.Achievement.PerfectForm", currentProgress: 0, isCompleted: false),
Challenge(title: "Dynamic Duo", description: "Level up your pet to level 10.", image: Image("DynamicDuo"), achievementIdentifier: "SmartWeights.Achievement.DynamicDuo", currentProgress: 0, isCompleted: false)
]
}
Loading

0 comments on commit e300639

Please sign in to comment.