HowTo: Build and Use React Native Demo of Open Source theta-client RICOH SDK

Getting the React Native demo running, Android emulator
theta-client 1.7.1
Windows 10, Node v18.17.1, Java version 1.8.0_371 and Java JDK v17.0.7

  1. Clone theta-client repository GitHub - ricohapi/theta-client: A library to control RICOH THETA
  2. In a new terminal, cd into demos/demo-react-native
  3. Start your Android emulator (more on how to get the emulator here
  4. Run “yarn install” in a new terminal
  5. In the src folder in demo-react-native, change const endpoint to ‘https://fake-theta.vercel.app’ for fake images to test in development
  6. Run “yarn run start” then click a to start app in your Android emulator

Development (theta-client React Native Demo creating a new button)

  • All source files for the app is stored in src folder
  • Page, style and home files are all stored in there
  • MainMenu.tsx acts as the main/master component of the application with it importing the rest of the files as components
  • App.tsx defines a set of routes by attaching a string reference to a component, routing to another page can be implicitly called with this string
    To create a example button/feature on the home page,
  1. Create a new file NewFeature.tsx in src folder
  2. In the new file we just created, put the follwowing code :
import React, {useEffect, useState, useCallback} from 'react';
import {
  StatusBar,
  Text,
  View,
  Image,
  RefreshControl,
  ScrollView,
  TouchableOpacity,
  Dimensions,
} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import styles from './Styles';

const NewFeauture = ({navigation}) => {
  return(
    <View>
      <Text>This is a new feature.</Text>
    </View>
  )
};
export default NewFeauture;
  1. Import this new component in App.tsx and add a new <Stack.Screen/> to <Stack.Navigator/> in to define a new navigation route for it
import NewFeature from './NewFeature'

<NavigationContainer>
      <Stack.Navigator screenOptions={screenOptions}>
        <Stack.Screen
          options={{title: 'Theta SDK sample app'}}
          name="main"
          component={MainMenu}
        />
        <Stack.Screen
          options={{title: 'Take Photo'}}
          name="take"
          component={TakePhoto}
        />
        <Stack.Screen
          options={{title: 'List Photos'}}
          name="list"
          component={ListPhotos}
        />
        <Stack.Screen
          options={{title: 'Sphere'}}
          name="sphere"
          component={PhotoSphere}
        />
        <Stack.Screen
          options={{title:'New Feature'}}
          name = "newFeature"
          component={NewFeature}
        />
      </Stack.Navigator>
  </NavigationContainer>
  1. In MainMenu.tsx, add a new navigation function for newFeature and create a new button ( in the that calls this function
const goNewFeature = ()=>{
    navigation.navigate('newFeature')
};
<SafeAreaView style={styles.container}>
      <StatusBar barStyle="light-content" />
      <TouchableOpacity style={styles.buttonBack}    onPress={goTake}>
        <Text style={styles.button}>Take a Photo</Text>
      </TouchableOpacity>
      <View style={styles.spacer} />
      <TouchableOpacity style={styles.buttonBack} onPress={goList}>
        <Text style={styles.button}>List Photos</Text>
      </TouchableOpacity>
<View style={styles.spacer} />
 <TouchableOpacity style={styles.buttonBack} onPress={goNewFeature}>
        <Text style={styles.button}>New Feature</Text>
      </TouchableOpacity>
</SafeAreaView>


1 Like

the process for yarn run android took 7 minutes on my M1 MacBook Air.

testing with physical device SC2 and physical device Pixel 4a

live preview

live preview works

Navigation of the live preview also works

verification tool

in React Native