Skip to content

Commit

Permalink
Initial WIP implementation of database
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrumartin committed Jul 3, 2023
1 parent 422dd79 commit 3220a3a
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 19 deletions.
89 changes: 88 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@rneui/base": "^4.0.0-rc.7",
"@rneui/themed": "^4.0.0-rc.7",
"expo": "~48.0.6",
"expo-sqlite": "~11.1.1",
"expo-status-bar": "~1.4.4",
"g": "^2.0.1",
"immer": "^10.0.1",
Expand All @@ -32,7 +33,8 @@
"react-native-screens": "~3.20.0",
"react-navigation-stack": "^2.10.4",
"react-redux": "^8.0.5",
"redux": "^4.2.1"
"redux": "^4.2.1",
"yup": "^1.2.0"
},
"devDependencies": {
"@babel/core": "^7.20.0"
Expand Down
7 changes: 5 additions & 2 deletions src/redux/reducers.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { ADD_SENSOR_DATA } from './actions';

const initialState = {
sensorValue: '{"humidity": 0, "temperature": 0, "pressure": 0}',
sensorValue: {
humidity: 0,
temperature: 0,
pressure: 0,
},
};

const sensorReducer = (state = initialState, action) => {
switch (action.type) {
case ADD_SENSOR_DATA:
console.log('sensorReducer is sending ' + action.payload);
return {
sensorValue: action.payload,
};
Expand Down
31 changes: 21 additions & 10 deletions src/screens/Home/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import React from 'react';

import { View, Text, Button, StyleSheet, ScrollView } from 'react-native';
import {
View,
Text,
Button,
StyleSheet,
ScrollView,
TouchableWithoutFeedback,
Keyboard,
} from 'react-native';

import Sensor from '../../shared/Sensor';

import ReduxTest from './src/components/ReduxTest';
import Database from './src/components/Database';

const styles = StyleSheet.create({
container: {
Expand All @@ -16,15 +25,17 @@ const styles = StyleSheet.create({

const HomeScreen = () => {
return (
<View style={styles.container}>
<ScrollView>
<Sensor initial={20} label={'degrees'} dataType={'temperature'} />
<Sensor initial={50} label={'Pa'} dataType={'pressure'} />
<Sensor initial={75} label={'%'} dataType={'humidity'} />
<Sensor initial={0} label={''} />
<ReduxTest />
</ScrollView>
</View>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={styles.container}>
<ScrollView>
<Sensor initial={0} label={'degrees'} dataType={'temperature'} />
<Sensor initial={0} label={'Pa'} dataType={'pressure'} />
<Sensor initial={0} label={'%'} dataType={'humidity'} />
<ReduxTest />
<Database />
</ScrollView>
</View>
</TouchableWithoutFeedback>
);
};

Expand Down
Loading

0 comments on commit 3220a3a

Please sign in to comment.