Implementación de la modificación y adición de una lista de material

parent 213309a0
Showing with 2928 additions and 237 deletions
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import type {Node} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
const Section = ({children, title}): Node => {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
};
import * as React from 'react';
import { View, Modal, ScrollView, TextInput, StyleSheet, Alert, Image, TouchableOpacity, Text } from 'react-native';
import { DefaultTheme, NavigationContainer, StackActions } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaView } from 'react-native-safe-area-context';
const App: () => Node = () => {
const isDarkMode = useColorScheme() === 'dark';
const Stack = createNativeStackNavigator();
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
/**
* @brief Se comprueba si los datos introducidos corresponden a algun usuario registrado
* @param {string} userName identificador de usuario de la cuenta
* @param {string} password contraseña de la cuenta
* @param {function} setM funcion para cambiar el estado del modal
* @returns la siguiente vista o un modal dependiendo si las credenciales son correctas
*/
function ComprobacionAuth(userName, password, setM, navigation){
const jsonInicio = require('./assets/data/load/usuarios.json');
const data = jsonInicio[userName];
if(data){ // se comprueba si el usuario existe
if(jsonInicio[userName].Password == password){ // se verifica si la contraseña corresponde
return navigation.dispatch(
StackActions.replace('TabBar',{id: userName})
); // Modificar por la visualizacion de la vista principal
}else{
return setM(true);
}
}else{
return setM(true);
}
}
/**
* @brief Presenta el contenido de la vista del Login
* @returns El contenido de la vista del Login
*/
function App({navigation}) {
const [identificador, setIdentificador] = React.useState("");
const [pass, setPass] = React.useState("");
const [m, setM] = React.useState(false);
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
<ScrollView>
<SafeAreaView style={estilos.ContenedorTexto}>
<View style={estilos.CentrarModal}>
<Modal transparent={true} visible={m} animationType={'fade'}>
<View style={estilos.CentrarModal}>
<View style={estilos.VistaModal}>
<Text style={estilos.TituloModal}>Login</Text>
<Text style={estilos.TextoModal}>Alguna de las credenciales no es correcta</Text>
<TouchableOpacity onPress={()=>setM(false)}>
<Text style={estilos.BotonAceptar}>ACEPTAR</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
</View>
<View style={{justifyContent: 'center', alignItems: 'center', padding:'5%'}}>
<Image style={estilos.Logo} source={require('./assets/img/logo.png')} />
</View>
<View>
<TextInput style={estilos.EntradaTexto} placeholder = "Nombre de usuario" onChangeText={(valor) => setIdentificador(valor)} ></TextInput>
<TextInput secureTextEntry={true} style={estilos.EntradaTexto} placeholder = "Contraseña" onChangeText={(valor) => setPass(valor)}></TextInput>
</View>
</ScrollView>
</SafeAreaView>
<TouchableOpacity style={estilos.Boton} onPress={() => ComprobacionAuth(identificador, pass, setM, navigation)}>
<Text style={{color:'white', fontWeight: 'bold', fontSize:15}}>INICIAR SESIÓN</Text>
</TouchableOpacity>
</SafeAreaView>
</ScrollView>
);
};
}
const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
/**
* @brief Mantiene todos los estilos aplicados a la vista del Login
*/
const estilos = StyleSheet.create({
EntradaTexto: {
borderBottomWidth: 1,
borderBottomColor: "#B5B2B2",
paddingBottom: 15,
},
ContenedorTexto:{
padding: 18,
justifyContent: 'center',
backgroundColor: '#FFFFFF'
},
Logo:{
width:220,
height:220,
resizeMode:'contain'
},
Boton:{
marginTop:40,
alignContent:'center',
alignItems:'center',
justifyContent:'center',
backgroundColor:'#7D9BFF',
height:45,
borderRadius:3
},
CentrarModal: {
flex: 1,
backgroundColor: "rgba(1,1,1,0.5)",
justifyContent: "center",
alignItems: "center"
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
VistaModal: {
width:330,
height:180,
margin: 20,
backgroundColor: "white",
borderRadius: 1,
padding: 35,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
BotonAceptar: {
marginTop: 25,
textAlign: "right",
color:"#47525E"
},
highlight: {
fontWeight: '700',
TextoModal: {
color:"#47525E"
},
TituloModal:{
fontWeight:"bold",
color:"#47525E",
fontSize:20,
paddingBottom:25
}
});
export default App;
export default App;
\ No newline at end of file
import React from "react";
import { StyleSheet, Image, View, TouchableOpacity } from "react-native";
/**
* @brief Mantiene todos los estilos aplicados a esta vista
*/
const estilosBoton = StyleSheet.create({
contenedorBoton: {
backgroundColor: '#7D9BFF',
......@@ -22,9 +25,12 @@ const estilosBoton = StyleSheet.create({
}
});
const BotonAñadir = () => {
/**
* Componente que contiene el botón que permite añadir una reserva de material o instalacion
*/
const BotonAñadir = (props) => {
return(
<TouchableOpacity style={estilosBoton.botonPos}>
<TouchableOpacity style={estilosBoton.botonPos} onPress={()=> props.class.setModalAdd()}>
<View style={estilosBoton.contenedorBoton}>
<Image style={estilosBoton.contenedorImage} source={require("./assets/img/icons/iconoAdd.png")}></Image>
</View>
......
import React, {useState} from 'react';
import { View, Image, Modal, StyleSheet, TouchableOpacity, Text, TextInput } from 'react-native';
import DatePicker from 'react-native-date-picker';
import { Picker } from '@react-native-picker/picker';
const meses = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]
/**
* Modal que permite introducir el nombre de la nueva lista, fecha y hora de reserva
* @param {class} props Clase que contiene los materiales del usuario
*/
const ModalAddListaMat = (props) => {
const [textoNombreLista, setTextoNombreLista] = useState("");
const [date, setDate] = useState(new Date()); //Fecha de reserva
const [open, setOpen] = useState(false); //Booleano utilizado para abrir el modal que permite indicar la fecha
const [cFVis, setCFVis] = useState(false); // Booleano utilizado para mostrar un texto que indica que el usuario no ha introducido el nombre de la lista
const rangosHorarios = require("./assets/data/load/RangoHorarios.json")
const [hora, setHora] = useState(rangosHorarios[0].horaInicio + " - " + rangosHorarios[0].horaFin); //Hora de reserva
return (
<Modal transparent={true} visible={props.class.state.modalAdd} animationType={'fade'}>
<View style={estiloModalAddListaMat.CentrarModal}>
<View style={estiloModalAddListaMat.VistaModal}>
{/* Título del modal que permite introducir una nueva lista de materiales */}
<Text style={estiloModalAddListaMat.TituloModal}>Añadir lista</Text>
{/* Nombre de la lista de materiales */}
<Text style={estiloModalAddListaMat.TextoModal}>Indique el nombre de la lista</Text>
<TextInput style={[estiloModalAddListaMat.input, estiloModalAddListaMat.textoInput, {height: 35}]}
onChangeText={(text) => setTextoNombreLista(text)}
placeholder='Nombre de la lista' />
{/* Fecha de reserva de la lista de materiales */}
<Text style={estiloModalAddListaMat.TextoModal}>Seleccione una fecha</Text>
<View style={[estiloModalAddListaMat.input, estiloModalAddListaMat.contenedorFecha]}>
<Text style={estiloModalAddListaMat.textoInput}>{date.getDate()} de {meses[date.getMonth()]} de {date.getFullYear()}</Text>
<TouchableOpacity onPress={() => setOpen(true)}>
<Image style={estiloModalAddListaMat.iconoCalendario} source={require("./assets/img/icons/Calendario.png")}></Image>
</TouchableOpacity>
<DatePickerAddListaMat open={open} setOpen={setOpen} date={date} setDate={setDate} />
</View>
{/* Hora de reserva de la lista de materiales */}
<Text style={estiloModalAddListaMat.TextoModal}>Seleccione una hora</Text>
<View style={estiloModalAddListaMat.input}>
<Picker mode='dropdown'
selectedValue={hora}
onValueChange={(itemValue) => setHora(itemValue)}
style={estiloModalAddListaMat.picker}>
{rangosHorarios.map((rangoHor) =>
<Picker.Item key={rangoHor.horaInicio + " - " + rangoHor.horaFin}
style={estiloModalAddListaMat.textoInput}
label={rangoHor.horaInicio + " - " + rangoHor.horaFin}
value={rangoHor.horaInicio + " - " + rangoHor.horaFin} />
)}
</Picker>
</View>
{/* Si al pulsar sobre el botón crear lista no se han incluido todos los campos, se muestra un texto informátivo */}
<CamposFaltantes cFVis={cFVis} />
{/* Botónes de crear lista y cancelar la creación */}
<View style={estiloModalAddListaMat.contenedorBotones}>
<TouchableOpacity onPress={() => {
if(textoNombreLista == "") {
setCFVis(true)
} else {
props.class.setModalAdd()
props.class.props.navigation.navigate("Reserva de material", {fechaRes: date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear(), horaRes: hora, setJson: ()=> props.class.setJson("añadir", false)});
}
}}>
<Text style={{color: "#47525E", marginLeft: 15}}>CREAR LISTA</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => {
setCFVis(false)
props.class.setModalAdd()
}}>
<Text style={{color: "#F95F62"}}>CANCELAR</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
);
}
/**
* Devuelve un texto indicando al usuario que no ha introducido el nombre de la lista de reserva de material, en caso necesario
* @param {cFVis} props Booleano utilizado para mostrar un texto que indica que el usuario no ha introducido el nombre de la lista
* @returns
*/
const CamposFaltantes = (props) => {
if(props.cFVis) {
return <Text style={{color: "#F95F62", fontSize: 12}}>Se debe rellenar el nombre de la lista</Text>
} else {
return <Text></Text>
}
}
/**
* Picker que permite a un usuario escoger una fecha
* @param {open, date} props booleano utilizado para indicar si se debe introducir una fecha y fecha actual
*/
const DatePickerAddListaMat = (props) => {
return (
<DatePicker
modal
open={props.open}
date={props.date}
locale='es'
mode='date'
title="Selecciona una fecha"
confirmText='Confirmar'
cancelText='Cancelar'
onConfirm={(date) => {
props.setOpen(false)
props.setDate(date)
}}
onCancel={() => {
props.setOpen(false)
}}
/>
);
}
/**
* @brief Mantiene todos los estilos aplicados a esta vista
*/
const estiloModalAddListaMat = StyleSheet.create({
CentrarModal: {
flex: 1,
backgroundColor: "rgba(1,1,1,0.5)",
justifyContent: "center",
alignItems: "center"
},
VistaModal: {
width:330,
height:360,
margin: 10,
backgroundColor: "white",
borderRadius: 1,
padding: 25,
},
TituloModal:{
fontWeight:"bold",
color:"#47525E",
fontSize:20,
marginBottom:25
},
TextoModal: {
fontSize: 10,
color:"#8492A6",
},
contenedorFecha: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 10,
marginLeft: 3,
height: 27
},
input: {
borderBottomWidth: 1,
borderBottomColor: "#B5B2B2",
paddingBottom: 5,
marginBottom: 15
},
textoInput: {
color:"#47525E",
fontSize: 14
},
picker: {
marginLeft: -13,
marginRight: -15,
marginBottom: -15,
marginTop: -4
},
contenedorBotones: {
flexDirection: 'row-reverse',
bottom: 20,
right: 20,
position: 'absolute'
},
iconoCalendario: {
width: 19,
height: 19
},
});
export default ModalAddListaMat;
\ No newline at end of file
import * as React from 'react';
import { DefaultTheme, NavigationContainer} from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import TabBar from './TabBar';
import App from './App';
import ListaMateriales from './materialesLista';
import ListaMaterialesSis from './materialesListaSis';
const Stack = createNativeStackNavigator();
function Navegacion() {
const ref = React.useRef(null);
const tema = DefaultTheme;
tema.colors.background = 'white';
return (
<NavigationContainer ref={ref}>
<Stack.Navigator initialRouteName="App">
<Stack.Screen name="Inicio de sesión" component={App}
options={{ headerStyle:{ backgroundColor: '#7D9BFF' }, headerTitleStyle: {
color: 'white'
}}} />
<Stack.Screen name="TabBar" component={TabBar} options={{"headerShown": false}}/>
<Stack.Screen
name="Materiales"
component={ListaMateriales}
options = {({route}) => ({
title: route.params.nombreListaMat,
headerStyle: { backgroundColor: '#7D9BFF' },
headerTintColor: 'white'
})}/>
<Stack.Screen
name="Reserva de material"
component={ListaMaterialesSis}
options = {{
headerStyle: { backgroundColor: '#7D9BFF' },
headerTintColor: 'white'
}}/>
</Stack.Navigator>
</NavigationContainer>
);
}
export default Navegacion;
\ No newline at end of file
import React from "react";
import { Image, StyleSheet } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import listaMatRes from './listaMatRes.js';
/**
* @brief Mantiene todos los estilos aplicados a esta vista
*/
const tabBarEstilos = StyleSheet.create({
icono: {
width: 20,
......@@ -11,38 +12,60 @@ const tabBarEstilos = StyleSheet.create({
}
});
const tabBar = createBottomTabNavigator();
const tabBar = createBottomTabNavigator(); // Tab bar
const TabBar = () => {
/**
* Componente que incorpora el tab bar de la aplicación
* @param param0 id del usuario logueado
*/
const TabBar = ({route}) => {
return(
<NavigationContainer>
<tabBar.Navigator screenOptions={{headerShown: false}}>
<tabBar.Screen name="Inicio" component={listaMatRes}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoInicio.png")}/>
}
}}/>
<tabBar.Screen name="Instalaciones" component={listaMatRes}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoInstalaciones.png")}/>
}
}}/>
<tabBar.Screen name="Material" component={listaMatRes}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoMaterial.png")}/>
}
}}/>
<tabBar.Screen name="Perfil" component={listaMatRes}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoPerfil.png")}/>
}
}}/>
</tabBar.Navigator>
</NavigationContainer>
<tabBar.Navigator >
{/* Vista de inicio */}
<tabBar.Screen name="Inicio" component={listaMatRes} initialParams={{id: route.params.id}}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoInicio.png")}/>
},
headerShown: false
}}/>
{/* Vista que contienen guardias que el usuario debera atender */}
<tabBar.Screen name="Guardias" component={listaMatRes} initialParams={{id: route.params.id}}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/guardias.png")}/>
},
headerTitle: "Mis guardias",
tabBarLabel: "Guardias"
}}/>
{/* Vista de reservas de instalaciones */}
<tabBar.Screen name="Instalaciones" component={listaMatRes} initialParams={{id: route.params.id}}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoInstalaciones.png")}/>
},
headerTitle: "Reservas de instalaciones",
tabBarLabel: "Instalaciones"
}}/>
{/* Vista de reservas de material */}
<tabBar.Screen name="Material" component={listaMatRes} initialParams={{id: route.params.id}}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoMaterial.png")}/>
},
headerTitle: "Reservas de material",
tabBarLabel: "Material",
headerShadowVisible: false
}}/>
{/* Vista con informacion del perfil de usuario */}
<tabBar.Screen name="Perfil" component={listaMatRes} initialParams={{id: route.params.id}}
options={{
tabBarIcon: ({size, color}) => {
return <Image style={{width: size, height: size, tintColor: color}} source={require("./assets/img/icons/IconoPerfil.png")}/>
},
headerShown: false
}}/>
</tabBar.Navigator>
);
}
......
/**
* @format
*/
import 'react-native';
import React from 'react';
import App from '../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
lib_deps = []
create_aar_targets(glob(["libs/*.aar"]))
create_jar_targets(glob(["libs/*.jar"]))
android_library(
name = "all-libs",
exported_deps = lib_deps,
)
android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)
android_build_config(
name = "build_config",
package = "com.proyecto",
)
android_resource(
name = "res",
package = "com.proyecto",
res = "src/main/res",
)
android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
"""Helper definitions to glob .aar and .jar targets"""
def create_aar_targets(aarfiles):
for aarfile in aarfiles:
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
lib_deps.append(":" + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)
def create_jar_targets(jarfiles):
for jarfile in jarfiles:
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
lib_deps.append(":" + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)
No preview for this file type
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
</application>
</manifest>
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*/
package com.proyecto;
import android.content.Context;
import com.facebook.flipper.android.AndroidFlipperClient;
import com.facebook.flipper.android.utils.FlipperUtils;
import com.facebook.flipper.core.FlipperClient;
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
import com.facebook.react.ReactInstanceEventListener;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.network.NetworkingModule;
import okhttp3.OkHttpClient;
public class ReactNativeFlipper {
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (FlipperUtils.shouldEnableFlipper(context)) {
final FlipperClient client = AndroidFlipperClient.getInstance(context);
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
client.addPlugin(new ReactFlipperPlugin());
client.addPlugin(new DatabasesFlipperPlugin(context));
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
client.addPlugin(CrashReporterPlugin.getInstance());
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
NetworkingModule.setCustomClientBuilder(
new NetworkingModule.CustomClientBuilder() {
@Override
public void apply(OkHttpClient.Builder builder) {
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
}
});
client.addPlugin(networkFlipperPlugin);
client.start();
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
// Hence we run if after all native modules have been initialized
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
reactInstanceManager.addReactInstanceEventListener(
new ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext reactContext) {
reactInstanceManager.removeReactInstanceEventListener(this);
reactContext.runOnNativeModulesQueueThread(
new Runnable() {
@Override
public void run() {
client.addPlugin(new FrescoFlipperPlugin());
}
});
}
});
} else {
client.addPlugin(new FrescoFlipperPlugin());
}
}
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.proyecto">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package com.proyecto;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "Proyecto";
}
/**
* Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
* you can specify the rendered you wish to use (Fabric or the older renderer).
*/
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new MainActivityDelegate(this, getMainComponentName());
}
public static class MainActivityDelegate extends ReactActivityDelegate {
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
super(activity, mainComponentName);
}
@Override
protected ReactRootView createRootView() {
ReactRootView reactRootView = new ReactRootView(getContext());
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
return reactRootView;
}
}
}
package com.proyecto;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.soloader.SoLoader;
import com.proyecto.newarchitecture.MainApplicationReactNativeHost;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
private final ReactNativeHost mNewArchitectureNativeHost =
new MainApplicationReactNativeHost(this);
@Override
public ReactNativeHost getReactNativeHost() {
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
return mNewArchitectureNativeHost;
} else {
return mReactNativeHost;
}
}
@Override
public void onCreate() {
super.onCreate();
// If you opted-in for the New Architecture, we enable the TurboModule system
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.proyecto.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
package com.proyecto.newarchitecture;
import android.app.Application;
import androidx.annotation.NonNull;
import com.facebook.react.PackageList;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.JSIModuleProvider;
import com.facebook.react.bridge.JSIModuleSpec;
import com.facebook.react.bridge.JSIModuleType;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.fabric.ComponentFactory;
import com.facebook.react.fabric.CoreComponentsRegistry;
import com.facebook.react.fabric.EmptyReactNativeConfig;
import com.facebook.react.fabric.FabricJSIModuleProvider;
import com.facebook.react.uimanager.ViewManagerRegistry;
import com.proyecto.BuildConfig;
import com.proyecto.newarchitecture.components.MainComponentsRegistry;
import com.proyecto.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
import java.util.ArrayList;
import java.util.List;
/**
* A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
* TurboModule delegates and the Fabric Renderer.
*
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
* `newArchEnabled` property). Is ignored otherwise.
*/
public class MainApplicationReactNativeHost extends ReactNativeHost {
public MainApplicationReactNativeHost(Application application) {
super(application);
}
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
// packages.add(new TurboReactPackage() { ... });
// If you have custom Fabric Components, their ViewManagers should also be loaded here
// inside a ReactPackage.
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@NonNull
@Override
protected ReactPackageTurboModuleManagerDelegate.Builder
getReactPackageTurboModuleManagerDelegateBuilder() {
// Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
// for the new architecture and to use TurboModules correctly.
return new MainApplicationTurboModuleManagerDelegate.Builder();
}
@Override
protected JSIModulePackage getJSIModulePackage() {
return new JSIModulePackage() {
@Override
public List<JSIModuleSpec> getJSIModules(
final ReactApplicationContext reactApplicationContext,
final JavaScriptContextHolder jsContext) {
final List<JSIModuleSpec> specs = new ArrayList<>();
// Here we provide a new JSIModuleSpec that will be responsible of providing the
// custom Fabric Components.
specs.add(
new JSIModuleSpec() {
@Override
public JSIModuleType getJSIModuleType() {
return JSIModuleType.UIManager;
}
@Override
public JSIModuleProvider<UIManager> getJSIModuleProvider() {
final ComponentFactory componentFactory = new ComponentFactory();
CoreComponentsRegistry.register(componentFactory);
// Here we register a Components Registry.
// The one that is generated with the template contains no components
// and just provides you the one from React Native core.
MainComponentsRegistry.register(componentFactory);
final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
ViewManagerRegistry viewManagerRegistry =
new ViewManagerRegistry(
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
return new FabricJSIModuleProvider(
reactApplicationContext,
componentFactory,
new EmptyReactNativeConfig(),
viewManagerRegistry);
}
});
return specs;
}
};
}
}
package com.proyecto.newarchitecture.components;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.fabric.ComponentFactory;
import com.facebook.soloader.SoLoader;
/**
* Class responsible to load the custom Fabric Components. This class has native methods and needs a
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
* folder for you).
*
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
* `newArchEnabled` property). Is ignored otherwise.
*/
@DoNotStrip
public class MainComponentsRegistry {
static {
SoLoader.loadLibrary("fabricjni");
}
@DoNotStrip private final HybridData mHybridData;
@DoNotStrip
private native HybridData initHybrid(ComponentFactory componentFactory);
@DoNotStrip
private MainComponentsRegistry(ComponentFactory componentFactory) {
mHybridData = initHybrid(componentFactory);
}
@DoNotStrip
public static MainComponentsRegistry register(ComponentFactory componentFactory) {
return new MainComponentsRegistry(componentFactory);
}
}
package com.proyecto.newarchitecture.modules;
import com.facebook.jni.HybridData;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.soloader.SoLoader;
import java.util.List;
/**
* Class responsible to load the TurboModules. This class has native methods and needs a
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
* folder for you).
*
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
* `newArchEnabled` property). Is ignored otherwise.
*/
public class MainApplicationTurboModuleManagerDelegate
extends ReactPackageTurboModuleManagerDelegate {
private static volatile boolean sIsSoLibraryLoaded;
protected MainApplicationTurboModuleManagerDelegate(
ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
super(reactApplicationContext, packages);
}
protected native HybridData initHybrid();
native boolean canCreateTurboModule(String moduleName);
public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
protected MainApplicationTurboModuleManagerDelegate build(
ReactApplicationContext context, List<ReactPackage> packages) {
return new MainApplicationTurboModuleManagerDelegate(context, packages);
}
}
@Override
protected synchronized void maybeLoadOtherSoLibraries() {
if (!sIsSoLibraryLoaded) {
// If you change the name of your application .so file in the Android.mk file,
// make sure you update the name here as well.
SoLoader.loadLibrary("proyecto_appmodules");
sIsSoLibraryLoaded = true;
}
}
}
THIS_DIR := $(call my-dir)
include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
# If you wish to add a custom TurboModule or Fabric component in your app you
# will have to include the following autogenerated makefile.
# include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk
include $(CLEAR_VARS)
LOCAL_PATH := $(THIS_DIR)
# You can customize the name of your application .so file here.
LOCAL_MODULE := proyecto_appmodules
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
# If you wish to add a custom TurboModule or Fabric component in your app you
# will have to uncomment those lines to include the generated source
# files from the codegen (placed in $(GENERATED_SRC_DIR)/codegen/jni)
#
# LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
# LOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp)
# LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
# Here you should add any native library you wish to depend on.
LOCAL_SHARED_LIBRARIES := \
libfabricjni \
libfbjni \
libfolly_futures \
libfolly_json \
libglog \
libjsi \
libreact_codegen_rncore \
libreact_debug \
libreact_nativemodule_core \
libreact_render_componentregistry \
libreact_render_core \
libreact_render_debug \
libreact_render_graphics \
librrc_view \
libruntimeexecutor \
libturbomodulejsijni \
libyoga
LOCAL_CFLAGS := -DLOG_TAG=\"ReactNative\" -fexceptions -frtti -std=c++17 -Wall
include $(BUILD_SHARED_LIBRARY)
#include "MainApplicationModuleProvider.h"
#include <rncore.h>
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
const std::string moduleName,
const JavaTurboModule::InitParams &params) {
// Here you can provide your own module provider for TurboModules coming from
// either your application or from external libraries. The approach to follow
// is similar to the following (for a library called `samplelibrary`:
//
// auto module = samplelibrary_ModuleProvider(moduleName, params);
// if (module != nullptr) {
// return module;
// }
// return rncore_ModuleProvider(moduleName, params);
return rncore_ModuleProvider(moduleName, params);
}
} // namespace react
} // namespace facebook
#pragma once
#include <memory>
#include <string>
#include <ReactCommon/JavaTurboModule.h>
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
const std::string moduleName,
const JavaTurboModule::InitParams &params);
} // namespace react
} // namespace facebook
#include "MainApplicationTurboModuleManagerDelegate.h"
#include "MainApplicationModuleProvider.h"
namespace facebook {
namespace react {
jni::local_ref<MainApplicationTurboModuleManagerDelegate::jhybriddata>
MainApplicationTurboModuleManagerDelegate::initHybrid(
jni::alias_ref<jhybridobject>) {
return makeCxxInstance();
}
void MainApplicationTurboModuleManagerDelegate::registerNatives() {
registerHybrid({
makeNativeMethod(
"initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid),
makeNativeMethod(
"canCreateTurboModule",
MainApplicationTurboModuleManagerDelegate::canCreateTurboModule),
});
}
std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const std::shared_ptr<CallInvoker> jsInvoker) {
// Not implemented yet: provide pure-C++ NativeModules here.
return nullptr;
}
std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const JavaTurboModule::InitParams &params) {
return MainApplicationModuleProvider(name, params);
}
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
std::string name) {
return getTurboModule(name, nullptr) != nullptr ||
getTurboModule(name, {.moduleName = name}) != nullptr;
}
} // namespace react
} // namespace facebook
#include <memory>
#include <string>
#include <ReactCommon/TurboModuleManagerDelegate.h>
#include <fbjni/fbjni.h>
namespace facebook {
namespace react {
class MainApplicationTurboModuleManagerDelegate
: public jni::HybridClass<
MainApplicationTurboModuleManagerDelegate,
TurboModuleManagerDelegate> {
public:
// Adapt it to the package you used for your Java class.
static constexpr auto kJavaDescriptor =
"Lcom/proyecto/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>);
static void registerNatives();
std::shared_ptr<TurboModule> getTurboModule(
const std::string name,
const std::shared_ptr<CallInvoker> jsInvoker) override;
std::shared_ptr<TurboModule> getTurboModule(
const std::string name,
const JavaTurboModule::InitParams &params) override;
/**
* Test-only method. Allows user to verify whether a TurboModule can be
* created by instances of this class.
*/
bool canCreateTurboModule(std::string name);
};
} // namespace react
} // namespace facebook
#include "MainComponentsRegistry.h"
#include <CoreComponentsRegistry.h>
#include <fbjni/fbjni.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <react/renderer/components/rncore/ComponentDescriptors.h>
namespace facebook {
namespace react {
MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {}
std::shared_ptr<ComponentDescriptorProviderRegistry const>
MainComponentsRegistry::sharedProviderRegistry() {
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
// Custom Fabric Components go here. You can register custom
// components coming from your App or from 3rd party libraries here.
//
// providerRegistry->add(concreteComponentDescriptorProvider<
// AocViewerComponentDescriptor>());
return providerRegistry;
}
jni::local_ref<MainComponentsRegistry::jhybriddata>
MainComponentsRegistry::initHybrid(
jni::alias_ref<jclass>,
ComponentFactory *delegate) {
auto instance = makeCxxInstance(delegate);
auto buildRegistryFunction =
[](EventDispatcher::Weak const &eventDispatcher,
ContextContainer::Shared const &contextContainer)
-> ComponentDescriptorRegistry::Shared {
auto registry = MainComponentsRegistry::sharedProviderRegistry()
->createComponentDescriptorRegistry(
{eventDispatcher, contextContainer});
auto mutableRegistry =
std::const_pointer_cast<ComponentDescriptorRegistry>(registry);
mutableRegistry->setFallbackComponentDescriptor(
std::make_shared<UnimplementedNativeViewComponentDescriptor>(
ComponentDescriptorParameters{
eventDispatcher, contextContainer, nullptr}));
return registry;
};
delegate->buildRegistryFunction = buildRegistryFunction;
return instance;
}
void MainComponentsRegistry::registerNatives() {
registerHybrid({
makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid),
});
}
} // namespace react
} // namespace facebook
#pragma once
#include <ComponentFactory.h>
#include <fbjni/fbjni.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
namespace facebook {
namespace react {
class MainComponentsRegistry
: public facebook::jni::HybridClass<MainComponentsRegistry> {
public:
// Adapt it to the package you used for your Java class.
constexpr static auto kJavaDescriptor =
"Lcom/proyecto/newarchitecture/components/MainComponentsRegistry;";
static void registerNatives();
MainComponentsRegistry(ComponentFactory *delegate);
private:
static std::shared_ptr<ComponentDescriptorProviderRegistry const>
sharedProviderRegistry();
static jni::local_ref<jhybriddata> initHybrid(
jni::alias_ref<jclass>,
ComponentFactory *delegate);
};
} // namespace react
} // namespace facebook
#include <fbjni/fbjni.h>
#include "MainApplicationTurboModuleManagerDelegate.h"
#include "MainComponentsRegistry.h"
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
return facebook::jni::initialize(vm, [] {
facebook::react::MainApplicationTurboModuleManagerDelegate::
registerNatives();
facebook::react::MainComponentsRegistry::registerNatives();
});
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
android:insetTop="@dimen/abc_edit_text_inset_top_material"
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
<selector>
<!--
This file is a copy of abc_edit_text_material (https://bit.ly/3k8fX7I).
The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
<item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
For more info, see https://bit.ly/3CdLStv (react-native/pull/29452) and https://bit.ly/3nxOMoR.
-->
<item android:state_enabled="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
<item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
</selector>
</inset>
<resources>
<string name="app_name">Proyecto</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
</style>
</resources>
import org.apache.tools.ant.taskdefs.condition.Os
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.125.0
# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
No preview for this file type
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
rootProject.name = 'Proyecto'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')
if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") {
include(":ReactAndroid")
project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid')
}
{
"name": "gestion",
"displayName": "gestion"
"name": "Proyecto",
"displayName": "Proyecto"
}
\ No newline at end of file
[
{
"horaInicio": "08:00",
"horaFin": "09:00"
},
{
"horaInicio": "09:00",
"horaFin": "10:00"
},
{
"horaInicio": "10:00",
"horaFin": "11:00"
},
{
"horaInicio": "11:00",
"horaFin": "12:00"
},
{
"horaInicio": "12:00",
"horaFin": "13:00"
},
{
"horaInicio": "13:00",
"horaFin": "14:00"
}
]
\ No newline at end of file
{
"guardia1": {
"dia": "19",
"mes": "01",
"año": "2023",
"horaInicio": "10:00",
"horaFin": "11:00",
"clase": "Clase de 1 ESO A",
"tareas": ["Escribir un poema siguiendo las indicaciones del apartado 2 de la página 17 del libro de Lengua",
"Análisis sintáctico de las siguientes frases: \n\n - Me encontré con Pablo en el parque \n\n - Anduve sin rumbo durante un tiempo \n\n - Lo escucho desde que era pequeño",
"Leer y resumir el fragmento de la obra de Romeo y Julieta de la página 65 del libro de Lengua",
"Responda razonadamente las preguntas de la siguiente página relacionadas con el fragmento mencionado"]
},
"guardia2": {
"dia": "20",
"mes": "01",
"año": "2023",
"horaInicio": "11:00",
"horaFin": "12:00",
"clase": "Clase de 2 BACH D",
"tareas": ["Ejercicios 5, 6 y 7 de la página 44 del libro de Lengua"]
},
"guardia3": {
"dia": "20",
"mes": "01",
"año": "2023",
"horaInicio": "09:00",
"horaFin": "10:00",
"clase": "Clase de 2 ESO B",
"tareas":[]
},
"guardia4": {
"dia": "25",
"mes": "01",
"año": "2023",
"horaInicio": "13:00",
"horaFin": "14:00",
"clase": "Clase de 4 ESO B",
"tareas":["Ejercicios 1, 3 y 7 de la página 23 del libro de Ciencias Sociales"]
},
"guardia5": {
"dia": "25",
"mes": "01",
"año": "2023",
"horaInicio": "12:00",
"horaFin": "13:00",
"clase": "Clase de 1 BACH A",
"tareas":["Resumen de la página 43 del libro de Historia"]
}
}
\ No newline at end of file
{
"listaResMat0": {
"dia": "19",
"mes": "01",
"dia": "18",
"mes": "1",
"año": "2023",
"horaInicio": "10:00",
"horaFin": "11:00",
......@@ -23,7 +23,7 @@
},
"listaResMat1": {
"dia": "20",
"mes": "01",
"mes": "1",
"año": "2023",
"horaInicio": "11:00",
"horaFin": "12:00",
......@@ -45,7 +45,7 @@
},
"listaResMat2": {
"dia": "20",
"mes": "01",
"mes": "1",
"año": "2023",
"horaInicio": "09:00",
"horaFin": "10:00",
......@@ -73,11 +73,11 @@
},
{
"cantidadMaterial": 4,
"material": "Pelotas de baloncesto"
"material": "Balones de baloncesto"
},
{
"cantidadMaterial": 4,
"material": "Pelotas de fúbtol"
"material": "Balón de fútbol"
}
]
}
......
[
{
"nombreMaterial": "Balones de baloncesto",
"cantidades": [
{
"fecha": "15/1/2023",
"hora": "08:00 - 09:00",
"cantidad": 20
},
{
"fecha": "20/1/2023",
"hora": "09:00 - 10:00",
"cantidad": 10
}
]
},
{
"nombreMaterial": "Conos",
"cantidades": [
{
"fecha": "15/1/2023",
"hora": "08:00 - 09:00",
"cantidad": 15
},
{
"fecha": "20/1/2023",
"hora": "09:00 - 10:00",
"cantidad": 20
}
]
},
{
"nombreMaterial": "Balón de fútbol",
"cantidades": [
{
"fecha": "15/1/2023",
"hora": "08:00 - 09:00",
"cantidad": 18
},
{
"fecha": "20/1/2023",
"hora": "09:00 - 10:00",
"cantidad": 21
}
]
},
{
"nombreMaterial": "Cinta métrica",
"cantidades": [
{
"fecha": "15/1/2023",
"hora": "08:00 - 09:00",
"cantidad": 1
},
{
"fecha": "20/1/2023",
"hora": "09:00 - 10:00",
"cantidad": 2
}
]
},
{
"nombreMaterial": "Balones medicinales",
"cantidades": [
{
"fecha": "15/1/2023",
"hora": "08:00 - 09:00",
"cantidad": 5
},
{
"fecha": "20/1/2023",
"hora": "09:00 - 10:00",
"cantidad": 5
}
]
},
{
"nombreMaterial": "Pelotas de goma",
"cantidades": [
{
"fecha": "15/1/2023",
"hora": "08:00 - 09:00",
"cantidad": 7
},
{
"fecha": "20/1/2023",
"hora": "09:00 - 10:00",
"cantidad": 7
}
]
},
{
"nombreMaterial": "Pelotas de balonmano",
"cantidades": [
{
"fecha": "15/1/2023",
"hora": "08:00 - 09:00",
"cantidad": 8
},
{
"fecha": "20/1/2023",
"hora": "09:00 - 10:00",
"cantidad": 16
}
]
}
]
\ No newline at end of file
{
"dgh00001":{
"Telefono": "677490125",
"Nombre": "David",
"Apellidos":"González Hidalgo",
"Password": "qwerty",
"Correo": "dgh00001@gmail.com",
"ImagenPerfil":"vacio",
"idListaMaterial": ["listaResMat0", "listaResMat1", "listaResMat2"],
"idGuardias": ["guardia1", "guardia2", "guardia4"]
},
"icl00001":{
"Telefono": "658968701",
"Nombre": "Isabel",
"Apellidos": "Cazalla Loma",
"Password": "12345",
"Correo": "icl00001@gmail.com",
"ImagenPerfil":"vacio",
"idListaMaterial": [],
"idGuardias": ["guardia3", "guardia5"]
}
}
\ No newline at end of file
{
"listaResMat1": {
"dia": "20",
"mes": "1",
"año": "2023",
"horaInicio": "11:00",
"horaFin": "12:00",
"nombreLista": "Juegos de Fútbol",
"materiales": [
{
"cantidadMaterial": 1,
"material": "Balón de fútbol"
},
{
"cantidadMaterial": 20,
"material": "Conos"
},
{
"cantidadMaterial": 2,
"material": "Cinta métrica"
}
]
},
"listaResMat2": {
"dia": "20",
"mes": "1",
"año": "2023",
"horaInicio": "09:00",
"horaFin": "10:00",
"nombreLista": "Pruebas físicas",
"materiales": [
{
"cantidadMaterial": 50,
"material": "Conos"
},
{
"cantidadMaterial": 1,
"material": "Cinta métrica"
},
{
"cantidadMaterial": 3,
"material": "Balones medicinales"
},
{
"cantidadMaterial": 2,
"material": "Pelotas de goma"
},
{
"cantidadMaterial": 4,
"material": "Pelotas de balonmano"
},
{
"cantidadMaterial": 4,
"material": "Balones de baloncesto"
},
{
"cantidadMaterial": 4,
"material": "Balón de fútbol"
}
]
},
"listaResMat3": {
"dia": "20",
"mes": "1",
"año": "2023",
"horaInicio": "12:00",
"horaFin": "13:00",
"nombreLista": "Pruebas de velocidad",
"materiales": [
{
"cantidadMaterial": 10,
"material": "Conos"
},
{
"cantidadMaterial": 1,
"material": "Cinta métrica"
},
{
"cantidadMaterial": 7,
"material": "Pelotas de goma"
}
]
}
}
\ No newline at end of file
{
"listaResMat1": {
"dia": "20",
"mes": "01",
"año": "2023",
"horaInicio": "11:00",
"horaFin": "12:00",
"nombreLista": "Juegos de Fútbol",
"materiales": [
{
"cantidadMaterial": 1,
"material": "Balón de fútbol"
},
{
"cantidadMaterial": 20,
"material": "Conos"
},
{
"cantidadMaterial": 2,
"material": "Cinta métrica"
}
]
},
"listaResMat2": {
"dia": "20",
"mes": "01",
"año": "2023",
"horaInicio": "09:00",
"horaFin": "10:00",
"nombreLista": "Pruebas físicas",
"materiales": [
{
"cantidadMaterial": 50,
"material": "Conos"
},
{
"cantidadMaterial": 1,
"material": "Cinta métrica"
},
{
"cantidadMaterial": 3,
"material": "Balones medicinales"
},
{
"cantidadMaterial": 2,
"material": "Pelotas de goma"
},
{
"cantidadMaterial": 4,
"material": "Pelotas de balonmano"
},
{
"cantidadMaterial": 4,
"material": "Balones de baloncesto"
},
{
"cantidadMaterial": 4,
"material": "Balón de fútbol"
}
]
}
}
\ No newline at end of file
{
"listaResMat0": {
"dia": "18",
"mes": "1",
"año": "2023",
"horaInicio": "10:00",
"horaFin": "11:00",
"nombreLista": "Juegos de Baloncesto",
"materiales": [
{
"cantidadMaterial": 10,
"material": "Balones de baloncesto"
},
{
"cantidadMaterial": 50,
"material": "Conos"
},
{
"cantidadMaterial": 1,
"material": "Cinta métrica"
}
]
},
"listaResMat1": {
"dia": "20",
"mes": "1",
"año": "2023",
"horaInicio": "11:00",
"horaFin": "12:00",
"nombreLista": "Juegos de Fútbol",
"materiales": [
{
"cantidadMaterial": 1,
"material": "Balón de fútbol"
},
{
"cantidadMaterial": 20,
"material": "Conos"
},
{
"cantidadMaterial": 2,
"material": "Cinta métrica"
}
]
},
"listaResMat2": {
"dia": "20",
"mes": "1",
"año": "2023",
"horaInicio": "09:00",
"horaFin": "10:00",
"nombreLista": "Pruebas físicas",
"materiales": [
{
"cantidadMaterial": 30,
"material": "Conos"
},
{
"cantidadMaterial": 1,
"material": "Cinta métrica"
},
{
"cantidadMaterial": 3,
"material": "Balones medicinales"
},
{
"cantidadMaterial": 2,
"material": "Pelotas de goma"
},
{
"cantidadMaterial": 2,
"material": "Pelotas de balonmano"
},
{
"cantidadMaterial": 4,
"material": "Balones de baloncesto"
},
{
"cantidadMaterial": 4,
"material": "Balón de fútbol"
}
]
}
}
\ No newline at end of file
{
"dgh00001":{
"Telefono": "677490125",
"Nombre": "David",
"Apellidos":"González Hidalgo",
"Password": "qwerty",
"Correo": "dgh00001@gmail.com",
"ImagenPerfil":"vacio",
"idListaMaterial": ["listaResMat1", "listaResMat2", "listaResMat3"],
"idGuardias": ["guardia1", "guardia2", "guardia4"]
},
"icl00001":{
"Telefono": "658968701",
"Nombre": "Isabel",
"Apellidos": "Cazalla Loma",
"Password": "12345",
"Correo": "icl00001@gmail.com",
"ImagenPerfil":"vacio",
"idListaMaterial": [],
"idGuardias": ["guardia3", "guardia5"]
}
}
\ No newline at end of file
{
"dgh00001":{
"Telefono": "677490125",
"Nombre": "David",
"Apellidos": "González Hidalgo",
"Password": "qwerty",
"Correo": "dgh00001@gmail.com",
"ImagenPerfil":"vacio",
"idListaMaterial": ["listaResMat1", "listaResMat2"],
"idGuardias": ["guardia1", "guardia2", "guardia4"]
},
"icl00001":{
"Telefono": "658968701",
"Nombre": "Isabel",
"Apellidos": "Cazalla Loma",
"Password": "12345",
"Correo": "icl00001@gmail.com",
"ImagenPerfil":"vacio",
"idListaMaterial": [],
"idGuardias": ["guardia3", "guardia5"]
}
}
\ No newline at end of file
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './TabBar';
AppRegistry.registerComponent("gestion", () => App);
/**
* @format
*/
import {AppRegistry} from 'react-native';
import Navegacion from './Navegacion';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => Navegacion);
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
install! 'cocoapods', :deterministic_uuids => false
target 'Proyecto' do
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'ProyectoTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1210"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "Proyecto.app"
BlueprintName = "Proyecto"
ReferencedContainer = "container:Proyecto.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
BuildableName = "ProyectoTests.xctest"
BlueprintName = "ProyectoTests"
ReferencedContainer = "container:Proyecto.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "Proyecto.app"
BlueprintName = "Proyecto"
ReferencedContainer = "container:Proyecto.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "Proyecto.app"
BlueprintName = "Proyecto"
ReferencedContainer = "container:Proyecto.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTAppSetupUtils.h>
#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
RCTTurboModuleManager *_turboModuleManager;
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTAppSetupPrepareApp(application);
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
#if RCT_NEW_ARCH_ENABLED
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"Proyecto", nil);
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
#if RCT_NEW_ARCH_ENABLED
#pragma mark - RCTCxxBridgeDelegate
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
delegate:self
jsInvoker:bridge.jsCallInvoker];
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}
#pragma mark RCTTurboModuleManagerDelegate
- (Class)getModuleClassFromName:(const char *)name
{
return RCTCoreModulesClassProvider(name);
}
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return nullptr;
}
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
return RCTAppSetupDefaultModuleFromClass(moduleClass);
}
#endif
@end
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Proyecto</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Proyecto" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="0.0" y="202" width="375" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="MN2-I3-ftu">
<rect key="frame" x="0.0" y="626" width="375" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="bottom" secondItem="MN2-I3-ftu" secondAttribute="bottom" constant="20" id="OZV-Vh-mqD"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
<constraint firstItem="MN2-I3-ftu" firstAttribute="centerX" secondItem="Bcu-3y-fUS" secondAttribute="centerX" id="akx-eg-2ui"/>
<constraint firstItem="MN2-I3-ftu" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" id="i1E-0Y-4RG"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="x7j-FC-K8j"/>
</constraints>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="52.173913043478265" y="375"/>
</scene>
</scenes>
</document>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#define TIMEOUT_SECONDS 600
#define TEXT_TO_LOOK_FOR @"Welcome to React"
@interface ProyectoTests : XCTestCase
@end
@implementation ProyectoTests
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test
{
if (test(view)) {
return YES;
}
for (UIView *subview in [view subviews]) {
if ([self findSubviewInView:subview matching:test]) {
return YES;
}
}
return NO;
}
- (void)testRendersWelcomeScreen
{
UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;
__block NSString *redboxError = nil;
#ifdef DEBUG
RCTSetLogFunction(
^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) {
redboxError = message;
}
});
#endif
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
foundElement = [self findSubviewInView:vc.view
matching:^BOOL(UIView *view) {
if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
return YES;
}
return NO;
}];
}
#ifdef DEBUG
RCTSetLogFunction(RCTDefaultLogFunction);
#endif
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
}
@end
import React, { useEffect, Component} from 'react';
import {FlatList, Text, TextInput, View, StyleSheet, TouchableOpacity, Image} from 'react-native';
import React, {Component} from 'react';
import {FlatList, LogBox, Text, TextInput, View, StyleSheet, TouchableOpacity, Image} from 'react-native';
/**
* @brief Mantiene todos los estilos aplicados a esta vista
*/
const estilosMaterialesLista = StyleSheet.create({
margenes: {
flex: 1,
......@@ -37,86 +40,59 @@ const estilosMaterialesLista = StyleSheet.create({
}
});
/*const ListaMateriales = ({navigation, route}) => {
useEffect (() => {
navigation.setOptions({title: route.params.nombreListaMat});
})
const [actualizar, setActualizar] = useState(false)
const [texto, setTexto] = useState('')
const AumentarCantidad = (item) => {
setActualizar(!actualizar)
item.cantidadMaterial = item.cantidadMaterial + 1
}
const DisminuirCantidad = (item) => {
if(item.cantidadMaterial > 0) {
setActualizar(!actualizar)
item.cantidadMaterial = item.cantidadMaterial - 1
}
}
const Material = ({item}) => {
return (
<View>
<View style={[estilosMaterialesLista.elementosFila, estilosMaterialesLista.contenedorMaterial]}>
<Text style={estilosMaterialesLista.textoMaterial}>{item.material}</Text>
<View style={[estilosMaterialesLista.elementosFila, {width: 75}]}>
<TouchableOpacity style={{marginRight: 3, alignSelf: 'center'}} onPress={() => DisminuirCantidad(item)}>
<Image style={estilosMaterialesLista.iconos} source={require("./Imagenes/iconoElim.png")}/>
</TouchableOpacity>
<TextInput style={estilosMaterialesLista.textoMaterial} textAlign={'center'} maxLength={3} keyboardType={'numeric'}
defaultValue={item.cantidadMaterial.toString()} onSubmitEditing={{
newtext => setTexto(newtext);
item.cantidadMaterial = newtext;
}}/>
<TouchableOpacity style={{marginLeft: 3, alignSelf: 'center'}} onPress={()=> AumentarCantidad(item)}>
<Image style={estilosMaterialesLista.iconos} source={require("./Imagenes/iconoAñadir.png")}/>
</TouchableOpacity>
</View>
</View>
</View>
);
}
return (
<View style={estilosMaterialesLista.margenes}>
<FlatList
extraData={actualizar}
data = {route.params.listaMat}
renderItem={Material}
/>
<TouchableOpacity style={estilosMaterialesLista.botonMod}>
<Text style={estilosMaterialesLista.textoBoton}>MODIFICAR</Text>
</TouchableOpacity>
</View>
);
}*/
class ListaMateriales extends Component {
state = {
listaMat: [],
cantidadTotal: 0
listaMat: [], // Lista de materiales contenidos en la lista de reserva
cantidadesMax: [], // Cantidades maxima de material en el sistema
indiceAux: 0,
indiceAux2: 0,
cantidadTotal: 0 // Cantidad total de material reservado
}
// Constructor
constructor(props) {
super(props);
LogBox.ignoreAllLogs()
// Se carga los materiales contenidos en la lista de material
this.state.listaMat = this.props.route.params.listaMat;
this.state.listaMat.map((item, index) =>
// Se cargan los materiales del sistema
const materialesSis = require("./assets/data/load/materialesSis.json");
// Se carga la cantidad maxima de materiales del sistema para cada material contenido en la lista
this.state.listaMat.map((item, index) => {
this.state.indiceAux = materialesSis.findIndex((itemSis) => itemSis.nombreMaterial === item.material)
this.state.indiceAux2 = materialesSis[this.state.indiceAux].cantidades.findIndex((itemCant) => itemCant.fecha === this.props.route.params.fechaRes
&& itemCant.hora === this.props.route.params.horaRes);
if(materialesSis[this.state.indiceAux].cantidades[this.state.indiceAux2] !== undefined) {
this.state.cantidadesMax.push(materialesSis[this.state.indiceAux].cantidades[this.state.indiceAux2].cantidad + item.cantidadMaterial)
} else {
this.state.cantidadesMax.push(item.cantidadMaterial)
}
this.state.cantidadTotal = this.state.cantidadTotal + item.cantidadMaterial
)
})
}
/**
* Metodo que permite incrementar la cantidad actual de un material determinado
* @param index indice de la estructura
*/
AumentarCantidad = (index) => {
let {listaMat} = this.state;
listaMat[index].cantidadMaterial = listaMat[index].cantidadMaterial + 1;
this.state.cantidadTotal = this.state.cantidadTotal + 1;
// Se comprueba que la cantidad actual no supera la cantidad máxima del sistema
if(listaMat[index].cantidadMaterial < this.state.cantidadesMax[index]) {
listaMat[index].cantidadMaterial = listaMat[index].cantidadMaterial + 1;
this.state.cantidadTotal = this.state.cantidadTotal + 1;
}
this.setState({listaMat});
}
/**
* Metodo que permite decrementar la cantidad actual de un material determinado
* @param index indice de la estructura que contiene los materiales contenidos en la lista
*/
DisminuirCantidad = (index) => {
let {listaMat} = this.state;
// Se comprueba si el usuario esta intentando introducir una cantidad negativa de material
if(listaMat[index].cantidadMaterial > 0) {
listaMat[index].cantidadMaterial = listaMat[index].cantidadMaterial - 1
this.state.cantidadTotal = this.state.cantidadTotal - 1;
......@@ -124,34 +100,29 @@ class ListaMateriales extends Component {
}
}
CambiarCantidad = (index, text) => {
const numeroTexto = Number(text)
if(!isNaN(numeroTexto)) {
let {listaMat} = this.state;
this.state.cantidadTotal = this.state.cantidadTotal + (numeroTexto - listaMat[index].cantidadMaterial);
listaMat[index].cantidadMaterial = Number(text);
this.setState({listaMat});
}
}
//Metodo render
render() {
return (
<View style={estilosMaterialesLista.margenes}>
<FlatList
{/* Lista que contiene los materiales contenidos en la lista de reserva */}
<FlatList removeClippedSubviews={false}
data = {this.state.listaMat}
keyExtractor={(item) => item.material}
renderItem={({item, index}) => {
return (
<View>
<View style={[estilosMaterialesLista.elementosFila, estilosMaterialesLista.contenedorMaterial]}>
{/* Nombre del material */}
<Text style={estilosMaterialesLista.textoMaterial}>{item.material}</Text>
<View style={[estilosMaterialesLista.elementosFila, {width: 75}]}>
{/* Boton que permite disminuir la cantidad de material */}
<TouchableOpacity style={{marginRight: 3, alignSelf: 'center'}} onPress={() => {this.DisminuirCantidad(index)}}>
<Image style={estilosMaterialesLista.iconos} source={require("./assets/img/icons/iconoElim.png")}/>
</TouchableOpacity>
{/* Numero de reservas actual del material */}
<TextInput style={estilosMaterialesLista.textoMaterial} textAlign={'center'} maxLength={3} keyboardType={'number-pad'}
value={item.cantidadMaterial.toString()} placeholder={item.cantidadMaterial.toString()}
onChangeText={(text) => this.CambiarCantidad(index, text)}/>
value={item.cantidadMaterial.toString()} editable={false}/>
{/* Boton que permite aumentar la cantidad de material */}
<TouchableOpacity style={{marginLeft: 3, alignSelf: 'center'}} onPress={() => {this.AumentarCantidad(index)}}>
<Image style={estilosMaterialesLista.iconos} source={require("./assets/img/icons/iconoAdd.png")}/>
</TouchableOpacity>
......@@ -161,7 +132,11 @@ class ListaMateriales extends Component {
);
}}
/>
<TouchableOpacity style={estilosMaterialesLista.botonMod} onPress={() => this.props.navigation.goBack(null)}>
{/* Boton que permite confirmar la modificacion de una reserva reserva */}
<TouchableOpacity style={estilosMaterialesLista.botonMod} onPress={() => {
this.props.route.params.setJson()
this.props.navigation.goBack(null)
}}>
<Text style={estilosMaterialesLista.textoBoton}>MODIFICAR ({this.state.cantidadTotal} materiales)</Text>
</TouchableOpacity>
</View>
......
import React, {Component} from 'react';
import {FlatList, LogBox, Text, TextInput, View, StyleSheet, TouchableOpacity, Image} from 'react-native';
/**
* @brief Mantiene todos los estilos aplicados a esta vista
*/
const estilosMaterialesLista = StyleSheet.create({
margenes: {
flex: 1,
marginLeft: 30,
marginRight: 30
},
contenedorMaterial: {
marginTop: 10,
marginBottom: 10
},
textoMaterial: {
fontSize: 14,
color: '#1f2d3d',
alignSelf: 'center'
},
elementosFila: {
flexDirection: 'row',
justifyContent: "space-between",
},
iconos: {
width: 15,
height: 15
},
botonMod: {
backgroundColor: '#7D9BFF',
height: 40,
bottom: 25,
justifyContent: 'center'
},
textoBoton: {
alignSelf: 'center',
color: 'white',
fontWeight: 'bold'
}
});
class ListaMaterialesSis extends Component {
state = {
listaMat: [], // Lista de materiales contenidos en la lista de reserva
cantidadesMax: [], // Cantidades maxima de material en el sistema
cantidadesAct: [], // Cantidades actuales de material reservado para cada material
cantidadTotal: 0 // Cantidad total de material reservado
}
// Constructor
constructor(props) {
super(props);
LogBox.ignoreAllLogs()
// Se cargan los materiales del sistema
const materialesSis = require("./assets/data/load/materialesSis.json");
// Se carga la cantidad maxima de materiales del sistema para cada material
materialesSis.map((item, index) => {
this.state.cantidadesMax.push(item.cantidades.find((itemCant) => itemCant.fecha === this.props.route.params.fechaRes
&& itemCant.hora === this.props.route.params.horaRes));
this.state.listaMat.push(item.nombreMaterial);
this.state.cantidadesAct.push(0);
})
}
/**
* Metodo que permite incrementar la cantidad actual de un material determinado
* @param index indice de la estructura
*/
AumentarCantidad = (index) => {
let {cantidadesAct} = this.state;
// Se comprueba que la cantidad actual no supera la cantidad máxima del sistema
if(this.state.cantidadesMax[index] !== undefined) {
if(cantidadesAct[index] < this.state.cantidadesMax[index].cantidad) {
cantidadesAct[index] = cantidadesAct[index] + 1;
this.state.cantidadTotal = this.state.cantidadTotal + 1;
this.setState({cantidadesAct});
}
}
}
/**
* Metodo que permite decrementar la cantidad actual de un material determinado
* @param index indice de la estructura que contiene los materiales contenidos en la lista
*/
DisminuirCantidad = (index) => {
let {cantidadesAct} = this.state;
// Se comprueba si el usuario esta intentando introducir una cantidad negativa de material
if(cantidadesAct[index] > 0) {
cantidadesAct[index] = cantidadesAct[index] - 1
this.state.cantidadTotal = this.state.cantidadTotal - 1;
this.setState({cantidadesAct});
}
}
//Metodo render
render() {
return (
<View style={estilosMaterialesLista.margenes}>
{/* Lista que contiene los materiales contenidos en la lista de reserva */}
<FlatList removeClippedSubviews={false}
data = {this.state.listaMat}
keyExtractor={(item) => item}
renderItem={({item, index}) => {
return (
<View>
<View style={[estilosMaterialesLista.elementosFila, estilosMaterialesLista.contenedorMaterial]}>
{/* Nombre del material */}
<Text style={estilosMaterialesLista.textoMaterial}>{item}</Text>
<View style={[estilosMaterialesLista.elementosFila, {width: 75}]}>
{/* Boton que permite disminuir la cantidad de material */}
<TouchableOpacity style={{marginRight: 3, alignSelf: 'center'}} onPress={() => {this.DisminuirCantidad(index)}}>
<Image style={estilosMaterialesLista.iconos} source={require("./assets/img/icons/iconoElim.png")}/>
</TouchableOpacity>
{/* Numero de reservas actual del material */}
<TextInput style={estilosMaterialesLista.textoMaterial} textAlign={'center'} maxLength={3} keyboardType={'number-pad'}
value={this.state.cantidadesAct[index].toString()} editable={false}/>
{/* Boton que permite aumentar la cantidad de material */}
<TouchableOpacity style={{marginLeft: 3, alignSelf: 'center'}} onPress={() => {this.AumentarCantidad(index)}}>
<Image style={estilosMaterialesLista.iconos} source={require("./assets/img/icons/iconoAdd.png")}/>
</TouchableOpacity>
</View>
</View>
</View>
);
}}
/>
{/* Boton que permite confirmar la adicion de una lista de reserva de material */}
<TouchableOpacity style={estilosMaterialesLista.botonMod} onPress={() => {
this.props.route.params.setJson()
this.props.navigation.goBack(null)}}>
<Text style={estilosMaterialesLista.textoBoton}>RESERVAR ({this.state.cantidadTotal} materiales)</Text>
</TouchableOpacity>
</View>
);
}
}
export default ListaMaterialesSis;
\ No newline at end of file
This diff could not be displayed because it is too large.
{
"name": "gestion",
"name": "Proyecto",
"version": "0.0.1",
"private": true,
"scripts": {
......@@ -10,22 +10,25 @@
"lint": "eslint ."
},
"dependencies": {
"@react-native-picker/picker": "^2.4.8",
"@react-navigation/bottom-tabs": "^6.5.3",
"@react-navigation/native": "^6.1.2",
"@react-navigation/native-stack": "^6.9.8",
"@react-navigation/native": "^6.1.0",
"@react-navigation/native-stack": "^6.9.5",
"@react-navigation/stack": "^6.3.8",
"react": "17.0.2",
"react-native": "0.68.2",
"react-native-date-picker": "^4.2.6",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.18.2"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@babel/runtime": "^7.20.6",
"@react-native-community/eslint-config": "^3.2.0",
"babel-jest": "^29.3.1",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"metro-react-native-babel-preset": "^0.73.4",
"@babel/core": "7.20.2",
"@babel/runtime": "7.20.1",
"@react-native-community/eslint-config": "2.0.0",
"babel-jest": "26.6.3",
"eslint": "7.32.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.67.0",
"react-test-renderer": "17.0.2"
},
"jest": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment