Skip to content

Commit

Permalink
Merge pull request #482 from pennlabs/change-dining-slope
Browse files Browse the repository at this point in the history
made the slope average of total + last7
  • Loading branch information
christinaqiu3 authored Jan 21, 2024
2 parents 92233c0 + 22e14aa commit dee15ff
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 25 deletions.
4 changes: 4 additions & 0 deletions PennMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
CF29A1771FB788820067D946 /* OnboardingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF29A1671FB7887E0067D946 /* OnboardingController.swift */; };
CF29A1781FB788820067D946 /* PageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF29A1681FB7887E0067D946 /* PageCell.swift */; };
CF7FCA761FAFCD9E0052F0A9 /* RoomSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */; };
E735C9422AF81498000F7376 /* DiningSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E735C9412AF81498000F7376 /* DiningSettingsView.swift */; };
EF23946423EF4117005BA55F /* GSRGroupInviteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */; };
EF30077223EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF30077123EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift */; };
EF30077423EE139F006C9CF0 /* HomeGroupInvitesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF30077323EE139F006C9CF0 /* HomeGroupInvitesCell.swift */; };
Expand Down Expand Up @@ -680,6 +681,7 @@
CF29A1671FB7887E0067D946 /* OnboardingController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingController.swift; sourceTree = "<group>"; };
CF29A1681FB7887E0067D946 /* PageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageCell.swift; sourceTree = "<group>"; };
CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSelectionViewController.swift; sourceTree = "<group>"; };
E735C9412AF81498000F7376 /* DiningSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiningSettingsView.swift; sourceTree = "<group>"; };
EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSRGroupInviteCell.swift; sourceTree = "<group>"; };
EF30077123EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCellItem.swift; sourceTree = "<group>"; };
EF30077323EE139F006C9CF0 /* HomeGroupInvitesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1392,6 +1394,7 @@
6CC88D5627B1BF50006896F6 /* DiningViewControllerSwiftUI.swift */,
6CC88D5527B1BF50006896F6 /* DiningViewModelSwiftUI.swift */,
6CC88D3527B1BF50006896F6 /* Views */,
E735C9412AF81498000F7376 /* DiningSettingsView.swift */,
);
path = SwiftUI;
sourceTree = "<group>";
Expand Down Expand Up @@ -2513,6 +2516,7 @@
219F01F61FB7E14B006BBC4E /* SelectionCell.swift in Sources */,
2190FD351EC625BB00EC683C /* Protocols.swift in Sources */,
2189C0A82027CE4B00771C1F /* ThumbLayer.swift in Sources */,
E735C9422AF81498000F7376 /* DiningSettingsView.swift in Sources */,
21B653B92245EB67001A97C5 /* PennAuthRequestable.swift in Sources */,
421B03CA29E22035003AE6DC /* FitnessRoomRow.swift in Sources */,
F2C7E5F5259EE1CA0043A98A /* CourseAlertSettings.swift in Sources */,
Expand Down
26 changes: 20 additions & 6 deletions PennMobile/Dining/SwiftUI/DiningAnalyticsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct DiningAnalyticsView: View {
@State var showMissingDiningTokenAlert = false
@State var showDiningLoginView = false
@State var notLoggedInAlertShowing = false
@State var showSettingsSheet = false
@Environment(\.presentationMode) var presentationMode
func showCorrectAlert () -> Alert {
if !Account.isLoggedIn {
Expand All @@ -30,6 +31,17 @@ struct DiningAnalyticsView: View {
let dollarHistory = $diningAnalyticsViewModel.dollarHistory
let swipeHistory = $diningAnalyticsViewModel.swipeHistory
HStack {
Spacer()
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
showSettingsSheet.toggle()
}) {
Image(systemName: "gear")
.imageScale(.large)
}
}
}
if Account.isLoggedIn, let diningExpiration = UserDefaults.standard.getDiningTokenExpiration(), Date() <= diningExpiration {
if dollarHistory.wrappedValue.isEmpty && swipeHistory.wrappedValue.isEmpty {
ZStack {
Expand All @@ -45,9 +57,6 @@ struct DiningAnalyticsView: View {
} else {
ScrollView {
VStack(alignment: .leading, spacing: 20) {
Text("Dining Analytics")
.font(.system(size: 32))
.bold()
// Only show dollar history view if there is data for the graph
if !dollarHistory.wrappedValue.isEmpty {
CardView {
Expand Down Expand Up @@ -80,6 +89,10 @@ struct DiningAnalyticsView: View {
DiningLoginNavigationView()
.environmentObject(diningAnalyticsViewModel)
}
.navigationTitle("Analytics")
.sheet(isPresented: $showSettingsSheet) {
DiningSettingsView(viewModel: diningAnalyticsViewModel) // Replace with your settings view
}
} else {
let dollarXYHistory = Binding(
get: {
Expand Down Expand Up @@ -109,9 +122,6 @@ struct DiningAnalyticsView: View {
} else {
ScrollView {
VStack(alignment: .leading, spacing: 20) {
Text("Dining Analytics")
.font(.system(size: 32))
.bold()
// Only show dollar history view if there is data for the graph
if !dollarXYHistory.wrappedValue.isEmpty {
CardView {
Expand Down Expand Up @@ -144,6 +154,10 @@ struct DiningAnalyticsView: View {
DiningLoginNavigationView()
.environmentObject(diningAnalyticsViewModel)
}
.navigationTitle("Analytics")
.sheet(isPresented: $showSettingsSheet) {
DiningSettingsView(viewModel: diningAnalyticsViewModel)
}
}
}
}
Expand Down
73 changes: 73 additions & 0 deletions PennMobile/Dining/SwiftUI/DiningSettingsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// DiningSettingsView.swift
// PennMobile
//
// Created by Christina Qiu on 11/5/23.
// Copyright © 2023 PennLabs. All rights reserved.
//

import SwiftUI
import PennMobileShared

struct DiningSettingsView: View {
@ObservedObject var viewModel: DiningAnalyticsViewModel

@Environment(\.presentationMode) var presentationMode
@State private var totalData = false
private let options = ["All data",
"Smart calculation",
"Weighted average"]

var body: some View {
if #available(iOS 16.0, *) {
NavigationView {
Form {
Picker(selection: $viewModel.selectedOptionIndex, label: Text("Slope Calculation")) {
ForEach(0..<options.count, id: \.self) { index in
Text(options[index]).tag(index)
}
}
.pickerStyle(MenuPickerStyle())

// Toggle("Include guest swipes", isOn: $totalData)
}
.navigationBarTitle("Dining Analytics Settings", displayMode: .inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
presentationMode.wrappedValue.dismiss()
}) {
Text("Done")
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
.presentationDetents([.medium])
} else {
NavigationView {
Form {
Picker(selection: $viewModel.selectedOptionIndex, label: Text("Slope Calculation")) {
ForEach(0..<options.count, id: \.self) { index in
Text(options[index]).tag(index)
}
}
.pickerStyle(MenuPickerStyle())

// Toggle("Include guest swipes", isOn: $totalData)
}
.navigationBarTitle("Dining Analytics Settings", displayMode: .inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
presentationMode.wrappedValue.dismiss()
}) {
Text("Done")
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
}
}
Loading

0 comments on commit dee15ff

Please sign in to comment.