Skip to content

Commit

Permalink
abuseAlarm - News&Stories Switch Params
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanobaldassarre committed May 6, 2021
1 parent 2877a3f commit 0ef5e08
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 18 deletions.
10 changes: 8 additions & 2 deletions src/components/home-drawer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,20 @@ export const HomeDrawer = ({ navigation }): DrawerElement => {
// AbuseAlarm
case 3: {
navigation.toggleDrawer();
navigation.navigate('AbuseAlarm');
navigation.navigate('AbuseAlarm', {
screen: 'ContentsList',
params: { abuseAlarm: true},
});
return;
}

// News&Stories
case 4: {
navigation.toggleDrawer();
navigation.navigate('NewsStories');
navigation.navigate('NewsStories', {
screen: 'ContentsList',
params: { abuseAlarm: false},
});
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/menu-grid-list.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MenuItem } from '../model/menu-item.model';

export interface MenuGridListProps extends Omit<ListProps, 'renderItem'> {
data: MenuItem[];
onItemPress: (index: number) => void;
onItemPress: (index: number, var_name: string, var_value: boolean) => void;
}

export const MenuGridList = (props: MenuGridListProps): ListElement => {
Expand All @@ -21,7 +21,7 @@ export const MenuGridList = (props: MenuGridListProps): ListElement => {
const renderItem = (info: ListRenderItemInfo<MenuItem>): ListItemElement => (
<Card
style={styles.item}
onPress={() => props.onItemPress(info.index)}>
onPress={() => props.onItemPress(info.index, info.item.var_name, info.item.var_value)}>
{info.item.icon({ width: 64, height: 64, alignSelf: 'center' })}
<Text
style={styles.itemTitle}
Expand Down
10 changes: 10 additions & 0 deletions src/i18n/en.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,14 @@ export default {
'Description missing': 'Description missing',
'Please fill the compliant descripton': 'Please fill the compliant descripton',
'Don\'t know how to open Terms and Conditions URL': 'Don\'t know how to open Terms and Conditions URL',
'AbuseAlarm - List': 'AbuseAlarm - List',
'News&Stories - List': 'News&Stories - List',
'Tap on AbuseAlarm for the preview': 'Tap on AbuseAlarm for the preview',
'Swipe left on AbuseAlarm to delete it': 'Swipe left on AbuseAlarm to delete it',
'Tap on News&Story for the preview': 'Tap on News&Story for the preview',
'Swipe left on News&Story to delete it': 'Swipe left on News&Story to delete it',
'AbuseAlarm - New': 'AbuseAlarm - New',
'News&Stories - New': 'News&Stories - New',
'AbuseAlarm - Edit': 'AbuseAlarm - Edit',
'News&Stories - Edit': 'News&Stories - Edit',
};
2 changes: 2 additions & 0 deletions src/model/menu-item.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ import { ImageStyle } from 'react-native';
export interface MenuItem {
title: string;
icon: (style: ImageStyle) => React.ReactElement;
var_name: string;
var_value: boolean;
}
7 changes: 6 additions & 1 deletion src/services/zenroom/zenroom-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ export async function recoveryKeypair(clientSideContractText: string, answers:
}

// Verify that the answers are correct
export async function verifyAnswers(clientSideContractText: string, answers: any, PBKDF: string, userPublicKey: string) {
export async function verifyAnswers(
clientSideContractText: string,
answers: any,
PBKDF: string,
userPublicKey: string,
) {
const execution = await recoveryKeypair(
clientSideContractText,
answers,
Expand Down
10 changes: 7 additions & 3 deletions src/views/contents-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export const ContentsDetailsScreen = (props): React.ReactElement => {
const [loading, setLoading] = React.useState(false);
const [data, setData] = React.useState([]);

const item = null;
// const item = null;
const styles = useStyleSheet(themedStyles);

const { abuseAlarm } = props.route.params;
const { item, abuseAlarm } = props.route.params;

const ZoomImage = (): void => {
setmodalFileVisible(true);
Expand Down Expand Up @@ -300,7 +300,11 @@ export const ContentsDetailsScreen = (props): React.ReactElement => {
insets='top'>
<KeyboardAvoidingView style= {styles.FlexGrowOne}>
<TopNavigation
title={ item ? I18n.t('Edit Compliant') : I18n.t('New Compliant') }
title={
item ?
abuseAlarm ? I18n.t('AbuseAlarm - Edit') : I18n.t('News&Stories - Edit') :
abuseAlarm ? I18n.t('AbuseAlarm - New') : I18n.t('News&Stories - New')
}
titleStyle={styles.topBarTitle}
leftControl={renderDrawerAction() }
style={styles.topBar}
Expand Down
33 changes: 26 additions & 7 deletions src/views/contents-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { MenuItem } from '../model/menu-item.model';
import axios from 'axios';

// AsyncStorage import
import AsyncStorage from '@react-native-async-storage/async-storage';
// import AsyncStorage from '@react-native-async-storage/async-storage';

// Other imports
import Spinner from 'react-native-loading-spinner-overlay';
Expand All @@ -38,6 +38,10 @@ export interface LayoutData extends MenuItem {
route: string;
}

// Redux import
import { useSelector } from 'react-redux';
import { selectToken } from '../redux/tokenSlice';

export const ContentsListScreen = (props): React.ReactElement => {
const styles = useStyleSheet(themedStyles);
const [compliants, setCompliants] = React.useState([]);
Expand All @@ -50,7 +54,12 @@ export const ContentsListScreen = (props): React.ReactElement => {
const [alertMessage, setAlertMessage] = React.useState('');
const [loading, setLoading] = React.useState(false);

// const { abuseAlarm } = props.route.params;
// Get Token from Redux
const token = useSelector(selectToken);

const { abuseAlarm } = props.route.params;
// let abuseAlarm = null;


const onItemRemove = (compliant: Compliant, index: number): void => {
// DeleteDocument(document,index);
Expand All @@ -62,7 +71,7 @@ export const ContentsListScreen = (props): React.ReactElement => {

async function DeleteCompliant() {
setLoading(true);
const token = await AsyncStorage.getItem('token');
// const token = await AsyncStorage.getItem('token');
/*axios
.delete(AppOptions.getServerUrl() + 'documents/' + documentDelete.idDocument, {
headers: {
Expand All @@ -85,7 +94,7 @@ export const ContentsListScreen = (props): React.ReactElement => {
}

const onItemPress = (compliant: Compliant, index: number): void => {
props.navigation && props.navigation.navigate('ContentsDetails', { item: compliant });
props.navigation && props.navigation.navigate('ContentsDetails', { item: compliant, abuseAlarm: abuseAlarm });
};

const renderCompliantItem = (info: ListRenderItemInfo<Compliant>): React.ReactElement => (
Expand Down Expand Up @@ -124,6 +133,7 @@ export const ContentsListScreen = (props): React.ReactElement => {

useEffect(() => {
getMyCompliants();
// console.log(abuseAlarm);
}, []);


Expand Down Expand Up @@ -152,7 +162,7 @@ export const ContentsListScreen = (props): React.ReactElement => {
style={styles.safeArea}
insets='top'>
<TopNavigation
title={I18n.t('Compliants')}
title={abuseAlarm === true ? I18n.t('AbuseAlarm - List') : I18n.t('News&Stories - List')}
titleStyle={styles.topBarTitle}
leftControl={renderDrawerAction() }
style={styles.topBar}
Expand All @@ -165,11 +175,20 @@ export const ContentsListScreen = (props): React.ReactElement => {
textContent={I18n.t('Please wait') + '...'}
textStyle={styles.spinnerTextStyle}
/>
{ abuseAlarm === true && (
<Text
style={styles.infoSection}>
{I18n.t('Tap on compliant for the preview') + '. '
+ I18n.t('Swipe left on compliant to delete it') + '.' }
{I18n.t('Tap on AbuseAlarm for the preview') + '. '
+ I18n.t('Swipe left on AbuseAlarm to delete it') + '.' }
</Text>
)}
{ abuseAlarm === false && (
<Text
style={styles.infoSection}>
{I18n.t('Tap on News&Story for the preview') + '. '
+ I18n.t('Swipe left on News&Story to delete it') + '.' }
</Text>
)}
<List style={styles.container}
data={compliants}
renderItem={renderCompliantItem}
Expand Down
26 changes: 23 additions & 3 deletions src/views/homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,26 @@ import { MenuGridList } from '../components/menu-grid-list.component';
import { MenuIcon, CustomDocWalletIcon, CustomAroundMeIcon, CustomAbuseAlarmIcon, CustomNewsStoriesIcon } from '../components/icons';
import { ThemedIcon } from '../components/themed-icon.component';

interface PropsObject {
[key: string]: any;
}

export const HomepageScreen = (props): React.ReactElement => {
const [data, setData] = React.useState([]);
const styles = useStyleSheet(themedStyles);

// Homepage button press event
const onItemPress = (index: number): void => {
props.navigation.navigate(data[index].route);
const onItemPress = (index: number, var_name: string = null, var_value: boolean = null): void => {
const vars: PropsObject = {};
if (var_name) {
vars[var_name] = var_value;
props.navigation && props.navigation.navigate(data[index].route, {
screen: 'ContentsList',
params: vars,
});
} else {
props.navigation && props.navigation.navigate(data[index].route);
}
};

// Navbar menu render
Expand Down Expand Up @@ -50,6 +63,8 @@ export const HomepageScreen = (props): React.ReactElement => {
{ ...style, light: CustomDocWalletIcon, dark: CustomDocWalletIcon },
);
},
var_name: null,
var_value: null,
},
);

Expand All @@ -64,6 +79,8 @@ export const HomepageScreen = (props): React.ReactElement => {
{ ...style, light: CustomAroundMeIcon, dark: CustomAroundMeIcon },
);
},
var_name: null,
var_value: null,
},
);

Expand All @@ -78,6 +95,8 @@ export const HomepageScreen = (props): React.ReactElement => {
{ ...style, light: CustomAbuseAlarmIcon, dark: CustomAbuseAlarmIcon },
);
},
var_name: 'abuseAlarm',
var_value: true,
},
);

Expand All @@ -92,9 +111,10 @@ export const HomepageScreen = (props): React.ReactElement => {
{ ...style, light: CustomNewsStoriesIcon, dark: CustomNewsStoriesIcon },
);
},
var_name: 'abuseAlarm',
var_value: false,
},
);

setData(buttonsArray);
}

Expand Down
2 changes: 2 additions & 0 deletions src/views/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export default ({ navigation }): React.ReactElement => {
setAnswer3('');
setAnswer4('');
setAnswer5('');
setEmail('test4@stefanobaldassarre.it');
setPassword('12345678');
}, []);

// Open the sign-up page
Expand Down

0 comments on commit 0ef5e08

Please sign in to comment.