0.5.3 • Published 6 days ago

@eohjsc/react-native-smart-city v0.5.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

react-native-smart-city

Getting started

  1. Install package dependencies:
  • Using Yarn: yarn add react-native-reanimated@^1.10.1
  1. Install:
  • Using npm: npm install @eohjsc/react-native-smart-city --save
  • Using Yarn: yarn add @eohjsc/react-native-smart-city
  1. Compile application using react-native run-android

Mostly automatic installation

$ react-native link @eohjsc/react-native-smart-city

Usage

  1. StackNavigator
import {
  UnitStack,
  AddMemberStack,
  AddSubUnitStack,
  AddDeviceStack,
  AddGatewayStack,
  SCContext,
  AddLGDeviceStack,
  initSCConfig,
  AddUnitStack,
  AutomateStack,
  NotificationStack,
} from '@eohjsc/react-native-smart-city';
import Config from 'react-native-config';
import { createStackNavigator } from '@react-navigation/stack';

// TODO: What to do with the module?
const Stack = createStackNavigator();

const YourStack = () => {


  useEffect(() => {
    const config = {
      apiRoot: Config.API_ROOT,
      GOOGLE_MAP_API_KEY: Config.GOOGLE_MAP_API_KEY,
      LG_CLIENT_ID: Config.LG_CLIENT_ID,
      LG_REDIRECT_URI_APP: Config.LG_REDIRECT_URI_APP,
      LG_URL: Config.LG_URL,
      VCONNEX_CLIENT_ID: Config.VCONNEX_CLIENT_ID,
      VCONNEX_REDIRECT_URI_APP: Config.VCONNEX_REDIRECT_URI,
      pusherAppKey: Config.PUSHER_APP_KEY,
      pusherAppCluster: Config.PUSHER_APP_CLUSTER,
      language,
      setCurrentSensorDisplay,
      appName: Config.APP_NAME,
      packageName: Config.APP_PACKAGE_NAME,  //  Your package name is required
      versionCode: Config.APP_VERSION_CODE,  //  Your app version is required
    };
    initSCConfig(config);
  }, [language, setCurrentSensorDisplay]);

  // Declare yourAuthObject and params
  return (
    <Stack.Navigator>
      <Stack.Screen
        name={'MainTab'}
        component={MainTab}
        options={{
          headerShown: false,
        }}
      />
      <Stack.Screen
        name={'UnitStack'}
        component={UnitStack}
        initialParams={params}
        options={{
          headerShown: false,
        }}
      />
      <Stack.Screen
        name={'AddGatewayStack'}
        component={AddGatewayStack}
        options={{ headerShown: false }}
      />
      <Stack.Screen
        name={'AddDeviceStack'}
        component={AddDeviceStack}
        options={{ headerShown: false }}
      />
      <Stack.Screen
        name={'AddMemberStack'}
        component={AddMemberStack}
        options={{ headerShown: false }}
      />
      <Stack.Screen
        name={'AddSubUnitStack'}
        component={AddSubUnitStack}
        options={{ headerShown: false }}
      />
    </Stack.Navigator>
  );
};
const MainTab = () => {
  return (
    <Tab.Navigator>
      <Tab.Screen name={'AutomateStack'} component={AutomateStack} />
      <Tab.Screen name={'NotificationStack'} component={NotificationStack} />
    </Tab.Navigator>
  );
};
  1. Use components
import React from 'react';
import { View } from 'react-native';
import { MyPinnedSharedUnit, MyUnit } from '@eohjsc/react-native-smart-city';

const MyScreen = () => {
  return (
    <View>
      <MyUnit />
      <MyPinnedSharedUnit />
    </View>
  );
};
  1. Trigger quick action
import React from 'react';
import { View, Button } from 'react-native';
import { sendRemoteCommand } from '@eohjsc/react-native-smart-city/src/iot/RemoteControl';

