import React, { Component } from 'react'; import { StyleSheet, View, FlatList, RefreshControl, ScrollView, Text } from 'react-native'; import NoteCell from "./NoteCell" import Search from 'react-native-search-box' import GlobalStyles from "../Styles" import App from "../app" export default class NoteList extends Component { constructor(props) { super(props); this.styles = StyleSheet.create({ container: { flex: 1, }, decryptNoticeContainer: { flex: 1, justifyContent: 'center', alignItems: 'center', zIndex: -1, position: "absolute", height: "100%", width: "100%" }, decryptNotice: { position: "absolute", opacity: 0.5, color: GlobalStyles.constants().mainTextColor } }); } 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 = App.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} renderItem={this._renderItem} ListHeaderComponent={this.renderHeader} /> ) } }