-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from DroidKaigi/yamada-ika/add-sponsors-screen
add sponsors screen
- Loading branch information
Showing
23 changed files
with
727 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 21 additions & 9 deletions
30
...droidMain/kotlin/io/github/droidkaigi/confsched/data/sponsors/SponsorsRepositoryModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
package io.github.droidkaigi.confsched.data.sponsors | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import dagger.multibindings.ClassKey | ||
import dagger.multibindings.IntoMap | ||
import io.github.droidkaigi.confsched.data.di.RepositoryQualifier | ||
import io.github.droidkaigi.confsched.model.SponsorsRepository | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
public class SponsorsRepositoryModule { | ||
@Provides | ||
@Singleton | ||
public fun provideSponsorsRepository( | ||
sponsorsApi: SponsorsApiClient, | ||
): SponsorsRepository { | ||
return DefaultSponsorsRepository( | ||
sponsorsApi = sponsorsApi, | ||
) | ||
public abstract class SponsorsRepositoryModule { | ||
@Binds | ||
@RepositoryQualifier | ||
@IntoMap | ||
@ClassKey(SponsorsRepository::class) | ||
public abstract fun bind(repository: SponsorsRepository): Any | ||
|
||
public companion object { | ||
@Provides | ||
@Singleton | ||
public fun provideSponsorsRepository( | ||
sponsorsApi: SponsorsApiClient, | ||
): SponsorsRepository { | ||
return DefaultSponsorsRepository( | ||
sponsorsApi = sponsorsApi, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched/model/SponsorsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
package io.github.droidkaigi.confsched.model | ||
|
||
import androidx.compose.runtime.Composable | ||
import io.github.droidkaigi.confsched.model.compositionlocal.LocalRepositories | ||
import kotlinx.collections.immutable.PersistentList | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlin.coroutines.cancellation.CancellationException | ||
|
||
public interface SponsorsRepository { | ||
public fun sponsors(): Flow<PersistentList<Sponsor>> | ||
public fun getSponsorStream(): Flow<PersistentList<Sponsor>> | ||
|
||
@Throws(CancellationException::class) | ||
public suspend fun refresh() | ||
|
||
@Composable | ||
fun sponsors(): PersistentList<Sponsor> | ||
} | ||
|
||
@Composable | ||
fun localSponsorsRepository(): SponsorsRepository { | ||
return LocalRepositories.current[SponsorsRepository::class] as SponsorsRepository | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/SponsorsScreenRobot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.github.droidkaigi.confsched.testing.robot | ||
|
||
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme | ||
import io.github.droidkaigi.confsched.sponsors.SponsorsScreen | ||
import io.github.droidkaigi.confsched.testing.DefaultScreenRobot | ||
import io.github.droidkaigi.confsched.testing.DefaultSponsorsServerRobot | ||
import io.github.droidkaigi.confsched.testing.ScreenRobot | ||
import io.github.droidkaigi.confsched.testing.SponsorsServerRobot | ||
import javax.inject.Inject | ||
|
||
class SponsorsScreenRobot @Inject constructor( | ||
private val screenRobot: DefaultScreenRobot, | ||
private val sponsorsServerRobot: DefaultSponsorsServerRobot, | ||
) : ScreenRobot by screenRobot, | ||
SponsorsServerRobot by sponsorsServerRobot { | ||
fun setupScreenContent() { | ||
robotTestRule.setContent { | ||
KaigiTheme { | ||
SponsorsScreen( | ||
onNavigationIconClick = {}, | ||
onSponsorsItemClick = {}, | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
plugins { | ||
id("droidkaigi.convention.kmpfeature") | ||
} | ||
|
||
android.namespace = "io.github.droidkaigi.confsched.feature.sponsors" | ||
roborazzi.generateComposePreviewRobolectricTests.packages = listOf("io.github.droidkaigi.confsched.sponsors") | ||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
implementation(projects.core.model) | ||
implementation(projects.core.ui) | ||
implementation(libs.kotlinxCoroutinesCore) | ||
implementation(projects.core.designsystem) | ||
implementation(libs.moleculeRuntime) | ||
} | ||
} | ||
androidUnitTest { | ||
dependencies { | ||
implementation(projects.core.testing) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle.kts. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
76 changes: 76 additions & 0 deletions
76
.../src/androidUnitTest/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreenTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package io.github.droidkaigi.confsched.sponsors | ||
|
||
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.SponsorsServerRobot.ServerStatus | ||
import io.github.droidkaigi.confsched.testing.describeBehaviors | ||
import io.github.droidkaigi.confsched.testing.execute | ||
import io.github.droidkaigi.confsched.testing.robot.SponsorsScreenRobot | ||
import io.github.droidkaigi.confsched.testing.runRobot | ||
import io.github.droidkaigi.confsched.testing.todoChecks | ||
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 SponsorsScreenTest( | ||
private val testCase: DescribedBehavior<SponsorsScreenRobot>, | ||
) { | ||
@get:Rule | ||
@BindValue val robotTestRule: RobotTestRule = RobotTestRule(testInstance = this) | ||
|
||
@Inject | ||
lateinit var sponsorsScreenRobot: SponsorsScreenRobot | ||
|
||
@Test | ||
fun runTest() { | ||
runRobot(sponsorsScreenRobot) { | ||
testCase.execute(sponsorsScreenRobot) | ||
} | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}") | ||
fun behaviors(): List<DescribedBehavior<SponsorsScreenRobot>> { | ||
return describeBehaviors<SponsorsScreenRobot>(name = "SponsorsScreen") { | ||
describe("when server is operational") { | ||
run { | ||
setupSponsorsServer(ServerStatus.Operational) | ||
} | ||
describe("when launch") { | ||
run { | ||
setupScreenContent() | ||
} | ||
itShould("display sponsors") { | ||
captureScreenWithChecks( | ||
checks = todoChecks("This screen is still empty now. Please add some checks."), | ||
) | ||
} | ||
} | ||
} | ||
|
||
describe("when server is down") { | ||
run { | ||
setupSponsorsServer(ServerStatus.Error) | ||
} | ||
describe("when launch") { | ||
run { | ||
setupScreenContent() | ||
} | ||
itShould("show error message") { | ||
captureScreenWithChecks( | ||
checks = todoChecks("This screen is still empty now. Please add some checks."), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
feature/sponsors/src/androidUnitTest/resources/robolectric.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
9 changes: 9 additions & 0 deletions
9
feature/sponsors/src/commonMain/composeResources/values-ja/sponsors_strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="sponsor">スポンサー</string> | ||
<string name="platinum_sponsor">プラチナスポンサー</string> | ||
<string name="gold_sponsor">ゴールドスポンサー</string> | ||
<string name="supporters">サポーター</string> | ||
<string name="content_description_back">戻る</string> | ||
<string name="content_description_sponsor_logo">スポンサーロゴ</string> | ||
</resources> |
9 changes: 9 additions & 0 deletions
9
feature/sponsors/src/commonMain/composeResources/values/sponsors_strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="sponsor">Sponsor</string> | ||
<string name="platinum_sponsor">PLATINUM SPONSORS</string> | ||
<string name="gold_sponsor">GOLD SPONSORS</string> | ||
<string name="supporters">SUPPORTERS</string> | ||
<string name="content_description_back">Back</string> | ||
<string name="content_description_sponsor_logo">sponsor logo</string> | ||
</resources> |
8 changes: 8 additions & 0 deletions
8
...ure/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsRes.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.github.droidkaigi.confsched.sponsors | ||
|
||
import conference_app_2024.feature.sponsors.generated.resources.Res | ||
|
||
object SponsorsRes { | ||
val string = Res.string | ||
val drawable = Res.drawable | ||
} |
Oops, something went wrong.