Skip to content

Commit

Permalink
Construção da tabela
Browse files Browse the repository at this point in the history
Popular a tabela de forma dinâmica pra calcular
  • Loading branch information
ricardorohrs committed May 26, 2020
1 parent 7ba1d16 commit 26066e7
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 2,651 deletions.
169 changes: 47 additions & 122 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,120 +1,9 @@
/*import React, { Component } from 'react';
import { Text, Button, StyleSheet, Alert, View, FlatList, TextInput } from 'react-native'
var SampleArray = ["ONE", "TWO"] ;
export default class MainActivity extends Component {
_onPressButton() {
alert('Arquivo selecionado!')
}
constructor(props) {
super(props)
this.state = {
Holder: ''
}
}
AddItemsToArray=()=>{
//Adding Items To Array.
SampleArray.push( this.state.Holder.toString() );
// Showing the complete Array on Screen Using Alert.
Alert.alert(SampleArray.toString());
}
render() {
const dados = [
{key: 'Linha 1'},
{key: 'Linha 2'},
{key: 'Linha 3'},
{key: 'Linha 4'},
{key: 'Linha 5'}
]
function rendertodo() {
for (todo of todos) {
var todoElement = document.createElement('li');
var todoText = document.createTextNode(todo);
todoElement.appendChild(todoText);
listElement.appendChild(todoElement);
}
}
function addtodo() {
var todoText = inputElement.value;
todos.push(todoText);
inputElement.value = '';
rendertodo();
}
return (
<View style={styles.MainContainer}>
<TextInput
placeholder="Digite o valor"
onChangeText={TextInputValue => this.setState({ Holder : TextInputValue }) }
style={{textAlign: 'center', marginBottom: 6, height: 45}}
/>
<Button title="Adicionar valor" onPress={this.AddItemsToArray} />
<View style={styles.buttonContainer}>
<Button
onPress={this._onPressButton}
title="Upar arquivo!"
/>
</View>
<View style={styles.input}>
<TextInput
placeholder="Escreva aqui!"
onChangeText={(text) => this.setState({text})}
value={this.state.text}
/>
<Button
onPress={this._onPressButton}
title="Salvar valor"
/>
</View>
<FlatList
data={dados}
renderItem = { ({item}) => <Text style={styles.textoItem}>{item.key}</Text> }
/>
</View>
);
}
}
const styles = StyleSheet.create({
MainContainer: {
flex:1,
justifyContent: 'center',
backgroundColor: "#f4f4f4",
margin: 15
},
input: {
margin: 5,
width: 250,
borderColor: "#c3c3c3",
borderWidth: 1
},
textoItem: {
fontSize: 20,
color: "#000",
padding: 25,
borderBottomWidth: 2
},
buttonContainer: {
margin: 25
},
});*/

import React, { Component } from 'react';
import { Text, Button, StyleSheet, Alert, View, FlatList, TextInput } from 'react-native'
import { Table, TableWrapper, Row, Rows, Col, Cols, Cell } from 'react-native-table-component';

const SampleArray = [1,2,3,4,5,6,7,8,9,0,1,5,2,3,6,4,9,7,8,1,2,3,4,6,9,5,2,3,1,7,0,8,5,9,4,6,3,1,2,0,7,8,4,1,5,2,3,0,6,9,2,3,4,5,0,1,9,4,2,1,6];
var SampleArray = [1,2,10,3,4,5,6,7,8,9,0,1,5,2,3,6,4,9,7,8,1,2,3,4,6,9,5,2,3,1,7,0,8,5,9,4,6,3,1,2,0,7,8,4,1,10,5,2,3,0,6,9,2,3,4,5,0,1,9,4,
12,16,15,17,19,20,11,13,17,19,12,14,13,18,17,20,16,11,10,19,18,13,16,15,10,17,14,20,12,11,3,6,9,8,7,4,2,1,10,20,11,2,1,6];

const data = [
{ key: 'Dado' },
Expand All @@ -125,6 +14,13 @@ const data = [
{ key: '%' }
];

/* const max = SampleArray.reduce(function(a, b) {
return Math.max(a, b);
});
const linhas = max/10;
//Alert.alert(linhas.toString());
//Alert.alert(max.toString()); */

const numColumns = 6;

const formatData = (data, numColumns) => {
Expand All @@ -147,23 +43,44 @@ export default class MainActivity extends Component {
constructor(props) {
super(props)
this.state = {
Holder: ''
HeadTable: ['Dado', 'xi', 'Xi', 'fi', 'Fi', 'fr', 'Fr', '%'],
DataTable: [
[1,2,0,3,4,2,6,7],
[5,6,7,8,9,7,8,1],
[0,1,5,2,3,0,2,6],
[6,4,9,7,8,4,3,1],
[1,2,3,4,6,1,7,6],
], //valores teste
Holder: ''
}
}

AddItemsToArray=()=>{
AddItemsToArray = () => {
//Adding Items To Array.
SampleArray.push(this.state.Holder.toString());
// Showing the complete Array on Screen Using Alert.
Alert.alert(SampleArray.toString());
// Alert.alert(SampleArray.toString());
}

renderItem = ({item}) => (
calculate = () => {
let k = Math.round((1 + 3.3 * Math.log10(SampleArray.length)));
let max = Math.max(...SampleArray);
let min = Math.min(...SampleArray);
let A = max - min;
let intervalo = (A/k).toFixed(4);

Alert.alert(intervalo.toString());



}

/* renderItem = ({item}) => (
<View>
<Text>{item}</Text>
</View>
);
); */

renderItem = ({ item, index }) => {
if (item.empty === true) {
return <View style={[styles.item]} />;
Expand All @@ -178,6 +95,7 @@ export default class MainActivity extends Component {
};

render() {
const state = this.state;
return (
<View style={styles.MainContainer}>
<TextInput
Expand All @@ -192,12 +110,19 @@ export default class MainActivity extends Component {
renderItem = { ({item}) => <Text style={styles.textoItem}>{item}</Text>}
/>

<FlatList
<Button title="Calcular" onPress={this.calculate}/>

{/* <FlatList
data={formatData(data, numColumns)}
style={styles.container}
renderItem={this.renderItem}
numColumns={numColumns}
/>
/> */}

<Table borderStyle={{borderWidth: 1, borderColor: '#333'}}>
<Row data={state.HeadTable}/>
<Rows data={state.DataTable}/>
</Table>

</View>
);
Expand Down
Loading

0 comments on commit 26066e7

Please sign in to comment.