0.2.2 • Published 5 years ago

hypertoxin v0.2.2

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

Hypertoxin

Image

npm version npm downloads

A themeable and declarative React Native component library for developing native mobile apps.


Published Open-source App Virida built with Hypertoxin component library.

Checkout Virida on the app store!


Documeantations are still WIP.


Installation

$ npm install hypertoxin --save

Demo & Showcase

Hypertoxin comes with a full demo that you can build and run on your device or simulator. All of the code examples in this README are from the demo. To build the demo for iOS,

$ cd hypertoxin/demo
npm install

This will install the required modules such as React Native, Hypertoxin, Hyperflow, and others. Then open hypertoxin/demo/ios with Xcode, select your ios simulator/device, and build. The default build scheme is release. When use successfully, you will see the following on your device or simulator.

Usage

The imported hypertoxin object is consists of Ht, ThemeContext, and Theme. Ht is an object containing all available components. Theme is the default global theme object which is used as a reference for making custom themes. ThemeContext the a react context provider which is required for setting custom themes.

import React, { Component } from 'react';
import ReactNative from 'react-native'
import { Ht, ThemeContext, Theme as DefaultTheme } from 'hyperflow';

// All current available components with more to come. See todo list.
const {
    FlatButton,
    RaisedButton,
    AreaButton,

    AvatarImage,
    IconImage,
    CoverImage,

    TextField,
    SearchField,

    HorizontalDivider,
    VeriticalDivider,

    HeadlineText,
    TitleText,
    SubtitleText,
    InfoText,
    CaptionText,

    BodyScreen,
    HeaderScreen,

    RowLayout,
    ColumnLayout
} = Ht;

export default class App extends Component {
  render() {
      return (
          <ThemeContext.Provider value = {{
              DefaultTheme // Modify this DefaultTheme object to make your own custom theme
          }}>
              // Top level app component goes here...
          </ThemeContext.Provider>
      );
  }
}

Documentations

Button Components

Hypertoxin has three button components, FlatButton, RaisedButton, and AreaButton

Flat Button Properties

A standard button component that can be styled as an icon, a clear, or simply a flat opaque button.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet button's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
actionstring, objectnoneSet button's onPress callback action to be defined by the parent component. This property is used when a button is set as a child search button for parent components such as SearchField, TextField, or HeaderScreen. See Using Action Property section for details
shadestring, objectthemedSet button's shade theme, can be themed, light, or dark
overlaystringthemedSet button's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet button's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet button's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet button's margin styles. As a number, the margin is equally set around the button. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
disabledbooleanfalseDisable the button
busybooleanfalseEnable button busy activity indicator
rippledboolean, stringthemedEnable button ripple animation
labelstringNoneButton string label
colorstringthemedSet button's color style. Can be hex string, default color name, or themed color name
debouncedbooleanfalseEnable button debouncing at 250 ms
onPressfunctionNoneCalls when button is pressed
styleobjectNoneFlat button style is an object with the following properties: container: {...}, contentLeftRoom: {...}, contentMiddleRoom: {...}, contentRightRoom: {...}, badgeRoom: {...}, activityIndicatorRoom: {...}, label: {...}, ripple: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object

Raised Button Properties

Raised button is similar to flat button with the exceptions that it has permanent drop shadow and opaque color.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet button's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
actionstring, objectnoneSet button's onPress callback action to be defined by the parent component. This property is used when a button is set as a child search button for parent components such as SearchField, TextField, or HeaderScreen. See Using Action Property section for details
shadestring, objectthemedSet button's shade theme, can be themed, light, or dark
cornerstring, number, objectthemedSet button's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet button's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet button's margin styles. As a number, the margin is equally set around the button. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
disabledbooleanfalseDisable the button
busybooleanfalseEnable button busy activity indicator
rippledboolean, stringthemedEnable button ripple animation
labelstringNoneButton string label
colorstringthemedSet button's color style. Can be hex string, default color name, or themed color name
debouncedbooleanfalseEnable button debouncing at 250 ms
onPressfunctionNoneCalls when button is pressed
styleobjectNoneRaised button style is an object with the following properties: container: {...}, contentLeftRoom: {...}, contentMiddleRoom: {...}, contentRightRoom: {...}, badgeRoom: {...}, activityIndicatorRoom: {...}, label: {...}, ripple: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object

