0.2.1 • Published 2 years ago

react-native-settings-ui v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-settings-ui

Platform - Android and iOS License: MIT React Native

Note that the color is a bit different because of the video format

Installation

npm install react-native-settings-ui

Imports

import {
  SettingsProvider,
  SettingsGroup,
  SettingsInfoDisplay,
  SettingsToggle,
  SettingsButton,
} from 'react-native-settings-ui';

Expo

Take a look of example, which used expo.


Component breakdown, complete code in here

SettingsProvider

<SettingsProvider theme="light">{SettingsGroup}</SettingsProvider>

SettingsProvider is a wrapper component that provides a prebuilt theme.

PropTypeDefaultDescription
themestring"light"The theme to be applied to the settings components. Accepted values are "light" and "dark".

SettingsGroup

<SettingsGroup title="My app settings" footerText="Hello, this is toggle">
    {SettingsComponent}
</SettingsProvider>

The SettingsGroup component is a container for organizing your settings components into logical groups. It displays a title and an optional footer text.

PropTypeDefaultDescription
titlestringThe title displayed at the top of the settings group.
childrenReactNodeThe settings components to be displayed within the group.
footerTextstring(Optional) The footer text displayed at the bottom of the settings group. Default is null.

SettingsToggle

<SettingsToggle
  title="Default color"
  value={isToggled}
  onValueChange={() => setIsToggled(!isToggled)}
/>

The SettingsToggle component is a customizable switch for the settings components. It allows you to toggle between true and false states, and dispaly different infos.

PropTypeDefaultDescription
titlestringThe title displayed next to the toggle switch.
valuebooleanThe current value of the toggle switch (true or false).
onValueChange(newValue: boolean) => voidCallback function that is triggered when the toggle switch value changes.
titleTextStyleTextStyle(Optional) Custom text style for the title. Default is null.
trackColor{ false: ColorValue; true: ColorValue; }{ false: '#767577', true: '#81b0ff' }(Optional) Custom track color for the switch when false and true.
thumbColorOffColorValue"#eaeaea"(Optional) Custom thumb color for the switch when the value is false.
thumbColorOnColorValue"#fff"(Optional) Custom thumb color for the switch when the value is true.
ios_backgroundColorColorValue"#3e3e3e"(Optional) Custom background color for the switch on iOS.

SettingsInfoDisplay

<SettingsInfoDisplay
  title="switch 1 state (boolEnable)"
  status={isToggled}
  type="boolEnable"
/>

The SettingsInfoDisplay component acts like settings information display, allowing you to show different types of status information based on various conditions. It can display information for boolean states, custom string states, or use custom true/false status text.

PropTypeDefaultDescription
titlestringThe title displayed next to the status information.
statusboolean | stringThe status value to be displayed based on the type prop.
typeInfoDisplayTypesThe type of information to display. Accepted values are 'boolEnable', 'boolYes', 'boolCustom', and 'custom'.
infoTitleTextStyle(Optional) Custom text style for the title. Default is null.
statusTextTextStyle(Optional) Custom text style for the status text. Default is null.
customTrueStatusstring(Optional) Custom status text when status is true. Default is null.
customFalseStatusstring(Optional) Custom status text when status is false. Default is null.

SettingsButton

<SettingsButton
  title="Press me"
  onPress={() => Alert.alert('', 'Something happened...')}
/>

The SettingsButton component is a customizable button. It supports two types: 'default' and 'newpage'. The 'newpage' type is used when you want to open a new settings screen in your current settings screen, while the 'default' type serves as a regular button.

PropTypeDefaultDescription
titlestringThe title displayed on the button.
onPress() => voidCallback function that is triggered when the button is pressed.
typeButtonVariant"default"(Optional) The type of button. Accepted values are 'default' and 'newpage'.
statusTextstring""(Optional) Status text displayed next to the arrow for the 'newpage' type. Default is an empty string.
buttonTitleTextStyle(Optional) Custom text style for the button title. Default is null.
arrowTextStyle(Optional) Custom text style for the arrow. Default is null.

Todo

  • better types and improve code quality
  • add icons
  • add more components & merge components
  • test on android

Contributing

If you've found an issue or have an idea for a new feature, feel free to open an issue or submit a pull request.

See the contributing guide to learn how to contribute to this repository and the development workflow.


If you like this library, consider giving it a star ⭐

Made with create-react-native-library

0.2.1

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago