import * as React from 'react'; import { Button, Component, Styles, Text, TextInput, Types, View } from 'reactxp'; import { colors } from '../../config.json'; import ImageView from './ImageView'; const styles = { cellButton: { base: Styles.createButtonStyle({ backgroundColor: colors.blue, paddingVertical: 0, paddingHorizontal: 16, marginBottom: 1, flex: 1, flexDirection: 'row', alignItems: 'center', alignContent: 'center', cursor: 'default', }), section: Styles.createButtonStyle({ backgroundColor: colors.blue40, }), hover: Styles.createButtonStyle({ backgroundColor: colors.blue80, }), }, cellContainer: Styles.createViewStyle({ backgroundColor: colors.blue, flexDirection: 'row', alignItems: 'center', paddingLeft: 16, paddingRight: 12, }), footer: { container: Styles.createViewStyle({ paddingTop: 8, paddingRight: 24, paddingBottom: 24, paddingLeft: 24, }), text: Styles.createTextStyle({ fontFamily: 'Open Sans', fontSize: 13, fontWeight: '600', lineHeight: 20, letterSpacing: -0.2, color: colors.white80, }), }, label: { container: Styles.createViewStyle({ marginLeft: 8, marginTop: 14, marginBottom: 14, flex: 1, }), text: Styles.createTextStyle({ fontFamily: 'DINPro', fontSize: 20, fontWeight: '900', lineHeight: 26, letterSpacing: -0.2, color: colors.white, }), }, input: { frame: Styles.createViewStyle({ flexGrow: 0, backgroundColor: 'rgba(255,255,255,0.1)', borderRadius: 4, paddingHorizontal: 2, paddingVertical: 2, }), text: Styles.createTextStyle({ color: colors.white, backgroundColor: 'transparent', fontFamily: 'Open Sans', fontSize: 20, fontWeight: '600', lineHeight: 26, textAlign: 'right', }), }, icon: Styles.createViewStyle({ marginLeft: 8, }), subtext: Styles.createTextStyle({ color: colors.white60, fontFamily: 'Open Sans', fontSize: 13, fontWeight: '800', flex: -1, textAlign: 'right', marginLeft: 8, }), sectionTitle: Styles.createTextStyle({ backgroundColor: colors.blue, paddingVertical: 14, paddingHorizontal: 24, marginBottom: 1, fontFamily: 'DINPro', fontSize: 20, fontWeight: '900', lineHeight: 26, color: colors.white, }), }; interface ICellButtonProps { children?: React.ReactNode; disabled?: boolean; cellHoverStyle?: Types.StyleRuleSetRecursive; style?: Types.StyleRuleSetRecursive; onPress?: () => void; } interface IState { hovered: boolean; } const CellSectionContext = React.createContext(false); const CellHoverContext = React.createContext(false); export class CellButton extends Component { public state = { hovered: false }; public onHoverStart = () => (!this.props.disabled ? this.setState({ hovered: true }) : null); public onHoverEnd = () => (!this.props.disabled ? this.setState({ hovered: false }) : null); public render() { const { children, style, cellHoverStyle, ...otherProps } = this.props; const hoverStyle = cellHoverStyle || styles.cellButton.hover; return ( {(containedInSection) => ( )} ); } } interface ISectionTitleProps { children?: React.ReactText; } export function SectionTitle(props: ISectionTitleProps) { return {props.children}; } interface ISectionProps { children?: React.ReactNode; } export class Section extends Component { public render() { return ( {this.props.children} ); } } interface IContainerProps { children: React.ReactNode; } export function Container({ children }: IContainerProps) { return {children}; } interface ILabelProps { containerStyle?: Types.ViewStyleRuleSet; textStyle?: Types.TextStyleRuleSet; cellHoverContainerStyle?: Types.ViewStyleRuleSet; cellHoverTextStyle?: Types.TextStyleRuleSet; onPress?: (event: Types.SyntheticEvent) => void; children?: React.ReactNode; } export function Label(props: ILabelProps) { const { children, containerStyle, textStyle, cellHoverContainerStyle, cellHoverTextStyle, ...otherProps } = props; return ( {(hovered) => ( {children} )} ); } interface InputFrameProps { children?: React.ReactNode; style?: Types.StyleRuleSetRecursive; } export function InputFrame(props: InputFrameProps) { const { style, children } = props; return {children}; } export const Input = React.forwardRef(function InputT( props: Types.TextInputProps, ref?: React.Ref, ) { const { style, ...otherProps } = props; return ( ); }); type SubTextProps = Types.TextProps & { cellHoverStyle?: Types.ViewStyle; }; export function SubText(props: SubTextProps) { const { children, ref: _, style, cellHoverStyle, ...otherProps } = props; return ( {(hovered) => ( {children} )} ); } export function Icon(props: ImageView['props']) { const { children: _children, style, tintColor, tintHoverColor, ...otherProps } = props; return ( {(hovered) => ( )} ); } export function Footer({ children }: IContainerProps) { return ( {children} ); }