-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
186 lines (157 loc) · 3.79 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import { NativeStackScreenProps } from "@react-navigation/native-stack";
import { Item, List } from "./data/data";
import { ListsAction, ListsData } from "./data/reducers/lists.reducer";
/**
* Navigation
*/
export type AppStackNavigatorParamList = {
Lists: undefined;
Items: {
listIndex: number;
};
Settings: undefined;
Legal: undefined;
AddUpdateItem: {
listIndex: number;
itemIndex: number;
currentItem?: Item;
};
AddUpdateList: {
listIndex: number;
currentList?: List;
visibleFrom: CollectionViewCellType;
};
Actions: {
cellType: CollectionViewCellType;
cells: SelectionValue<number>[];
selectActions: [CellSelect, number[]][];
cellActions: [CellAction, ListsAction][];
listIndex?: number;
};
};
export type ListPageNavigationProps = NativeStackScreenProps<
AppStackNavigatorParamList,
"Lists"
>;
export type ItemPageNavigationProps = NativeStackScreenProps<
AppStackNavigatorParamList,
"Items"
>;
export type SettingsPageNavigationProps = NativeStackScreenProps<
AppStackNavigatorParamList,
"Settings"
>;
export type LegalPageNavigationProps = NativeStackScreenProps<
AppStackNavigatorParamList,
"Legal"
>;
export type AddUpdateItemPageNavigationProps = NativeStackScreenProps<
AppStackNavigatorParamList,
"AddUpdateItem"
>;
export type AddUpdateListPageNavigationProps = NativeStackScreenProps<
AppStackNavigatorParamList,
"AddUpdateList"
>;
export type ActionsPageNavigationProps = NativeStackScreenProps<
AppStackNavigatorParamList,
"Actions"
>;
export type ItemParams = {
oldPos: number;
newPos: number;
listIndex: number;
item: Item;
};
export type ListParams = {
oldPos: number;
newPos: number;
list: List;
};
export type MenuOption = {
text: string;
onPress: () => void;
disabled?: boolean;
color?: string;
testId?: string;
};
export interface CollectionViewCell {
name: string;
type: CollectionViewCellType;
isSelected: boolean;
isLocked: boolean;
setIsSelected: (isSelected: boolean) => CollectionViewCell;
}
export type ListJSON = {
name: string;
listType: ListType;
defaultNewItemPosition: Position;
items: ItemJSON[];
isSelected: boolean;
isLocked: boolean;
};
export type ItemJSON = {
name: string;
notes: string;
quantity: number;
isComplete: boolean;
isSelected: boolean;
isLocked: boolean;
};
export type SettingsJSON = {
isDeveloperModeEnabled: boolean;
defaultListType: ListType;
defaultListPosition: Position;
};
export type ListsContextData = {
data: ListsData;
listsDispatch: (action: ListsAction) => void;
};
// For selection components (dropdowns, radio buttons, etc.)
export type SelectionValue<T> = {
label: string;
value: T;
};
export type ModalButton = {
text: string;
onPress: () => void;
disabled?: boolean;
};
export type Position = "top" | "current" | "bottom";
export type ListType = "List" | "Shopping" | "To-Do" | "Ordered To-Do";
export type CollectionViewCellType = "List" | "Item";
export type MoveItemAction = "Copy" | "Move";
export type CellSelect =
| "All"
| "None"
| "Complete"
| "Incomplete"
| "Locked"
| "Unlocked"
| "Generic List"
| "Shopping List"
| "To-Do List"
| "Ordered To-Do List"
| "Custom";
export type CellAction =
| "Delete"
| "Complete"
| "Incomplete"
| "Lock"
| "Unlock";
export type ActionMetadata = {
label: CellSelect | CellAction;
method: (indices: number[]) => void;
isTerminating: boolean;
};
/**
* Legal
*/
export type Hyperlink = {
text: string;
url: string;
};
export type ImageAttribution = {
hyperlink: Hyperlink;
image: any;
};