Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-search-screen-placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom authored Sep 8, 2024
2 parents 20a99e6 + f73a145 commit 7ed774e
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package io.github.droidkaigi.confsched.primitive
import org.gradle.api.Plugin
import org.gradle.api.Project

// This plugin is used for debugging re-composition.
// Therefore, it may appear to be unused, but it is sometimes used.
@Suppress("unused")
class ComposeInvestigatorPlugin : Plugin<Project> {
override fun apply(target: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
Expand Down Expand Up @@ -105,19 +102,7 @@ fun ClickableLinkText(
findUrlResults = findResults,
)

val layoutResult = remember { mutableStateOf<LayoutCoordinates?>(null) }

val density = LocalDensity.current

val isOverflowing by remember {
derivedStateOf {
val actualHeight = layoutResult.value?.size?.height?.toFloat() ?: 0f
val expectedHeight = with(density) {
style.fontSize.toPx() + style.lineHeight.toPx() * (maxLines - 1)
}
actualHeight > expectedHeight
}
}
var isOverflowing by remember { mutableStateOf(false) }

LaunchedEffect(isOverflowing) {
onOverflow(isOverflowing)
Expand All @@ -127,14 +112,14 @@ fun ClickableLinkText(
modifier = modifier
.animateContentSize(
animationSpec = tween(ClickableTextExpandAnimateDurationMillis, easing = EaseInQuart),
)
.onGloballyPositioned { coordinates ->
layoutResult.value = coordinates
},
),
text = annotatedString,
style = style,
overflow = overflow,
maxLines = maxLines,
onTextLayout = { textLayoutResult ->
isOverflowing = textLayoutResult.hasVisualOverflow
},
onClick = { offset ->
findResults.forEach { matchResult ->
annotatedString.getStringAnnotations(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,48 @@ import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.vectorResource

@Composable
fun TimetableItemTag(
tagText: String,
modifier: Modifier = Modifier,
) {
TimetableItemTag(
tagText = tagText,
contentColor = MaterialTheme.colorScheme.onSurfaceVariant,
borderColor = MaterialTheme.colorScheme.outline,
icon = null,
modifier = modifier,
)
}

@Composable
fun TimetableItemTag(
tagText: String,
tagColor: Color,
icon: DrawableResource?,
modifier: Modifier = Modifier,
) {
TimetableItemTag(
tagText = tagText,
contentColor = tagColor,
borderColor = tagColor,
icon = icon,
modifier = modifier,
)
}

@Composable
private fun TimetableItemTag(
tagText: String,
contentColor: Color,
borderColor: Color,
icon: DrawableResource?,
modifier: Modifier = Modifier,
icon: DrawableResource? = null,
) {
Row(
modifier = modifier
.border(
border = BorderStroke(width = 1.dp, color = tagColor),
border = BorderStroke(width = 1.dp, color = borderColor),
shape = RoundedCornerShape(2.dp),
)
.padding(
Expand All @@ -44,11 +75,11 @@ fun TimetableItemTag(
modifier = Modifier.size(12.dp),
imageVector = vectorResource(ico),
contentDescription = "",
tint = tagColor,
tint = contentColor,
)
}
Text(
color = tagColor,
color = contentColor,
text = tagText,
style = MaterialTheme.typography.labelMedium,
maxLines = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package io.github.droidkaigi.confsched.about.component

import androidx.compose.animation.core.Animatable
import androidx.compose.foundation.Image
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction.Cancel
import androidx.compose.foundation.interaction.PressInteraction.Press
import androidx.compose.foundation.interaction.PressInteraction.Release
import androidx.compose.foundation.layout.size
import androidx.compose.material3.IconButton
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
Expand All @@ -23,9 +33,22 @@ fun AboutFooterLinksIcon(
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {
val animationScale by remember { mutableStateOf(Animatable(1f)) }

val interactionSource = remember { MutableInteractionSource() }
LaunchedEffect(interactionSource) {
interactionSource.interactions.collect {
when (it) {
is Press -> animationScale.animateTo(targetValue = 0.9f)
is Release, is Cancel -> animationScale.animateTo(targetValue = 1.0f)
}
}
}

IconButton(
onClick = onClick,
modifier = modifier.testTag(testTag),
interactionSource = interactionSource,
modifier = modifier.testTag(testTag).scale(animationScale.value),
) {
Image(
painter = painter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
Expand Down Expand Up @@ -131,16 +130,10 @@ fun FavoriteList(
modifier = Modifier.background(LocalRoomTheme.current.containerColor),
)
timetableItem.language.labels.forEach { label ->
TimetableItemTag(
tagText = label,
tagColor = MaterialTheme.colorScheme.outline,
)
TimetableItemTag(tagText = label)
}
timetableItem.day?.let {
TimetableItemTag(
tagText = "9/${it.dayOfMonth}",
tagColor = MaterialTheme.colorScheme.outline,
)
TimetableItemTag(tagText = "9/${it.dayOfMonth}")
}
},
timetableItem = timetableItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import conference_app_2024.feature.sessions.generated.resources.select_language
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched.designsystem.theme.LocalRoomTheme
import io.github.droidkaigi.confsched.droidkaigiui.component.TimetableItemTag
import io.github.droidkaigi.confsched.droidkaigiui.icon
import io.github.droidkaigi.confsched.droidkaigiui.rememberAsyncImagePainter
import io.github.droidkaigi.confsched.model.Lang
import io.github.droidkaigi.confsched.model.TimetableItem
Expand All @@ -66,26 +67,27 @@ fun TimetableItemDetailHeadline(
onLanguageSelect: (Lang) -> Unit,
modifier: Modifier = Modifier,
) {
val roomTheme = LocalRoomTheme.current
val currentLang = currentLang ?: timetableItem.language.toLang()

Column(
modifier = modifier
// FIXME: Implement and use a theme color instead of fixed colors like RoomColors.primary and RoomColors.primaryDim
.background(LocalRoomTheme.current.dimColor)
.background(roomTheme.dimColor)
.padding(horizontal = 8.dp)
.fillMaxWidth(),
) {
FlowRow {
TimetableItemTag(
modifier = Modifier.align(Alignment.CenterVertically),
tagText = timetableItem.room.name.currentLangTitle,
tagColor = LocalRoomTheme.current.primaryColor,
tagColor = roomTheme.primaryColor,
icon = timetableItem.room.icon,
)
timetableItem.language.labels.forEach { label ->
Spacer(modifier = Modifier.padding(4.dp))
TimetableItemTag(
modifier = Modifier.align(Alignment.CenterVertically),
tagText = label,
tagColor = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Spacer(modifier = Modifier.weight(1f))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.droidkaigi.confsched.sessions.section

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import io.github.droidkaigi.confsched.droidkaigiui.component.TimetableItemTag
Expand All @@ -27,10 +26,7 @@ fun SearchList(
modifier = modifier,
timetableItemTagsContent = { timetableItem ->
timetableItem.day?.monthAndDay()?.let { monthAndDay ->
TimetableItemTag(
tagText = monthAndDay,
tagColor = MaterialTheme.colorScheme.onSurfaceVariant,
)
TimetableItemTag(tagText = monthAndDay)
}
},
)
Expand Down
Loading

0 comments on commit 7ed774e

Please sign in to comment.