Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Timer Stats View is Updating
Browse files Browse the repository at this point in the history
  • Loading branch information
josiahdowdy committed Dec 18, 2021
1 parent 87b7513 commit 3dd507f
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Art_Athlete.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@
2C131564273386D3001019BA /* iOS */,
2C663A9327234FCF0097AEFE /* Supporting Files */,
2C663A5C271DC98E0097AEFE /* Shared */,
2CED7E0D27272A3000B99CAD /* Entity DB */,
2C02D896253A2C5A00D5F960 /* tests */,
2C02D8A1253A2C5A00D5F960 /* UI_tests */,
2C663A60271E1D720097AEFE /* Frameworks */,
Expand All @@ -444,6 +443,7 @@
2C02D884253A2C5700D5F960 /* Art_Athlete */ = {
isa = PBXGroup;
children = (
2CED7E0D27272A3000B99CAD /* Entity DB */,
2C02D88B253A2C5900D5F960 /* Preview Content */,
2C02D885253A2C5700D5F960 /* pose_referenceApp.swift */,
2C02D8C2253A50D200D5F960 /* Views */,
Expand Down
22 changes: 13 additions & 9 deletions Art_Athlete/Views/Buttons/ToggleSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ struct toggleSwitch: View {
@EnvironmentObject var prefs: GlobalVariables

var body: some View {
Text("Random")
.foregroundColor(prefs.isRandom ? .green : .gray)
Toggle("Random", isOn: $prefs.isRandom)
.labelsHidden()
.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(lineWidth: 2)
.foregroundColor(prefs.isRandom ? .green : .gray)
)
Toggle("Random Order", isOn: $prefs.isRandom)
// HStack{
// Text("Random Order")
// .foregroundColor(prefs.isRandom ? .green : .gray)
// Toggle("Random", isOn: $prefs.isRandom)
// .labelsHidden()
// .overlay(
// RoundedRectangle(cornerRadius: 15)
// .stroke(lineWidth: 2)
// .foregroundColor(prefs.isRandom ? .green : .gray)
// )
// }

}
}

Expand Down
83 changes: 46 additions & 37 deletions Art_Athlete/Views/MainViews/Bottom/SettingsSlideCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,58 +21,64 @@ struct ArtAthleteSettings : View {

var body: some View {
VStack {
HStack {
Text("Settings")//.font(.title)
.bold()
.foregroundColor(Color("ColorAccentWhite"))
.background(Color("ColorGrayTwo"))
.cornerRadius(2)
.font(.subheadline)
// .alignmentGuide(.center, computeValue: { _ in 90 } )
Button("Done") {
prefs.showSettings = false
}.alignmentGuide(.trailing, computeValue: { _ in 90 } )

// Button(action: {
// self.locationManager.requestAlwaysAuthorization()
// // self.locationManager.requestWhenInUseAuthorization()
// }) {
// Text("Request authorization")
// }
ZStack {
HStack{
Spacer()
Text("Settings")//.font(.title)
.font(.title3)
Spacer()
}
HStack {
Spacer()
Button("Done") {
prefs.showSettings = false
}.padding(.trailing, 10).foregroundColor(.blue)//.alignmentGuide(.trailing, computeValue: { _ in 90 } )
}
}

toggleSwitch()

Spacer()
}
// Spacer()


Form {
Section(header: Text("Notifications")) {
Picker("Notify Me About", selection: $notifyMeAbout) {
Text("Direct Messages")//.tag(NotifyMeAboutType.directMessages)
Text("Mentions")//.tag(NotifyMeAboutType.mentions)
Text("Anything")//.tag(NotifyMeAboutType.anything)
}
Toggle("Play notification sounds", isOn: $playNotificationSounds)
Toggle("Send read receipts", isOn: $sendReadReceipts)

Section() {
Toggle("Show Timer", isOn: $playNotificationSounds)
Toggle("Show Session Options", isOn: $sendReadReceipts)
toggleSwitch()

}
Section(header: Text("User Profiles")) {
Picker("Profile Image Size", selection: $profileImageSize) {
Text("Large")//.tag(ProfileImageSize.large)
Text("Medium")//.tag(ProfileImageSize.medium)
Text("Small")//.tag(ProfileImageSize.small)
}

Section(header: Text("Reset")) {
// Picker("Profile Image Size", selection: $profileImageSize) {
// Text("Large")//.tag(ProfileImageSize.large)
// Text("Medium")//.tag(ProfileImageSize.medium)
// Text("Small")//.tag(ProfileImageSize.small)
// }
Button {
deleteFilesInDirectory()
} label: {
HStack {
Image(systemName: "trash.circle")
Text("Delete All Photos")
}
}

Button {
//deleteFilesInDirectory()
} label: {
HStack {
Image(systemName: "0.circle.fill")
Text("Reset All User Stats")
}
}
Text("Files").font(.title3)

//Text("Please email me with any bugs or features you'd like to see added :)")
Text("Support: [email protected]")
}

}

}
}
//End view
Expand All @@ -96,6 +102,9 @@ struct ArtAthleteSettings : View {
print("JD451: THIS WORKS, but it does NOT delete the document directory. Just everything inside of it. ••••••\n", error)
}

let documentsFolder = try Folder(path: "/users/john/folder")


print("JD451: Files in Documents -->", FileManager.default.urls(for: .documentDirectory) ?? "none") //Extension upgraded this to show directory folders.
// return path
}
Expand Down
11 changes: 5 additions & 6 deletions Art_Athlete/Views/MainViews/Bottom/TimerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct TimerView: View{
entity: UserData.entity(), sortDescriptors: []
//sortDescriptors: [NSSortDescriptor(keyPath: \UserData.countPoses, ascending: true)]
)
var testData : FetchedResults<UserData>
var userData : FetchedResults<UserData>

// @Binding var startSession: Bool
/*
Expand Down Expand Up @@ -86,8 +86,7 @@ struct TimerView: View{
//If the time is less than
if self.timeObject.currentTime < timeObject.timeChosen {
self.timeObject.currentTime += 1
print("Time: \(self.timeObject.currentTime)")

userData[0].timeDrawn += 1
self.timeObject.progressValue += Float(1 / timeObject.timeChosen)

} else if (timeObject.currentTime == timeObject.timeChosen) {
Expand All @@ -98,11 +97,11 @@ struct TimerView: View{
if (prefs.currentIndex + 1 < prefs.sPoseCount) {
prefs.currentIndex += 1
prefs.sURL = prefs.arrayOfURLStrings[self.prefs.currentIndex]


updateSession() //Only done at end of session. And called when quit.
} else {
testData[testData.count - 1].countPoses += 1 //Add 1 more pose count if the user finishees. DO NOT put this in endSession function, otherwise it'll get called when that function is called in other areas like quit.
userData[0].timeDrawn += 1 //Is this needed?
userData[userData.count - 1].countPoses += 1 //Add 1 more pose count if the user finishees. DO NOT put this in endSession function, otherwise it'll get called when that function is called in other areas like quit.
endSession()
}
}
Expand All @@ -114,7 +113,7 @@ struct TimerView: View{
//Update data in future.
func updateSession(){
posesCount += 1
testData[testData.count - 1].countPoses += 1
userData[userData.count - 1].countPoses += 1

do{
try context.save()
Expand Down
14 changes: 7 additions & 7 deletions Art_Athlete/Views/MainViews/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ struct ContentView: View {

//MARK: - FUNCTIONS
public func scanAllFolders() {
if (UIDevice.current.userInterfaceIdiom == .mac) {
print("JD451: mac")
Folder.documents!.subfolders.recursive.forEach { folder in
homeData.folders.append(Product(type: .Poses, title: folder.name, subtitle: "xx", count: folder.files.count()))
/// Different on mac --> folder.files vs Folder.documents!.files
}
}
// if (UIDevice.current.userInterfaceIdiom == .mac) {
// print("JD451: mac")
// Folder.documents!.subfolders.recursive.forEach { folder in
// homeData.folders.append(Product(type: .Poses, title: folder.name, subtitle: "xx", count: folder.files.count()))
// /// Different on mac --> folder.files vs Folder.documents!.files
// }
// }

///important --> when running "My Mac (designed for ipad)", this if statement is used.
// if (UIDevice.current.userInterfaceIdiom == .pad) {
Expand Down
13 changes: 13 additions & 0 deletions Art_Athlete/Views/MainViews/HomeScreenButtonsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,23 @@ struct HomeScreenButtonsView: View {
//MARK: - VIEW
var body: some View {
NavigationView {

VStack {
// if UIDevice.current.userInterfaceIdiom == (.phone) {
// HStack() {
// Text("Art Athlete").font(.title3).padding(.leading)
// Text("Photo Timer").font(.caption)
// Spacer()
// }
// }
//FileImporterView() //This loads in photos MARK: [BLUE BOX]


MultipleSelectRow(rowSelection: $rowSelection, isloadingPhotos: $isloadingPhotos)
.environmentObject(homeData)

if UIDevice.current.userInterfaceIdiom == (.phone) {

Text(prefs.error)
countPickerView()
timePickerView()
Expand All @@ -72,7 +82,10 @@ struct HomeScreenButtonsView: View {

if UIDevice.current.userInterfaceIdiom != (.phone) {
VStack { // MARK: - Shows the main screen (right side).
Text("Art Athlete").font(.title)
Text("Photo Timer").font(.caption)
VStack {

if !(isloadingPhotos) {
Text(prefs.error)
// Spacer().frame(maxWidth: .infinity)
Expand Down
19 changes: 9 additions & 10 deletions Art_Athlete/Views/MainViews/MultipleSelectRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,20 @@ struct MultipleSelectRow: View {
HStack {
Text("Photos").font(.title3)
.foregroundColor(currentDarkLightMode == .dark ? Color.white : Color.black)
if (UIDevice.current.userInterfaceIdiom == .mac) {
LoadFoldersButton(isloadingPhotos: $isloadingPhotos)
.environmentObject(homeData)
}
// if (UIDevice.current.userInterfaceIdiom == .mac) {
// LoadFoldersButton(isloadingPhotos: $isloadingPhotos)
// .environmentObject(homeData)
// }

if !(UIDevice.current.userInterfaceIdiom == .mac) {
///if !(UIDevice.current.userInterfaceIdiom == .mac) {
LoadFoldersButtoniPad(isloadingPhotos: $isloadingPhotos).environmentObject(homeData)
}
//}

Spacer()


// Text("Files").font(.title3)
if (UIDevice.current.userInterfaceIdiom == .mac) {
Text("Files").font(.title3)
}
}.padding()

List {
Expand All @@ -81,8 +82,6 @@ struct MultipleSelectRow: View {
}
} //End func.



private func deleteAllFolders() {
homeData.folders.removeAll()
}
Expand Down
2 changes: 1 addition & 1 deletion Art_Athlete/Views/Stats/StatsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct StatsView: View {
// Text("\(Image(systemName: "clock")) Draw time: \(userObject.totalTimeDrawn ?? 999)").padding(.top, 10)


Text("\(Image(systemName: "clock")) Total Draw time: \(sumTimeDrawn)").padding(.top, 10)
Text("\(Image(systemName: "clock")) Total Draw time: \((sumTimeDrawn/60)) minutes").padding(.top, 10)

Text("\(Image(systemName: "pencil.and.outline")) Poses drawn: \(sumPoses)").padding(.top, 10)

Expand Down

0 comments on commit 3dd507f

Please sign in to comment.