export const MyFunctionalComponent = () => {
  const sensor = {
    id: 1,
    remote_control_options: {
      internet: {},
      bluetooth: {},
    },
  };
  const action = {
    color: '#00979D',
    command_prefer_over_bluetooth: true,
    command_prefer_over_googlehome: false,
    command_prefer_over_internet: false,
    googlehome_actions: [],
    icon: 'caret-up',
    icon_kit: null,
    id: 1,
    key: '24240de0-5c8e-11ec-bf63-0242ac130002',
    lg_actions: [],
    name: 'Garage Up',
  };
  const handleQuickAction = async () => {
    const result = await sendRemoteCommand(sensor, action); // Action Garage Up
    if (result) {
      console.log('Successful control');
    } else {
      console.log('Control failed');
    }
  };
  return (
    <View>
      <Button
        onPress={handleQuickAction}
        title="Example trigger quick action control Garage Up"
      />
    </View>
  );
};
  • sendRemoteCommand user needs to have permission to control the device, you pass in the sensor and action to it and it will run after calling render.
  • sensor is a device in your Unit and action is the action key of the device..
  • You can take out the sensor and action from your Unit when calling the API.UNIT.UNIT_DETAIL(unitId) it will return all devices in 1 unit.
  • Or get sensor from API.DEVICE.DISPLAY(sensor.id) returns all actions of 1 device.
  • Refer YourProjectPath /node_modules/@eohjsc/react-native-smart-city/src/screens/Unit/Detail.js

Sync file to EoH source

  yarn install && yarn watch
@ant-design/icons-react-native@ant-design/react-native@babel/helper-environment-visitor@eohjsc/react-native-keyboard-aware-scroll-view@formatjs/intl-getcanonicallocales@formatjs/intl-numberformat@formatjs/intl-pluralrules@invertase/react-native-apple-authentication@messageformat/core@miblanchard/react-native-slider@react-native-clipboard/clipboard@react-native-community/async-storage@react-native-community/cameraroll@react-native-community/checkbox@react-native-community/datetimepicker@react-native-community/geolocation@react-native-community/masked-view@react-native-community/netinfo@react-native-community/segmented-control@react-native-community/slider@react-native-community/toolbar-android@react-native-picker/picker@react-navigation/bottom-tabs@react-navigation/drawer@react-navigation/native@react-navigation/stack@sentry/react-native@testing-library/react-hooksapisauceaxiosbase-64deprecated-react-native-prop-typesdotenvgoogle-libphonenumberhome-assistant-js-websocketi18n-jsi18nextlodashlottie-react-nativemomentmoment-timezonenumeralpatch-packagepluralizepostinstallprecompiled-mqttpusher-jspusher-js-authpython-structquerystringreact-content-loaderreact-domreact-hooks-global-statereact-i18nextreact-native-alert-asyncreact-native-android-keyboard-adjustreact-native-android-location-enablerreact-native-android-wifireact-native-appearancereact-native-base64react-native-ble-plxreact-native-bootsplashreact-native-calendarsreact-native-chart-kitreact-native-credit-card-inputreact-native-crypto-aes-cbcreact-native-dashreact-native-deep-linkingreact-native-device-inforeact-native-draggable-flatlistreact-native-fast-imagereact-native-geocoderreact-native-gesture-handlerreact-native-get-locationreact-native-image-crop-pickerreact-native-image-resizerreact-native-input-credit-cardreact-native-iphone-x-helperreact-native-linear-gradientreact-native-localizereact-native-mapsreact-native-maps-directionsreact-native-modalreact-native-modal-datetime-pickerreact-native-new-snap-carouselreact-native-onesignalreact-native-pager-viewreact-native-parallax-scroll-viewreact-native-parsed-textreact-native-permissionsreact-native-popover-viewreact-native-progressreact-native-reanimatedreact-native-responsive-fontsizereact-native-safe-area-contextreact-native-screensreact-native-super-gridreact-native-svgreact-native-toast-messagereact-native-udpreact-native-version-checkreact-native-vlc-media-playerreact-native-webviewreact-native-wheel-color-pickerreact-native-wheel-scrollview-pickerreact-native-wifi-rebornreact-navigationstring-formatsync-directorytimezone-mockuuid-by-stringuuidv4validatorvictory-native
0.5.3

