-
Notifications
You must be signed in to change notification settings - Fork 734
Feat/segemented control new UI preset #3061
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 16 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
093dfd6
added new segmented control ui preset
nitzanyiz 356c534
fixed icon tint coloring
nitzanyiz 1b20dd7
changed display name and removed extra imports
nitzanyiz 6666f8c
fixed outline offsets with the divider
nitzanyiz ca6bd35
Merge remote-tracking branch 'origin' into feat/SegementedControlNewU…
nitzanyiz 7b4a79a
changed inset and width calculation. added key to dividers
nitzanyiz b2614f5
exposed iconTintColor. added example in example screen
nitzanyiz e5aa8c7
removed icon from example
nitzanyiz 1a73286
Merge remote-tracking branch 'origin' into feat/SegementedControlNewU…
nitzanyiz fe74337
added key to fregment
nitzanyiz 6d06d0b
changed const to enum
nitzanyiz 8762bb0
added static members
nitzanyiz eeca220
removed enum usage in useSegmentedControl
nitzanyiz 6c15bce
added preset segmented control to screen
nitzanyiz 5ecb31f
fixed labels
nitzanyiz 04ac68d
remnoved another reanimated view on default preset
nitzanyiz a58aeda
changed borderWidth checking
nitzanyiz c44252c
changed displayName
nitzanyiz 00020ca
moved custom styling to bottom of screen
nitzanyiz 25f498d
fixed displayName
nitzanyiz 39b81a3
fix to preset change
nitzanyiz 7acbb2d
removed extra segmentes. removed key from view
nitzanyiz 3eb4c8f
formattings
nitzanyiz 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
54 changes: 54 additions & 0 deletions
54
src/components/segmentedControl/useSegmentedControlPreset.ts
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,54 @@ | ||
import type {SegmentedControlProps, Presets} from './'; | ||
import {BorderRadiuses, Colors} from '../../style/'; | ||
import {SegmentProps} from './segment'; | ||
import type {ColorValue} from 'react-native'; | ||
|
||
interface useSegmentedControlPresetProps extends SegmentedControlProps, Partial<SegmentProps> { | ||
Inbal-Tish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
segmentDividerWidth: number; | ||
segmentDividerColor: ColorValue; | ||
iconTintColor?: string; | ||
} | ||
const DEFAULT_ACTIVE_COLOR = Colors.$textPrimary; | ||
const FORM_TEXT_COLOR = Colors.$textDefault; | ||
|
||
const useSegmentedControlPreset = (props: SegmentedControlProps): useSegmentedControlPresetProps => { | ||
const {preset = 'default', activeColor, inactiveColor, outlineColor} = props; | ||
const presetProps = { | ||
...defaultsPresetsProps[preset], | ||
...props | ||
}; | ||
if (activeColor && !outlineColor && preset === 'default') { | ||
presetProps.outlineColor = activeColor; | ||
} | ||
if (activeColor || inactiveColor) { | ||
delete presetProps.iconTintColor; | ||
} | ||
return presetProps; | ||
}; | ||
|
||
const defaultsPresetsProps: Record<`${Presets}`, useSegmentedControlPresetProps> = { | ||
default: { | ||
activeColor: DEFAULT_ACTIVE_COLOR, | ||
borderRadius: BorderRadiuses.br100, | ||
backgroundColor: Colors.$backgroundNeutralLight, | ||
activeBackgroundColor: Colors.$backgroundDefault, | ||
inactiveColor: Colors.$textNeutralHeavy, | ||
outlineColor: DEFAULT_ACTIVE_COLOR, | ||
outlineWidth: 1, | ||
segmentDividerWidth: 0, | ||
segmentDividerColor: '' | ||
}, | ||
form: { | ||
activeColor: FORM_TEXT_COLOR, | ||
inactiveColor: FORM_TEXT_COLOR, | ||
backgroundColor: Colors.$backgroundDefault, | ||
activeBackgroundColor: Colors.$backgroundElevated, | ||
outlineColor: Colors.$outlinePrimary, | ||
borderRadius: BorderRadiuses.br20, | ||
outlineWidth: 2, | ||
iconTintColor: Colors.$iconDefault, | ||
segmentDividerWidth: 1, | ||
segmentDividerColor: Colors.$outlineDefault | ||
} | ||
}; | ||
export default useSegmentedControlPreset; |
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.