Skip to content

Commit

Permalink
Merge pull request #124 from DroidKaigi/feature/74-timetable-header-t…
Browse files Browse the repository at this point in the history
…ake2

Fixed day buttons (missing data to do anything yet)
  • Loading branch information
takahirom authored Jul 19, 2024
2 parents 4be46ba + 43e795f commit a016a03
Showing 1 changed file with 27 additions and 56 deletions.
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

0 comments on commit a016a03

Please sign in to comment.