This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor of Filter -> SideMenu, Account -> Settings, and NoteOptions …
…screen
- Loading branch information
Showing
12 changed files
with
740 additions
and
715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React, { Component } from 'react'; | ||
import { StyleSheet, View, FlatList, RefreshControl, ScrollView, Text } from 'react-native'; | ||
import GlobalStyles from "../Styles" | ||
import TableSection from "../components/TableSection"; | ||
import SectionHeader from "../components/SectionHeader"; | ||
import SectionedAccessoryTableCell from "../components/SectionedAccessoryTableCell"; | ||
import ItemActionManager from '../lib/itemActionManager' | ||
import ActionSheet from 'react-native-actionsheet' | ||
import ApplicationState from "../ApplicationState" | ||
|
||
export default class TagList extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = {}; | ||
} | ||
|
||
onPress = (tag) => { | ||
this.props.onTagSelect(tag); | ||
} | ||
|
||
onLongPress = (tag) => { | ||
this.props.onTagLongPress(tag); | ||
} | ||
|
||
static ActionSheetCancelIndex = 0; | ||
static ActionSheetDestructiveIndex = 1; | ||
|
||
actionSheetActions() { | ||
return [ | ||
['Cancel', ""], | ||
['Delete', ItemActionManager.DeleteEvent] | ||
]; | ||
} | ||
|
||
showActionSheet = (item) => { | ||
// Dont show actionsheet for "All notes" tag | ||
if(item.key !== "all") { | ||
this.actionSheetItem = item; | ||
this.setState((prevState) => { | ||
return _.merge(prevState, {actionSheetTitle: item.title}) | ||
}) | ||
this.actionSheet.show(); | ||
} | ||
} | ||
|
||
handleActionSheetPress = (index) => { | ||
if(index == 0) { | ||
return; | ||
} | ||
|
||
this.props.onManageTagEvent(this.actionSheetActions()[index][1], this.actionSheetItem, () => { | ||
this.forceUpdate(); | ||
}); | ||
this.actionSheetItem = null; | ||
} | ||
|
||
// must pass title, text, and tags as props so that it re-renders when either of those change | ||
_renderItem = ({item}) => { | ||
return ( | ||
<View> | ||
<SectionedAccessoryTableCell | ||
onPress={() => {this.onPress(item)}} | ||
onLongPress={() => this.showActionSheet(item)} | ||
text={item.deleted ? "Deleting..." : item.title} | ||
color={item.deleted ? GlobalStyles.constants().mainTintColor : undefined} | ||
key={item.uuid} | ||
first={this.props.tags.indexOf(item) == 0} | ||
last={this.props.tags.indexOf(item) == this.props.tags.length - 1} | ||
selected={() => {return this.props.selected.includes(item.uuid)}} | ||
/> | ||
|
||
<ActionSheet | ||
title={this.state.actionSheetTitle} | ||
ref={o => this.actionSheet = o} | ||
options={this.actionSheetActions().map((action) => {return action[0]})} | ||
cancelButtonIndex={TagList.ActionSheetCancelIndex} | ||
destructiveButtonIndex={TagList.ActionSheetDestructiveIndex} | ||
onPress={this.handleActionSheetPress} | ||
{...GlobalStyles.actionSheetStyles()} | ||
/> | ||
</View> | ||
) | ||
} | ||
|
||
render() { | ||
return ( | ||
<TableSection style={GlobalStyles.styles().view}> | ||
<SectionHeader title={this.props.title} buttonText={this.props.hasClearButton && "Clear"} buttonAction={() => {this.props.clearSelection(true)}}/> | ||
|
||
<FlatList style={{height: "100%"}} | ||
initialNumToRender={10} | ||
windowSize={10} | ||
maxToRenderPerBatch={10} | ||
data={this.props.tags} | ||
renderItem={this._renderItem} | ||
/> | ||
|
||
</TableSection> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.