Skip to content

Commit

Permalink
Refactor naming
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom committed Dec 19, 2024
1 parent 00c4442 commit 2efd214
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ interface RoborazziComposeActivityScenarioOption : RoborazziComposeOption {
}

@ExperimentalRoborazziApi
interface RoborazziComposeActivityScenarioCreationOption : RoborazziComposeOption {
interface RoborazziComposeActivityScenarioCreatorOption : RoborazziComposeOption {
@Suppress("RemoveRedundantQualifierName")
fun createScenario(chain: () -> ActivityScenario<out androidx.activity.ComponentActivity>): ActivityScenario<out androidx.activity.ComponentActivity>
}

Expand All @@ -45,22 +46,22 @@ interface RoborazziComposeComposableOption : RoborazziComposeOption {

@ExperimentalRoborazziApi
class RoborazziComposeOptions private constructor(
private val createActivityScenarioOptions: List<RoborazziComposeActivityScenarioCreationOption>,
private val activityScenarioCreatorOptions: List<RoborazziComposeActivityScenarioCreatorOption>,
private val activityScenarioOptions: List<RoborazziComposeActivityScenarioOption>,
private val composableOptions: List<RoborazziComposeComposableOption>,
private val setupOptions: List<RoborazziComposeSetupOption>
) {
class Builder {
private val activityScenarioOptions =
mutableListOf<RoborazziComposeActivityScenarioOption>()
private val createActivityScenarioOptions =
mutableListOf<RoborazziComposeActivityScenarioCreationOption>()
private val activityScenarioCreatorOptions =
mutableListOf<RoborazziComposeActivityScenarioCreatorOption>()
private val composableOptions = mutableListOf<RoborazziComposeComposableOption>()
private val setupOptions = mutableListOf<RoborazziComposeSetupOption>()

fun addOption(option: RoborazziComposeOption): Builder {
if (option is RoborazziComposeActivityScenarioCreationOption) {
createActivityScenarioOptions.add(option)
if (option is RoborazziComposeActivityScenarioCreatorOption) {
activityScenarioCreatorOptions.add(option)
}
if (option is RoborazziComposeActivityScenarioOption) {
activityScenarioOptions.add(option)
Expand All @@ -76,7 +77,7 @@ class RoborazziComposeOptions private constructor(

fun build(): RoborazziComposeOptions {
return RoborazziComposeOptions(
createActivityScenarioOptions = createActivityScenarioOptions,
activityScenarioCreatorOptions = activityScenarioCreatorOptions,
activityScenarioOptions = activityScenarioOptions,
composableOptions = composableOptions,
setupOptions = setupOptions
Expand All @@ -87,7 +88,7 @@ class RoborazziComposeOptions private constructor(
fun builder(): Builder {
return Builder()
.apply {
createActivityScenarioOptions.forEach { addOption(it) }
activityScenarioCreatorOptions.forEach { addOption(it) }
activityScenarioOptions.forEach { addOption(it) }
composableOptions.forEach { addOption(it) }
setupOptions.forEach { addOption(it) }
Expand All @@ -96,7 +97,7 @@ class RoborazziComposeOptions private constructor(

@ExperimentalRoborazziApi
fun createScenario(chain: () -> ActivityScenario<out androidx.activity.ComponentActivity>): ActivityScenario<out androidx.activity.ComponentActivity> {
return createActivityScenarioOptions.fold(chain) { acc, option ->
return activityScenarioCreatorOptions.fold(chain) { acc, option ->
{ option.createScenario(acc) }
}()
}
Expand Down Expand Up @@ -290,7 +291,7 @@ fun RoborazziComposeOptions.Builder.theme(themeResId: Int): RoborazziComposeOpti

@ExperimentalRoborazziApi
data class RoborazziComposeActivityThemeOption(private val themeResId: Int) :
RoborazziComposeActivityScenarioCreationOption {
RoborazziComposeActivityScenarioCreatorOption {
override fun createScenario(chain: () -> ActivityScenario<out ComponentActivity>): ActivityScenario<out ComponentActivity> {
return createActivityScenario(themeResId)
}
Expand Down

0 comments on commit 2efd214

Please sign in to comment.