Skip to content

Commit

Permalink
WIP Show modal if version not big enough
Browse files Browse the repository at this point in the history
- Use storeurl as a build config
  • Loading branch information
rottabonus committed Oct 6, 2024
1 parent c62fc4e commit 236ec77
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ cp config.template.ios.json config.json

You can edit the config file as suited:

| Parameter | Description |
| -------------- | ---------------------------------|
| `baseUrl` | Ylitse API base URL |
| `loginUrl` | Ylitse service login URL |
| `feedBackUrl` | Feedback form URL |
| `termsUrl` | Terms and conditions URL |
| `userGuideUrl` | User's manual URL |
| `apuuUrl` | Apuu-chat URL |
| `sekasinUrl` | Sekasin-chat URL |
| `saferSpaceUrl` | Principals of a safer space URL |
| `messageFetchDelay`| Delay between polling |
| Parameter | Description |
| ----------------- | ---------------------------------------|
| `baseUrl` | Ylitse API base URL |
| `loginUrl` | Ylitse service login URL |
| `feedBackUrl` | Feedback form URL |
| `termsUrl` | Terms and conditions URL |
| `userGuideUrl` | User's manual URL |
| `apuuUrl` | Apuu-chat URL |
| `sekasinUrl` | Sekasin-chat URL |
| `saferSpaceUrl` | Principals of a safer space URL |
| `storeUrl` | App marketplace URL (build specific) |
| `messageFetchDelay`| Delay between polling |


### Running on iOS
Expand Down
1 change: 1 addition & 0 deletions appcenter-pre-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tee config.json > /dev/null <<EOF
"userGuideUrl": "$YLITSE_USERGUIDEURL",
"apuuUrl": "$YLITSE_APUUURL",
"sekasinUrl": "$YLITSE_SEKASINURL",
"storeUrl": $YLITSE_STOREURL
"saferSpaceUrl": "$YLITSE_SAFERSPACEURL",
"messageFetchDelay": $YLITSE_MESSAGEFETCHDELAY
}
Expand Down
1 change: 1 addition & 0 deletions config.template.android.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"apuuUrl": "http://10.0.2.2:3000",
"sekasinUrl": "http://10.0.2.2:3000",
"saferSpaceUrl": "http://10.0.2.2:3000",
"storeUrl":"http://localhost:3000",
"messageFetchDelay": 2000
}
1 change: 1 addition & 0 deletions config.template.ios.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"userGuideUrl": "http://localhost:3000",
"apuuUrl": "http://localhost:3000",
"sekasinUrl": "http://localhost:3000",
"storeUrl":"http://localhost:3000",
"saferSpaceUrl": "http://10.0.2.2:3000",
"messageFetchDelay": 2000
}
19 changes: 16 additions & 3 deletions src/Screens/Main/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import * as RN from 'react-native';

import * as ReactRedux from 'react-redux';
import * as redux from 'redux';
import { selectFirstQuestion } from '../../state/reducers/questions';

import { selectIsVersionBigEnough } from '../../state/reducers/minimumVersion';
import { storeUrl } from '../../api/config';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import * as actions from '../../state/actions';

Expand All @@ -21,6 +23,7 @@ import Settings, { SettingsRoute } from './Settings';
import QuestionModal from '../components/QuestionModal';
import { Answer } from '../../api/feedback';
import { TabBar } from './TabBar';
import Modal from '../components/Modal';

export type TabsRoute = {
'Main/Tabs': {
Expand All @@ -37,9 +40,10 @@ type Props = {} & StackScreenProps<StackRoutes, 'Main/Tabs'>;
const Main = ({ navigation, route }: Props) => {
const dispatch = ReactRedux.useDispatch<redux.Dispatch<actions.Action>>();
const initialRouteName = route.params?.initial;
const appClient = getClient();

const isAppVersionBigEnough = ReactRedux.useSelector(
selectIsVersionBigEnough(getClient()),
selectIsVersionBigEnough(appClient),
);

const handleRefetchData = () => {
Expand All @@ -61,6 +65,8 @@ const Main = ({ navigation, route }: Props) => {
callback: handleRefetchData,
});

const openStore = () => RN.Linking.openURL(storeUrl);

React.useEffect(() => {
navigation.dispatch(state => {
const routes = state.routes.filter(r => !r.name.includes('Onboarding'));
Expand All @@ -77,8 +83,6 @@ const Main = ({ navigation, route }: Props) => {
dispatch({ type: 'minimumVersion/get/start', payload: undefined });
}, []);

console.log('is app version is big enough:', isAppVersionBigEnough);

return (
<>
<Tab.Navigator
Expand All @@ -97,6 +101,15 @@ const Main = ({ navigation, route }: Props) => {
onAnswer={handleAnswer}
/>
)}
{isAppVersionBigEnough && (
<Modal
modalType="danger"
title="main.version.not.big.enough.title"
messageId="main.version.not.big.enough.text"
primaryButtonMessage="main.version.not.big.enough.button"
onPrimaryPress={openStore}
/>
)}
</>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/api/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export const apuuUrl = config.apuuUrl;
export const sekasinUrl = config.sekasinUrl;
export const saferSpaceUrl = config.saferSpaceUrl;
export const messageFetchDelay = config.messageFetchDelay;
export const storeUrl = config.storeUrl;
4 changes: 4 additions & 0 deletions src/localization/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export const messages: { [key in MessageId]: string } = {
'SOS-Lapsikylä representative will contact you after the investigation.',
'main.userreport.title': 'Report',

'main.version.not.big.enough.button': 'Store',
'main.version.not.big.enough.text': 'You must update',
'main.version.not.big.enough.title': 'Version not big enough',

'meta.back': 'Back',
'meta.blank': ' ',
'meta.cancel': 'Cancel',
Expand Down
4 changes: 4 additions & 0 deletions src/localization/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export const messages = {
'SOS-Lapsikylän työntekijä selvittää tilanteen ja ottaa sinuun yhteyttä.',
'main.userreport.title': 'Ilmianna',

'main.version.not.big.enough.button': 'Kauppaan',
'main.version.not.big.enough.text': 'Sinun taytyy paivittaa',
'main.version.not.big.enough.title': 'Versio ei ole tarpeeksi iso',

'meta.back': 'Takaisin',
'meta.blank': ' ',
'meta.cancel': 'Peru',
Expand Down

0 comments on commit 236ec77

Please sign in to comment.