Skip to content
Snippets Groups Projects
Commit 0bdcef5b authored by Botond Ortutay's avatar Botond Ortutay
Browse files

Exercise 4.2 done and deemed ready

parent 84351577
No related branches found
No related tags found
No related merge requests found
import * as React from 'react'; import * as React from 'react';
import { Text, View, Button, ActivityIndicator, TextInput, ScrollView, StyleSheet } from 'react-native'; import { Text, View, Button, ActivityIndicator, TextInput, ScrollView, StyleSheet, Alert } from 'react-native';
import { NavigationContainer } from '@react-navigation/native'; import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack'; import { createStackNavigator } from '@react-navigation/stack';
import Constants from 'expo-constants'; import Constants from 'expo-constants';
...@@ -10,33 +10,41 @@ import AssetExample from './components/AssetExample'; ...@@ -10,33 +10,41 @@ import AssetExample from './components/AssetExample';
// or any pure javascript modules available in npm // or any pure javascript modules available in npm
import { Card } from 'react-native-paper'; import { Card } from 'react-native-paper';
let listOfNotes = ["Note 1","Note 2","Note 3","Note 4","Note 5","Note 6","Note 7","Note 8","Note 9","Note 10","Note 11","Note 12","Note 13","Note 14","Note 15","Note 16","Note 17","Note 18","Note 19","Note 20","Note 21"]; const Stack = createStackNavigator();
const screen1 = () => { class screen1 extends React.Component {
const [text, onChangeText] = React.useState("Enter text here"); state = {
inpText: "",
lONotes: ["Note 1","Note 2","Note 3","Note 4","Note 5","Note 6","Note 7","Note 8","Note 9","Note 10","Note 11","Note 12","Note 13","Note 14","Note 15","Note 16","Note 17","Note 18","Note 19","Note 20","Note 21"]
}
updateIText = (text) => {
this.setState({ inpText: text })
}
render() {
return ( return (
<View style={styles.mainContainer}> <View style={styles.mainContainer}>
{listOfNotes.map(note => <Text>{note}</Text>)} {this.state.lONotes.map(note => <Text>{note}</Text>)}
<View style={styles.botPos}> <View style={styles.botPos}>
<TextInput <TextInput
style={styles.input} style={styles.input}
onChangeText={onChangeText} placeholder = "Enter text here"
value={text} onChangeText={this.updateIText}
/> />
</View>
<View style={styles.botPos}>
<View style={{position: 'absolute',bottom:0}}>
<Button <Button
title="ADD NOTE" title="ADD NOTE"
onPress={() => {
this.state.lONotes.push(this.state.inpText) //Lisää uusi note stateen
this.forceUpdate(); // Uudelleenrenderöi
}}
/> />
</View>
</View> </View>
</View> </View>
); );
} }
}
const Stack = createStackNavigator();
export default function App() { export default function App() {
return ( return (
...@@ -55,11 +63,8 @@ const styles = StyleSheet.create({ ...@@ -55,11 +63,8 @@ const styles = StyleSheet.create({
}, },
botPos:{ botPos:{
position: 'absolute',
bottom:0, bottom:0,
height:75,
backgroundColor: '#ffffff' backgroundColor: '#ffffff'
}, },
input: { input: {
height: 40, height: 40,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment