forked from vergnet/application-amicale
Improved documentation and fixed debug mode
This commit is contained in:
parent
4cdfc607e6
commit
03549957a8
3 changed files with 110 additions and 5 deletions
|
@ -10,6 +10,12 @@ type listItem = {
|
||||||
version: string
|
version: string
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the dependencies list from the raw json
|
||||||
|
*
|
||||||
|
* @param object The raw json
|
||||||
|
* @return {Array<listItem>}
|
||||||
|
*/
|
||||||
function generateListFromObject(object: { [string]: string }): Array<listItem> {
|
function generateListFromObject(object: { [string]: string }): Array<listItem> {
|
||||||
let list = [];
|
let list = [];
|
||||||
let keys = Object.keys(object);
|
let keys = Object.keys(object);
|
||||||
|
|
|
@ -105,7 +105,7 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
icon: 'bug-check',
|
icon: 'bug-check',
|
||||||
text: i18n.t('aboutScreen.debug'),
|
text: i18n.t('aboutScreen.debug'),
|
||||||
showChevron: true,
|
showChevron: true,
|
||||||
showOnlyDebug: true
|
showOnlyInDebug: true
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
|
@ -171,6 +171,9 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
showChevron: true
|
showChevron: true
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
/**
|
||||||
|
* Order of information cards
|
||||||
|
*/
|
||||||
dataOrder: Array<Object> = [
|
dataOrder: Array<Object> = [
|
||||||
{
|
{
|
||||||
id: 'app',
|
id: 'app',
|
||||||
|
@ -201,6 +204,11 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
this.colors = props.theme.colors;
|
this.colors = props.theme.colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the app icon
|
||||||
|
* @param props
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getAppIcon(props) {
|
getAppIcon(props) {
|
||||||
return (
|
return (
|
||||||
<Avatar.Image
|
<Avatar.Image
|
||||||
|
@ -211,10 +219,21 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyExtractor(item: Object) {
|
/**
|
||||||
|
* Extracts a key from the given item
|
||||||
|
*
|
||||||
|
* @param item The item to extract the key from
|
||||||
|
* @return {string} The extracted key
|
||||||
|
*/
|
||||||
|
keyExtractor(item: Object): string {
|
||||||
return item.icon;
|
return item.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the app card showing information and links about the app.
|
||||||
|
*
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getAppCard() {
|
getAppCard() {
|
||||||
return (
|
return (
|
||||||
<Card style={{marginBottom: 10}}>
|
<Card style={{marginBottom: 10}}>
|
||||||
|
@ -235,6 +254,11 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the team card showing information and links about the team
|
||||||
|
*
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getTeamCard() {
|
getTeamCard() {
|
||||||
return (
|
return (
|
||||||
<Card style={{marginBottom: 10}}>
|
<Card style={{marginBottom: 10}}>
|
||||||
|
@ -263,6 +287,11 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the techno card showing information and links about the technologies used in the app
|
||||||
|
*
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getTechnoCard() {
|
getTechnoCard() {
|
||||||
return (
|
return (
|
||||||
<Card style={{marginBottom: 10}}>
|
<Card style={{marginBottom: 10}}>
|
||||||
|
@ -280,12 +309,25 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a chevron icon
|
||||||
|
*
|
||||||
|
* @param props
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getChevronIcon(props: Object) {
|
getChevronIcon(props: Object) {
|
||||||
return (
|
return (
|
||||||
<List.Icon {...props} icon={'chevron-right'}/>
|
<List.Icon {...props} icon={'chevron-right'}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a custom list item icon
|
||||||
|
*
|
||||||
|
* @param item The item to show the icon for
|
||||||
|
* @param props
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getItemIcon(item: Object, props: Object) {
|
getItemIcon(item: Object, props: Object) {
|
||||||
return (
|
return (
|
||||||
<List.Icon {...props} icon={item.icon}/>
|
<List.Icon {...props} icon={item.icon}/>
|
||||||
|
@ -295,10 +337,12 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
/**
|
/**
|
||||||
* Get a clickable card item to be rendered inside a card.
|
* Get a clickable card item to be rendered inside a card.
|
||||||
*
|
*
|
||||||
* @returns {React.Node}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
getCardItem({item}: Object) {
|
getCardItem({item}: Object) {
|
||||||
let shouldShow = !item.showOnlyInDebug || (item.showOnlyInDebug && this.state.isDebugUnlocked);
|
let shouldShow = item === undefined
|
||||||
|
|| !item.showOnlyInDebug
|
||||||
|
|| (item.showOnlyInDebug && this.state.isDebugUnlocked);
|
||||||
const getItemIcon = this.getItemIcon.bind(this, item);
|
const getItemIcon = this.getItemIcon.bind(this, item);
|
||||||
if (shouldShow) {
|
if (shouldShow) {
|
||||||
if (item.showChevron) {
|
if (item.showChevron) {
|
||||||
|
@ -323,6 +367,9 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to unlock debug mode
|
||||||
|
*/
|
||||||
tryUnlockDebugMode() {
|
tryUnlockDebugMode() {
|
||||||
this.debugTapCounter = this.debugTapCounter + 1;
|
this.debugTapCounter = this.debugTapCounter + 1;
|
||||||
if (this.debugTapCounter >= 4) {
|
if (this.debugTapCounter >= 4) {
|
||||||
|
@ -330,12 +377,20 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlocks debug mode
|
||||||
|
*/
|
||||||
unlockDebugMode() {
|
unlockDebugMode() {
|
||||||
this.setState({isDebugUnlocked: true});
|
this.setState({isDebugUnlocked: true});
|
||||||
let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
|
let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
|
||||||
AsyncStorageManager.getInstance().savePref(key, '1');
|
AsyncStorageManager.getInstance().savePref(key, '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bug report modal's content
|
||||||
|
*
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getBugReportModal() {
|
getBugReportModal() {
|
||||||
return (
|
return (
|
||||||
<View style={{
|
<View style={{
|
||||||
|
@ -376,12 +431,21 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* opens the bug report modal
|
||||||
|
*/
|
||||||
openBugReportModal() {
|
openBugReportModal() {
|
||||||
if (this.modalRef) {
|
if (this.modalRef) {
|
||||||
this.modalRef.open();
|
this.modalRef.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a card, depending on the given item's id
|
||||||
|
*
|
||||||
|
* @param item The item to show
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getMainCard({item}: Object) {
|
getMainCard({item}: Object) {
|
||||||
switch (item.id) {
|
switch (item.id) {
|
||||||
case 'app':
|
case 'app':
|
||||||
|
@ -394,6 +458,11 @@ class AboutScreen extends React.Component<Props, State> {
|
||||||
return <View/>;
|
return <View/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used when receiving the modal ref
|
||||||
|
*
|
||||||
|
* @param ref
|
||||||
|
*/
|
||||||
onModalRef(ref: Object) {
|
onModalRef(ref: Object) {
|
||||||
this.modalRef = ref;
|
this.modalRef = ref;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ type State = {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class defining the Debug screen. This screen allows the user to get detailed information on the app/device.
|
* Class defining the Debug screen.
|
||||||
|
* This screen allows the user to get and modify information on the app/device.
|
||||||
*/
|
*/
|
||||||
class DebugScreen extends React.Component<Props, State> {
|
class DebugScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
|
@ -37,6 +38,15 @@ class DebugScreen extends React.Component<Props, State> {
|
||||||
this.colors = props.theme.colors;
|
this.colors = props.theme.colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a clickable list item
|
||||||
|
*
|
||||||
|
* @param onPressCallback The function to call when clicking on the item
|
||||||
|
* @param icon The item's icon
|
||||||
|
* @param title The item's title
|
||||||
|
* @param subtitle The item's subtitle
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) {
|
static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) {
|
||||||
if (icon !== undefined) {
|
if (icon !== undefined) {
|
||||||
return (
|
return (
|
||||||
|
@ -58,6 +68,10 @@ class DebugScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the
|
||||||
|
* @param item
|
||||||
|
*/
|
||||||
showEditModal(item: Object) {
|
showEditModal(item: Object) {
|
||||||
this.setState({
|
this.setState({
|
||||||
modalCurrentDisplayItem: item
|
modalCurrentDisplayItem: item
|
||||||
|
@ -67,6 +81,11 @@ class DebugScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the edit modal content
|
||||||
|
*
|
||||||
|
* @return {*}
|
||||||
|
*/
|
||||||
getModalContent() {
|
getModalContent() {
|
||||||
return (
|
return (
|
||||||
<View style={{
|
<View style={{
|
||||||
|
@ -104,6 +123,12 @@ class DebugScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the new value of the given preference
|
||||||
|
*
|
||||||
|
* @param key The pref key
|
||||||
|
* @param value The pref value
|
||||||
|
*/
|
||||||
saveNewPrefs(key: string, value: string) {
|
saveNewPrefs(key: string, value: string) {
|
||||||
this.setState((prevState) => {
|
this.setState((prevState) => {
|
||||||
let currentPreferences = {...prevState.currentPreferences};
|
let currentPreferences = {...prevState.currentPreferences};
|
||||||
|
@ -113,6 +138,11 @@ class DebugScreen extends React.Component<Props, State> {
|
||||||
AsyncStorageManager.getInstance().savePref(key, value);
|
AsyncStorageManager.getInstance().savePref(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used when receiving the modal ref
|
||||||
|
*
|
||||||
|
* @param ref
|
||||||
|
*/
|
||||||
onModalRef(ref: Object) {
|
onModalRef(ref: Object) {
|
||||||
this.modalRef = ref;
|
this.modalRef = ref;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue