Skip to content
Open
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
8 changes: 8 additions & 0 deletions app/dime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
AEADEF742AE94DC3006EB614 /* ToolbarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEADEF722AE94DC3006EB614 /* ToolbarButton.swift */; };
AEADEF752AE94DC3006EB614 /* Toolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEADEF732AE94DC3006EB614 /* Toolbar.swift */; };
AECE7F9E2AED1A6800B57267 /* SuggestedTransactions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECE7F9D2AED1A6800B57267 /* SuggestedTransactions.swift */; };
C5C6FA032E3D5A4800C6AED7 /* SettingsNotificationCustomTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5C6FA022E3D5A3600C6AED7 /* SettingsNotificationCustomTimeView.swift */; };
C5C6FA052E3D5A6F00C6AED7 /* UserDefaultsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5C6FA042E3D5A6E00C6AED7 /* UserDefaultsExtension.swift */; };
D63B204A2D8728C300CAFB20 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D63B20462D8728C300CAFB20 /* Localizable.strings */; };
D63B204B2D8728C300CAFB20 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = D63B20482D8728C300CAFB20 /* Localizable.stringsdict */; };
D6A4DE202D61744400F7F751 /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = D6A4DE1F2D61744400F7F751 /* SwiftUIIntrospect */; };
Expand Down Expand Up @@ -331,6 +333,8 @@
AEADEF722AE94DC3006EB614 /* ToolbarButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolbarButton.swift; sourceTree = "<group>"; };
AEADEF732AE94DC3006EB614 /* Toolbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Toolbar.swift; sourceTree = "<group>"; };
AECE7F9D2AED1A6800B57267 /* SuggestedTransactions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestedTransactions.swift; sourceTree = "<group>"; };
C5C6FA022E3D5A3600C6AED7 /* SettingsNotificationCustomTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsNotificationCustomTimeView.swift; sourceTree = "<group>"; };
C5C6FA042E3D5A6E00C6AED7 /* UserDefaultsExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsExtension.swift; sourceTree = "<group>"; };
D63B20472D8728C300CAFB20 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Localizations/en.lproj/Localizable.strings; sourceTree = "<group>"; };
D63B20492D8728C300CAFB20 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = Localizations/en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -472,6 +476,7 @@
5327D296287C69A400F76ADF /* Utilities */ = {
isa = PBXGroup;
children = (
C5C6FA042E3D5A6E00C6AED7 /* UserDefaultsExtension.swift */,
5358E9182AC885E3003E8CA9 /* AlertToast.swift */,
53A839C028D732E1006F227C /* TabBarHiding.swift */,
53A839B928D33840006F227C /* UnlockManager.swift */,
Expand Down Expand Up @@ -621,6 +626,7 @@
53D6BDDB2AF73E1900F5728E /* Settings Subviews */ = {
isa = PBXGroup;
children = (
C5C6FA022E3D5A3600C6AED7 /* SettingsNotificationCustomTimeView.swift */,
53D6BDD92AF73DE900F5728E /* SettingsCloudView.swift */,
53D6BDD72AF73CFC00F5728E /* SettingsEraseView.swift */,
53D6BDCB2AF73BC800F5728E /* SettingsCurrencyView.swift */,
Expand Down Expand Up @@ -924,6 +930,7 @@
5327D2C8287C6B2500F76ADF /* ChartTimeFrame.swift in Sources */,
536FA6C12A7E05C600C52490 /* GetInsightsIntent.swift in Sources */,
533D1C3E2AE8023B00894764 /* PencilShape.swift in Sources */,
C5C6FA032E3D5A4800C6AED7 /* SettingsNotificationCustomTimeView.swift in Sources */,
532C58BC2A629C3900DA2C81 /* NewBudgetView.swift in Sources */,
AE5B3D792AEE99E000AB364E /* NumberPad.swift in Sources */,
53D5F02328A8E0E4004573C8 /* InsightsWidget.swift in Sources */,
Expand Down Expand Up @@ -972,6 +979,7 @@
53D40B652AB1B2DB001D3866 /* UpdateSheet.swift in Sources */,
5327D2BA287C6AFB00F76ADF /* ViewExtension.swift in Sources */,
5327D2DB287C6B5F00F76ADF /* LogView.swift in Sources */,
C5C6FA052E3D5A6F00C6AED7 /* UserDefaultsExtension.swift in Sources */,
5362CF322A92750800244744 /* ImportDataView.swift in Sources */,
5327D287287C697400F76ADF /* dimeApp.swift in Sources */,
53A4147728B3B559008C30E7 /* WelcomeSheetView.swift in Sources */,
Expand Down
26 changes: 26 additions & 0 deletions app/dime/Utilities/UserDefaultsExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// UserDefaultsExtension.swift
// dime
//
// Created by Ahmer Mughal on 01.08.25.
//

import Foundation

extension UserDefaults {
private static let customTimerKey = "customTimerList"

func saveCustomTimerList(_ dates: [Date]) {
if let encoded = try? JSONEncoder().encode(dates) {
set(encoded, forKey: UserDefaults.customTimerKey)
}
}

func loadCustomTimerList() -> [Date] {
if let savedData = data(forKey: UserDefaults.customTimerKey),
let decoded = try? JSONDecoder().decode([Date].self, from: savedData) {
return decoded
}
return []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//
// SettingsNotificationCustomTimeView.swift
// dime
//
// Created by Ahmer Mughal on 31.07.25.
//

import SwiftUI

struct SettingsNotificationCustomTimeView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>

@Binding var customTimerList: [Date]

var onDismiss: (() -> Void)

var body: some View {
VStack {
Text("Custom Times")
.font(.system(.title3, design: .rounded).weight(.semibold))
.foregroundColor(Color.PrimaryText)
.frame(maxWidth: .infinity)
.overlay(alignment: .leading) {
Button {
self.presentationMode.wrappedValue.dismiss()
self.onDismiss()
} label: {
SettingsBackButton()
}
}
.padding(.bottom, 20)
.padding(.horizontal, 20)

if #available(iOS 16.0, *) {
List {
ForEach(customTimerList.indices, id: \.self) { index in
HStack{
Text("Custom Time")
.font(.system(.body, design: .rounded))
.foregroundColor(Color.PrimaryText)

Spacer()

DatePicker(
"Select Time",
selection: Binding(
get: { customTimerList[index] },
set: { customTimerList[index] = $0 }
),
displayedComponents: .hourAndMinute
)
.labelsHidden()
}
.listRowBackground(Color.SettingsBackground)
.padding(.vertical, 1)

}
.onDelete(perform: delete)

Button(action: {
customTimerList.append(Date()) // Add new date picker
}) {
HStack {
Image(systemName: "plus.circle.fill")
.font(.title2)
.foregroundColor(Color.PrimaryText)
Text("Add Time")
.font(.system(.body, design: .rounded))
.foregroundColor(Color.PrimaryText)
}
.foregroundColor(.blue)
.frame(maxWidth: .infinity, alignment: .center)
.padding(.vertical, 4)
}
.listRowBackground(Color.SettingsBackground)

}
.scrollContentBackground(.hidden)

} else {
List {
ForEach(customTimerList.indices, id: \.self) { index in
HStack{
Text("Custom Time")
.font(.system(.body, design: .rounded))
.foregroundColor(Color.PrimaryText)

Spacer()

DatePicker(
"Select Time",
selection: Binding(
get: { customTimerList[index] },
set: { customTimerList[index] = $0 }
),
displayedComponents: .hourAndMinute
)
.labelsHidden()
}
.listRowBackground(Color.SettingsBackground)
.padding(.vertical, 1)

}

Button(action: {
customTimerList.append(Date())
}) {
HStack {
Image(systemName: "plus.circle.fill")
.font(.title2)
.foregroundColor(Color.PrimaryText)
Text("Add Time")
.font(.system(.body, design: .rounded))
.foregroundColor(Color.PrimaryText)
}
.foregroundColor(.blue)
.frame(maxWidth: .infinity, alignment: .center)
.padding(.vertical, 9)
.padding(.horizontal, 0)
}
.listRowBackground(Color.SettingsBackground)
}
.background(Color.clear)
}

}
.navigationBarBackButtonHidden(true)
.navigationBarTitle("")
.navigationBarHidden(true)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.background(Color.PrimaryBackground)
.dynamicTypeSize(...DynamicTypeSize.xxxLarge)
.padding(.vertical, 20)
}

func delete(at offsets: IndexSet) {
customTimerList.remove(atOffsets: offsets)
}
}

#Preview {
SettingsNotificationCustomTimeView(customTimerList: .constant([Date.now, Date.now]), onDismiss: {})
}
Loading