import React, { Component } from 'react';
import { StyleSheet, View, FlatList, RefreshControl, ScrollView, Text } from 'react-native';
import NoteCell from "@Screens/Notes/NoteCell"
import Search from 'react-native-search-box'
import StyleKit from "@Style/StyleKit"
import ApplicationState from "@Lib/ApplicationState"
import ThemedComponent from "@Components/ThemedComponent"
export default class NoteList extends ThemedComponent {
renderHeader = () => {
return (
);
};
// must pass title, text, and tags as props so that it re-renders when either of those change
_renderItem = ({item}) => {
// On Android, only one tag is selected at a time. If it is selected, we don't need to display the tags string
// above the note cell
let selectedTags = this.props.selectedTags || [];
let renderTags = ApplicationState.isIOS || selectedTags.length == 0 || (!item.tags.includes(selectedTags[0]));
return (
)
}
render() {
var placeholderText = "";
if(this.props.decrypting) {
placeholderText = "Decrypting notes...";
} else if(this.props.loading) {
placeholderText = "Loading notes...";
} else if(this.props.notes.length == 0) {
placeholderText = "No notes.";
}
return (
{placeholderText.length > 0 &&
{placeholderText}
}
}
data={this.props.notes}
options={this.props.options}
renderItem={this._renderItem}
ListHeaderComponent={this.renderHeader}
/>
)
}
loadStyles() {
this.styles = StyleSheet.create({
container: {
flex: 1,
},
loadingTextContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
zIndex: -1,
position: "absolute",
height: "100%",
width: "100%"
},
loadingText: {
position: "absolute",
opacity: 0.5,
color: StyleKit.variables.stylekitForegroundColor
}
});
}
}