2020-02-11 14:01:35 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, Text, View } from 'react-native';
|
|
|
|
import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit';
|
|
|
|
|
|
|
|
import sharedStyles from '../../views/Styles';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../lib/constants';
|
2022-03-16 19:07:49 +00:00
|
|
|
import { IInput } from './interfaces';
|
2020-02-11 14:01:35 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
marginBottom: 16
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
fontSize: 14,
|
|
|
|
marginVertical: 10,
|
|
|
|
...sharedStyles.textSemibold
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
marginBottom: 10,
|
|
|
|
fontSize: 15,
|
|
|
|
...sharedStyles.textRegular
|
|
|
|
},
|
|
|
|
error: {
|
|
|
|
marginTop: 8,
|
|
|
|
fontSize: 14,
|
|
|
|
...sharedStyles.textRegular,
|
|
|
|
...sharedStyles.textAlignCenter
|
|
|
|
},
|
|
|
|
hint: {
|
|
|
|
fontSize: 14,
|
|
|
|
...sharedStyles.textRegular
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
export const Input = ({ element, parser, label, description, error, hint, theme }: IInput) => (
|
2020-02-11 14:01:35 +00:00
|
|
|
<View style={styles.container}>
|
2021-09-13 20:41:05 +00:00
|
|
|
{label ? (
|
|
|
|
<Text style={[styles.label, { color: error ? themes[theme].dangerColor : themes[theme].titleText }]}>{label}</Text>
|
|
|
|
) : null}
|
2020-02-11 14:01:35 +00:00
|
|
|
{description ? <Text style={[styles.description, { color: themes[theme].auxiliaryText }]}>{description}</Text> : null}
|
|
|
|
{parser.renderInputs({ ...element }, BLOCK_CONTEXT.FORM, parser)}
|
|
|
|
{error ? <Text style={[styles.error, { color: themes[theme].dangerColor }]}>{error}</Text> : null}
|
|
|
|
{hint ? <Text style={[styles.hint, { color: themes[theme].auxiliaryText }]}>{hint}</Text> : null}
|
|
|
|
</View>
|
|
|
|
);
|