0.2.2 • Published 2 years ago

react-native-lucky-wheel v0.2.2

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

react-native-lucky-wheel

npm version CircleCI Commitizen friendly license

A decent lucky wheel component for React-Native

It's sucks that writing a lucky wheel (known as wheel of fortune) component. I wrote one, so you wouldn't have to.

Table of Contents

Getting started

:warning: it's not tested on field.

yarn add react-native-lucky-wheel

Dependencies

This library needs these dependencies to be installed in your project before you can use it:

For Expo CLI:

expo install react-native-svg

For React Native CLI

yarn add react-native-svg

Check react-native-svg installation guide.

API

The <LuckyWheel> component can take a number of inputs to customize it as needed. They are outlined below:

Props

NameTypeRequiredDefault Value
slicesISlice[]+-
padAnglenumber-0.01
outerRadiusnumber-13
innerRadiusnumber-30
durationnumber-4
enableGestureboolean-false
enablePhysicsboolean-false
enableOuterDotsboolean-true
gestureTypeGestureType-GestureTypes.CLOCKWISE
sizenumber-width - 40
winnerIndexnumber--
minimumSpinVelocitynumber-1
textStyleITextStyle--
textAngleTextAngleType-TextAngles.VERTICAL
backgroundColorOptionsRandomColorOptionsSingle-{luminosity: 'dark', hue: 'random'}
offsetnumber-0
backgroundColorColor-#FFF
knobSizenumber-30
knobColorColor-#FF0000
easingEasingType-EasingTypes.OUT
dotColorColor-#000
onKnobTick() => void--
onSpinningStart() => void--
onSpinningEnd(winner: ISlice) => void--
sourceImageSourcePropType--
customKnob(params: ICustomKnob) => React.ReactChild--
customText(params: IWheelText) => React.ReactChild--
waitWinnerboolean-false
enableInnerShadowboolean-true

Methods

These are the various methods.

MethodParamsDescription
start-Start spinning.
stop-Stop spinning.
reset-Reset spinning.

Usage

import LuckyWheel from 'react-native-lucky-wheel';

const SLICES = [
  { text: 'foo' },
  { text: 'bar' },
  { text: 'baz' },
  { text: 'qux' },
];

const App = () => {
  return <LuckyWheel slices={SLICES} />;
};

Advance Styling

I added some props to styling the wheel:

@TODO

Spin Types: Gesture and Method

You can spin the wheel with two different method:

@TODO

Wheel Types: SVG and Image

There are two different method to create a Lucky Wheel:

@TODO

Endless Spinning

If you want to select a winner after spinning begin you can use endless spinning feature of this library.

@TODO

Play Tick Sound

There are some libraries to play sound, I don't want to select one, so I decide to not add this feature. However, you can add this feature by yourself following below instructions:

@TODO

Example App

# clone the project
git clone https://github.com/ridvanaltun/react-native-lucky-wheel.git

# go into the project
cd react-native-lucky-wheel

# make project ready
npm run bootstrap

# go into the example
cd example

# run for android
npm run android

# or

# run for ios
npm run ios

Contributing

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

License

MIT