Skip to content

Commit

Permalink
Relocated database and form to a separate screen
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrumartin committed Jul 4, 2023
1 parent 5f151ae commit 26ef911
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
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
1 change: 0 additions & 1 deletion src/screens/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const HomeScreen = () => {
<Sensor initial={0} label={'Pa'} dataType={'pressure'} />
<Sensor initial={0} label={'%'} dataType={'humidity'} />
<ReduxTest />
<Database />
</ScrollView>
</KeyboardAvoidingView>
</TouchableWithoutFeedback>
Expand Down
5 changes: 5 additions & 0 deletions src/screens/Home/src/components/Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export default class Database extends React.Component {
title="Clear data"
onPress={this.handleClear}
></Button>

<Text style={styles.text}>{JSON.stringify(this.state.data)}</Text>
</View>
);
}
Expand Down Expand Up @@ -213,6 +215,9 @@ const styles = {
borderWidth: 2,
minWidth: 300,
},
text: {
maxWidth: 300,
},
errorText: {
color: 'red',
maxWidth: 300,
Expand Down
38 changes: 38 additions & 0 deletions src/screens/PlantsScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import {
View,
Text,
Button,
StyleSheet,
ScrollView,
TouchableWithoutFeedback,
Keyboard,
KeyboardAvoidingView,
Platform,
} from 'react-native';
import Database from './Home/src/components/Database';

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});

const PlantsScreen = () => {
return (
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'none'}
style={styles.container}
>
<ScrollView>
<Database />
</ScrollView>
</KeyboardAvoidingView>
</TouchableWithoutFeedback>
);
};

export default PlantsScreen;

0 comments on commit 26ef911

Please sign in to comment.