File tree Expand file tree Collapse file tree 4 files changed +24
-12
lines changed
Notes.xcworkspace/xcuserdata/rabeetahmad.xcuserdatad
Notes/presentation/screens Expand file tree Collapse file tree 4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -100,12 +100,15 @@ struct HomeScreen: View {
100100 . navigationTitle ( LocalizedStringKey ( " Notes " ) )
101101 . toolbar {
102102 ToolbarItem ( placement: . topBarLeading) {
103- Picker ( " " , selection: $sortMode) {
104- Label ( " Recent " , systemImage: " clock.arrow.circlepath " ) . tag ( SortMode . recent)
105- Label ( " Title " , systemImage: " textformat " ) . tag ( SortMode . title)
103+ Menu {
104+ Picker ( " Sort by " , selection: $sortMode) {
105+ Label ( " Recent " , systemImage: " clock.arrow.circlepath " ) . tag ( SortMode . recent)
106+ Label ( " Title " , systemImage: " textformat " ) . tag ( SortMode . title)
107+ }
108+ } label: {
109+ Image ( systemName: " arrow.up.arrow.down.circle " )
106110 }
107- . pickerStyle ( . segmented)
108- . frame ( maxWidth: 220 )
111+ . accessibilityLabel ( " Sort " )
109112 }
110113
111114 ToolbarItem ( placement: . topBarTrailing) {
Original file line number Diff line number Diff line change 66//
77
88import SwiftUI
9+ import SwiftData
910import CoreLocation
1011import MapKit
1112import AVKit
1213
1314struct NotesDetail : View {
14- @State var notesItem : NotesItem
15+ @Environment ( \. modelContext) private var context
16+
17+ @Bindable var notesItem : NotesItem
1518 @State private var imageSheetExpanded : Bool = false
1619 @State private var position : MapCameraPosition = . region(
1720 MKCoordinateRegion (
@@ -69,16 +72,22 @@ struct NotesDetail: View {
6972 . foregroundColor ( . secondary)
7073 }
7174
72- // Checklist details
75+ // Checklist details (interactive)
7376 if !notesItem. checklist. isEmpty {
7477 Section ( header: Text ( " Checklist " ) ) {
75- ForEach ( notesItem. checklist) { item in
76- HStack {
77- Image ( systemName: item. isDone ? " checkmark.circle.fill " : " circle " )
78- . foregroundColor ( item. isDone ? . green : . gray)
78+ ForEach ( $notesItem. checklist) { $item in
79+ Toggle ( isOn: $item. isDone) {
7980 Text ( item. title)
80- Spacer ( )
8181 }
82+ . onChange ( of: item. isDone) { _, _ in
83+ notesItem. updatedAt = Date ( )
84+ try ? context. save ( )
85+ }
86+ }
87+ . onDelete { offsets in
88+ notesItem. checklist. remove ( atOffsets: offsets)
89+ notesItem. updatedAt = Date ( )
90+ try ? context. save ( )
8291 }
8392 }
8493 }
You can’t perform that action at this time.
0 commit comments