Area Button Properties

Unlike flat or raised button, area button was intended mainly as a list item component. Therefore it works nicely as a selectable item in a typical list view.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet button's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
actionstring, objectnoneSet button's onPress callback action to be defined by the parent component. This property is used when a button is set as a child search button for parent components such as SearchField, TextField, or HeaderScreen. See Using Action Property section for details
shadestring, objectthemedSet button's shade theme, can be themed, light, or dark
overlaystringthemedSet button's overlay style which can be one of themed, opaque, translucent, transparent
sizestringthemedSet button's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet button's margin styles. As a number, the margin is equally set around the button. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
disabledbooleanfalseDisable the button
rippledboolean, stringthemedEnable button ripple animation
debouncedbooleanfalseEnable button debouncing at 250 ms
onPressfunctionNoneCalls when button is pressed
styleobjectNoneArea button style is an object with the following properties: container: {...}, contentLeftRoom: {...}, contentRightRoom: {...}, ripple: {...}. Unlike flat and raised buttons, there is no middle room styling. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object

Note: themed property indicates using values defined by the global theme provider.

By default, flat, raised, and area button components pass shade, size, color (flat & raised only), and disabled properties down to their child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. This behavior can be override by child components with the exclusions property. . See Using Exclusions Property section for details.

Flat & raised button animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-content-left-room-view
  • animated-content-middle-room-view
  • animated-content-right-room-view
  • animated-activity-indicator-room-view
  • animated-badge-room-view

Area button animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-content-left-room-view
  • animated-content-right-room-view

Flat, raised & area button methods & callbacks:

  • animate - See Animation API for details
  • onPress - Button press callback
    • arguments:
      • event (object) - React Native event
    • return: None

Flat Button Examples

<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'default' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'primary' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'secondary' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'accent' />

Clear buttons can be created when styling flat buttons with overlay = 'transparent' property. The component will auto-adjust the label text color accordingly.

<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'default' />
<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'primary' />
<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'secondary' />
<FlatButton overlay = 'transparent' label = 'BUTTON' color = 'accent' />

To add icon image to button, add a child icon image component (more details for IconImage component below) with a content room property. All button components have 4 child rooms, content-left, content-middle, content-right, and badge.

Internally, a room is just a convenient way for creating child Views, thus allowing the JSX code to be less clutter and much more declarative.

<FlatButton overlay = 'opaque' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage  room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'opaque' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage  room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-right' source = 'profile' />
</FlatButton>
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'primary' corner = 'sharp' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'secondary' corner = 'round' />
<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'accent' corner = 'circular' />

To create a button with a badge, add a child text component with a room = 'badge'.

<FlatButton overlay = 'opaque' label = 'BUTTON' color = 'primary' >
    <InfoText room = 'badge' color = 'white' > 0 </InfoText>
    <IconImage room = 'content-left' source = 'home' />
</FlatButton>
<FlatButton overlay = 'transparent-outline' size = 'small' label = 'BUTTON' color = 'primary' corner = 'sharp' >
    <IconImage room = 'content-left' source = 'star' />
</FlatButton>
<FlatButton overlay = 'transparent-outline' size = 'normal' label = 'BUTTON' color = 'secondary' corner = 'round' >
    <IconImage room = 'content-right' source = 'star' />
</FlatButton>
<FlatButton overlay = 'transparent-outline' size = 'large' label = 'BUTTON' color = 'accent' corner = 'circular' />
<FlatButton overlay = 'transparent' size = 'small' color = 'primary' corner = 'circular' >
    <IconImage room = 'content-middle' source = 'favorite' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'normal' color = 'secondary' corner = 'circular' >
    <IconImage room = 'content-middle' source = 'favorite' />