6 days ago

0.5.2

13 days ago

0.4.65-rc

15 days ago

0.5.1

22 days ago

0.5.0

1 month ago

0.4.99

2 months ago

0.4.98

2 months ago

0.4.97

2 months ago

0.4.95

2 months ago

0.4.96

2 months ago

0.4.93

2 months ago

0.4.94

2 months ago

0.4.92

2 months ago

0.4.91

2 months ago

0.4.90

3 months ago

0.4.89

3 months ago

0.4.88

3 months ago

0.4.87

3 months ago

0.4.86

3 months ago

0.4.84

5 months ago

0.4.85

5 months ago

0.4.82

6 months ago

0.4.83

5 months ago

0.4.80

6 months ago

0.4.81

6 months ago

0.4.75

6 months ago

0.4.76

6 months ago

0.4.73

7 months ago

0.4.74

7 months ago

0.4.71

7 months ago

0.4.72

7 months ago

0.4.70

7 months ago

0.4.79

6 months ago

0.4.77

6 months ago

0.4.78

6 months ago

0.4.64

8 months ago

0.4.65

8 months ago

0.4.62

9 months ago

0.4.63

9 months ago

0.4.60

9 months ago

0.4.61

9 months ago

0.4.68

7 months ago

0.4.69

7 months ago

0.4.66

8 months ago

0.4.67

7 months ago

0.4.59

9 months ago

0.4.57

10 months ago

0.4.58

10 months ago

0.4.56

10 months ago

0.4.42

11 months ago

0.4.43

11 months ago

0.4.40

11 months ago

0.4.41

11 months ago

0.4.48

11 months ago

0.4.49

11 months ago

0.4.46

11 months ago

0.4.47

11 months ago

0.4.44

11 months ago

0.4.45

11 months ago

0.4.31

12 months ago

0.4.32

12 months ago

0.4.30

12 months ago

0.4.39

11 months ago

0.4.37

11 months ago

0.4.38

11 months ago

0.4.35

12 months ago

0.4.36

11 months ago

0.4.33

12 months ago

0.4.34

12 months ago

0.4.21

12 months ago

0.4.28

12 months ago

0.4.29

12 months ago

0.4.26

12 months ago

0.4.27

12 months ago

0.4.24

12 months ago

0.4.25

12 months ago

0.4.22

12 months ago

0.4.23

12 months ago

0.3.97

1 year ago

0.3.96

1 year ago

0.3.95

1 year ago

0.3.94

1 year ago

0.3.93

1 year ago

0.3.92

1 year ago

0.3.91

1 year ago

0.3.90

1 year ago

0.3.99

12 months ago

0.3.98

1 year ago

0.4.53

11 months ago

0.3.86

1 year ago

0.4.54

10 months ago

0.4.51

11 months ago

0.4.52

11 months ago

0.4.50

11 months ago

0.3.89

1 year ago

0.4.55

10 months ago

0.3.88

1 year ago

0.3.87

1 year ago

0.4.1

12 months ago

0.4.0

12 months ago

0.4.3

12 months ago

0.4.2

12 months ago

0.3.79

1 year ago

0.3.78

1 year ago

0.3.77

1 year ago

0.3.85

1 year ago

0.3.84

1 year ago

0.3.83

1 year ago

0.3.82

1 year ago

0.3.81

1 year ago

0.3.80

1 year ago

0.3.75

1 year ago

0.3.74

1 year ago

0.3.73

1 year ago

0.3.72

1 year ago

0.3.71

1 year ago

0.3.70

