-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
280 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
wearApp/src/main/java/nl/tiebe/otarium/wear/ui/home/grades/GradeScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package nl.tiebe.otarium.wear.ui.home.grades | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.derivedStateOf | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn | ||
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState | ||
import androidx.wear.compose.material3.ListHeader | ||
import androidx.wear.compose.material3.Text | ||
import androidx.wear.compose.material3.TitleCard | ||
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState | ||
import dev.tiebe.magisterapi.response.general.year.grades.RecentGrade | ||
import nl.tiebe.otarium.MR | ||
import nl.tiebe.otarium.logic.root.home.children.grades.RecentGradesComponent | ||
import nl.tiebe.otarium.utils.ui.getLocalizedString | ||
|
||
@Composable | ||
fun GradeScreen(component: RecentGradesComponent) { | ||
component.refreshGrades() | ||
val grades = component.grades.subscribeAsState().value | ||
|
||
val listState = rememberScalingLazyListState() | ||
val reachedEnd by remember { derivedStateOf { listState.centerItemIndex >= (grades.size * 0.5).toInt() } } | ||
|
||
LaunchedEffect(reachedEnd) { | ||
if (!component.refreshState.value) | ||
component.loadNextGrades() | ||
} | ||
|
||
ScalingLazyColumn(modifier = Modifier.fillMaxSize(), state = listState) { | ||
item { ListHeader { | ||
Text(text = getLocalizedString(MR.strings.gradesItem)) | ||
} } | ||
for (grade in grades) { | ||
item { GradeItem(grade) } | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun GradeItem(grade: RecentGrade) { | ||
TitleCard(onClick = {}, title = { | ||
Text(text = grade.subject.description + ": " + grade.description) | ||
}, subtitle = { | ||
Text(grade.grade, maxLines = 1) | ||
}) | ||
} |
12 changes: 12 additions & 0 deletions
12
wearApp/src/main/java/nl/tiebe/otarium/wear/ui/home/timetable/TimetableItemPopup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package nl.tiebe.otarium.wear.ui.home.timetable | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.wear.compose.material3.Text | ||
import nl.tiebe.otarium.magister.AgendaItemWithAbsence | ||
|
||
|
||
//TODO: finish this, too lazy to do right now | ||
@Composable | ||
fun TimetableItemPopup(item: AgendaItemWithAbsence) { | ||
Text(text = "Popup!") | ||
} |
15 changes: 15 additions & 0 deletions
15
wearApp/src/main/java/nl/tiebe/otarium/wear/ui/home/timetable/TimetableRootScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package nl.tiebe.otarium.wear.ui.home.timetable | ||
|
||
import androidx.compose.runtime.Composable | ||
import nl.tiebe.otarium.logic.root.home.children.timetable.TimetableRootComponent | ||
import nl.tiebe.otarium.wear.ui.utils.SwipeToDismissBox | ||
|
||
@Composable | ||
fun TimetableRootScreen(component: TimetableRootComponent) { | ||
SwipeToDismissBox(stack = component.childStack, onDismissed = { component.back() }) { | ||
when (val instance = it.instance) { | ||
is TimetableRootComponent.Child.TimetableChild -> TimetableScreen(component.timetableComponent) | ||
is TimetableRootComponent.Child.TimetablePopupChild -> TimetableItemPopup(instance.agendaItem) | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
wearApp/src/main/java/nl/tiebe/otarium/wear/ui/home/timetable/TimetableScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package nl.tiebe.otarium.wear.ui.home.timetable | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.toArgb | ||
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn | ||
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState | ||
import androidx.wear.compose.material3.ListHeader | ||
import androidx.wear.compose.material3.MaterialTheme | ||
import androidx.wear.compose.material3.Text | ||
import androidx.wear.compose.material3.TitleCard | ||
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState | ||
import kotlinx.datetime.Clock | ||
import kotlinx.datetime.DatePeriod | ||
import kotlinx.datetime.TimeZone | ||
import kotlinx.datetime.plus | ||
import kotlinx.datetime.toLocalDateTime | ||
import nl.tiebe.otarium.logic.root.home.children.timetable.children.timetable.TimetableComponent | ||
import nl.tiebe.otarium.magister.AgendaItemWithAbsence | ||
import nl.tiebe.otarium.ui.utils.HtmlView | ||
import nl.tiebe.otarium.utils.toFormattedStringTime | ||
import java.time.format.TextStyle | ||
import java.util.Locale | ||
|
||
@Composable | ||
fun TimetableScreen(component: TimetableComponent) { | ||
val today = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).date | ||
|
||
component.refreshTimetable(today, today + DatePeriod(days = 31)) | ||
|
||
val listState = rememberScalingLazyListState() | ||
val items = component.timetable.subscribeAsState().value.groupBy { it.start.toLocalDateTime(TimeZone.currentSystemDefault()).date } | ||
|
||
ScalingLazyColumn(modifier = Modifier.fillMaxSize(), state = listState) { | ||
for ((day, timetableItems) in items) { | ||
item { ListHeader { | ||
Text(day.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault()) + " ${day.dayOfMonth}-${day.monthNumber}") | ||
} } | ||
for (item in timetableItems) item { TimetableItem(item = item) { /*component.parentComponent.navigate(TimetableRootComponent.Config.TimetablePopup(item))*/ } } | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun TimetableItem(item: AgendaItemWithAbsence, onClick: () -> Unit) { | ||
TitleCard(onClick = onClick, title = { | ||
Text(text = item.agendaItem.subjects.firstOrNull()?.name?.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() } ?: item.agendaItem.description ?: "No description") | ||
}, subtitle = { | ||
if (item.agendaItem.content != null) HtmlView(html = item.agendaItem.content!!, maxLines = 1, backgroundColor = -1, textColor = MaterialTheme.colorScheme.onSurface.toArgb()) | ||
}, time = { Text("${item.start.toFormattedStringTime(false)} - ${item.end.toFormattedStringTime(false)}") }) | ||
} |
Oops, something went wrong.