</FlatButton>
<FlatButton overlay = 'transparent' size = 'large' color = 'accent' corner = 'circular' >
    <IconImage room = 'content-middle' source = 'favorite' />
</FlatButton>
<FlatButton overlay = 'transparent' color = { Theme.color.palette.purple } corner = 'circular' >
    <IconImage room = 'content-middle' source = 'smiley-face' />
</FlatButton>
<FlatButton overlay = 'transparent' color = { Theme.color.palette.green } corner = 'circular' >
    <IconImage room = 'content-middle' source = 'star' />
</FlatButton>

Raised Button Examples

<RaisedButton label = 'BUTTON' color = 'default' />
<RaisedButton label = 'BUTTON' color = 'primary' />
<RaisedButton label = 'BUTTON' color = 'secondary' />
<RaisedButton label = 'BUTTON' color = 'accent' />
<RaisedButton size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-left' source = 'home' />
</RaisedButton>
<RaisedButton size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-left' source = 'home' />
</RaisedButton>
<RaisedButton size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-left' source = 'home' />
</RaisedButton>
<RaisedButton size = 'small' label = 'SMALL' color = 'primary' >
    <IconImage room = 'content-right' source = 'profile' />
</RaisedButton>
<RaisedButton size = 'normal' label = 'NORMAL' color = 'secondary' >
    <IconImage room = 'content-right' source = 'profile' />
</RaisedButton>
<RaisedButton size = 'large' label = 'LARGE' color = 'accent' >
    <IconImage room = 'content-right' source = 'profile' />
</RaisedButton>
<RaisedButton label = 'BUTTON' color = 'primary' corner = 'sharp' />
<RaisedButton label = 'BUTTON' color = 'secondary' corner = 'round' />
<RaisedButton label = 'BUTTON' color = 'accent' corner = 'circular' />
<RaisedButton color = 'primary' corner = 'circular' size = 'large' >
    <IconImage room = 'content-middle' source = 'add' />
</RaisedButton>
<RaisedButton color = 'secondary' corner = 'circular' size = 'large' >
    <IconImage room = 'content-middle' source = 'edit' />
</RaisedButton>
<RaisedButton color = 'accent' corner = 'circular' size = 'large' >
    <IconImage room = 'content-middle' source = 'star' />
</RaisedButton>

Area Button Examples

<FlatList
    data = { animals }
    renderItem = {(listData) => {
        const animal = listData.item;
        return (
            <AreaButton shade = { shade }>
                <ColumnLayout room = 'content-left' roomAlignment = 'center' >
                    <AvatarImage room = 'content-left' source = { animal.avatarImage } dropShadowed = { false } />
                    <TitleText room = 'content-right' size = 'small' indentation = { 20 }>{ animal.name }</TitleText>
                </ColumnLayout>
                <FlatButton room = 'content-right' overlay = 'transparent' corner = 'circular' color = 'red' >
                    <IconImage room = 'content-middle' source = `favorite` />
                </FlatButton>
            </AreaButton>
        );
    }}
/>

Field Components

Hypertoxin has two field components, TextField and SearchField

Search Field Properties

