Skip to content

Commit b5b5959

Browse files
SubjectScreen added
1 parent 78816d5 commit b5b5959

File tree

4 files changed

+441
-127
lines changed

4 files changed

+441
-127
lines changed

app/src/main/java/com/example/studysmart/MainActivity.kt

+130-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,144 @@ package com.example.studysmart
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6+
import com.example.studysmart.domain.model.Session
7+
import com.example.studysmart.domain.model.Subject
8+
import com.example.studysmart.domain.model.Task
69
import com.example.studysmart.presentation.dashboard.DashboardScreen
10+
import com.example.studysmart.presentation.subject.SubjectScreen
711
import com.example.studysmart.presentation.theme.StudySmartTheme
812

913
class MainActivity : ComponentActivity() {
1014
override fun onCreate(savedInstanceState: Bundle?) {
1115
super.onCreate(savedInstanceState)
1216
setContent {
1317
StudySmartTheme {
14-
DashboardScreen()
18+
SubjectScreen()
1519
}
1620
}
1721
}
18-
}
22+
}
23+
24+
val subjects = listOf(
25+
Subject(
26+
name = "English",
27+
goalHours = 10f,
28+
colors = Subject.subjectCardColors[0],
29+
subjectId = 0
30+
),
31+
Subject(
32+
name = "Physics",
33+
goalHours = 10f,
34+
colors = Subject.subjectCardColors[1],
35+
subjectId = 0
36+
),
37+
Subject(
38+
name = "Maths",
39+
goalHours = 10f,
40+
colors = Subject.subjectCardColors[2],
41+
subjectId = 0
42+
),
43+
Subject(
44+
name = "Geology",
45+
goalHours = 10f,
46+
colors = Subject.subjectCardColors[3],
47+
subjectId = 0
48+
),
49+
Subject(
50+
name = "Fine Arts",
51+
goalHours = 10f,
52+
colors = Subject.subjectCardColors[4],
53+
subjectId = 0
54+
),
55+
)
56+
57+
val tasks = listOf(
58+
Task(
59+
title = "Prepare notes",
60+
description = "",
61+
dueDate = 0L,
62+
priority = 0,
63+
relatedToSubject = "",
64+
isComplete = false,
65+
taskSubjectId = 0,
66+
taskId = 1
67+
),
68+
Task(
69+
title = "Do Homework",
70+
description = "",
71+
dueDate = 0L,
72+
priority = 1,
73+
relatedToSubject = "",
74+
isComplete = true,
75+
taskSubjectId = 0,
76+
taskId = 1
77+
),
78+
Task(
79+
title = "Go Coaching",
80+
description = "",
81+
dueDate = 0L,
82+
priority = 2,
83+
relatedToSubject = "",
84+
isComplete = false,
85+
taskSubjectId = 0,
86+
taskId = 1
87+
),
88+
Task(
89+
title = "Assignment",
90+
description = "",
91+
dueDate = 0L,
92+
priority = 1,
93+
relatedToSubject = "",
94+
isComplete = false,
95+
taskSubjectId = 0,
96+
taskId = 1
97+
),
98+
Task(
99+
title = "Write Poem",
100+
description = "",
101+
dueDate = 0L,
102+
priority = 0,
103+
relatedToSubject = "",
104+
isComplete = true,
105+
taskSubjectId = 0,
106+
taskId = 1
107+
)
108+
)
109+
110+
val sessions = listOf(
111+
Session(
112+
relatedToSubject = "English",
113+
date = 0L,
114+
duration = 2,
115+
sessionSubjectId = 0,
116+
sessionId = 0
117+
),
118+
Session(
119+
relatedToSubject = "English",
120+
date = 0L,
121+
duration = 2,
122+
sessionSubjectId = 0,
123+
sessionId = 0
124+
),
125+
Session(
126+
relatedToSubject = "Physics",
127+
date = 0L,
128+
duration = 2,
129+
sessionSubjectId = 0,
130+
sessionId = 0
131+
),
132+
Session(
133+
relatedToSubject = "Maths",
134+
date = 0L,
135+
duration = 2,
136+
sessionSubjectId = 0,
137+
sessionId = 0
138+
),
139+
Session(
140+
relatedToSubject = "English",
141+
date = 0L,
142+
duration = 2,
143+
sessionSubjectId = 0,
144+
sessionId = 0
145+
)
146+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.example.studysmart.presentation.components
2+
3+
import androidx.compose.material3.AlertDialog
4+
import androidx.compose.material3.Text
5+
import androidx.compose.material3.TextButton
6+
import androidx.compose.runtime.Composable
7+
8+
@Composable
9+
fun DeleteDialog(
10+
isOpen: Boolean,
11+
title: String,
12+
bodyText: String,
13+
onDismissRequest: () -> Unit,
14+
onConfirmButtonClick: () -> Unit
15+
) {
16+
if (isOpen) {
17+
AlertDialog(
18+
onDismissRequest = onDismissRequest,
19+
title = { Text(text = title) },
20+
text = { Text(text = bodyText) },
21+
dismissButton = {
22+
TextButton(onClick = onDismissRequest) {
23+
Text(text = "Cancel")
24+
}
25+
},
26+
confirmButton = {
27+
TextButton(onClick = onConfirmButtonClick) {
28+
Text(text = "Delete")
29+
}
30+
}
31+
)
32+
}
33+
}

app/src/main/java/com/example/studysmart/presentation/dashboard/DashboardScreen.kt

+16-125
Original file line numberDiff line numberDiff line change
@@ -37,144 +37,26 @@ import androidx.compose.ui.graphics.Color
3737
import androidx.compose.ui.res.painterResource
3838
import androidx.compose.ui.text.style.TextAlign
3939
import androidx.compose.ui.unit.dp
40+
import androidx.room.Delete
4041
import com.example.studysmart.R
4142
import com.example.studysmart.domain.model.Session
4243
import com.example.studysmart.domain.model.Subject
4344
import com.example.studysmart.domain.model.Task
4445
import com.example.studysmart.presentation.components.AddSubjectDialog
4546
import com.example.studysmart.presentation.components.CountCard
47+
import com.example.studysmart.presentation.components.DeleteDialog
4648
import com.example.studysmart.presentation.components.SubjectCard
4749
import com.example.studysmart.presentation.components.studySessionsList
4850
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
4954

5055
@Composable
5156
fun DashboardScreen() {
5257

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-
17758
var isAddSubjectDialogOpen by rememberSaveable { mutableStateOf(false) }
59+
var isDeleteSessionDialogOpen by rememberSaveable { mutableStateOf(false) }
17860

17961
var subjectName by remember { mutableStateOf("") }
18062
var goalHours by remember { mutableStateOf("") }
@@ -194,6 +76,15 @@ fun DashboardScreen() {
19476
}
19577
)
19678

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+
19788
Scaffold(
19889
topBar = { DashboardScreenTopBar() }
19990
) { paddingValues ->
@@ -245,7 +136,7 @@ fun DashboardScreen() {
245136
emptyListText = "You don't have any recent study sessions.\n " +
246137
"Start a study session to begin recording your progress.",
247138
sessions = sessions,
248-
onDeleteIconClick = {}
139+
onDeleteIconClick = { isDeleteSessionDialogOpen = true }
249140
)
250141
}
251142
}

0 commit comments

Comments
 (0)