Skip to content

Instantly share code, notes, and snippets.

import React, { useEffect } from 'react'
import { Text } from 'react-native'
import PropTypes from 'prop-types'
import DefaultPage from '../../components/DefaultPage'
const SceneSplash = ({ navigation }) => {
useEffect(() => {
setTimeout(() => {
navigation.navigate('Login')
}, 2000)
export const USER = '[USER]'
export const USER_LOGIN = `${USER} Set user as logged in`
export const USER_LOGOUT = `${USER} Set user as logged out`
export const userLogin = ({ name }) => ({
type: USER_LOGIN,
payload: {
name,
},
})
import { USER_LOGIN, USER_LOGOUT } from '../actions/user.actions'
const initialState = {
isLoggedIn: false,
}
const userReducer = (state = initialState, action) => {
switch (action.type) {
case USER_LOGIN: {
const { name } = action.payload
import React, { useState } from 'react'
import { Text, TextInput, Button } from 'react-native'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import DefaultPage from '../../components/DefaultPage'
import { userLogin } from '../../redux/actions/user.actions'
const SceneLogin = ({ loginUser, isUserLoggedIn, storedUserName }) => {
const [name, setName] = useState('')
import { USER_LOGIN } from '../../actions/user.actions'
import * as RootNavigation from '../../../navigation/RootNavigation'
const fakeLoginCheck = () => true // It's an older code, sir, but it checks out.
const userMiddleware = () => (next) => (action) => {
if (action.type === USER_LOGIN) {
if (fakeLoginCheck()) {
next(action) // continue with the login
import * as React from 'react'
export const navigationRef = React.createRef()
export function navigate(name, params) {
navigationRef.current.navigate(name, params)
}
import React from 'react'
import { Text, Button } from 'react-native'
import PropTypes from 'prop-types'
import DefaultPage from '../../components/DefaultPage'
const SceneHome = ({ navigation }) => (
<DefaultPage>
<Text>
Home
</Text>
import React from 'react'
import { Button, Text } from 'react-native'
import PropTypes from 'prop-types'
import DefaultPage from '../../components/DefaultPage'
const SceneSettings = ({ navigation }) => (
<DefaultPage>
<Text>
Settings
</Text>
import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import SceneSplash from '../scenes/auth/sceneSplash'
import SceneAppLoading from '../scenes/auth/sceneAppLoading'
import SceneLogin from '../scenes/auth/sceneLogin'
import SceneHome from '../scenes/auth/sceneHome'
import SceneSettings from '../scenes/auth/sceneSettings'
import SceneGameHome from '../scenes/game/sceneGameHome'
import React from 'react'
import { TouchableWithoutFeedback, StyleSheet, View } from 'react-native'
import PropTypes from 'prop-types'
const TouchableWrapper = ({ handlePress, children }) => (
<TouchableWithoutFeedback
style={styles.touchableWrapper}
onPress={() => handlePress()}
>
<View style={styles.touchableWrapperHelper}>