Use search field to create functional search bar. Notable feature is suggestion pull-up view.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet search field's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
shadestring, objectthemedSet search field's shade theme, can be themed, light, or dark
overlaystringthemedSet search field's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet search field's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet search field's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet search field's margin styles. As a number, the margin is equally set around search field container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
dropShadowedboolean, stringthemedEnable search field's container drop shadow
autoFocusbooleantrueEnable search field's auto focus
autoCorrectbooleantrueEnable search field's auto correct spelling
suggestivebooleantrueEnable search field's suggestion pull-up view
pinnedSuggestionValuesarray of string, number, or object[]A list of pinned suggestion values
hintstringNoneSet search field's hint
styleobjectNoneSearch field style is an object with the following properties: container: {...}, box, {...}, contentLeftRoom: {...}, contentRightRoom: {...}, input: {...}, suggestion: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onSearchfunctionNoneCalls after search field's text input onSubmitEditing
onGetAutocompletionValuesasync functionNoneAsync retrieve autocompletion string value array for suggestion pull-up view
onEditingfunctionNoneCalls when search field's text input onChangeText
onFocusfunctionNoneCalls after search field's text input is focused
onBlurfunctionNoneCalls after search field's text input is blurred
onCollapsefunctionNoneCalls after search field view collapsed
onExpandfunctionNoneCalls after search field view expanded
onHidefunctionNoneCalls when search field view becomes hidden
onShowfunctionNoneCalls when search field view becomes visible
onHideSuggestionfunctionNoneCalls when search field's suggestion view becomes hidden
onShowSuggestionfunctionNoneCalls when search field's suggestion view becomes visible
onClearfunctionNoneCalls after search field's text input is cleared
onClearSuggestionfunctionNoneCalls after search field's suggestion is clear
renderSuggestionItemfunctionNoneTakes an item from a list of suggestion items (pinned, autocompleted, & history) and renders them into the list in pull-up suggestion view

Text Field Properties

Use text fields to create beautiful input forms. Notable features are input reformatting & validation and selectable pull-up view.

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet text field's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media. See Using Room Property section for details
shadestring, objectthemedSet text field's shade theme, can be themed, light, or dark
overlaystringthemedSet text field's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
cornerstring, number, objectthemedSet text field's corner styles. As a number, border radius = corner. Set corner as an object for more control. For example corner = { topLeft: 0.1, topRight: 0.1, bottomLeft: 0.1, bottomRight: 0.1}
sizestringthemedSet text field's size which can be one of themed, small, normal, large
marginstring, number, objectNoneSet text field's margin styles. As a number, the margin is equally set around text field container. Set margin as an object for more control. For example margin = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
autoFocusbooleantrueEnable text field's auto focus
autoCorrectbooleantrueEnable text field's auto correct spelling
securedbooleanfalseEnable text field's secure mode
underlinedboolean, stringthemedEnable text field's underlined animation
disabledbooleanfalseDisable text field's input
initialValuestring, numberNoneSet text input's initial value
selectableValuesarray of string, number, or object[]A list of selectable values
labelstringNoneSet text field's label
hintstringNoneSet text field's hint
charLimitnumber-1Set text input's max characters count. Set charLimit > -1 for no character limit. When charLimit > 1, a little character counter will be visible in the bottom right
lineLimitnumber1Set text input's max lines count. Set lineLimit > 1 for multi-lined text input
inputTypestringdefaultSet text input's type which can be one of default, numeric, monetary, phone-pad, email-address, credit-card-visa, credit-card-master, credit-card-discover, credit-card-american-express
disableValidationboolfalseDisable text input validation
disableFormattingboolfalseDisable text input formatting
styleobjectNoneText field style is an object with the following properties: container: {...}, box: {...}, contentLeftRoom: {...}, contentRightRoom: {...}, input: {...}, helper: {...}, status: {...}, label: {...}, underline: {...}, selection: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onValidatefunctionNoneCalls after text field's text input onChangeText or onEndEditing
onReformatfunctionNoneCalls after text field's text input onChangeText
onEditingfunctionNoneCalls when text field's text input onChangeText
onDoneEditfunctionNoneCalls when a value in text field's selectable pull-up view is selected or after text field's text input onSubmitEditing
onSelectfunctionNoneCalls when a value in text field's selectable pull-up view is selected
onFocusfunctionNoneCalls after text field's text input is focused
onBlurfunctionNoneCalls after text field's text input is blurred
onHideSelectionfunctionNoneCalls after text field's selectable pull-up view is hidden
onShowSelectionfunctionNoneCalls after text field's selectable pull-up view is visible
onClearfunctionNoneCalls after text field's text input is cleared
renderSelectableItemfunctionNoneTakes an item from a list of selectable items and renders them into the list in pull-up selection view