1 year ago

0.3.76

1 year ago

0.3.64

1 year ago

0.3.63

1 year ago

0.3.62

1 year ago

0.3.61

1 year ago

0.3.60

1 year ago

0.3.69

1 year ago

0.3.68

1 year ago

0.3.67

1 year ago

0.3.66

1 year ago

0.3.65

1 year ago

0.3.53

2 years ago

0.3.52

2 years ago

0.3.51

2 years ago

0.3.50

2 years ago

0.3.59

1 year ago

0.3.58

1 year ago

0.3.57

1 year ago

0.3.56

1 year ago

0.3.55

1 year ago

0.3.54

1 year ago

0.3.42

2 years ago

0.3.41

2 years ago

0.3.40

2 years ago

0.3.49

2 years ago

0.3.48

2 years ago

0.3.47

2 years ago

0.3.46

2 years ago

0.3.45

2 years ago

0.3.44

2 years ago

0.3.39

2 years ago

0.3.38

2 years ago

0.3.37

2 years ago

0.2.99

2 years ago

0.3.0

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.31

2 years ago

0.3.30

2 years ago

0.3.36

2 years ago

0.3.35

2 years ago

0.3.34

2 years ago

0.3.33

2 years ago

0.3.32

2 years ago

0.3.29

2 years ago

0.3.20

2 years ago

0.3.28

2 years ago

0.3.27

2 years ago

0.3.26

2 years ago

0.3.25

2 years ago

0.3.24

2 years ago

0.3.23

2 years ago

0.3.22

2 years ago

0.3.21

2 years ago

0.3.19

2 years ago

0.3.18

2 years ago

0.3.9

2 years ago

0.3.17

2 years ago

0.3.16

2 years ago

0.3.15

2 years ago

0.3.14

2 years ago

0.3.13

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.2.96

2 years ago

0.2.98

2 years ago

0.2.97

2 years ago

0.2.95

2 years ago

0.2.94

2 years ago

0.2.93

2 years ago

0.2.92

2 years ago

0.2.91

2 years ago

0.2.90

2 years ago

0.2.89

2 years ago

0.2.88

2 years ago

0.2.87

2 years ago

0.2.63

2 years ago

0.2.62

2 years ago

0.2.61

2 years ago

0.2.60

2 years ago

0.2.69

2 years ago

0.2.68

2 years ago

0.2.67

2 years ago

0.2.66

2 years ago

0.2.65

2 years ago

0.2.64

2 years ago

0.2.59

2 years ago

0.2.58

2 years ago

0.2.57

2 years ago

0.2.85

2 years ago

0.2.84

2 years ago

0.2.83

2 years ago

0.2.82

2 years ago

0.2.81

2 years ago

0.2.86

2 years ago

0.2.74

2 years ago

0.2.73

2 years ago

0.2.72

2 years ago

0.2.71

2 years ago

0.2.70

2 years ago

0.2.79

2 years ago

0.2.78

2 years ago

0.2.77

2 years ago

0.2.76

2 years ago

0.2.75

2 years ago

0.2.52

2 years ago

0.2.51

2 years ago

0.2.50

2 years ago

0.2.56

2 years ago

0.2.55

2 years ago

0.2.54

2 years ago

0.2.53

2 years ago

0.2.49

2 years ago

0.2.48

2 years ago

0.2.47

2 years ago

0.2.41

2 years ago

0.2.40

2 years ago

0.2.46

2 years ago

0.2.45

2 years ago

0.2.44

2 years ago

0.2.43

2 years ago

0.2.42

2 years ago

0.2.36

2 years ago

0.2.34

2 years ago

0.2.33

2 years ago

0.2.31

2 years ago

0.2.30

2 years ago

0.2.29

3 years ago

0.2.28

3 years ago

0.2.27

3 years ago

0.2.26

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.8

3 years ago

0.2.3

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.4

3 years ago

0.2.2

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago