-
Notifications
You must be signed in to change notification settings - Fork 2
feat: create component - tag #654
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
473f7e4
Fix badge kdoc
paulinea 0fd4851
Add tag component to the lib
paulinea 0005a64
Add tag component paparazzi snapshots
paulinea a63ca96
Add tag component to demo app
paulinea 0edc261
Fix after rebase
paulinea a8b4077
Introduce inset padding for assets
paulinea d4731da
Update tag snapshots
paulinea 7cb1aa1
Update tag bullet icon
paulinea 19a8e8c
Review: Remove empty line
paulinea 95b3331
Review: Update Tag illustration in demo app
paulinea 9248a9c
Review: Add empty line
paulinea f0a199f
Review: Add missing top padding
paulinea d1bf31d
Review: Add loading customization switch
paulinea d345ccb
Review: Add loading parameter in the code snippet
paulinea afa060f
Review: Fix kdoc
paulinea 3a7bbab
Review: Fix kdoc wording
paulinea ad3a474
Review: A tag with a disabled status and a loader is not allowed
paulinea 8882e71
Review: Fix the space between asset and label
paulinea 3924308
Review: Use StrokeCap.Butt for loader
paulinea 994551e
Review: Add kdoc for Loading progress parameter
paulinea 4e09372
Review: Use full names for OudsTag statuses
paulinea 6c95e1f
Review: Add missing header
paulinea 053a586
Update snapshots
paulinea 952e408
Review: Update kdoc with design guideline URL and version
paulinea 1abdbab
Review: Add version to Tag demo screen
paulinea e8fa73f
Update CheckedContent method to enhance previews
florentmaitre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
172 changes: 172 additions & 0 deletions
172
app/src/main/java/com/orange/ouds/app/ui/components/tag/TagDemoScreen.kt
This file contains hidden or 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,172 @@ | ||
| /* | ||
| * Software Name: OUDS Android | ||
| * SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * This software is distributed under the MIT license, | ||
| * the text of which is available at https://opensource.org/license/MIT/ | ||
| * or see the "LICENSE" file for more details. | ||
| * | ||
| * Software description: Android library of reusable graphical components | ||
| */ | ||
|
|
||
| package com.orange.ouds.app.ui.components.tag | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.tooling.preview.PreviewLightDark | ||
| import com.orange.ouds.app.R | ||
| import com.orange.ouds.app.ui.components.Component | ||
| import com.orange.ouds.app.ui.components.labelArgument | ||
| import com.orange.ouds.app.ui.components.painterArgument | ||
| import com.orange.ouds.app.ui.utilities.Code | ||
| import com.orange.ouds.app.ui.utilities.composable.CustomizationDropdownMenu | ||
| import com.orange.ouds.app.ui.utilities.composable.CustomizationDropdownMenuItem | ||
| import com.orange.ouds.app.ui.utilities.composable.CustomizationFilterChips | ||
| import com.orange.ouds.app.ui.utilities.composable.CustomizationSwitchItem | ||
| import com.orange.ouds.app.ui.utilities.composable.CustomizationTextField | ||
| import com.orange.ouds.app.ui.utilities.composable.DemoScreen | ||
| import com.orange.ouds.app.ui.utilities.formattedName | ||
| import com.orange.ouds.core.component.OudsTag | ||
| import com.orange.ouds.core.theme.OudsTheme | ||
| import com.orange.ouds.core.utilities.OudsPreview | ||
| import com.orange.ouds.theme.OudsVersion | ||
|
|
||
| @Composable | ||
| fun TagDemoScreen() { | ||
| val state = rememberTagDemoState() | ||
| DemoScreen( | ||
| description = stringResource(id = Component.Tag.descriptionRes), | ||
| bottomSheetContent = { TagDemoBottomSheetContent(state = state) }, | ||
| codeSnippet = { tagDemoCodeSnippet(state = state) }, | ||
| demoContent = { TagDemoContent(state = state) }, | ||
| version = OudsVersion.Component.Tag | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun TagDemoBottomSheetContent(state: TagDemoState) { | ||
| with(state) { | ||
| CustomizationFilterChips( | ||
| label = stringResource(R.string.app_components_common_hierarchy_label), | ||
| chipLabels = OudsTag.Hierarchy.entries.map { it.name }, | ||
| selectedChipIndex = OudsTag.Hierarchy.entries.indexOf(hierarchy), | ||
| onSelectionChange = { id -> hierarchy = OudsTag.Hierarchy.entries[id] } | ||
| ) | ||
| val statuses = OudsTag.Status.entries | ||
| CustomizationDropdownMenu( | ||
| modifier = Modifier.padding(top = OudsTheme.spaces.fixed.medium), | ||
| label = stringResource(id = R.string.app_components_common_status_label), | ||
| items = statuses.map { status -> | ||
| CustomizationDropdownMenuItem( | ||
| label = status.formattedName, | ||
| leadingIcon = { | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .background(status.backgroundColor(hierarchy)) | ||
| ) | ||
| }, | ||
| enabled = !(status == OudsTag.Status.Disabled && loading) | ||
| ) | ||
| }, | ||
| selectedItemIndex = statuses.indexOf(status), | ||
| onSelectionChange = { status = statuses[it] } | ||
| ) | ||
| CustomizationFilterChips( | ||
| modifier = Modifier.padding(top = OudsTheme.spaces.fixed.medium), | ||
| label = stringResource(R.string.app_components_common_layout_label), | ||
| chipLabels = TagDemoState.Layout.entries.map { stringResource(it.labelRes) }, | ||
| selectedChipIndex = TagDemoState.Layout.entries.indexOf(layout), | ||
| onSelectionChange = { id -> layout = TagDemoState.Layout.entries[id] } | ||
| ) | ||
| CustomizationSwitchItem( | ||
| label = stringResource(R.string.app_components_tag_loading_label), | ||
| checked = loading, | ||
| onCheckedChange = { loading = it }, | ||
| enabled = loadingSwitchEnabled | ||
| ) | ||
| CustomizationFilterChips( | ||
| modifier = Modifier.padding(top = OudsTheme.spaces.fixed.medium), | ||
| label = stringResource(R.string.app_components_tag_shape_label), | ||
| chipLabels = OudsTag.Shape.entries.map { it.name }, | ||
| selectedChipIndex = OudsTag.Shape.entries.indexOf(shape), | ||
| onSelectionChange = { id -> shape = OudsTag.Shape.entries[id] } | ||
| ) | ||
| CustomizationFilterChips( | ||
| modifier = Modifier.padding(top = OudsTheme.spaces.fixed.medium), | ||
| label = stringResource(R.string.app_components_common_size_label), | ||
| chipLabels = OudsTag.Size.entries.map { it.name }, | ||
| selectedChipIndex = OudsTag.Size.entries.indexOf(size), | ||
| onSelectionChange = { id -> size = OudsTag.Size.entries[id] } | ||
| ) | ||
| CustomizationTextField( | ||
| modifier = Modifier.padding(top = OudsTheme.spaces.fixed.medium), | ||
| label = stringResource(R.string.app_components_common_label_label), | ||
florentmaitre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| value = label, | ||
| onValueChange = { value -> label = value } | ||
| ) | ||
florentmaitre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun TagDemoContent(state: TagDemoState) { | ||
| with(state) { | ||
| val loading = if (loading) OudsTag.Loading(null) else null | ||
| if (layout == TagDemoState.Layout.TextAndIcon) { | ||
| OudsTag( | ||
| icon = OudsTag.Icon(painter = painterResource(R.drawable.ic_heart)), | ||
| label = label, | ||
| hierarchy = hierarchy, | ||
| status = status, | ||
| size = size, | ||
| shape = shape, | ||
| loading = loading, | ||
| ) | ||
| } else { | ||
| OudsTag( | ||
| hasBullet = layout == TagDemoState.Layout.TextAndBullet, | ||
| label = label, | ||
| hierarchy = hierarchy, | ||
| status = status, | ||
| size = size, | ||
| shape = shape, | ||
| loading = loading, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun Code.Builder.tagDemoCodeSnippet(state: TagDemoState) { | ||
| with(state) { | ||
| functionCall(OudsTag::class.simpleName.orEmpty()) { | ||
| when (layout) { | ||
| TagDemoState.Layout.TextAndBullet -> typedArgument("hasBullet", true) | ||
| TagDemoState.Layout.TextAndIcon -> { | ||
| constructorCallArgument<OudsTag.Icon>("icon") { | ||
| painterArgument(R.drawable.ic_heart) | ||
| } | ||
| } | ||
| TagDemoState.Layout.TextOnly -> {} | ||
| } | ||
| labelArgument(label) | ||
| typedArgument("hierarchy", hierarchy) | ||
| typedArgument("shape", shape) | ||
| typedArgument("size", size) | ||
| typedArgument("status", status) | ||
florentmaitre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| typedArgument("loading", loading) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @PreviewLightDark | ||
| @Composable | ||
| private fun PreviewTagDemoScreen() = OudsPreview { | ||
| TagDemoScreen() | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.