Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -30,7 +30,7 @@ import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.assertLabelEquals
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithLabel
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import dagger.hilt.android.testing.HiltAndroidRule
Expand Down Expand Up @@ -69,16 +69,16 @@ class CalendarTest {

@Test
fun scrollsToTheBottom() {
composeTestRule.onNodeWithLabel("January 1").assertExists()
composeTestRule.onNodeWithLabel("December 31").performScrollTo().performClick()
composeTestRule.onNodeWithText("January 1").assertExists()
composeTestRule.onNodeWithText("December 31").performScrollTo().performClick()
assert(datesRepository.datesSelected.toString() == "Dec 31")
}

@Test
fun onDaySelected() {
composeTestRule.onNodeWithLabel("January 1").assertExists()
composeTestRule.onNodeWithLabel("January 2").assertExists().performClick()
composeTestRule.onNodeWithLabel("January 3").assertExists()
composeTestRule.onNodeWithText("January 1").assertExists()
composeTestRule.onNodeWithText("January 2").assertExists().performClick()
composeTestRule.onNodeWithText("January 3").assertExists()

val datesNoSelected = composeTestRule.onDateNodes(NoSelected)
datesNoSelected[0].assertLabelEquals("January 1")
Expand All @@ -89,13 +89,13 @@ class CalendarTest {

@Test
fun twoDaysSelected() {
composeTestRule.onNodeWithLabel("January 2").assertExists().performClick()
composeTestRule.onNodeWithText("January 2").assertExists().performClick()

val datesNoSelectedOneClick = composeTestRule.onDateNodes(NoSelected)
datesNoSelectedOneClick[0].assertLabelEquals("January 1")
datesNoSelectedOneClick[1].assertLabelEquals("January 3")

composeTestRule.onNodeWithLabel("January 4").assertExists().performClick()
composeTestRule.onNodeWithText("January 4").assertExists().performClick()

composeTestRule.onDateNode(FirstDay).assertLabelEquals("January 2")
composeTestRule.onDateNode(Selected).assertLabelEquals("January 3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private fun CraneBaseUserInput(
showCaption: () -> Boolean = { true },
tintIcon: () -> Boolean,
tint: Color = AmbientContentColor.current,
children: @Composable () -> Unit
content: @Composable () -> Unit
) {
Surface(modifier = modifier, color = MaterialTheme.colors.primaryVariant) {
Row(Modifier.padding(all = 12.dp)) {
Expand All @@ -138,15 +138,15 @@ private fun CraneBaseUserInput(
Spacer(Modifier.preferredWidth(8.dp))
}
Row(Modifier.weight(1f).align(Alignment.CenterVertically)) {
children()
content()
}
}
}
}

@Preview
@Composable
fun previewInput() {
fun PreviewInput() {
CraneScaffold {
CraneBaseUserInput(
tintIcon = { true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.lazy.LazyColumnFor
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
Expand Down Expand Up @@ -62,16 +62,19 @@ fun ExploreSection(
style = MaterialTheme.typography.caption.copy(color = crane_caption)
)
Spacer(Modifier.preferredHeight(8.dp))
LazyColumnFor(
LazyColumn(
modifier = Modifier.weight(1f),
items = exploreList
) { item ->
ExploreItem(
modifier = Modifier.fillParentMaxWidth(),
item = item,
onItemClicked = onItemClicked
)
Divider(color = crane_divider_color)
) {
items(exploreList) { exploreItem ->
Column(Modifier.fillParentMaxWidth()) {
ExploreItem(
modifier = Modifier.fillParentMaxWidth(),
item = exploreItem,
onItemClicked = onItemClicked
)
Divider(color = crane_divider_color)
}
}
}
}
}
Expand Down Expand Up @@ -119,8 +122,8 @@ private fun ExploreItem(
}

@Composable
private fun ExploreImageContainer(children: @Composable () -> Unit) {
private fun ExploreImageContainer(content: @Composable () -> Unit) {
Surface(Modifier.preferredSize(width = 60.dp, height = 60.dp), RoundedCornerShape(4.dp)) {
children()
content()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.samples.crane.ui.CraneTheme

@Composable
fun CraneScaffold(children: @Composable () -> Unit) {
fun CraneScaffold(content: @Composable () -> Unit) {
CraneTheme {
Surface(color = MaterialTheme.colors.primary) {
children()
content()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.SemanticsPropertyKey
import androidx.compose.ui.semantics.SemanticsPropertyReceiver
import androidx.compose.ui.semantics.accessibilityLabel
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -137,7 +137,7 @@ private fun Week(
day,
onDayClicked,
Modifier.semantics {
accessibilityLabel = "${month.name} ${day.value}"
contentDescription = "${month.name} ${day.value}"
dayStatusProperty = day.status
}
)
Expand Down Expand Up @@ -195,21 +195,21 @@ private fun Day(name: String) {
private fun DayContainer(
modifier: Modifier = Modifier,
backgroundColor: Color = Color.Transparent,
children: @Composable () -> Unit
content: @Composable () -> Unit
) {
// What if this doesn't fit the screen? - LayoutFlexible(1f) + LayoutAspectRatio(1f)
Surface(
modifier = modifier.preferredSize(width = CELL_SIZE, height = CELL_SIZE),
color = backgroundColor
) {
children()
content()
}
}

@Composable
private fun DayStatusContainer(
status: DaySelectedStatus,
children: @Composable () -> Unit
content: @Composable () -> Unit
) {
if (status.isMarked()) {
Box {
Expand All @@ -220,10 +220,10 @@ private fun DayStatusContainer(
} else if (status == DaySelectedStatus.LastDay) {
SemiRect(color = color, lookingLeft = true)
}
children()
content()
}
} else {
children()
content()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data class CalendarMonth(
val monthNumber: Int,
val startDayOfWeek: DayOfWeek
) {
val days = mutableListOf<CalendarDay>().apply {
private val days = mutableListOf<CalendarDay>().apply {
// Add offset of the start of the month
for (i in 1..startDayOfWeek.ordinal) {
add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.material.Button
import androidx.compose.material.ButtonConstants
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -186,7 +186,7 @@ private fun ZoomControls(
private fun ZoomButton(text: String, onClick: () -> Unit) {
Button(
modifier = Modifier.padding(8.dp),
colors = ButtonConstants.defaultButtonColors(
colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.onPrimary,
contentColor = MaterialTheme.colors.primary
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ fun EatSearchContent(datesSelected: String, eatUpdates: EatSearchContentUpdates)
}

@Composable
private fun CraneSearch(searchItems: @Composable () -> Unit) {
private fun CraneSearch(content: @Composable () -> Unit) {
Column(Modifier.padding(start = 24.dp, top = 0.dp, end = 24.dp, bottom = 12.dp)) {
searchItems()
content()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ val BottomSheetShape = RoundedCornerShape(
)

@Composable
fun CraneTheme(children: @Composable () -> Unit) {
fun CraneTheme(content: @Composable () -> Unit) {
MaterialTheme(colors = craneColors, typography = craneTypography) {
children()
content()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object Libs {
}

object Accompanist {
private const val version = "0.4.0"
private const val version = "0.4.1.compose-7033025-SNAPSHOT"
const val coil = "dev.chrisbanes.accompanist:accompanist-coil:$version"
}

Expand All @@ -49,8 +49,8 @@ object Libs {

object AndroidX {
object Compose {
const val snapshot = ""
const val version = "1.0.0-alpha08"
const val snapshot = "7033025"
private const val version = "1.0.0-SNAPSHOT"

const val runtime = "androidx.compose.runtime:runtime:$version"
const val runtimeLivedata = "androidx.compose.runtime:runtime-livedata:$version"
Expand Down