mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
98 lines
2.6 KiB
TypeScript
98 lines
2.6 KiB
TypeScript
/* eslint react/prop-types: "off", react-native/no-inline-styles: "off" */
|
|
import React, { useState } from 'react';
|
|
import { Keyboard, Pressable, StyleSheet, View } from 'react-native';
|
|
import { Icon, Text } from '@rneui/themed';
|
|
|
|
import loc from '../loc';
|
|
import { useTheme } from './themes';
|
|
|
|
interface IHash {
|
|
[key: string]: string;
|
|
}
|
|
|
|
type ArrowPickerProps = {
|
|
onChange: (key: string) => void;
|
|
items: IHash;
|
|
isItemUnknown: boolean;
|
|
};
|
|
|
|
export const ArrowPicker = (props: ArrowPickerProps) => {
|
|
const keys = Object.keys(props.items);
|
|
const [keyIndex, setKeyIndex] = useState(0);
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesHook = {
|
|
text: {
|
|
color: colors.foregroundColor,
|
|
},
|
|
};
|
|
return (
|
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
<Pressable
|
|
accessibilityRole="button"
|
|
accessibilityLabel={loc.send.dynamic_prev}
|
|
onPress={() => {
|
|
Keyboard.dismiss();
|
|
let newIndex = keyIndex;
|
|
if (keyIndex <= 0) {
|
|
newIndex = keys.length - 1;
|
|
} else {
|
|
newIndex--;
|
|
}
|
|
setKeyIndex(newIndex);
|
|
props.onChange(keys[newIndex]);
|
|
}}
|
|
style={({ pressed }) => [
|
|
{
|
|
backgroundColor: pressed ? 'rgb(210, 230, 255)' : 'white',
|
|
},
|
|
styles.wrapperCustom,
|
|
]}
|
|
>
|
|
{/*
|
|
// @ts-ignore: Ignore */}
|
|
<Icon size={24} name="chevron-left" type="ionicons" tvParallaxProperties={undefined} />
|
|
</Pressable>
|
|
<View style={{ width: 200 }}>
|
|
<Text style={[styles.text, stylesHook.text]}>{props.isItemUnknown ? loc.send.fee_custom : keys[keyIndex]}</Text>
|
|
</View>
|
|
<Pressable
|
|
accessibilityRole="button"
|
|
accessibilityLabel={loc.send.dynamic_next}
|
|
onPress={() => {
|
|
Keyboard.dismiss();
|
|
let newIndex = keyIndex;
|
|
if (keyIndex + 1 >= keys.length) {
|
|
newIndex = 0;
|
|
} else {
|
|
newIndex++;
|
|
}
|
|
setKeyIndex(newIndex);
|
|
props.onChange(keys[newIndex]);
|
|
}}
|
|
style={({ pressed }) => [
|
|
{
|
|
backgroundColor: pressed ? 'rgb(210, 230, 255)' : 'white',
|
|
},
|
|
styles.wrapperCustom,
|
|
]}
|
|
>
|
|
{/*
|
|
// @ts-ignore: Ignore */}
|
|
<Icon size={24} name="chevron-right" type="ionicons" tvParallaxProperties={undefined} />
|
|
</Pressable>
|
|
</View>
|
|
);
|
|
};
|
|
|
|
const styles = StyleSheet.create({
|
|
wrapperCustom: {
|
|
borderRadius: 8,
|
|
padding: 5,
|
|
marginLeft: 20,
|
|
marginRight: 20,
|
|
},
|
|
text: { fontWeight: 'bold', fontSize: 12, textAlign: 'center' },
|
|
});
|