Skip to content

Commit

Permalink
dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos committed Sep 21, 2023
1 parent e2323e4 commit 2b4c3aa
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .idea/artifacts/common_desktop_1_0_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/desktop_jvm_1_0_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/ktlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions common/src/commonMain/kotlin/com/example/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ package com.example.common

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import com.example.common.model.AttendanceTei
import com.example.common.model.StudentModel
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme

@Composable
fun App() {
val student = StudentModel("Manu", "Muñoz", true)
val students = listOf(student, student, student, student, student)
DHIS2Theme {
LazyColumn {
items(8) {
AttendanceItem(
AttendanceTei(
firstName = "Manu",
lastName = "Muñoz",
attend = false,
),
)
}
AttendanceScreen(
students
) {

}
}
}


61 changes: 48 additions & 13 deletions common/src/commonMain/kotlin/com/example/common/AttendanceItem.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,70 @@
package com.example.common

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.example.common.model.AttendanceTei
import androidx.compose.ui.draw.drawBehind
import com.example.common.model.StudentModel
import org.hisp.dhis.mobile.ui.designsystem.component.CheckBox
import org.hisp.dhis.mobile.ui.designsystem.component.CheckBoxData
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

@Composable
fun AttendanceItem(attendanceItem: AttendanceTei) {
Row {
fun StudentItem(
attendanceItem: StudentModel,
onChecked: (Boolean) -> Unit,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
attendanceItem.firstName.first().toString(),
style = MaterialTheme.typography.labelLarge,
color = TextColor.OnPrimary,
modifier = Modifier
.background(SurfaceColor.Primary, CircleShape)
.padding(Spacing.Spacing10),
.padding(Spacing.Spacing24)
.drawBehind {
drawCircle(
color = SurfaceColor.Primary,
radius = this.size.maxDimension,
)
}
,
)
Text(
attendanceItem.firstName + attendanceItem.lastName,
style = MaterialTheme.typography.titleLarge,
color = TextColor.OnSurface,
modifier = Modifier.padding(Spacing.Spacing10),
Column {
Text(
attendanceItem.firstName,
style = MaterialTheme.typography.titleSmall,
color = TextColor.OnSurface,
modifier = Modifier.padding(top = Spacing.Spacing8),
)
Text(
attendanceItem.lastName,
style = MaterialTheme.typography.labelMedium,
color = TextColor.OnSurface.copy(alpha = 0.7f),
modifier = Modifier.padding(top = Spacing.Spacing4),
)
}
Spacer(modifier = Modifier.weight(1f))
CheckBox(
modifier = Modifier.padding(Spacing.Spacing16),
checkBoxData = CheckBoxData(
uid = "",
checked = attendanceItem.attend,
enabled = true,
textInput = null,
),
onCheckedChange = onChecked,
)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.example.common

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.example.common.model.StudentModel
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AttendanceScreen(
students: List<StudentModel>,
onAttendanceClicked: (StudentModel) -> Unit
) {
Scaffold(
topBar = {
TopAppBar(
title = { Text(
text = "Attendance",
color = TextColor.OnPrimary,
modifier = Modifier.padding(start = Spacing.Spacing8),
) },
navigationIcon = { Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = null,
modifier = Modifier.padding(start = Spacing.Spacing8),
) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = SurfaceColor.Primary,
titleContentColor = TextColor.OnPrimary,
navigationIconContentColor = TextColor.OnPrimary)
)
}
)
{
Column(Modifier.padding(it).fillMaxHeight()) {
Text(
modifier = Modifier.padding(vertical = Spacing.Spacing8, horizontal = Spacing.Spacing16),
text = "6th grade, A",
style = MaterialTheme.typography.titleLarge
)
Text(
modifier = Modifier.padding(start = Spacing.Spacing16),
text = "Friday, Sep. 21, 2023",
style = MaterialTheme.typography.titleMedium
)
LazyColumn(Modifier.padding(top = Spacing.Spacing8)) {
items(students) { student ->
StudentItem(student) {
onAttendanceClicked.invoke(student.copy(attend = it))
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.common.model

data class AttendanceTei(
data class StudentModel(
val firstName: String,
val lastName: String,
val attend: Boolean
Expand Down

0 comments on commit 2b4c3aa

Please sign in to comment.