2019-06-29 13:37:21 +02:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import * as React from 'react';
|
2019-06-27 11:08:56 +02:00
|
|
|
import {FlatList} from "react-native";
|
2020-03-06 09:12:56 +01:00
|
|
|
import packageJson from '../../package';
|
2020-03-06 23:15:01 +01:00
|
|
|
import {List} from 'react-native-paper';
|
2019-06-27 11:08:56 +02:00
|
|
|
|
2020-03-22 17:02:00 +01:00
|
|
|
type listItem = {
|
|
|
|
name: string,
|
|
|
|
version: string
|
|
|
|
};
|
|
|
|
|
2020-03-29 15:08:51 +02:00
|
|
|
/**
|
|
|
|
* Generates the dependencies list from the raw json
|
|
|
|
*
|
|
|
|
* @param object The raw json
|
|
|
|
* @return {Array<listItem>}
|
|
|
|
*/
|
2020-03-22 17:02:00 +01:00
|
|
|
function generateListFromObject(object: { [string]: string }): Array<listItem> {
|
2019-06-27 11:08:56 +02:00
|
|
|
let list = [];
|
|
|
|
let keys = Object.keys(object);
|
|
|
|
let values = Object.values(object);
|
|
|
|
for (let i = 0; i < keys.length; i++) {
|
|
|
|
list.push({name: keys[i], version: values[i]});
|
|
|
|
}
|
2020-03-22 17:02:00 +01:00
|
|
|
//$FlowFixMe
|
2019-06-27 11:08:56 +02:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2019-06-29 13:37:21 +02:00
|
|
|
type Props = {
|
2020-03-06 09:12:56 +01:00
|
|
|
navigation: Object,
|
|
|
|
route: Object
|
2019-06-29 13:37:21 +02:00
|
|
|
}
|
2019-06-27 11:08:56 +02:00
|
|
|
|
2019-06-29 15:43:57 +02:00
|
|
|
/**
|
|
|
|
* Class defining a screen showing the list of libraries used by the app, taken from package.json
|
|
|
|
*/
|
2019-06-29 13:37:21 +02:00
|
|
|
export default class AboutDependenciesScreen extends React.Component<Props> {
|
2019-06-27 11:08:56 +02:00
|
|
|
|
|
|
|
render() {
|
2020-03-06 09:12:56 +01:00
|
|
|
const data = generateListFromObject(packageJson.dependencies);
|
2019-06-27 11:08:56 +02:00
|
|
|
return (
|
2020-03-06 09:12:56 +01:00
|
|
|
<FlatList
|
|
|
|
data={data}
|
|
|
|
keyExtractor={(item) => item.name}
|
|
|
|
style={{minHeight: 300, width: '100%'}}
|
|
|
|
renderItem={({item}) =>
|
2020-03-06 23:15:01 +01:00
|
|
|
<List.Item
|
|
|
|
title={item.name}
|
|
|
|
description={item.version.replace('^', '').replace('~', '')}
|
|
|
|
/>}
|
2020-03-06 09:12:56 +01:00
|
|
|
/>
|
2019-06-27 11:08:56 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|