1.3.1 • Published 6 years ago

react-native-alert-pickers v1.3.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

About

An advanced alerts and pickers with js.

Installation

$ npm install react-native-alert-pickers
$ react-native link react-native-alert-pickers

Contents

Advanced Pickers

Advanced Alerts

Notes

All APXXXPickers or APXXXAlerts aren't support props while config.
For example:

/// Bad use
<APColorPicker mode="hls" ref={r => (this.picker = r)} />

/// Good use
<APColorPicker ref={r => (this.picker = r)} />

Usages

APColorPicker

  • 配置(Configuration)
属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
mode"rgb", "rgba"(默认/Default), "rgb-hex", "rgba-hex", "hsl", "hsla"NO是否以 16 进制显示
cancelButtonAPButtonNO设置取消按钮
selectButtonAPButtonNO设置选择按钮
  • 方法(Method)
/**
* @param colorPickerConfig: The picker's config
* refrence `Configuration`
*/
show({ colorPickerConfig?: APColorPickerConfig })
  • Usage
// import module
import { APColorPicker } from "react-native-alert-pickers"

// Use
render() {
    return (
      <View style={{ flex: 1, justifyContent: "center" }}>
        <APColorPicker ref={r => (this.picker = r)} />
      </View>
    );
  }

// Show picker
_onShow = () => {
	// Normal
	this.picker.show()
	// Use keyword `global`
	// global.picker.show()
	
	// maybe you want to show with "hsla", easy...
	// this.picker.show({ mode: "hsla" })
	// also, if you want to set `cancelButton`
	// this.picker.show({ cancelButton: { title: "Oh, Amazing!", font: { color: "skyblue" } } })
}
  • Results

The mode is "rgba" or "hlsa":

APContactPicker

  • 配置(Configuration)
属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
cancelButtonAPButtonNO设置取消按钮
searchBarAPSearchBarNO设置搜索框
onSelected({ name: string, phoneNumber: string}) => voidNO回调函数
  • 方法(Method)
/**
* @param contactPickerConfig: The picker's config
* refrence `Configuration`
*/
show({ contactPickerConfig?: APContactPickerConfig })
  • Usage
// import module
import { APContactPicker } from "react-native-alert-pickers"

// Use
render() {
    return (
      <View style={{ flex: 1, justifyContent: "center" }}>
        <APContactPicker ref={r => (this.picker = r)} />
      </View>
    );
  }

// Show picker
_onShow = () => {
  // Normal
  this.picker.show()
  // Use keyword `global`
  // global.picker.show()

  // add some config
  // this.picker.show({ #your_configuration# })
}
  • Results

APLocalePicker

  • 配置(Configuration)
属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
mode"country"(默认/Default), "phoneCode"NO显示模式
cancelButtonAPButtonNO设置取消按钮
searchBarAPSearchBarNO设置搜索框
onSelected({ code: string, name: string, dial_code: string }) => voidNO回调函数
  • 方法(Method)
/**
* @param localePickerConfig: The picker's config
* refrence `Configuration`
*/
show({ localePickerConfig?: APLocalePickerConfig })
  • Usage
// import module
import { APLocalePicker } from "react-native-alert-pickers"

// Use
render() {
    return (
      <View style={{ flex: 1, justifyContent: "center" }}>
        <APLocalePicker ref={r => (this.picker = r)} />
      </View>
    );
  }

// Show picker
_onShow = () => {
  // Normal
  this.picker.show()
  // Use keyword `global`
  // global.picker.show()

  // add some config
  // this.picker.show({ #your_configuration# })
}
  • Results

mode: phoneCode

mode: country

APImagePicker(iOS only)

  • 配置(Configuration)
属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
provider"system"(默认/Default), "self"NO图片提供者
horizontaltrue/falseNO是否水平展示图片
imagesimageNO图片数组,在provider="self"下赋值
selectMode"single", "multiple"NO单选或多选
selectTitle"选择"NO选择按钮的标题
cancelTitle"取消"NO取消按钮的标题
onSelected(images) => voidNO回调函数,返回选中的图片
  • 方法(Method)
/**
* @param imagePickerConfig: The picker's config
* refrence `Configuration`
*/
show({ imagePickerConfig?: APImagePickerConfig })
  • Usage
// import module
import { APImagePicker } from "react-native-alert-pickers"

