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

Implement about screen roughly #131

Merged
merged 7 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ dependencies {
implementation(projects.feature.sessions)
implementation(projects.feature.eventmap)
implementation(projects.feature.profilecard)
implementation(projects.feature.about)
implementation(projects.core.model)
implementation(projects.core.data)
implementation(projects.core.designsystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import androidx.navigation.compose.rememberNavController
import androidx.window.layout.DisplayFeature
import co.touchlab.kermit.Logger
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import io.github.droidkaigi.confsched.about.aboutScreen
import io.github.droidkaigi.confsched.about.aboutScreenRoute
import io.github.droidkaigi.confsched.about.navigateAboutScreen
import io.github.droidkaigi.confsched.contributors.contributorsScreenRoute
import io.github.droidkaigi.confsched.contributors.contributorsScreens
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
Expand All @@ -40,7 +43,10 @@ import io.github.droidkaigi.confsched.main.MainScreenTab.ProfileCard
import io.github.droidkaigi.confsched.main.MainScreenTab.Timetable
import io.github.droidkaigi.confsched.main.mainScreen
import io.github.droidkaigi.confsched.main.mainScreenRoute
import io.github.droidkaigi.confsched.model.AboutItem
import io.github.droidkaigi.confsched.model.Lang.JAPANESE
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.defaultLang
import io.github.droidkaigi.confsched.sessions.navigateTimetableScreen
import io.github.droidkaigi.confsched.sessions.navigateToTimetableItemDetailScreen
import io.github.droidkaigi.confsched.sessions.nestedSessionScreens
Expand Down Expand Up @@ -119,6 +125,45 @@ private fun NavGraphBuilder.mainScreen(
onNavigationIconClick = navController::popBackStack,
onEventMapItemClick = externalNavController::navigate,
)
aboutScreen(
contentPadding = contentPadding,
onAboutItemClick = { aboutItem ->
val portalBaseUrl = if (defaultLang() == JAPANESE) {
"https://portal.droidkaigi.jp"
} else {
"https://portal.droidkaigi.jp/en"
}
when (aboutItem) {
AboutItem.Sponsors -> TODO()
AboutItem.CodeOfConduct -> {
externalNavController.navigate(
url = "$portalBaseUrl/about/code-of-conduct",
)
}

AboutItem.Contributors -> navController.navigate(contributorsScreenRoute)
AboutItem.License -> externalNavController.navigateToLicenseScreen()
AboutItem.Medium -> externalNavController.navigate(
url = "https://medium.com/droidkaigi",
)

AboutItem.PrivacyPolicy -> {
externalNavController.navigate(
url = "$portalBaseUrl/about/privacy",
)
}

AboutItem.Staff -> TODO()
AboutItem.X -> externalNavController.navigate(
url = "https://twitter.com/DroidKaigi",
)

AboutItem.YouTube -> externalNavController.navigate(
url = "https://www.youtube.com/c/DroidKaigi",
)
}
},
)
profileCardScreen(contentPadding)
},
)
Expand All @@ -131,6 +176,7 @@ class KaigiAppMainNestedGraphStateHolder : MainNestedGraphStateHolder {
return when (route) {
timetableScreenRoute -> Timetable
profileCardScreenRoute -> ProfileCard
aboutScreenRoute -> About
else -> null
}
}
Expand All @@ -143,7 +189,7 @@ class KaigiAppMainNestedGraphStateHolder : MainNestedGraphStateHolder {
Timetable -> mainNestedNavController.navigateTimetableScreen()
EventMap -> mainNestedNavController.navigateEventMapScreen()
Favorite -> {}
About -> {}
About -> mainNestedNavController.navigateAboutScreen()
ProfileCard -> mainNestedNavController.navigateProfileCardScreen()
}
}
Expand Down
1 change: 1 addition & 0 deletions app-ios-shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ kotlin {
api(projects.feature.eventmap)
api(projects.feature.contributors)
api(projects.feature.profilecard)
api(projects.feature.about)
implementation(libs.kotlinxCoroutinesCore)
implementation(libs.skieAnnotation)
}
Expand Down
1 change: 1 addition & 0 deletions core/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
implementation(projects.feature.main)
implementation(projects.feature.sessions)
implementation(projects.feature.profilecard)
implementation(projects.feature.about)
implementation(libs.daggerHiltAndroidTesting)
implementation(libs.roborazzi)
implementation(libs.kermit)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.github.droidkaigi.confsched.testing.robot

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasTestTag
import io.github.droidkaigi.confsched.about.AboutScreen
import io.github.droidkaigi.confsched.about.AboutTestTag
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched.testing.DefaultScreenRobot
import io.github.droidkaigi.confsched.testing.ScreenRobot
import javax.inject.Inject