Note: themed property indicates using values defined by the global theme provider.

By default, text field component passes shade, size, and disabled properties down to it child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. By default, search field component passes shade property down to it child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. This behavior can be override by child components with the exclusions property. See Using Exclusions Property section for details.

Search field animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-box-view
  • animated-content-left-room-view
  • animated-content-right-room-view
  • animated-suggestion-view

Search field available actions:

  • search
  • clear
  • blur
  • focus
  • expand
  • collapse
  • show
  • show-suggestion
  • hide
  • hide-suggestion

Search field methods & callbacks:

  • animate - See Animation API for details
  • isCollapsed
    • arguments: None
    • return: bool
  • isVisible
    • arguments: None
    • return: bool
  • isSuggestionVisible
    • arguments: None
    • return: bool
  • isFocused
    • arguments: None
    • return: bool
  • collapse
    • arguments:
      • animation (object) - Collapse animation object. See Animation API for details.
    • return: None
  • expand
    • arguments:
      • animation (object) - Expand animation object. See Animation API for details
    • return: None
  • show
    • arguments:
      • animation (object) - Show animation object. See Animation API for details
    • return: None
  • showSuggestion
    • arguments:
      • animation (object) - Show animation object. See Animation API for details
    • return: None
  • hide
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • hideSuggestion
    • arguments:
      • animation (object) - Hide animation object. See Animation API for details
    • return: None
  • focus
    • arguments: None
    • return: None
  • blur
    • arguments: None
    • return: None
  • clear
    • arguments: None
    • return: None
  • clearSuggestion
    • arguments: None
    • return: None
  • onSearch
    • arguments:
      • value (string) - Submitted search text value
    • return: None
  • onGetAutocompletionValues (async)
    • arguments:
      • value (string) - Submitted search text value
    • return:
      • results (array) - An array of autocompletion text values
  • onEditing
    • arguments:
      • value (string) - Current search text value
    • return: None
  • onFocus
    • arguments: None
    • return: None
  • onBlur
    • arguments: None
    • return: None
  • onCollapse
    • arguments: None
    • return: None
  • onExpand
    • arguments: None
    • return: None
  • onHide
    • arguments: None
    • return: None
  • onShow
    • arguments: None
    • return: None
  • onHideSuggestion
    • arguments: None
    • return: None
  • onShowSuggestion
    • arguments: None
    • return: None
  • onClear
    • arguments: None
    • return: None
  • onClearSuggestion
    • arguments: None
    • return: None
  • renderSuggestionItem - Render the suggestion item component
    • arguments:
      • item (object) - Suggestion item
      • onPressSelectAndSubmit - Callback to indicate which item was selected and then submitted
        • arguments:
          • item - Selected item
        • return: None
      • onPressSelect - Callback to indicate which item was selected
        • arguments:
          • item - Selected item
        • return: None
    • return - Component

Text field animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-box-view
  • animated-label-text
  • animated-underline-focused-view
  • animated-content-left-room-view
  • animated-content-right-room-view
  • animated-selection-view

Text field available actions:

  • clear
  • blur
  • focus
  • show-selection
  • hide-selection

