mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-07 20:53:54 -05:00
* [INJIMOB-3622]: add the new branding changes Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3651]: update the new branding changes Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3651]: update the new snapshots Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3651]: update the changes mentioned deskcheck Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> --------- Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> Signed-off-by: jaswanthkumartw <jaswanthkumar.p@thoughtworks.com>
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import React, {useEffect, useState} from 'react';
|
|
import {Dimensions} from 'react-native';
|
|
import {Icon, ListItem} from 'react-native-elements';
|
|
import {Column} from './Layout';
|
|
import {Text} from './Text';
|
|
import {Theme} from './styleUtils';
|
|
import testIDProps from '../../shared/commonUtil';
|
|
|
|
interface Picker extends React.VFC<PickerProps<unknown>> {
|
|
<T>(props: PickerProps<T>): ReturnType<React.FC>;
|
|
}
|
|
|
|
export const SetupPicker: Picker = (props: PickerProps<unknown>) => {
|
|
const [isContentVisible, setIsContentVisible] = useState(false);
|
|
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
|
|
useEffect(() => {
|
|
setSelectedIndex(
|
|
props.items.findIndex(({value}) => value === props.selectedValue),
|
|
);
|
|
}, [props.selectedValue]);
|
|
|
|
const toggleContent = () => setIsContentVisible(!isContentVisible);
|
|
|
|
const selectItem = (index: number) => {
|
|
setSelectedIndex(index);
|
|
props.onValueChange(props.items[index].value, index);
|
|
toggleContent();
|
|
};
|
|
|
|
return (
|
|
<Column
|
|
testID={props.testID}
|
|
width={Dimensions.get('window').width * 0.8}
|
|
backgroundColor={Theme.Colors.whiteBackgroundColor}>
|
|
{props.items.map((item, index) => (
|
|
<ListItem
|
|
bottomDivider
|
|
topDivider={index !== 0}
|
|
onPress={() => selectItem(index)}
|
|
key={index}>
|
|
<ListItem.Content>
|
|
<ListItem.Title
|
|
{...testIDProps(item.value)}
|
|
style={{paddingTop: 3}}>
|
|
<Text
|
|
color={selectedIndex === index ? Theme.Colors.Icon : null}
|
|
size={'medium'}
|
|
weight={selectedIndex === index ? 'semibold' : 'regular'}>
|
|
{item.label}
|
|
</Text>
|
|
</ListItem.Title>
|
|
</ListItem.Content>
|
|
{selectedIndex === index ? (
|
|
<Icon name="radio-button-checked" color={Theme.Colors.Icon} />
|
|
) : (
|
|
<Icon name="radio-button-unchecked" color={Theme.Colors.GrayIcon} />
|
|
)}
|
|
</ListItem>
|
|
))}
|
|
</Column>
|
|
);
|
|
};
|
|
|
|
interface PickerProps<T> {
|
|
testID?: string;
|
|
items: PickerItem<T>[];
|
|
selectedValue: T;
|
|
onValueChange: (value: T, index: number) => void;
|
|
}
|
|
|
|
interface PickerItem<T> {
|
|
label: string;
|
|
value: T;
|
|
}
|