Skip to content

Commit fda3abe

Browse files
committed
show a disclaimer on the Balances view
- show a disclaimer on first launch of the view - show a disclaimer beneath each box
1 parent 0c63a0f commit fda3abe

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

source/views/sis/balances.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
/**
2-
* @flow
3-
* All About Olaf
4-
* Balances page
5-
*/
1+
// @flow
62

73
import React from 'react'
8-
import {StyleSheet, ScrollView, View, Text, RefreshControl} from 'react-native'
4+
import {
5+
StyleSheet,
6+
ScrollView,
7+
View,
8+
Text,
9+
RefreshControl,
10+
Alert,
11+
} from 'react-native'
912
import {TabBarIcon} from '../components/tabbar-icon'
1013
import {connect} from 'react-redux'
1114
import {Cell, TableView, Section} from 'react-native-tableview-simple'
1215
import type {LoginStateType} from '../../flux/parts/settings'
1316

17+
import {hasSeenAcknowledgement} from '../../flux/parts/settings'
1418
import {updateBalances} from '../../flux/parts/sis'
1519

1620
import delay from 'delay'
@@ -19,6 +23,10 @@ import * as c from '../components/colors'
1923

2024
import type {TopLevelViewPropsType} from '../types'
2125

26+
const DISCLAIMER = 'This data may be outdated or otherwise inaccurate.'
27+
const LONG_DISCLAIMER =
28+
'This data may be inaccurate.\nBon Appetit is always right.\nThis app is unofficial.'
29+
2230
class BalancesView extends React.Component {
2331
static navigationOptions = {
2432
tabBarLabel: 'Balances',
@@ -33,7 +41,9 @@ class BalancesView extends React.Component {
3341
dailyMeals: ?number,
3442
loginState: LoginStateType,
3543
message: ?string,
44+
alertSeen: boolean,
3645

46+
hasSeenAcknowledgement: () => any,
3747
updateBalances: boolean => any,
3848
}
3949

@@ -47,6 +57,15 @@ class BalancesView extends React.Component {
4757
this.refresh()
4858
}
4959

60+
componentDidMount() {
61+
if (!this.props.alertSeen) {
62+
Alert.alert(LONG_DISCLAIMER, '', [
63+
{text: 'I Disagree', onPress: this.goBack, style: 'cancel'},
64+
{text: 'Okay', onPress: this.props.hasSeenAcknowledgement},
65+
])
66+
}
67+
}
68+
5069
refresh = async () => {
5170
let start = Date.now()
5271
this.setState(() => ({loading: true}))
@@ -68,6 +87,10 @@ class BalancesView extends React.Component {
6887
this.props.navigation.navigate('SettingsView')
6988
}
7089

90+
goBack = () => {
91+
this.props.navigation.goBack(null)
92+
}
93+
7194
render() {
7295
let {flex, ole, print, dailyMeals, weeklyMeals} = this.props
7396
let {loading} = this.state
@@ -83,7 +106,7 @@ class BalancesView extends React.Component {
83106
}
84107
>
85108
<TableView>
86-
<Section header="BALANCES">
109+
<Section header="BALANCES" footer={DISCLAIMER}>
87110
<View style={styles.balancesRow}>
88111
<FormattedValueCell
89112
label="Flex"
@@ -109,7 +132,7 @@ class BalancesView extends React.Component {
109132
</View>
110133
</Section>
111134

112-
<Section header="MEAL PLAN">
135+
<Section header="MEAL PLAN" footer={DISCLAIMER}>
113136
<View style={styles.balancesRow}>
114137
<FormattedValueCell
115138
label="Daily Meals Left"
@@ -158,6 +181,7 @@ function mapState(state) {
158181
weeklyMeals: state.sis.balances.weekly,
159182
dailyMeals: state.sis.balances.daily,
160183
message: state.sis.balances.message,
184+
alertSeen: state.settings.unofficiallyAcknowledged,
161185

162186
loginState: state.settings.credentials.state,
163187
}
@@ -166,6 +190,7 @@ function mapState(state) {
166190
function mapDispatch(dispatch) {
167191
return {
168192
updateBalances: force => dispatch(updateBalances(force)),
193+
hasSeenAcknowledgement: () => dispatch(hasSeenAcknowledgement()),
169194
}
170195
}
171196

0 commit comments

Comments
 (0)