Text field methods & callbacks:

  • animate - See Animation API for details
  • isValidated - Check if text input's value is validated
    • arguments: None
    • return: bool
  • isSelectionVisible - Check if selectable pull-up view is visible
    • arguments: None
    • return: bool
  • isFocused - Check if text input's value is focused
    • arguments: None
    • return: bool
  • showSelection - Show selectable pull-up view if selectableValues is provided
    • arguments: None
    • return: None
  • hideSelection - Hide selectable pull-up view if selectableValues is provided
    • arguments: None
    • return: None
  • focus - Focus text input
    • arguments: None
    • return: None
  • blur - Blur text input
    • arguments: None
    • return: None
  • clear - Clear text input
    • arguments: None
    • return: None
  • onValidate - Calls after text field's text input onChangeText or onEndEditing. See default onValidate
    • arguments:
      • value (string) - Current text value
      • inputType
    • return: object - Expects return object with a validate boolean property and a status string property
  • onReformat - Calls after text field's text input onChangeText. See default onReformat
    • arguments:
      • value (string) - Current text value
    • return: string - Return reformatted value
  • onEditing - Calls when text field's text input onChangeText
    • arguments:
      • value (string) - Current text value
    • return: None
  • onDoneEdit - Calls when a value in text field's selectable pull-up view is selected or after text field's text input onSubmitEditing
    • arguments:
      • value (string) - Current text value
    • return: None
  • onSelect - Calls when a value in text field's selectable pull-up view is selected
    • arguments:
      • value (string) - Selected value
    • return: None
  • onFocus
    • arguments: None
    • return: None
  • onBlur
    • arguments: None
    • return: None
  • onHideSelection
    • arguments: None
    • return: None
  • onShowSelection
    • arguments: None
    • return: None
  • onClear
    • arguments: None
    • return: None
  • renderSelectableItem - Render an item from a list of selectable items and renders them into the list in pull-up selection view.See below for examples

Search Field Examples

<SearchField
    hint = 'Search...'
    pinnedSuggestionValues = {[ `Hypertoxin`, `React Native` ]}
    onGetAutocompletionValues = {async (text) => {
        if (text) {
            const response = await fetch(`http://suggestqueries.google.com/complete/search?client=firefox&q=${text}`, {
                method: `get`
            });
            const data = await response.json();
            return data[1].slice(0, 6);
        }
        return [];
    }}
    renderSuggestionItem = {(item, onPressSelectAndSubmit, onPressSelect) => {
        // item = {
        //     value: ...             String value of the suggestion item
        //     suggestionType: ..     String value to indicate the suggestion types: pin, autocompletion, or history
        // }
        // onPressSelect              Callback to indicate which item was selected
        // onPressSelectAndSubmit     Callback to indicate which item was selected and then submitted
        return (
            <AreaButton shade = { shade } overlay = 'transparent' size = 'small' onPress = {() => onPressSelectAndSubmit(item)}>
                <ColumnLayout room = 'content-left' roomAlignment = 'center'
                >
                    <IconImage
                        room = 'content-left'
                        source = {(() => {
                            switch (item.suggestionType) { // eslint-disable-line
                            case `pin`:
                                return `star`;
                            case `history`:
                                return `history`;
                            case `autocompletion`:
                                return `search`;
                            default:
                                return null;
                            }
                        })()}
                        margin = {{ left: 10 }}
                    />
                    <InfoText room = 'content-right' indentation = { 10 }>{ item.value }</InfoText>
                </ColumnLayout>
                {
                    item.suggestionType !== `pin` ?
                    <FlatButton room = 'content-right' overlay = 'transparent' corner = 'circular' onPress = {() => onPressSelect(item)} margin = {{ right: 10 }}>
                        <IconImage room = 'content-middle' source = 'recall' size = 'small' />
                    </FlatButton> : null
                }
            </AreaButton>
        );
    }}
    style = {{
        suggestion: {
            left: -10
        }
    }}
>
    <FlatButton room = 'content-left' action = 'expand' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'search' />
    </FlatButton>
    <FlatButton room = 'content-left' action = 'collapse' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'go-back' />
    </FlatButton>
    <FlatButton room = 'content-right' action = 'clear' overlay = 'transparent' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</SearchField>

Text Field Examples

<TextField label = 'EMAIL' hint = 'user@gmail.com' inputType = 'email-address' >
    <IconImage room = 'content-left' source = 'email' />
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>
<TextField secured = { true } label = 'PASSWORD' >
    <IconImage room = 'content-left' source = 'lock' />
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>
<TextField label = 'ADD NOTE' charLimit = { 128 } lineLimit = { 5 }>
    <FlatButton overlay = 'transparent' room = 'content-right' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>
