-
Notifications
You must be signed in to change notification settings - Fork 0
feat(rn-davinci): add BooleanCollector and ReadOnlyTextCollector bridge (SDKS-5209) #64
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
Open
pingidentity-gaurav
wants to merge
2
commits into
main
Choose a base branch
from
feat/SDKS-5209-rn-davinci-boolean-readonly-collectors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
111 changes: 111 additions & 0 deletions
111
PingSampleApp/ui/davinci/components/molecules/DaVinciBooleanField.tsx
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,111 @@ | ||
| /* | ||
| * Copyright (c) 2026 Ping Identity Corporation. All rights reserved. | ||
| * | ||
| * This software may be modified and distributed under the terms | ||
| * of the MIT license. See the LICENSE file for details. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { Pressable, Switch, Text, View } from 'react-native'; | ||
| import type { BooleanCollector } from '@ping-identity/rn-davinci'; | ||
| import { davinciFieldStyles } from '../../../../src/styles/davinciStyles'; | ||
| import RichTextLabel from './RichTextLabel'; | ||
| import type { DaVinciCollectorRendererProps } from './types'; | ||
|
|
||
| /** | ||
| * Renders a {@link BooleanCollector} as a checkbox row or a switch toggle, | ||
| * depending on the collector's `appearance` field. | ||
| * | ||
| * @param props Renderer props. | ||
| * @returns Boolean field element. | ||
| */ | ||
| export default function DaVinciBooleanField( | ||
| props: DaVinciCollectorRendererProps, | ||
| ): React.ReactElement { | ||
| const { collector, value, onChange } = props; | ||
| const booleanCollector = collector as BooleanCollector; | ||
| const checked = typeof value === 'boolean' ? value : booleanCollector.value; | ||
| const showError = | ||
| booleanCollector.required && !checked && booleanCollector.errorMessage; | ||
|
|
||
| const label = booleanCollector.required | ||
| ? `${booleanCollector.label} *` | ||
| : booleanCollector.label; | ||
|
|
||
| if (booleanCollector.appearance === 'SWITCH') { | ||
| return ( | ||
| <View style={davinciFieldStyles.card}> | ||
| <View style={styles.switchRow}> | ||
| <RichTextLabel | ||
| text={label} | ||
| richContent={booleanCollector.richContent} | ||
| style={[davinciFieldStyles.fieldLabel, styles.switchLabel]} | ||
| /> | ||
| <Switch | ||
| value={checked} | ||
| onValueChange={next => onChange(next)} | ||
| accessibilityLabel={booleanCollector.label} | ||
| /> | ||
| </View> | ||
| {showError ? ( | ||
| <Text style={davinciFieldStyles.errorText}> | ||
| {booleanCollector.errorMessage} | ||
| </Text> | ||
| ) : null} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <View style={davinciFieldStyles.card}> | ||
| <Pressable | ||
| style={styles.checkboxRow} | ||
| onPress={() => onChange(!checked)} | ||
| accessibilityRole="checkbox" | ||
| accessibilityState={{ checked }} | ||
| accessibilityLabel={booleanCollector.label} | ||
| > | ||
| <View | ||
| style={[ | ||
| davinciFieldStyles.optionCheckbox, | ||
| checked && davinciFieldStyles.optionCheckboxSelected, | ||
| ]} | ||
| > | ||
| {checked ? <Text style={styles.checkmark}>✓</Text> : null} | ||
| </View> | ||
| <RichTextLabel | ||
| text={label} | ||
| richContent={booleanCollector.richContent} | ||
| style={davinciFieldStyles.fieldLabel} | ||
| /> | ||
| </Pressable> | ||
| {showError ? ( | ||
| <Text style={davinciFieldStyles.errorText}> | ||
| {booleanCollector.errorMessage} | ||
| </Text> | ||
| ) : null} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = { | ||
| switchRow: { | ||
| flexDirection: 'row' as const, | ||
| alignItems: 'center' as const, | ||
| justifyContent: 'space-between' as const, | ||
| }, | ||
| switchLabel: { | ||
| flex: 1, | ||
| marginBottom: 0, | ||
| marginRight: 8, | ||
| }, | ||
| checkboxRow: { | ||
| flexDirection: 'row' as const, | ||
| alignItems: 'center' as const, | ||
| }, | ||
| checkmark: { | ||
| color: '#fff', | ||
| fontSize: 12, | ||
| fontWeight: '700' as const, | ||
| }, | ||
| }; | ||
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
39 changes: 39 additions & 0 deletions
39
PingSampleApp/ui/davinci/components/molecules/DaVinciReadOnlyTextField.tsx
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,39 @@ | ||
| /* | ||
| * Copyright (c) 2026 Ping Identity Corporation. All rights reserved. | ||
| * | ||
| * This software may be modified and distributed under the terms | ||
| * of the MIT license. See the LICENSE file for details. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { Text, View } from 'react-native'; | ||
| import type { ReadOnlyTextCollector } from '@ping-identity/rn-davinci'; | ||
| import { davinciFieldStyles } from '../../../../src/styles/davinciStyles'; | ||
| import type { DaVinciCollectorRendererProps } from './types'; | ||
|
|
||
| /** | ||
| * Renders a {@link ReadOnlyTextCollector} as a read-only content block, | ||
| * with an optional title when `titleEnabled` is `true`. | ||
| * | ||
| * @param props Renderer props. | ||
| * @returns Read-only text element. | ||
| */ | ||
| export default function DaVinciReadOnlyTextField( | ||
| props: DaVinciCollectorRendererProps, | ||
| ): React.ReactElement { | ||
| const { collector } = props; | ||
| const readOnlyCollector = collector as ReadOnlyTextCollector; | ||
|
|
||
| return ( | ||
| <View style={davinciFieldStyles.card}> | ||
| {readOnlyCollector.titleEnabled && readOnlyCollector.title ? ( | ||
| <Text style={davinciFieldStyles.fieldLabel}> | ||
| {readOnlyCollector.title} | ||
| </Text> | ||
| ) : null} | ||
| <Text style={davinciFieldStyles.labelContent}> | ||
| {readOnlyCollector.content} | ||
| </Text> | ||
| </View> | ||
| ); | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Render the required indicator outside
RichTextLabel.When
richContentexists,RichTextLabelrendersrichContent.contentand ignoreslabel. Required BooleanCollector fields with rich content therefore do not show*.Render the required indicator independently in both the switch and checkbox paths.
Also applies to: 76-79
🤖 Prompt for AI Agents