tttstudios / react-native-otp-input

Tiny Javascript library which provides an elegant UI for user to input one time passcode.
MIT License
531 stars 241 forks source link

Background is off when autoFocusOnLoad is used #69

Closed alex-mironov closed 3 years ago

alex-mironov commented 4 years ago
const cellStyle = {
  width: 56,
  height: 56,
  borderWidth: 0,
  color: theme.colors.black,
  borderBottomWidth: 2,
  fontSize: 22,
  lineHeight: 24,
}

export const styleSheet = StyleSheet.create({
  cellBase: {
    ...cellStyle,
    borderBottomColor: theme.colors.black,
  },

  cellHighLighted: {
    backgroundColor: 'rgba(229, 0, 75, 0.05)',
    borderBottomColor: theme.colors.red,
  },

  cellError: {
    ...cellStyle,
    borderBottomColor: theme.colors.red,
  },
})

render () => {
  return (
      <OTPInputView
        pinCount={4}
        autoFocusOnLoad
        codeInputFieldStyle={error ? styleSheet.cellError : styleSheet.cellBase}
        codeInputHighlightStyle={styleSheet.cellHighLighted}
            onCodeChanged={setCode}
            code={code}
      />
  )
}

On the first run it produces

Screen Shot 2020-04-24 at 23 41 27
eric-dao37 commented 4 years ago

Hi @alex-mironov

Can you give more detail about the problem you have? We can see in the picture the background of highlighted slot is red