I have an app which was made entirely using react native. It's pretty much a todo list, this is the structure:
<SafeAreaView style={styles.container}>
<Text style={styles.title} >Registro de pacientes</Text>
{loading && (
<ActivityIndicator
style={styles.loading}
size="large"
color="#0066ff"
/>
)}
{!loading && (
<ListaPacientes
pacientes={pacientes}
onUpdate={this.handleUpdate}
/>
)}
</SafeAreaView>
And here is the list:
<SectionList
sections={
pacientes && pacientes.length ?
[
{title: "Pacientes sin registrar", data: pacientes.filter(paciente => !paciente.done)},
{title: "Pacientes registrados", data: pacientes.filter(paciente => paciente.done)}
] : []
}
keyExtractor={paciente => paciente.id}
renderItem={({item}) => renderItem(item)}
renderSectionHeader={renderSectionHeader}
style={styles.container}
ItemSeparatorComponent={renderSeparator}
ListEmptyComponent={renderEmptyComponent}
stickySectionHeadersEnabled={true}
/>
This takes a list of clients and displays their names. Upon being clicked on, they are removed from the list. Very simple.
The thing is, the list of clients must be read from a csv file and, after being clicked, update the csv. I already have a piece of code that does that. However, it's written in kotlin (It was coded for another project).
Instead of having to do the whole fetching/reading/treating/updating of the data again in react native, can I somehow use the kotlin code I already have? If so, care to provide an example on how it would be done?
EDIT: To clarify, I have a kotlin method that returns an ArrayList of strings with the names I want to store on the list. How can I call that method from the javascript, obtain the arraylist, and use it as data source for my SectionList ?.
lateinit var pacientes: Array<String>
@ReactMethod
fun getListaPacientes() : Array<String> {
return pacientes
}
Something like this?
var res = []
res = ListaPacientesModulo.getListaPacientes()
Thank you.