Skip to content

Commit

Permalink
[#141] Add bottom sheet to customize lists
Browse files Browse the repository at this point in the history
  • Loading branch information
florentmaitre committed Jul 19, 2022
1 parent 4712b66 commit d4f7af2
Show file tree
Hide file tree
Showing 12 changed files with 303 additions and 339 deletions.
1 change: 1 addition & 0 deletions demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ android {
kotlinOptions {
jvmTarget = "11"
allWarningsAsErrors = true
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}

buildFeatures {
Expand Down
20 changes: 13 additions & 7 deletions demo/src/main/java/com/orange/ods/demo/ui/components/Component.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import com.orange.ods.demo.R
import com.orange.ods.demo.ui.components.bottomnavigation.ComponentBottomNavigation
import com.orange.ods.demo.ui.components.checkboxes.ComponentCheckboxesContent
import com.orange.ods.demo.ui.components.dialogs.ComponentDialogsContent
import com.orange.ods.demo.ui.components.lists.ComponentListsBottomSheetContent
import com.orange.ods.demo.ui.components.lists.ComponentListsContent
import com.orange.ods.demo.ui.components.lists.rememberVariantListsState
import com.orange.ods.demo.ui.components.progress.ComponentProgressContent
import com.orange.ods.demo.ui.components.radiobuttons.ComponentRadioButtonsContent
import com.orange.ods.demo.ui.components.sliders.ComponentSlidersContent
Expand Down Expand Up @@ -66,8 +69,7 @@ sealed class Component(
R.string.component_lists,
R.drawable.il_lists,
null,
R.string.component_lists_description,
listOf(Variant.ListsSingleLine, Variant.ListsTwoLine, Variant.ListsThreeLine)
R.string.component_lists_description
)

object Progress : Component(R.string.component_progress, R.drawable.il_progress, null, R.string.component_progress_description)
Expand Down Expand Up @@ -97,11 +99,19 @@ sealed class Component(
BottomNavigation -> ComponentBottomNavigation()
Checkboxes -> ComponentDetail(component = this) { ComponentCheckboxesContent() }
Dialogs -> ComponentDetail(component = this) { ComponentDialogsContent() }
Lists -> {
val variantListsState = rememberVariantListsState()
ComponentDetail(
component = this,
bottomSheetContent = { ComponentListsBottomSheetContent(variantListsState = variantListsState) },
content = { ComponentListsContent(variantListsState = variantListsState) }
)
}
Progress -> ComponentDetail(component = this) { ComponentProgressContent() }
RadioButtons -> ComponentDetail(component = this) { ComponentRadioButtonsContent() }
Sliders -> ComponentDetail(component = this) { ComponentSlidersContent() }
Switches -> ComponentDetail(component = this) { ComponentSwitchesContent() }
Buttons, Cards, Chips, Lists, TextFields, Tabs -> ComponentDetailWithVariants(component = this, onVariantClick = onVariantClick)
Buttons, Cards, Chips, TextFields, Tabs -> ComponentDetailWithVariants(component = this, onVariantClick = onVariantClick)
}
}
}
Expand All @@ -125,10 +135,6 @@ sealed class Variant(
object Chip : Variant(R.string.component_chip)
object ChipFilter : Variant(R.string.component_chip_filter)

object ListsSingleLine : Variant(R.string.component_lists_single_line)
object ListsTwoLine : Variant(R.string.component_lists_two_line)
object ListsThreeLine : Variant(R.string.component_lists_three_line)

object TextFieldsFilled : Variant(R.string.component_text_fields_filled)
object TextFieldsOutlined : Variant(R.string.component_text_fields_outlined)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.rememberBottomSheetScaffoldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource
import com.orange.ods.compose.component.list.OdsListItem
import com.orange.ods.demo.R
import com.orange.ods.demo.ui.components.utilities.ComponentCustomizationBottomSheetScaffold
import com.orange.ods.demo.ui.components.utilities.ComponentHeader

@ExperimentalMaterialApi
Expand All @@ -42,7 +44,7 @@ fun ComponentDetailScreen(

@ExperimentalMaterialApi
@Composable
fun ComponentDetail(component: Component, ComponentContent: @Composable () -> Unit) {
fun ComponentDetail(component: Component, content: @Composable () -> Unit) {
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
Expand All @@ -52,10 +54,20 @@ fun ComponentDetail(component: Component, ComponentContent: @Composable () -> Un
imageRes = component.imageRes,
description = component.descriptionRes
)
ComponentContent()
content()
}
}

@ExperimentalMaterialApi
@Composable
fun ComponentDetail(component: Component, bottomSheetContent: (@Composable () -> Unit), content: @Composable () -> Unit) {
ComponentCustomizationBottomSheetScaffold(
bottomSheetScaffoldState = rememberBottomSheetScaffoldState(),
bottomSheetContent = { bottomSheetContent() },
content = { ComponentDetail(component = component, content = content) }
)
}

@ExperimentalMaterialApi
@Composable
fun ComponentDetailWithVariants(component: Component, onVariantClick: (Long) -> Unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.orange.ods.demo.ui.components.buttons.ComponentButtons
import com.orange.ods.demo.ui.components.cards.ComponentCard
import com.orange.ods.demo.ui.components.chips.VariantChip
import com.orange.ods.demo.ui.components.chips.VariantChipFilter
import com.orange.ods.demo.ui.components.lists.ComponentList
import com.orange.ods.demo.ui.components.tabs.ComponentTabs
import com.orange.ods.demo.ui.components.tabs.TabsConfiguration
import com.orange.ods.demo.ui.components.textfields.ComponentTextField
Expand All @@ -40,7 +39,6 @@ fun VariantDetailScreen(
Component.Buttons -> ComponentButtons(variant = variant)
Component.Cards -> ComponentCard(variant = variant)
Component.Chips -> if (variant == Variant.ChipFilter) VariantChipFilter() else VariantChip()
Component.Lists -> ComponentList(variant = variant)
Component.TextFields -> ComponentTextField(variant = variant)
Component.Tabs -> ComponentTabs(variant, updateTopAppBarTabs)
else -> {}
Expand Down

This file was deleted.

Loading

0 comments on commit d4f7af2

Please sign in to comment.