Skip to content

Commit

Permalink
Merge pull request #14 from Annoyed-Raven/13-database
Browse files Browse the repository at this point in the history
13 database
  • Loading branch information
leandrumartin authored Jul 11, 2023
2 parents 422dd79 + 26ef911 commit ebdfcf5
Show file tree
Hide file tree
Showing 9 changed files with 408 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
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import HomeScreen from './screens/Home';
import App_2 from './screens/Home/src/components/mqttfile';
import store from './redux/store';
import { Provider } from 'react-redux';
import PlantsScreen from './screens/PlantsScreen';

const Tab = createBottomTabNavigator();

Expand All @@ -19,6 +20,7 @@ const App = () => {
<Tab.Navigator>
<Tab.Screen name="Sensors" component={HomeScreen} />
<Tab.Screen name="Mqtt" component={App_2} />
<Tab.Screen name="Plants" component={PlantsScreen} />
</Tab.Navigator>
</NavigationContainer>
</Provider>
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
35 changes: 25 additions & 10 deletions src/screens/Home/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import React from 'react';

import { View, Text, Button, StyleSheet, ScrollView } from 'react-native';
import {
View,
Text,
Button,
StyleSheet,
ScrollView,
TouchableWithoutFeedback,
Keyboard,
KeyboardAvoidingView,
Platform,
} 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 +27,19 @@ 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}>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'none'}
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 />
</ScrollView>
</KeyboardAvoidingView>
</TouchableWithoutFeedback>
);
};

Expand Down
Loading

0 comments on commit ebdfcf5

Please sign in to comment.