Skip to content

Commit

Permalink
Merge pull request #504 from Corvus400/feature/implement_middle_secti…
Browse files Browse the repository at this point in the history
…on_of_about_screen

✨ Implement Middle Section of AboutScreen
  • Loading branch information
takahirom authored Aug 15, 2023
2 parents fa5aee2 + f4e35d3 commit 46fb169
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ sealed class AboutStrings : Strings<AboutStrings>(Bindings) {
object PlaceTitle : AboutStrings()
object PlaceDescription : AboutStrings()
object PlaceLink : AboutStrings()
object CreditsTitle : AboutStrings()
object Staff : AboutStrings()
object Contributor : AboutStrings()
object Sponsor : AboutStrings()
object OthersTitle : AboutStrings()
object CodeOfConduct : AboutStrings()
object License : AboutStrings()
object PrivacyPolicy : AboutStrings()

private object Bindings : StringsBindings<AboutStrings>(
Lang.Japanese to { item, _ ->
when (item) {
Expand All @@ -22,17 +31,33 @@ sealed class AboutStrings : Strings<AboutStrings>(Bindings) {
PlaceTitle -> "場所"
PlaceDescription -> "ベルサール渋谷ガーデン"
PlaceLink -> "地図を見る"
CreditsTitle -> "Credits"
Staff -> "スタッフ"
Contributor -> "コントリビューター"
Sponsor -> "スポンサー"
OthersTitle -> "Others"
CodeOfConduct -> "行動規範"
License -> "ライセンス"
PrivacyPolicy -> "プライバシーポリシー"
}
},
Lang.English to { item, bindings ->
when (item) {
Title -> "About"
Title -> bindings.defaultBinding(item, bindings)
Description -> "DroidKaigi is a conference tailored for Android developers."
DateTitle -> "Date & Time"
DateDescription -> "2023.09.14(Thu) - 16(Sat) 3days"
PlaceTitle -> "Location"
PlaceDescription -> "Bellesalle Shibuya Garden"
PlaceLink -> "View Map"
CreditsTitle -> bindings.defaultBinding(item, bindings)
Staff -> "Staff"
Contributor -> "Contributor"
Sponsor -> "Sponsor"
OthersTitle -> bindings.defaultBinding(item, bindings)
CodeOfConduct -> "Code Of Conduct"
License -> "License"
PrivacyPolicy -> "Privacy Policy"
}
},
default = Lang.Japanese,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package io.github.droidkaigi.confsched2023.about.component

import android.content.res.Configuration
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.SentimentVerySatisfied
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.github.droidkaigi.confsched2023.about.AboutStrings
import io.github.droidkaigi.confsched2023.designsystem.theme.KaigiTheme

@Composable
fun AboutContentColumn(
leadingIcon: ImageVector,
label: String,
testTag: String,
onClickAction: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier
.fillMaxWidth()
.height(73.dp)
.testTag(testTag)
.clickable { onClickAction() },
) {
Row(
modifier = Modifier
.height(72.dp)
.align(
alignment = Alignment.Start,
),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = leadingIcon,
contentDescription = null,
modifier = Modifier
.padding(
horizontal = 12.dp,
),
)
Text(
text = label,
style = MaterialTheme.typography.labelLarge,
modifier = Modifier
.fillMaxWidth()
.padding(
end = 16.dp,
),
)
}
Divider(
thickness = 1.dp,
color = MaterialTheme.colorScheme.outlineVariant,
)
}
}

@Preview(locale = "en", uiMode = Configuration.UI_MODE_NIGHT_NO)
@Preview(locale = "ja", uiMode = Configuration.UI_MODE_NIGHT_NO)
@Composable
fun AboutContentColumnPreview() {
KaigiTheme {
Surface {
AboutContentColumn(
leadingIcon = Icons.Outlined.SentimentVerySatisfied,
label = AboutStrings.Staff.asString(),
testTag = "",
onClickAction = {},
)
}
}
}

@Preview(locale = "en", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Preview(locale = "ja", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
fun AboutContentColumnDarkModePreview() {
KaigiTheme {
Surface {
AboutContentColumn(
leadingIcon = Icons.Outlined.SentimentVerySatisfied,
label = AboutStrings.Staff.asString(),
testTag = "",
onClickAction = {},
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,72 @@
package io.github.droidkaigi.confsched2023.about.component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Apartment
import androidx.compose.material.icons.outlined.Diversity1
import androidx.compose.material.icons.outlined.SentimentVerySatisfied
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import io.github.droidkaigi.confsched2023.about.AboutStrings

const val AboutCreditsSponsorsItemTestTag = "AboutCreditsSponsorsItem"
const val AboutCreditsContributorsItemTestTag = "AboutCreditsContributorsItem"
const val AboutCreditsStaffItemTestTag = "AboutCreditsStaffItem"
const val AboutCreditsContributorsItemTestTag = "AboutCreditsContributorsItem"
const val AboutCreditsSponsorsItemTestTag = "AboutCreditsSponsorsItem"

fun LazyListScope.aboutCredits(
onStaffItemClick: () -> Unit,
onContributorsItemClick: () -> Unit,
onSponsorsItemClick: () -> Unit,
) {
item {
Text("Credits")
Text(
text = AboutStrings.CreditsTitle.asString(),
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.padding(
start = 16.dp,
top = 32.dp,
end = 16.dp,
),
)
}
item {
Text(
AboutContentColumn(
leadingIcon = Icons.Outlined.SentimentVerySatisfied,
label = AboutStrings.Staff.asString(),
testTag = AboutCreditsStaffItemTestTag,
onClickAction = onStaffItemClick,
modifier = Modifier
.testTag(AboutCreditsContributorsItemTestTag)
.clickable { onContributorsItemClick() },
text = "Go to contributors screen",
.padding(
horizontal = 16.dp,
),
)
}
item {
Text(
AboutContentColumn(
leadingIcon = Icons.Outlined.Diversity1,
label = AboutStrings.Contributor.asString(),
testTag = AboutCreditsContributorsItemTestTag,
onClickAction = onContributorsItemClick,
modifier = Modifier
.testTag(AboutCreditsStaffItemTestTag)
.clickable { onStaffItemClick() },
text = "Go to staff screen",
.padding(
horizontal = 16.dp,
),
)
}
item {
Text(
AboutContentColumn(
leadingIcon = Icons.Outlined.Apartment,
label = AboutStrings.Sponsor.asString(),
testTag = AboutCreditsSponsorsItemTestTag,
onClickAction = onSponsorsItemClick,
modifier = Modifier
.testTag(AboutCreditsSponsorsItemTestTag)
.clickable { onSponsorsItemClick() },
text = "Go to sponsors screen",
.padding(
horizontal = 16.dp,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ fun AboutDroidKaigiDetail(
start = 16.dp,
top = 12.dp,
end = 16.dp,
bottom = 16.dp,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package io.github.droidkaigi.confsched2023.about.component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.FileCopy
import androidx.compose.material.icons.outlined.Gavel
import androidx.compose.material.icons.outlined.PrivacyTip
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import io.github.droidkaigi.confsched2023.about.AboutStrings

const val AboutOthersCodeOfConductItemTestTag = "AboutOthersCodeOfConductItem"
const val AboutOthersLicenseItemTestTag = "AboutOthersLicenseItem"
Expand All @@ -15,33 +22,51 @@ fun LazyListScope.aboutOthers(
onPrivacyPolicyItemClick: () -> Unit,
) {
item {
Text("Others")
}
item {
Text("Others items")
Text(
text = AboutStrings.OthersTitle.asString(),
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.padding(
start = 16.dp,
top = 32.dp,
end = 16.dp,
),
)
}
item {
Text(
text = "Go to Code of Conduct screen",
modifier = androidx.compose.ui.Modifier
.testTag(AboutOthersCodeOfConductItemTestTag)
.clickable { onCodeOfConductItemClick() },
AboutContentColumn(
leadingIcon = Icons.Outlined.Gavel,
label = AboutStrings.CodeOfConduct.asString(),
testTag = AboutOthersCodeOfConductItemTestTag,
onClickAction = onCodeOfConductItemClick,
modifier = Modifier
.padding(
horizontal = 16.dp,
),
)
}
item {
Text(
text = "Go to License screen",
modifier = androidx.compose.ui.Modifier
.testTag(AboutOthersLicenseItemTestTag)
.clickable { onLicenseItemClick() },
AboutContentColumn(
leadingIcon = Icons.Outlined.FileCopy,
label = AboutStrings.License.asString(),
testTag = AboutOthersLicenseItemTestTag,
onClickAction = onLicenseItemClick,
modifier = Modifier
.padding(
horizontal = 16.dp,
),
)
}
item {
Text(
text = "Go to Privacy Policy screen",
modifier = androidx.compose.ui.Modifier
.testTag(AboutOthersPrivacyPolicyItemTestTag)
.clickable { onPrivacyPolicyItemClick() },
AboutContentColumn(
leadingIcon = Icons.Outlined.PrivacyTip,
label = AboutStrings.PrivacyPolicy.asString(),
testTag = AboutOthersPrivacyPolicyItemTestTag,
onClickAction = onPrivacyPolicyItemClick,
modifier = Modifier
.padding(
horizontal = 16.dp,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,18 @@ class AboutScreenTest {
checkScreenCapture()
}
}

@Test
@Category(ScreenshotTests::class)
fun checkScrollShot() {
aboutScreenRobot {
setupAboutScreenContent()
// Take a screenshot of Credits
scrollAboutScreen()
checkScreenCapture()
// Take a screenshot of the Others
scrollAboutScreen()
checkScreenCapture()
}
}
}

0 comments on commit 46fb169

Please sign in to comment.