Repository: Automattic/pocket-casts-android
File: modules/features/account/src/main/java/au/com/shiftyjelly/pocketcasts/account/onboarding/upgrade/UpgradeFeatureItem.kt (Kotlin)

Code before:
interface UpgradeFeatureItem {
    @get:DrawableRes
    val image: Int

    @get:StringRes
    val title: Int

    val isYearlyFeature: Boolean

    val isMonthlyFeature: Boolean
}

enum class PlusUpgradeFeatureItem(
    override val image: Int,
    override val title: Int,
) : UpgradeFeatureItem {
    BannerAds(
        image = IR.drawable.ic_remove_ads,
        title = LR.string.onboarding_plus_feature_no_banner_ads,
    ) {
        override val isYearlyFeature get() = FeatureFlag.isEnabled(Feature.BANNER_ADS)
        override val isMonthlyFeature get() = FeatureFlag.isEnabled(Feature.BANNER_ADS)
    },
    Folders(
        image = IR.drawable.ic_plus_feature_folder,
        title = if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
            LR.string.onboarding_upgrade_features_folders
        } else {
            LR.string.onboarding_plus_feature_folders_title
        },
    ),
    UpNextShuffle(
        image = IR.drawable.ic_plus_feature_shuffle,
        title = if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
            LR.string.onboarding_upgrade_features_shuffle
        } else {
            LR.string.onboarding_plus_feature_up_next_shuffle_title
        },
    ),
    Bookmarks(
        image = IR.drawable.ic_plus_feature_bookmark,
        title = if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
            LR.string.onboarding_upgrade_features_bookmarks
        } else {
            LR.string.onboarding_plus_feature_bookmarks_title
        },
    ),
    SkipChapters(
        image = IR.drawable.ic_plus_feature_chapters,
        title = if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
            LR.string.onboarding_upgrade_features_chapters

Review comment (suggestion):
There is a problem with this approach. Once `title` property is computed it will never change its value based on the feature flag regardless of its value. `title` has to be moved out of the constructor and change to be a `computed` property.

Code after:
interface UpgradeFeatureItem {
    @get:DrawableRes
    val image: Int

    @StringRes
    fun title(): Int

    val isYearlyFeature: Boolean

    val isMonthlyFeature: Boolean
}

enum class PlusUpgradeFeatureItem(
    override val image: Int,
) : UpgradeFeatureItem {
    BannerAds(
        image = IR.drawable.ic_remove_ads,
    ) {
        override val isYearlyFeature get() = FeatureFlag.isEnabled(Feature.BANNER_ADS)
        override val isMonthlyFeature get() = FeatureFlag.isEnabled(Feature.BANNER_ADS)
        override fun title() = LR.string.onboarding_plus_feature_no_banner_ads
    },
    Folders(
        image = IR.drawable.ic_plus_feature_folder,
    ) {
        override fun title() = if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
            LR.string.onboarding_upgrade_features_folders
        } else {
            LR.string.onboarding_plus_feature_folders_title
        }
    },
    UpNextShuffle(
        image = IR.drawable.ic_plus_feature_shuffle,
    ) {
        override fun title() = if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
            LR.string.onboarding_upgrade_features_shuffle
        } else {
            LR.string.onboarding_plus_feature_up_next_shuffle_title
        }
    },
    Bookmarks(
        image = IR.drawable.ic_plus_feature_bookmark,
    ) {
        override fun title() = if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
            LR.string.onboarding_upgrade_features_bookmarks
        } else {
            LR.string.onboarding_plus_feature_bookmarks_title
        }
    },
    SkipChapters(
        image = IR.drawable.ic_plus_feature_chapters,