Skip to content

Commit 7528182

Browse files
authored
Merge pull request #6 from KhubaibKhan4/feature/home_redesign
-Add Notes And Home Screen Redesign
2 parents 7594d9a + a11d313 commit 7528182

8 files changed

Lines changed: 1610 additions & 547 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Whitespace-only changes.
Binary file not shown.

Notes/NotesApp.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
//
77

88
import SwiftUI
9+
import SwiftData
910

1011
@main
1112
struct NotesApp: App {
1213

1314
@StateObject var appManager: AppManager = AppManager()
1415

15-
16-
1716
var body: some Scene {
1817
WindowGroup {
1918
ContentView()
20-
.modelContainer(for: [NotesItem.self,TodoItem.self])
19+
.modelContainer(for: [NotesItem.self, TodoItem.self])
2120
.environment(\.locale, Locale(identifier: appManager.appLanguage))
2221
.environmentObject(appManager)
2322
.preferredColorScheme(appManager.isDark ? .dark : .light)

Notes/data/NotesItem.swift

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class NotesItem: Identifiable {
1515
var title: String
1616
var desc: String
1717
var isPinned: Bool
18+
19+
// Persist coordinates separately; expose as computed CLLocationCoordinate2D
1820
var latitude: Double?
1921
var longitude: Double?
2022
var location: CLLocationCoordinate2D? {
@@ -30,10 +32,29 @@ class NotesItem: Identifiable {
3032
}
3133
}
3234

33-
var images: [Data]?
35+
// Media
36+
// Store image data externally to avoid Core Data transformable class issues and keep the store slim.
37+
@Attribute(.externalStorage) var images: [Data]?
3438
var videoURL: URL?
3539

36-
init(title: String, desc: String, isPinned: Bool, location: CLLocationCoordinate2D? = nil, images: [Data]? = nil, videoURL: URL? = nil) {
40+
// New fields
41+
var tags: [String]
42+
@Relationship(deleteRule: .cascade) var checklist: [ChecklistItem]
43+
var createdAt: Date
44+
var updatedAt: Date
45+
46+
init(
47+
title: String,
48+
desc: String,
49+
isPinned: Bool,
50+
location: CLLocationCoordinate2D? = nil,
51+
images: [Data]? = nil,
52+
videoURL: URL? = nil,
53+
tags: [String] = [],
54+
checklist: [ChecklistItem] = [],
55+
createdAt: Date = Date(),
56+
updatedAt: Date = Date()
57+
) {
3758
self.id = UUID().uuidString
3859
self.title = title
3960
self.desc = desc
@@ -42,5 +63,22 @@ class NotesItem: Identifiable {
4263
self.longitude = location?.longitude
4364
self.images = images
4465
self.videoURL = videoURL
66+
self.tags = tags
67+
self.checklist = checklist
68+
self.createdAt = createdAt
69+
self.updatedAt = updatedAt
70+
}
71+
}
72+
73+
@Model
74+
class ChecklistItem: Identifiable {
75+
var id: String
76+
var title: String
77+
var isDone: Bool
78+
79+
init(id: String = UUID().uuidString, title: String, isDone: Bool = false) {
80+
self.id = id
81+
self.title = title
82+
self.isDone = isDone
4583
}
4684
}

0 commit comments

Comments
 (0)