class AboutScreenRobot @Inject constructor(
screenRobot: DefaultScreenRobot,
) : ScreenRobot by screenRobot {
fun setupScreenContent() {
robotTestRule.setContent {
KaigiTheme {
AboutScreen(
onAboutItemClick = {},
)
}
}
waitUntilIdle()
}

fun checkDetailScreenDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutTestTag.DetailScreen.SCREEN))
.assertIsDisplayed()
}

fun checkCreditsScreenDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutTestTag.CreditsScreen.SCREEN))
.assertIsDisplayed()
}

fun checkOthersScreenDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutTestTag.OthersScreen.SCREEN))
.assertIsDisplayed()
}

fun checkFooterLinksScreenDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutTestTag.FooterLinksScreen.SCREEN))
.assertIsDisplayed()
}
}
1 change: 1 addition & 0 deletions feature/about/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions feature/about/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
id("droidkaigi.convention.kmpfeature")
}

android.namespace = "io.github.droidkaigi.confsched.feature.about"
roborazzi.generateComposePreviewRobolectricTests.packages = listOf("io.github.droidkaigi.confsched.about")
kotlin {
sourceSets {
commonMain {
dependencies {
implementation(projects.core.designsystem)
implementation(projects.core.ui)
implementation(projects.core.model)

implementation(libs.composeNavigation)
implementation(compose.materialIconsExtended)
}
}
androidTarget {
dependencies {
implementation(libs.composeMaterialWindowSize)
}
}
androidUnitTest {
dependencies {
implementation(projects.core.testing)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package io.github.droidkaigi.confsched.about

import dagger.hilt.android.testing.BindValue
import dagger.hilt.android.testing.HiltAndroidTest
import io.github.droidkaigi.confsched.testing.DescribedBehavior
import io.github.droidkaigi.confsched.testing.RobotTestRule
import io.github.droidkaigi.confsched.testing.describeBehaviors
import io.github.droidkaigi.confsched.testing.execute
import io.github.droidkaigi.confsched.testing.robot.AboutScreenRobot
import io.github.droidkaigi.confsched.testing.runRobot
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.ParameterizedRobolectricTestRunner
import javax.inject.Inject

@RunWith(ParameterizedRobolectricTestRunner::class)
@HiltAndroidTest
class AboutScreenTest(
private val testCase: DescribedBehavior<AboutScreenRobot>,
) {

@get:Rule
@BindValue
val robotTestRule: RobotTestRule = RobotTestRule(this)

@Inject
lateinit var aboutScreenRobot: AboutScreenRobot

@Test
fun runTest() {
runRobot(aboutScreenRobot) {
testCase.execute(aboutScreenRobot)
}
}

companion object {
@JvmStatic
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}")
fun behaviors(): List<DescribedBehavior<AboutScreenRobot>> {
return describeBehaviors("AboutScreen") {
describe("when launch") {
run {
captureScreenWithChecks {
setupScreenContent()
}
}
itShould("show detail screen") {
captureScreenWithChecks {
checkDetailScreenDisplayed()
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sdk=34
# RobolectricDeviceQualifiers.NexusOne
qualifiers=w320dp-h533dp-normal-long-notround-any-hdpi-keyshidden-trackball

application=dagger.hilt.android.testing.HiltTestApplication
# https://github.com/robolectric/robolectric/issues/6593
instrumentedPackages=androidx.loader.content
Loading
Loading