forked from vergnet/application-amicale
Fix for theme not updating
This commit is contained in:
parent
9f391fc335
commit
9bdfe3944e
3 changed files with 53 additions and 42 deletions
|
@ -1,46 +1,59 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import {View} from "react-native";
|
||||||
import {withTheme} from 'react-native-paper';
|
import {withTheme} from 'react-native-paper';
|
||||||
import {Agenda} from "react-native-calendars";
|
import {Agenda} from "react-native-calendars";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
theme: Object,
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstraction layer for Agenda component, using custom configuration
|
* Abstraction layer for Agenda component, using custom configuration
|
||||||
*
|
|
||||||
* @param props Props to pass to the element. Must specify an onRef prop to get an Agenda ref.
|
|
||||||
* @return {*}
|
|
||||||
*/
|
*/
|
||||||
function CustomAgenda(props) {
|
class CustomAgenda extends React.Component<Props> {
|
||||||
const {colors} = props.theme;
|
|
||||||
return (
|
getAgenda() {
|
||||||
<Agenda
|
return <Agenda
|
||||||
{...props}
|
{...this.props}
|
||||||
ref={props.onRef}
|
ref={this.props.onRef}
|
||||||
theme={{
|
theme={{
|
||||||
backgroundColor: colors.agendaBackgroundColor,
|
backgroundColor: this.props.theme.colors.agendaBackgroundColor,
|
||||||
calendarBackground: colors.background,
|
calendarBackground: this.props.theme.colors.background,
|
||||||
textSectionTitleColor: colors.agendaDayTextColor,
|
textSectionTitleColor: this.props.theme.colors.agendaDayTextColor,
|
||||||
selectedDayBackgroundColor: colors.primary,
|
selectedDayBackgroundColor: this.props.theme.colors.primary,
|
||||||
selectedDayTextColor: '#ffffff',
|
selectedDayTextColor: '#ffffff',
|
||||||
todayTextColor: colors.primary,
|
todayTextColor: this.props.theme.colors.primary,
|
||||||
dayTextColor: colors.text,
|
dayTextColor: this.props.theme.colors.text,
|
||||||
textDisabledColor: colors.agendaDayTextColor,
|
textDisabledColor: this.props.theme.colors.agendaDayTextColor,
|
||||||
dotColor: colors.primary,
|
dotColor: this.props.theme.colors.primary,
|
||||||
selectedDotColor: '#ffffff',
|
selectedDotColor: '#ffffff',
|
||||||
arrowColor: 'orange',
|
arrowColor: 'orange',
|
||||||
monthTextColor: colors.primary,
|
monthTextColor: this.props.theme.colors.primary,
|
||||||
indicatorColor: colors.primary,
|
indicatorColor: this.props.theme.colors.primary,
|
||||||
textDayFontWeight: '300',
|
textDayFontWeight: '300',
|
||||||
textMonthFontWeight: 'bold',
|
textMonthFontWeight: 'bold',
|
||||||
textDayHeaderFontWeight: '300',
|
textDayHeaderFontWeight: '300',
|
||||||
textDayFontSize: 16,
|
textDayFontSize: 16,
|
||||||
textMonthFontSize: 16,
|
textMonthFontSize: 16,
|
||||||
textDayHeaderFontSize: 16,
|
textDayHeaderFontSize: 16,
|
||||||
agendaDayTextColor: colors.agendaDayTextColor,
|
agendaDayTextColor: this.props.theme.colors.agendaDayTextColor,
|
||||||
agendaDayNumColor: colors.agendaDayTextColor,
|
agendaDayNumColor: this.props.theme.colors.agendaDayTextColor,
|
||||||
agendaTodayColor: colors.primary,
|
agendaTodayColor: this.props.theme.colors.primary,
|
||||||
agendaKnobColor: colors.primary,
|
agendaKnobColor: this.props.theme.colors.primary,
|
||||||
}}
|
}}
|
||||||
/>
|
/>;
|
||||||
);
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.props.theme.colors.text === "#ffffff") // We are in light mode
|
||||||
|
return (
|
||||||
|
<View style={{flex: 1}}>
|
||||||
|
{this.getAgenda()}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return this.getAgenda();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withTheme(CustomAgenda);
|
export default withTheme(CustomAgenda);
|
||||||
|
|
|
@ -40,7 +40,7 @@ const AGENDA_MONTH_SPAN = 3;
|
||||||
/**
|
/**
|
||||||
* Class defining the app's planning screen
|
* Class defining the app's planning screen
|
||||||
*/
|
*/
|
||||||
export default class PlanningScreen extends React.Component<Props, State> {
|
class PlanningScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
agendaRef: Object;
|
agendaRef: Object;
|
||||||
|
|
||||||
|
@ -226,10 +226,15 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps: Props, prevState: State, prevContext: *): * {
|
||||||
|
console.log('coucou');
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// console.log("rendering PlanningScreen");
|
// console.log("rendering PlanningScreen");
|
||||||
return (
|
return (
|
||||||
<CustomAgenda
|
<CustomAgenda
|
||||||
|
{...this.props}
|
||||||
// the list of items that have to be displayed in agenda. If you want to render item as empty date
|
// the list of items that have to be displayed in agenda. If you want to render item as empty date
|
||||||
// the value of date key kas to be an empty array []. If there exists no value for date key it is
|
// the value of date key kas to be an empty array []. If there exists no value for date key it is
|
||||||
// considered that the date in question is not yet loaded
|
// considered that the date in question is not yet loaded
|
||||||
|
@ -259,3 +264,5 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default PlanningScreen;
|
||||||
|
|
|
@ -4,9 +4,10 @@ import * as React from 'react';
|
||||||
import {FlatList, Image, Platform, ScrollView, View} from "react-native";
|
import {FlatList, Image, Platform, ScrollView, View} from "react-native";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import CustomModal from "../../components/Custom/CustomModal";
|
import CustomModal from "../../components/Custom/CustomModal";
|
||||||
import {IconButton, RadioButton, Searchbar, Subheading, Text, Title, withTheme} from "react-native-paper";
|
import {RadioButton, Searchbar, Subheading, Text, Title, withTheme} from "react-native-paper";
|
||||||
import {stringMatchQuery} from "../../utils/Search";
|
import {stringMatchQuery} from "../../utils/Search";
|
||||||
import ProximoListItem from "../../components/Lists/ProximoListItem";
|
import ProximoListItem from "../../components/Lists/ProximoListItem";
|
||||||
|
import HeaderButton from "../../components/Custom/HeaderButton";
|
||||||
|
|
||||||
function sortPrice(a, b) {
|
function sortPrice(a, b) {
|
||||||
return a.price - b.price;
|
return a.price - b.price;
|
||||||
|
@ -37,6 +38,7 @@ const LIST_ITEM_HEIGHT = 84;
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
route: Object,
|
route: Object,
|
||||||
|
theme: Object,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -54,8 +56,6 @@ class ProximoListScreen extends React.Component<Props, State> {
|
||||||
listData: Array<Object>;
|
listData: Array<Object>;
|
||||||
shouldFocusSearchBar: boolean;
|
shouldFocusSearchBar: boolean;
|
||||||
|
|
||||||
colors: Object;
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.listData = this.props.route.params['data']['data'];
|
this.listData = this.props.route.params['data']['data'];
|
||||||
|
@ -65,8 +65,6 @@ class ProximoListScreen extends React.Component<Props, State> {
|
||||||
currentSortMode: 3,
|
currentSortMode: 3,
|
||||||
modalCurrentDisplayItem: null,
|
modalCurrentDisplayItem: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.colors = props.theme.colors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,14 +102,7 @@ class ProximoListScreen extends React.Component<Props, State> {
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
getSortMenuButton = () => {
|
getSortMenuButton = () => {
|
||||||
return (
|
return <HeaderButton icon="sort" onPress={this.onSortMenuPress}/>;
|
||||||
<IconButton
|
|
||||||
icon="sort"
|
|
||||||
color={this.colors.text}
|
|
||||||
size={26}
|
|
||||||
onPress={this.onSortMenuPress}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,11 +155,11 @@ class ProximoListScreen extends React.Component<Props, State> {
|
||||||
getStockColor(availableStock: number) {
|
getStockColor(availableStock: number) {
|
||||||
let color: string;
|
let color: string;
|
||||||
if (availableStock > 3)
|
if (availableStock > 3)
|
||||||
color = this.colors.success;
|
color = this.props.theme.colors.success;
|
||||||
else if (availableStock > 0)
|
else if (availableStock > 0)
|
||||||
color = this.colors.warning;
|
color = this.props.theme.colors.warning;
|
||||||
else
|
else
|
||||||
color = this.colors.danger;
|
color = this.props.theme.colors.danger;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue