forked from vergnet/application-amicale
Set header title to match currently selected group
This commit is contained in:
parent
28168aacf8
commit
b6b87b6c06
3 changed files with 15 additions and 6 deletions
|
@ -18,8 +18,6 @@ type State = {
|
|||
|
||||
const LIST_ITEM_HEIGHT = 64;
|
||||
|
||||
const REPLACE_REGEX = /_/g;
|
||||
|
||||
export default class GroupListAccordion extends React.Component<Props, State> {
|
||||
|
||||
state = {
|
||||
|
@ -43,7 +41,7 @@ export default class GroupListAccordion extends React.Component<Props, State> {
|
|||
const onPress = () => this.props.onGroupPress(item);
|
||||
return (
|
||||
<List.Item
|
||||
title={item.name.replace(REPLACE_REGEX, " ")}
|
||||
title={item.name}
|
||||
onPress={onPress}
|
||||
left={props =>
|
||||
<List.Icon
|
||||
|
|
|
@ -30,6 +30,7 @@ function sortName(a, b) {
|
|||
}
|
||||
|
||||
const GROUPS_URL = 'http://planex.insa-toulouse.fr/wsAdeGrp.php?projectId=1';
|
||||
const REPLACE_REGEX = /_/g;
|
||||
|
||||
/**
|
||||
* Class defining proximo's article list of a certain category.
|
||||
|
@ -126,12 +127,19 @@ class GroupSelectionScreen extends React.Component<Props, State> {
|
|||
generateData(fetchedData: Object) {
|
||||
let data = [];
|
||||
for (let key in fetchedData) {
|
||||
this.formatGroupNames(fetchedData[key]);
|
||||
data.push(fetchedData[key]);
|
||||
}
|
||||
data.sort(sortName);
|
||||
return data;
|
||||
}
|
||||
|
||||
formatGroupNames(item: Object) {
|
||||
for (let i = 0; i < item.content.length; i++) {
|
||||
item.content[i].name = item.content[i].name.replace(REPLACE_REGEX, " ")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the dataset to be used in the FlatList
|
||||
*
|
||||
|
|
|
@ -137,16 +137,18 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
/**
|
||||
* Defines custom injected JavaScript to improve the page display on mobile
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.webScreenRef = React.createRef();
|
||||
this.barRef = React.createRef();
|
||||
|
||||
let currentGroup = AsyncStorageManager.getInstance().preferences.planexCurrentGroup.current;
|
||||
if (currentGroup === '')
|
||||
currentGroup = {name: "SELECT GROUP", id: -1};
|
||||
else
|
||||
else {
|
||||
currentGroup = JSON.parse(currentGroup);
|
||||
props.navigation.setOptions({title: currentGroup.name})
|
||||
}
|
||||
this.state = {
|
||||
bannerVisible:
|
||||
AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
|
||||
|
@ -183,6 +185,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
AsyncStorageManager.getInstance().savePref(
|
||||
AsyncStorageManager.getInstance().preferences.planexCurrentGroup.key,
|
||||
JSON.stringify(group));
|
||||
this.props.navigation.setOptions({title: group.name})
|
||||
this.generateInjectedJS(group.id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue