1- /**
2- * @flow
3- * All About Olaf
4- * Balances page
5- */
1+ // @flow
62
73import 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'
912import { TabBarIcon } from '../components/tabbar-icon'
1013import { connect } from 'react-redux'
1114import { Cell , TableView , Section } from 'react-native-tableview-simple'
1215import type { LoginStateType } from '../../flux/parts/settings'
1316
17+ import { hasSeenAcknowledgement } from '../../flux/parts/settings'
1418import { updateBalances } from '../../flux/parts/sis'
1519
1620import delay from 'delay'
@@ -19,6 +23,10 @@ import * as c from '../components/colors'
1923
2024import 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+
2230class 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) {
166190function mapDispatch ( dispatch ) {
167191 return {
168192 updateBalances : force => dispatch ( updateBalances ( force ) ) ,
193+ hasSeenAcknowledgement : ( ) => dispatch ( hasSeenAcknowledgement ( ) ) ,
169194 }
170195}
171196
0 commit comments