Giter VIP home page Giter VIP logo

toggle-switch-react-native's Issues

isOn state not updating dynamically

<ToggleSwitch isOn={this.state.toggle} />

When I change the toggle state to true once all the components are rendered it doesn't update the toggle button to true

My code for changong the toggle state :
this.setState({ toggle: true })

Not working in flatlist

Hey i'm using this in flatlist which render multiple switches, but it is not updating isOn value

Failed parsing on Web

Module parse failed: Unexpected token (52:19)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|   }
| 
>   static propTypes = {
|     isOn: PropTypes.bool.isRequired,
|     label: PropTypes.string,

babel.config.js

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      "@babel/plugin-proposal-class-properties",

      [
        "babel-plugin-inline-import",
        {
          extensions: [".svg"],
        },
      ],
    ],
  };
};

Disabled styles

It could be nice to have disabled style prop. It's better to change the color or opacity when the switch is disabled so it doesn't look like it's active. Thanks!

rtl support

The library does not seems to be supporting rtl :
WhatsApp Image 2019-09-05 at 10 15 11

the red dot is not inside the component.

Medium Size is wrong

This should be the setting for medium toggle button, not the current one

{ width: 60, padding: 14, circleWidth: 24, circleHeight: 24, translateX: 30 }

Opacity makes color weird

OS: Android

[Problem]
When I set opacity(style) at the parent of ToggleSwitch,
Circle's color is turned weird color.
I can't make circle white if the setting item is disabled.

up: opacity 0.3
down: opacity 1
스크린샷 2023-03-07 오전 9 50 59

is this Android OS Setting issue? auto-contrast??

TypeScript definition should work

When installing this lib in a TypeScript project (e.g default Expo project) the included definition does not work.

Should probably look like this (which I'm using):

/// <reference types="node" />

declare module 'toggle-switch-react-native' {
  import React from 'react';
  import {StyleProp, TextStyle, ViewStyle} from 'react-native';

  export type ToggleSwitchProps = {
    isOn: boolean;
    label?: string;
    onColor?: string;
    offColor?: string;
    size?: string;
    labelStyle?: StyleProp<TextStyle>;
    thumbOnStyle?: StyleProp<ViewStyle>;
    thumbOffStyle?: StyleProp<ViewStyle>;
    trackOnStyle?: StyleProp<ViewStyle>;
    trackOffStyle?: StyleProp<ViewStyle>;
    onToggle?: (isOn: boolean) => any;
    icon?: React.ReactNode;
    disabled?: boolean;
    animationSpeed?: number;
    useNativeDriver?: boolean;
    circleColor?: string;
  };

  class ToggleSwitch extends React.Component<ToggleSwitchProps> {}

  export default ToggleSwitch;
}

Issue with ios app

Hi,
Can you help here.
Toggle-switch-react-native is working fine for android but in ios it is not working it,s not getting on please help...
Will it work for ios or only for android.

Support hitSlop props

Sometimes the hit area is too small to tap on, it will be good if we can have a prop to control the hitSlop.

New Features

You can also add the following features
1.Label text need to change dynamically for on and off like "available" "not-available"
2.Label text position left or right options
3.Icon size with custom height and width instead of small,medium, and large

Adding in Accessibility props

Hi, I noticed there was no way to pass in any Accessibility props so users with their screen readers enabled cannot know what this plugin can do.

At minimum:

  • accessibilityLabel
  • accessibilityHint
  • accessibilityRole (could default this to either switch or checkbox but not required).

I was planning on making a PR to add in these props but wanted to submit this "issue/enhancement" first.

Not working example

Please see this gif, you can know about this issue all.

kapture 2018-06-06 at 11 12 39

I started working to fix it, will make a PR soon.

package don't support Typescript

Typing this:

npm i --save-dev @types/toggle-switch-react-native

Will result:

'@types/toggle-switch-react-native@*' is not in this registry.
You should bug the author to publish it (or use the name yourself!)

Can't wait to see it fix :)

Thank you,
Take care

Able to set lable and toggle in seperate style?

Is it possible to add "Label" style to left and "Toggle" to right in the same usage? The label will be on left of Toggle for now but it seems can't add more space style between it. May be I just don't know how to do it. Can't you guys (someone) guide me? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.