Skip to content

Commit 33f284c

Browse files
author
Jacob Jaffe
committed
yak profile lock
1 parent daa730d commit 33f284c

File tree

1 file changed

+134
-93
lines changed

1 file changed

+134
-93
lines changed

src/mobile/components/App/Main/Yak/List_Screen.jsx

Lines changed: 134 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ type DispatchProps = {
8181
type ReduxProps = {
8282
getYaksInProgress: boolean,
8383
currentYakIds: { byTime: number[], byScore: number[] },
84-
yakMap: { [id: number]: Yak }
84+
yakMap: { [id: number]: Yak },
85+
canBeActiveInScenes: boolean
8586
};
8687

8788
type SortOption = 'score' | 'time';
@@ -101,11 +102,14 @@ type State = {
101102
selectedYakId: null | number
102103
};
103104

104-
function mapStateToProps({ yaks }: ReduxState): ReduxProps {
105+
function mapStateToProps({ yaks, client }: ReduxState): ReduxProps {
105106
const { inProgress, byId, currentYakIds } = yaks;
106107
const currentYakIdsGreaterThan5 = currentYakIds.filter(
107108
id => byId[id].score > -5
108109
);
110+
if (!client) {
111+
throw new Error('Redux Client is null in Yak List');
112+
}
109113
return {
110114
getYaksInProgress: inProgress.get,
111115
currentYakIds: {
@@ -118,7 +122,8 @@ function mapStateToProps({ yaks }: ReduxState): ReduxProps {
118122
return 0;
119123
})
120124
},
121-
yakMap: byId
125+
yakMap: byId,
126+
canBeActiveInScenes: client.settings.canBeActiveInScenes
122127
};
123128
}
124129

@@ -266,28 +271,68 @@ class YakListScreen extends React.Component<Props, State> {
266271
currentYakIds,
267272
navigation,
268273
getYaksInProgress,
269-
getYaks
274+
getYaks,
275+
canBeActiveInScenes
270276
} = this.props;
271-
if (!yaksLoaded) {
272-
return (
273-
<View
274-
style={{
275-
flex: 1,
276-
alignContent: 'center',
277-
justifyContent: 'center'
278-
}}
277+
278+
const lockedAccountCopy =
279+
'Your account is currently locked. Please check your email for more information.';
280+
281+
const LockedBody = (
282+
<View
283+
style={{
284+
flex: 1,
285+
paddingHorizontal: '10.1%',
286+
alignContent: 'center',
287+
justifyContent: 'center'
288+
}}
289+
>
290+
<Text style={[textStyles.headline3Style, { textAlign: 'center' }]}>
291+
{'👀'}
292+
</Text>
293+
<Text
294+
style={[
295+
textStyles.subtitle1Style,
296+
{
297+
textAlign: 'center',
298+
color: Colors.Grapefruit
299+
}
300+
]}
279301
>
280-
<ActivityIndicator />
281-
</View>
282-
);
283-
}
302+
{lockedAccountCopy}
303+
</Text>
304+
</View>
305+
);
306+
307+
const LoadingBody = (
308+
<View
309+
style={{
310+
flex: 1,
311+
alignContent: 'center',
312+
justifyContent: 'center'
313+
}}
314+
>
315+
<ActivityIndicator />
316+
</View>
317+
);
318+
284319
const refreshComponent = (
285320
<RefreshControl
286321
refreshing={refreshManuallyTriggered}
287322
onRefresh={this._onRefresh}
288323
/>
289324
);
290325

326+
const TitleComponent = (
327+
<Text style={textStyles.headline5Style}>
328+
{'Jumbo'}
329+
<Text style={textStyles.headline5StyleDemibold}>{'Yak'}</Text>
330+
</Text>
331+
);
332+
const Footer = (
333+
<View style={{ height: NEW_ICON_HEIGHT + NEW_ICON_PADDING * 2 }} />
334+
);
335+
291336
const Header = (
292337
<View
293338
style={{
@@ -323,14 +368,76 @@ class YakListScreen extends React.Component<Props, State> {
323368
</View>
324369
);
325370

326-
const TitleComponent = (
327-
<Text style={textStyles.headline5Style}>
328-
{'Jumbo'}
329-
<Text style={textStyles.headline5StyleDemibold}>{'Yak'}</Text>
330-
</Text>
331-
);
332-
const Footer = (
333-
<View style={{ height: NEW_ICON_HEIGHT + NEW_ICON_PADDING * 2 }} />
371+
const Body = (
372+
<View style={{ flex: 1 }}>
373+
<ImageBackground
374+
source={wavesFull}
375+
style={{ width: '100%', height: '100%', position: 'absolute' }}
376+
/>
377+
{Header}
378+
<FlatList
379+
ref={ref => {
380+
this.flatListRef = ref;
381+
}}
382+
data={
383+
sortBy === 'time' ? currentYakIds.byTime : currentYakIds.byScore
384+
}
385+
renderItem={({ item: id }) => {
386+
return this._renderYak(id);
387+
}}
388+
keyExtractor={id => {
389+
return `${id}`;
390+
}}
391+
ItemSeparatorComponent={this._renderSeparator}
392+
refreshControl={refreshComponent}
393+
ListFooterComponent={Footer}
394+
/>
395+
<View
396+
style={{
397+
position: 'absolute',
398+
right: 0,
399+
bottom: 0,
400+
padding: NEW_ICON_PADDING,
401+
justifyContent: 'center',
402+
elevation: 1,
403+
shadowColor: Colors.Black,
404+
shadowOpacity: 0.57,
405+
shadowRadius: 2,
406+
shadowOffset: {
407+
height: 2,
408+
width: 1
409+
}
410+
}}
411+
>
412+
<Animatable.View
413+
animation="swing"
414+
easing="ease-out"
415+
iterationCount="infinite"
416+
iterationDelay={10000}
417+
delay={10000}
418+
>
419+
<View
420+
style={{
421+
width: NEW_ICON_HEIGHT,
422+
height: NEW_ICON_HEIGHT,
423+
backgroundColor: Colors.Grapefruit,
424+
borderRadius: NEW_ICON_HEIGHT,
425+
alignItems: 'center',
426+
justifyContent: 'center'
427+
}}
428+
>
429+
<CustomIcon
430+
name={'pencil'}
431+
color={Colors.White}
432+
size={30}
433+
onPress={() => {
434+
navigation.navigate(routes.YakNew);
435+
}}
436+
/>
437+
</View>
438+
</Animatable.View>
439+
</View>
440+
</View>
334441
);
335442
return (
336443
<View style={{ flex: 1 }}>
@@ -359,75 +466,9 @@ class YakListScreen extends React.Component<Props, State> {
359466
}}
360467
centerComponent={TitleComponent}
361468
/>
362-
<View style={{ flex: 1 }}>
363-
<ImageBackground
364-
source={wavesFull}
365-
style={{ width: '100%', height: '100%', position: 'absolute' }}
366-
/>
367-
{Header}
368-
<FlatList
369-
ref={ref => {
370-
this.flatListRef = ref;
371-
}}
372-
data={
373-
sortBy === 'time' ? currentYakIds.byTime : currentYakIds.byScore
374-
}
375-
renderItem={({ item: id }) => {
376-
return this._renderYak(id);
377-
}}
378-
keyExtractor={id => {
379-
return `${id}`;
380-
}}
381-
ItemSeparatorComponent={this._renderSeparator}
382-
refreshControl={refreshComponent}
383-
ListFooterComponent={Footer}
384-
/>
385-
<View
386-
style={{
387-
position: 'absolute',
388-
right: 0,
389-
bottom: 0,
390-
padding: NEW_ICON_PADDING,
391-
justifyContent: 'center',
392-
elevation: 1,
393-
shadowColor: Colors.Black,
394-
shadowOpacity: 0.57,
395-
shadowRadius: 2,
396-
shadowOffset: {
397-
height: 2,
398-
width: 1
399-
}
400-
}}
401-
>
402-
<Animatable.View
403-
animation="swing"
404-
easing="ease-out"
405-
iterationCount="infinite"
406-
iterationDelay={10000}
407-
delay={10000}
408-
>
409-
<View
410-
style={{
411-
width: NEW_ICON_HEIGHT,
412-
height: NEW_ICON_HEIGHT,
413-
backgroundColor: Colors.Grapefruit,
414-
borderRadius: NEW_ICON_HEIGHT,
415-
alignItems: 'center',
416-
justifyContent: 'center'
417-
}}
418-
>
419-
<CustomIcon
420-
name={'pencil'}
421-
color={Colors.White}
422-
size={30}
423-
onPress={() => {
424-
navigation.navigate(routes.YakNew);
425-
}}
426-
/>
427-
</View>
428-
</Animatable.View>
429-
</View>
430-
</View>
469+
{!yaksLoaded && LoadingBody}
470+
{yaksLoaded && !canBeActiveInScenes && LockedBody}
471+
{yaksLoaded && canBeActiveInScenes && Body}
431472
{this._renderActionSheet()}
432473
{this._renderReportPopup()}
433474
</View>

0 commit comments

Comments
 (0)