import React, { Component } from 'react'
import { StyleSheet, View, Text, Image, TouchableHighlightBase, ScrollView, TextInput } from 'react-native'
import { px2dp, replaceSymbol, width } from '../../utils/base'
export interface Props {
    title?: string
    onChangeText: (any) => void
}

export interface State {
    container: string
}


const setNumber = (text: string) => {
    let str = ""
    if (typeof text == "string") {
        str = replaceSymbol(text)
    }
    return str

}

const setText = (text) => {
    return text.split(" ").join("");
}


export default class LongTextInput extends React.Component<Props, State> {
    constructor(props: Props | Readonly<Props>) {
        super(props);

    }
    componentDidMount() {

    }

    componentWillUnmount() {
    }

    public readonly state: Readonly<State> = {
        container: ""
    }
    onChangeText = (text) => {
        let { onChangeText } = this.props;
        onChangeText && onChangeText(text)
    }

    render() {
        let { title } = this.props;
        return (
            <ScrollView style={styles.main}
                showsVerticalScrollIndicator={false}
                scrollEnabled={true}

            >
                <TextInput
                    style={styles.textEditArea}
                    multiline
                    placeholder={`${title}～`}
                    // maxLength={500}
                    onChangeText={this.onChangeText}
                    returnKeyLabel="完成"
                    returnKeyType="done"
                />
            </ScrollView>
        );

    }
}



const styles = StyleSheet.create({
    main: {
        // minHeight: px2dp(160),
        // height: px2dp(240)
        // width: width - px2dp(25),
        flex: 1,
        alignSelf: "center"

    },
    textEditArea: {
        width: width - px2dp(25),
        // maxHeight: px2dp(280),
        minHeight: px2dp(180),
        // overflow: 'scroll',
        paddingVertical: 0,
        fontSize: 16,
        color: '#333',
        // color: "#f6f6f6",
        lineHeight: 21,
    },


})

export {
    // LongTextInput,
    setNumber,
    setText
}