Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed day buttons (missing data to do anything yet) #124

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package io.github.droidkaigi.confsched.sessions

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material.icons.Icons
Expand All @@ -21,18 +21,14 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -58,7 +54,6 @@ import io.github.droidkaigi.confsched.ui.UserMessageStateHolder
import io.github.droidkaigi.confsched.ui.UserMessageStateHolderImpl
import io.github.droidkaigi.confsched.ui.compositionlocal.FakeClock
import io.github.droidkaigi.confsched.ui.compositionlocal.LocalClock
import io.github.droidkaigi.confsched.ui.getScreenSizeInfo
import kotlinx.collections.immutable.toPersistentMap

const val timetableScreenRoute = "timetable"
Expand Down Expand Up @@ -128,28 +123,6 @@ data class TimetableScreenUiState(
val userMessageStateHolder: UserMessageStateHolder,
)

private val timetableTopBackgroundLight = Color(0xFFF6FFD3)
private val timetableTopBackgroundDark = Color(0xFF2D4625)

@Composable
@ReadOnlyComposable
private fun timetableTopBackground() = if (!isSystemInDarkTheme()) {
timetableTopBackgroundLight
} else {
timetableTopBackgroundDark
}

private val timetableTopGradientLight = Color(0xFFA9E5FF)
private val timetableTopGradientDark = Color(0xFF050D10)

@Composable
@ReadOnlyComposable
private fun timetableTopGradient() = if (!isSystemInDarkTheme()) {
timetableTopGradientLight
} else {
timetableTopGradientDark
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun TimetableScreen(
Expand All @@ -161,34 +134,11 @@ private fun TimetableScreen(
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(),
) {
val density = LocalDensity.current
val layoutDirection = LocalLayoutDirection.current
val gradientEndRatio =
if (getScreenSizeInfo().isPort) {
0.2f
} else {
0.5f
}
val timetableTopGradient = timetableTopGradient()
val bottomPaddingPx = with(density) { contentPadding.calculateBottomPadding().toPx() }
Scaffold(
modifier = modifier
.testTag(TimetableScreenTestTag)
.background(timetableTopBackground())
.drawWithCache {
onDrawBehind {
drawRect(
brush = Brush.verticalGradient(
0f to timetableTopGradient,
gradientEndRatio to Color.Transparent,
),
size = Size(
size.width,
size.height - bottomPaddingPx,
),
)
}
},
.background(Color.Black),
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
topBar = {
TopAppBar(
Expand Down Expand Up @@ -228,9 +178,30 @@ private fun TimetableScreen(
),
containerColor = Color.Transparent,
) { innerPadding ->
Box(
modifier = Modifier.padding(top = innerPadding.calculateTopPadding()),
Column(
modifier = Modifier.padding(top = innerPadding.calculateTopPadding()).fillMaxWidth(),
) {
// TODO: Row not showing yet... there is a layout problem here I need to fix
Row {
TextButton(
modifier = Modifier.background(Color.Black),
onClick = { /* TODO: Search here */ },
) {
Text("Workday", color = Color.Green)
}
TextButton(
modifier = Modifier.background(Color.Black),
onClick = { /* TODO: Search here */ },
) {
Text("Day 1", color = Color.Green)
}
TextButton(
modifier = Modifier.background(Color.Black),
onClick = { /* TODO: Search here */ },
) {
Text("Day 2", color = Color.Green)
}
}
TimetableSheet(
modifier = Modifier
.fillMaxSize(),
Expand Down
Loading