<TextField
    label = 'PHONE NUMBER'
    inputType = 'phone-pad'
    charLimit = { 14 }
    onValidate = {(value, inputType) => {
        let regex;
        let validated = true;
        let status = ``;

        if (value !== `` && inputType === `phone-pad`) {
            regex = /^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/;

            validated = regex.test(value);
            status = validated ? `` : `Phone number is invalid`;
        }
        return {
            validated,
            status
        };
    }}
    onReformat = {(value) => {
        return value.split(``).filter((char) => char !== `-` && char !== `(` && char !== `)` && char !== ` `).map((char, index) => {
            if (index === 0) {
                return `(${char}`;
            }
            if (index === 2) {
                return `${char}) `;
            }
            if (index === 5) {
                return `${char}-`;
            }
            return char;
        }).join(``);
    }}
>
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
</TextField>
<TextField
    label = 'LABEL'
    selectableValues = {[ `VALUE A`, `VALUE B`, `VALUE C` ]}
    renderSelectableItem = {(item, onPressSelect) => {
        // item = {
        //     value: ...       String value of the selectable item
        //     selected: ..     Boolean to indicates that the item is selected or not
        // }
        // onPressSelect        Callback to indicate which item was selected
        return (
            <AreaButton
                shade = { shade }
                overlay = 'transparent'
                size = 'small'
                onPress = {() => onPressSelect(item)}
                contentRightRoomAlignment = 'start'
                margin = {{
                    horizontal: 10
                }}
            >
                <InfoText room = 'content-left' indentation = { 10 }>{ item.value }</InfoText>
                {
                    item.selected ? <IconImage room = 'content-right' source = 'check' /> : null
                }
            </AreaButton>
        );
    }}

    <FlatButton room = 'content-right' overlay = 'transparent' action = 'clear' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'cancel' />
    </FlatButton>
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'show-selection' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'collapse' />
    </FlatButton>
    <FlatButton room = 'content-right' overlay = 'transparent' action = 'hide-selection' corner = 'circular' >
        <IconImage room = 'content-middle' source = 'expand' />
    </FlatButton>
</TextField>

Text Components

Hypertoxin has five text components, CaptionText, InfoText, SubtitleText, TitleText, HeadlineText

Text (Caption, Info, Subtitle, Title, & Headline) Properties

PropTypeDefaultDescription
exclusionsarray of string[]Set which properties from parent component to exclude. See Using Exclusions Property section for details
roomstringnoneSet text's room with respect to parent component which can be one of none, content-left, content-middle, content-right, content-bottom, content-top, media, activity-indicator. See Using Room Property section for details
shadestring, objectthemedSet text shade theme, can be themed, light, or dark
sizestringthemedSet text font's size which can be one of themed, small, normal, large
alignmentstringleftSet text's alignment which can be one of left, center, right
decorationstringnoneSet text's decoration which can be one of none, underline, line-through
fontstringthemedSet text font's family which can be themed or font family name
uppercasedbooleanFalseForce uppercased text
lowercasedbooleanFalseForce lowercased text
indentationnumber0Set text indentation
colorstringthemedSet text's color style. Can be hex string, default color name, or themed color name
styleobjectNoneStandard React Native text style properties

Note: themed property indicates using values defined by the global theme provider.

Text (caption, info, subtitle, title, & headline) animated internal view composition reference names. See Animation API for details:

  • animated-text

Text (caption, info, subtitle, title, & headline) methods & callbacks:

Text (Caption, Info, Subtitle, Title, & Headline) Examples