// Use
render() {
    return (
      <View style={{ flex: 1, justifyContent: "center" }}>
        <APImagePicker ref={r => (this.picker = r)} />
      </View>
    );
  }

// Show picker
_onShow = () => {
  // Normal
  this.picker.show()
  // Use keyword `global`
  // global.picker.show()

  // add some config
  // this.picker.show({ #your_configuration# })
}
  • Results

APAlert

  • 配置(Configuration)
属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
mode"alert"(默认/Default), "action-sheet"NO提示模式
titlestringNO提示之标题
messagestringNO提示之信息
alertButtons[APButton]NO提示之按钮数组
cancelIndex0NO取消按钮在按钮数组中的下标
  • 方法(Method)
/**
* @param alertConfig: The picker's config
* refrence `Configuration`
*/
show({ alertConfig?: APAlertConfig })

// Convenience methods
alert({ alertConfig?: APAlertConfig })
actionSheet({ alertConfig?: APAlertCofnig})
  • Usage
// import module
import { APAlert } from "react-native-alert-pickers"

// Use
render() {
    return (
      <View style={{ flex: 1, justifyContent: "center" }}>
        <APAlert ref={r => (this.alert = r)} />
      </View>
    );
  }

// Show picker
_onShow = () => {
  // Normal
  this.alert.show()
  // Use keyword `global`
  // global.alert.show()

  // add some config
  // this.alert.show({ #your_configuration# })
}
  • Results

APTextFieldAlert

  • 配置(Configuration)
属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
iconAPImageNO图片
titlestringNO提示之标题
messagestringNO提示之信息
alertButtons[APButton]NO提示之按钮数组
textFields[APTextField]NO提示之输入框数组
  • 方法(Method)
/**
* @param textFieldAlertConfig: The picker's config
* refrence `Configuration`
*/
show({ textFieldAlertConfig?: APTextFieldAlertConfig })
  • Usage
// import module
import { APTextFieldAlert } from "react-native-alert-pickers"

// Use
render() {
    return (
      <View style={{ flex: 1, justifyContent: "center" }}>
        <APTextFieldAlert ref={r => (this.alert = r)} />
      </View>
    );
  }

// Show picker
_onShow = () => {
    this.alert.show({
      icon: { source: require("./interior_design_1.jpg") },
      title: "Log in",
      message: "Enter your Username and Password to login.",
      textFields: [
        {
          key: "username",
          config: { placeholder: "Choose your username" },
          borderStyle: { borderRadius: 0 }
        },
        {
          key: "password",
          config: { placeholder: "Enter your password" }
        }
      ],
      alertButtons: [
        { title: "Log in", onPress: vals => console.log(vals) },
        { title: "Cancel", font: { color: "red" } }
      ]
    })
  }
  
  // the vals format is associated with textFields key, eg: { username: "", password: "" }
  • Results

Properities

APFont

属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
color"black"NO字体颜色
fontSize17NO字体大小
fontWeight300NO字体粗细
textAlign"center", "left", "right"NO字体排列

APImage

属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
sourceimage's sourceNO图片资源
styleimage's styleNO图片风格

APButton

属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
fontAPFontNO按钮之字体设置
titlestringNO按钮之标题
styleview's styleNO按钮之style
enabletrue/falseNO按钮之使能(和失能)
disabledColor"gray"NO按钮之失能时标题的颜色
activeOpacity0.8NO按钮之点击透明度
onPress(title) => voidNO按钮之点击回调
leftImageAPImageNO按钮之左视图
rightImageAPImageNO按钮之右视图

APTextField

属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
keystringNO输入框之key
fontAPFontNO按钮之字体设置
configobjectNO输入框的配置
regularstringNO正则表达式
leftImageAPImageNO输入框之左视图
rightImageAPImageNO输入框之右视图
borderStyleAPBorderStyleNO输入框之边框设置

APSearchBar

属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
barWidth"100%"NO搜索框宽度
tintColor"rgb(220, 220, 220)"NO搜索框背景色
backgroundColor"white"NO搜索条背景色
textFieldAPTextFieldNO搜索输入框
cancelTitle"取消"NO取消按钮的标题

APBorderStyle

属性名称(Properties Name)值或类型(Values or Types)是否必需(Required)描述(Description)
borderWidth1NO边框宽度
borderColor"black"NO边框颜色
borderRadius0NO边框四角弧度
1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago