Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.149",
"green" : "0.090",
"red" : "0.031"
"blue" : "0x25",
"green" : "0x16",
"red" : "0x07"
}
},
"idiom" : "universal"
Expand Down
6 changes: 3 additions & 3 deletions VITTY/Assets.xcassets/Colors/Secondary.colorset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.192",
"green" : "0.118",
"red" : "0.051"
"blue" : "0x30",
"green" : "0x1E",
"red" : "0x0D"
}
},
"idiom" : "universal"
Expand Down
2 changes: 2 additions & 0 deletions VITTY/VITTY.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
4B8B32DC2D6D75F6004F01BA /* VittyWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 4B8B32C82D6D75F4004F01BA /* VittyWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
4B8B33752D7029AA004F01BA /* SideBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B33742D7029A3004F01BA /* SideBar.swift */; };
4BA03C1D2D7584F3000756B0 /* AddFriend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA03C1C2D7584EA000756B0 /* AddFriend.swift */; };
4BA6DFE92E33D5CE00B0411A /* NotesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB00322D957A6A003B8FE2 /* NotesModel.swift */; };
4BBB00312D955163003B8FE2 /* AcademicsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB00302D95515C003B8FE2 /* AcademicsViewModel.swift */; };
4BBB00332D957A6A003B8FE2 /* NotesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB00322D957A6A003B8FE2 /* NotesModel.swift */; };
4BC853C32DF693780092B2E2 /* SaveTimeTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC853C22DF6936E0092B2E2 /* SaveTimeTableView.swift */; };
Expand Down Expand Up @@ -1248,6 +1249,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4BA6DFE92E33D5CE00B0411A /* NotesModel.swift in Sources */,
4B5977482DFAC034009CC224 /* RemainderModel.swift in Sources */,
4BC853C42DF6DA7A0092B2E2 /* TimeTable.swift in Sources */,
4B2D64902E20BA6300412CB7 /* NetworkMonitor.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions VITTY/VITTY/Academics/View/CourseRefs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ struct OCourseRefs: View {

// Expandable FAB
VStack(spacing: 16) {
// Action buttons (shown when expanded)

if showExpandedFAB {
VStack(spacing: 12) {
// Set Reminder Button

ExpandableFABButton(
icon: "bell.fill",
title: "Set Reminder",
Expand Down
86 changes: 58 additions & 28 deletions VITTY/VITTY/Academics/View/CreateReminder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ struct ReminderView: View {
Spacer()

Button("Add") {
// Combine selected date with start and end times
let calendar = Calendar.current
let dateComponents = calendar.dateComponents([.year, .month, .day], from: selectedDate)
let startTimeComponents = calendar.dateComponents([.hour, .minute], from: startTime)
let endTimeComponents = calendar.dateComponents([.hour, .minute], from: endTime)

let finalStartTime = calendar.date(from: DateComponents(
year: dateComponents.year,
month: dateComponents.month,
day: dateComponents.day,
hour: startTimeComponents.hour,
minute: startTimeComponents.minute
)) ?? startTime

let finalEndTime = calendar.date(from: DateComponents(
year: dateComponents.year,
month: dateComponents.month,
day: dateComponents.day,
hour: endTimeComponents.hour,
minute: endTimeComponents.minute
)) ?? endTime

let newReminder = Remainder(
title: title,
subject: courseName,
Expand All @@ -51,19 +73,18 @@ struct ReminderView: View {
date: selectedDate,
isCompleted: false,
subjectDescription: description,
startTime: startTime,
endTime: endTime
startTime: finalStartTime,
endTime: finalEndTime
)

do {
modelContext.insert(newReminder)
try modelContext.save()
print("Saved successfully")


NotificationManager.shared.scheduleReminderNotifications(
title: title,
date: startTime,
date: finalStartTime,
subject: courseName
)

Expand All @@ -84,6 +105,14 @@ struct ReminderView: View {
.font(.system(size: 32, weight: .bold))
.foregroundColor(.white)
.padding(.bottom)
.onTapGesture {
// Close pickers when tapping on title
withAnimation(.easeInOut(duration: 0.3)) {
showDatePicker = false
showStartTimePicker = false
showEndTimePicker = false
}
}

TextField("Title", text: $title)
.padding()
Expand Down Expand Up @@ -114,44 +143,50 @@ struct ReminderView: View {
Spacer()
Text(selectedDate, style: .date)
.foregroundColor(.gray)
.id(selectedDate)
Image(systemName: showDatePicker ? "chevron.down" : "chevron.right")
.foregroundColor(.gray)
.rotationEffect(.degrees(showDatePicker ? 0 : 0))
}
.padding()
.background(Color("Secondary"))
.cornerRadius(10)
.onTapGesture {
withAnimation(.easeInOut(duration: 0.3)) {

showStartTimePicker = false
showEndTimePicker = false
showDatePicker.toggle()
}
}

if showDatePicker {
DatePicker(
"Select Date",
selection: $selectedDate,
displayedComponents: [.date]
)
.datePickerStyle(.graphical)
.colorScheme(.dark)
.labelsHidden()
.onChange(of: selectedDate) {
VStack(spacing: 12) {
DatePicker(
"Select Date",
selection: $selectedDate,
displayedComponents: [.date]
)
.datePickerStyle(.graphical)
.colorScheme(.dark)
.labelsHidden()
.onChange(of: selectedDate) { oldValue, newValue in
print("Date changed from \(oldValue) to \(newValue)")
}

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
Button("Done") {
withAnimation(.easeInOut(duration: 0.3)) {
showDatePicker = false
}
}
.foregroundColor(.red)
.frame(maxWidth: .infinity, alignment: .trailing)
}
.padding()
.background(Color("Secondary"))
.cornerRadius(10)
.transition(.opacity.combined(with: .scale))
}
}


VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Start Time")
Expand All @@ -167,7 +202,6 @@ struct ReminderView: View {
.cornerRadius(10)
.onTapGesture {
withAnimation(.easeInOut(duration: 0.3)) {

showDatePicker = false
showEndTimePicker = false
showStartTimePicker.toggle()
Expand Down Expand Up @@ -195,11 +229,13 @@ struct ReminderView: View {
.foregroundColor(.red)
.frame(maxWidth: .infinity, alignment: .trailing)
}
.padding()
.background(Color("Secondary"))
.cornerRadius(10)
.transition(.opacity.combined(with: .scale))
}
}


VStack(alignment: .leading, spacing: 8) {
HStack {
Text("End Time")
Expand All @@ -215,7 +251,6 @@ struct ReminderView: View {
.cornerRadius(10)
.onTapGesture {
withAnimation(.easeInOut(duration: 0.3)) {

showDatePicker = false
showStartTimePicker = false
showEndTimePicker.toggle()
Expand Down Expand Up @@ -243,6 +278,9 @@ struct ReminderView: View {
.foregroundColor(.red)
.frame(maxWidth: .infinity, alignment: .trailing)
}
.padding()
.background(Color("Secondary"))
.cornerRadius(10)
.transition(.opacity.combined(with: .scale))
}
}
Expand All @@ -252,13 +290,5 @@ struct ReminderView: View {
}
}
.preferredColorScheme(.dark)
.onTapGesture {

withAnimation(.easeInOut(duration: 0.3)) {
showDatePicker = false
showStartTimePicker = false
showEndTimePicker = false
}
}
}
}
20 changes: 17 additions & 3 deletions VITTY/VITTY/Academics/View/Notes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,14 @@ struct NoteEditorView: View {
}

private func handleBackNavigation() {
// Check if there are unsaved changes or if it's a new note

if hasUnsavedChanges || (existingNote == nil && !isEmpty) {
showTitleAlert = true

if existingNote != nil && !noteTitle.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
saveNoteWithTitle()
} else {
showTitleAlert = true
}
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
if presentationMode.wrappedValue.isPresented {
Expand Down Expand Up @@ -230,8 +235,16 @@ struct NoteEditorView: View {
}

func saveContent() {
showTitleAlert = true

if existingNote != nil && !noteTitle.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
saveNoteWithTitle()
} else {

showTitleAlert = true
}
}



private func saveNoteWithTitle() {
guard !noteTitle.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
Expand All @@ -256,6 +269,7 @@ struct NoteEditorView: View {
noteContent: dataString,
createdAt: Date.now
)
print("saved with a course id of \(courseCode)")
modelContext.insert(newNote)
}

Expand Down
6 changes: 3 additions & 3 deletions VITTY/VITTY/Connect/View/ConnectPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ struct ConnectPage: View {
selectedTab = 0
}
communityPageViewModel.fetchCircleData(
from: "\(APIConstants.base_url)circles",
from: "\(APIConstants.base_urlv3)circles",
token: authViewModel.loggedInBackendUser?.token ?? "",
loading: true
)
Expand Down Expand Up @@ -177,15 +177,15 @@ struct ConnectPage: View {

if communityPageViewModel.circles.isEmpty || !hasLoadedInitialData {
communityPageViewModel.fetchCircleData(
from: "\(APIConstants.base_url)circles",
from: "\(APIConstants.base_urlv3)circles",
token: authViewModel.loggedInBackendUser?.token ?? "",
loading: shouldShowLoading
)
}

if communityPageViewModel.circleRequests.isEmpty || !hasLoadedInitialData {
friendRequestViewModel.fetchFriendRequests(
from: URL(string: "\(APIConstants.base_url)requests/")!,
from: URL(string: "\(APIConstants.base_urlv3)requests/")!,
authToken: authViewModel.loggedInBackendUser?.token ?? "",
loading: shouldShowLoading
)
Expand Down
Loading
Loading