<HeadlineText size = 'large' color = 'default' > Headline Large </HeadlineText>
<HeadlineText size = 'normal' color = 'primary' > Headline Normal </HeadlineText>
<HeadlineText size = 'small' color = 'secondary' > Headline Small </HeadlineText>
<TitleText size = 'large' color = 'default' > Headline Large </TitleText>
<TitleText size = 'normal' color = 'primary' > Headline Normal </TitleText>
<TitleText size = 'small' color = 'secondary' > Headline Small </TitleText>
<SubtitleText size = 'large' color = 'default' > Headline Large </SubtitleText>
<SubtitleText size = 'normal' color = 'primary' > Headline Normal </SubtitleText>
<SubtitleText size = 'small' color = 'secondary' > Headline Small </SubtitleText>
<InfoText size = 'large' color = 'default' > Headline Large </InfoText>
<InfoText size = 'normal' color = 'primary' > Headline Normal </InfoText>
<InfoText size = 'small' color = 'secondary' > Headline Small </InfoText>
<CaptionText size = 'large' color = 'default' > Headline Large </CaptionText>
<CaptionText size = 'normal' color = 'primary' > Headline Normal </CaptionText>
<CaptionText size = 'small' color = 'secondary' > Headline Small </CaptionText>

Screen Components

Hypertoxin has two screen components, BodyScreen, HeaderScreen

Header Screen Properties

Use header screen to create navigation top bar.

PropTypeDefaultDescription
shadestring, objectthemedSet header screen's shade theme, can be themed, light, or dark
overlaystringthemedSet header screen's overlay style which can be one of themed, opaque, translucent, translucent-outline, transparent, transparent-outline
sizestringthemedSet header screen's size which can be one of themed, small, normal, large
dropShadowedboolean, stringthemedEnable header screen's drop shadow
coverImageSourceReact Native image sourceNoneHeader screen's background cover image source
labelstringNoneSet header screen's label
styleobjectNoneHeader screen style is an object with the following properties: container: {...}, status: {...}, navigation: {...}, contentLeftRoom: {...}, contentMiddleRoom: {...}, contentRightRoom: {...}, mediaRoom: {...}, label: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onHideNavigationfunctionNoneCalls when header screen's navigator view becomes hidden
onShowNavigationfunctionNoneCalls when header screen's navigator view becomes visible
onHideMediafunctionNoneCalls when header screen's media view becomes hidden
onShowMediafunctionNoneCalls when header screen's media view becomes visible

Body Screen Properties

PropTypeDefaultDescription
shadestring, objectthemedSet body screen's shade theme, can be themed, light, or dark
overlaystringthemedSet body screen's overlay style which can be one of themed, opaque, translucent, transparent
colorstringthemedSet body screen's color style. Can be hex string, default color name, or themed color name
paddingstring, number, objectNoneSet body screen's padding styles. As a number, the padding is equally set around the screen. Set padding as an object for more control. For example padding = { top: 5, bottom: 5, left: 5, right: 5, horizontal: 5, vertical: 5}
coverImageSourceReact Native image sourceNoneBody screen's background cover image source
contentTopRoomAlignmentstringnoneChild component top room property, which can be one of none, start, center, end, or stretch
contentMiddleRoomAlignmentstringnoneChild component middle room property, which can be one of none, start, center, end, or stretch
contentBottomRoomAlignmentstringnoneChild component bottom room property, which can be one of none, start, center, end, or stretch
scrollablebooleanFalseEnable to allow scrolling
keyboardAvoidingbooleanFalseEnable to allow keyboard avoiding. Works best with scrollable = true
styleobjectNoneBody screen style is an object with the following properties: container: {...}, contentTopRoom: {...}, contentMiddleRoom: {...}, contentBottomRoom: {...}. Standard React Native style properties go inside these properties. Changes to these properties will override the global theme. See default style object
onScrollfunctionNoneCalls when scrolling with scrollable = true

Note: themed property indicates using values defined by the global theme provider.

By default, header screen component passes shade, size, and color properties down to it child components and at the same time set margin = { 0 } and indentation = { 0 } properties onto its children. By default, body screen component passes shade property down to it child components. This behavior can be override by child components with the exclusions property. See Using Exclusions Property section for details.

Header screen animated internal view composition reference names. See Animation API for details:

  • animated-container-view
  • animated-navigation-view
  • animated-content-left-room-view
  • animated-content-middle-room-view
  • animated-content-right-room-view
  • `anima