Divider 分隔栏

更新时间:2023-10-12 08:00:19下载pdf

简介

分隔线。

代码演示

Divider 默认会根据父元素的宽度自动适配。

详细示例可参考 Divider Demo

import PropTypes from "prop-types";
import React from "react";
import { View, Text, TextInput, ViewPropTypes, StyleSheet } from "react-native";
import { Divider, TYText } from "tuya-panel-kit";

function InputItem({
  style,
  title,
  titleStyle,
  inputStyle,
  ...textInputProps
}) {
  return (
    <View style={[styles.container, style]}>
      <View style={styles.content}>
        <TYText style={[styles.title, titleStyle]}>{title}</TYText>
        <TextInput
          style={[styles.textInput, inputStyle]}
          placeholderTextColor="#dbdbdb"
          {...textInputProps}
        />
      </View>
      <View style={styles.dot} />
      <Divider />
    </View>
  );
}

InputItem.propTypes = {
  ...TextInput.propTypes,
  title: PropTypes.string.isRequired,
  titleStyle: Text.propTypes.style,
  inputStyle: ViewPropTypes.style,
};

InputItem.defaultProps = {
  titleStyle: null,
  inputStyle: null,
};

const styles = StyleSheet.create({
  container: {
    height: 94,
    alignSelf: "stretch",
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "center",
    paddingHorizontal: 24,
    backgroundColor: "#fff",
  },

  content: {
    flex: 1,
    alignItems: "flex-start",
    justifyContent: "center",
  },

  title: {
    fontSize: 14,
    color: "#999",
  },

  textInput: {
    alignSelf: "stretch",
    marginTop: 10,
    fontSize: 16,
    color: "#333",
  },

  dot: {
    width: 6,
    height: 6,
    borderRadius: 3,
    backgroundColor: "#dbdbdb",
  },
});

export default InputItem;

API

style

分隔线样式。

类型 必传
ViewPropTypes.style

flexDirection

主轴方向,默认为 row

类型 必传 默认值
row | column row

visible

是否显示

类型 必传 默认值
boolean true

color

分隔线颜色。

类型 必传 默认值
ColorPropType #dbdbdb

width

分隔线宽,默认为父元素宽。

类型 必传 默认值
number null

height

分隔线高,默认为父元素高。

类型 必传 默认值
number null