@@ -37,144 +37,26 @@ import androidx.compose.ui.graphics.Color
37
37
import androidx.compose.ui.res.painterResource
38
38
import androidx.compose.ui.text.style.TextAlign
39
39
import androidx.compose.ui.unit.dp
40
+ import androidx.room.Delete
40
41
import com.example.studysmart.R
41
42
import com.example.studysmart.domain.model.Session
42
43
import com.example.studysmart.domain.model.Subject
43
44
import com.example.studysmart.domain.model.Task
44
45
import com.example.studysmart.presentation.components.AddSubjectDialog
45
46
import com.example.studysmart.presentation.components.CountCard
47
+ import com.example.studysmart.presentation.components.DeleteDialog
46
48
import com.example.studysmart.presentation.components.SubjectCard
47
49
import com.example.studysmart.presentation.components.studySessionsList
48
50
import com.example.studysmart.presentation.components.tasksList
51
+ import com.example.studysmart.sessions
52
+ import com.example.studysmart.subjects
53
+ import com.example.studysmart.tasks
49
54
50
55
@Composable
51
56
fun DashboardScreen () {
52
57
53
- val subjects = listOf (
54
- Subject (
55
- name = " English" ,
56
- goalHours = 10f ,
57
- colors = Subject .subjectCardColors[0 ],
58
- subjectId = 0
59
- ),
60
- Subject (
61
- name = " Physics" ,
62
- goalHours = 10f ,
63
- colors = Subject .subjectCardColors[1 ],
64
- subjectId = 0
65
- ),
66
- Subject (
67
- name = " Maths" ,
68
- goalHours = 10f ,
69
- colors = Subject .subjectCardColors[2 ],
70
- subjectId = 0
71
- ),
72
- Subject (
73
- name = " Geology" ,
74
- goalHours = 10f ,
75
- colors = Subject .subjectCardColors[3 ],
76
- subjectId = 0
77
- ),
78
- Subject (
79
- name = " Fine Arts" ,
80
- goalHours = 10f ,
81
- colors = Subject .subjectCardColors[4 ],
82
- subjectId = 0
83
- ),
84
- )
85
-
86
- val tasks = listOf (
87
- Task (
88
- title = " Prepare notes" ,
89
- description = " " ,
90
- dueDate = 0L ,
91
- priority = 0 ,
92
- relatedToSubject = " " ,
93
- isComplete = false ,
94
- taskSubjectId = 0 ,
95
- taskId = 1
96
- ),
97
- Task (
98
- title = " Do Homework" ,
99
- description = " " ,
100
- dueDate = 0L ,
101
- priority = 1 ,
102
- relatedToSubject = " " ,
103
- isComplete = true ,
104
- taskSubjectId = 0 ,
105
- taskId = 1
106
- ),
107
- Task (
108
- title = " Go Coaching" ,
109
- description = " " ,
110
- dueDate = 0L ,
111
- priority = 2 ,
112
- relatedToSubject = " " ,
113
- isComplete = false ,
114
- taskSubjectId = 0 ,
115
- taskId = 1
116
- ),
117
- Task (
118
- title = " Assignment" ,
119
- description = " " ,
120
- dueDate = 0L ,
121
- priority = 1 ,
122
- relatedToSubject = " " ,
123
- isComplete = false ,
124
- taskSubjectId = 0 ,
125
- taskId = 1
126
- ),
127
- Task (
128
- title = " Write Poem" ,
129
- description = " " ,
130
- dueDate = 0L ,
131
- priority = 0 ,
132
- relatedToSubject = " " ,
133
- isComplete = true ,
134
- taskSubjectId = 0 ,
135
- taskId = 1
136
- )
137
- )
138
-
139
- val sessions = listOf (
140
- Session (
141
- relatedToSubject = " English" ,
142
- date = 0L ,
143
- duration = 2 ,
144
- sessionSubjectId = 0 ,
145
- sessionId = 0
146
- ),
147
- Session (
148
- relatedToSubject = " English" ,
149
- date = 0L ,
150
- duration = 2 ,
151
- sessionSubjectId = 0 ,
152
- sessionId = 0
153
- ),
154
- Session (
155
- relatedToSubject = " Physics" ,
156
- date = 0L ,
157
- duration = 2 ,
158
- sessionSubjectId = 0 ,
159
- sessionId = 0
160
- ),
161
- Session (
162
- relatedToSubject = " Maths" ,
163
- date = 0L ,
164
- duration = 2 ,
165
- sessionSubjectId = 0 ,
166
- sessionId = 0
167
- ),
168
- Session (
169
- relatedToSubject = " English" ,
170
- date = 0L ,
171
- duration = 2 ,
172
- sessionSubjectId = 0 ,
173
- sessionId = 0
174
- )
175
- )
176
-
177
58
var isAddSubjectDialogOpen by rememberSaveable { mutableStateOf(false ) }
59
+ var isDeleteSessionDialogOpen by rememberSaveable { mutableStateOf(false ) }
178
60
179
61
var subjectName by remember { mutableStateOf(" " ) }
180
62
var goalHours by remember { mutableStateOf(" " ) }
@@ -194,6 +76,15 @@ fun DashboardScreen() {
194
76
}
195
77
)
196
78
79
+ DeleteDialog (
80
+ isOpen = isDeleteSessionDialogOpen,
81
+ title = " Delete Session?" ,
82
+ bodyText = " Are you sure, you want to delete this session? Your studied hours will be reduced " +
83
+ " by this session time. This action can not be undone." ,
84
+ onDismissRequest = { isDeleteSessionDialogOpen = false },
85
+ onConfirmButtonClick = { isDeleteSessionDialogOpen = false }
86
+ )
87
+
197
88
Scaffold (
198
89
topBar = { DashboardScreenTopBar () }
199
90
) { paddingValues ->
@@ -245,7 +136,7 @@ fun DashboardScreen() {
245
136
emptyListText = " You don't have any recent study sessions.\n " +
246
137
" Start a study session to begin recording your progress." ,
247
138
sessions = sessions,
248
- onDeleteIconClick = {}
139
+ onDeleteIconClick = { isDeleteSessionDialogOpen = true }
249
140
)
250
141
}
251
142
}
0 commit comments