LoginSignup
6
4

More than 5 years have passed since last update.

ReactNativeでドラクエ風の会話画面を作った

Last updated at Posted at 2018-12-07

良いライブラリがあったのでそれの紹介になります。

タイプライターアニメーション

import { View } from 'react-native'
import TypeWriter from 'react-native-typewriter'

...(省略)...

<View style={styles.talkWrap}>
  <TypeWriter typing={1} style={styles.talk}>
    おぉ、目覚めたか?\n自分の名前は覚えておるか?
  </TypeWriter>
</View>

...(省略)...

const styles = {
  talk: {
    color: '#eee',
    fontWeight: 'bold',
  },
  talkWrap: {
    backgroundColor: '#000',
    borderColor: '#ccc',
    borderRadius: 15,
    borderWidth: 3,
    margin: 1,
    padding: 8
  },
}

フォームとエラー表示

  • Native BaseのToastとFormを使いました
Toast
import { Toast } from 'native-base'

...(省略)...

Toast.show({
  text: 'たしか6文字までの名前だったはずじゃ',
  type: 'danger',
  duration: 3000,
  textStyle: { fontWeight: 'bold' }
})
Form
import { Text, Item, Input, Icon } from 'native-base'

...(省略)...

const ToggleForm = ({ isError, name, handleChangeName }) => (
  isError ? (
    <Item error>
      <Text>名前:</Text>
      <Input value={name} onChangeText={handleChangeName} />
      <Icon active name="close-circle" />
    </Item>
  ) : (
    <Item success>
      <Text>名前:</Text>
      <Input value={name} onChangeText={handleChangeName} />
      <Icon active name="checkmark-circle" />
    </Item>
  )
)
6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4