Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Work on inputs #719

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-shared-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:

- name: Set up config values
if: ${{ inputs.upload == 'true' }}
working-directory: ./dev-client/ios
working-directory: ./dev-client
run: |
echo "GOOGLE_OAUTH_IOS_CLIENT_ID=${{ secrets.GOOGLE_OAUTH_IOS_CLIENT_ID }}" >> .env
echo "GOOGLE_OAUTH_IOS_URI_SCHEME=${{ secrets.GOOGLE_OAUTH_IOS_URI_SCHEME }}" >> .env
Expand All @@ -70,8 +70,8 @@ jobs:
echo "PUBLIC_MAPBOX_TOKEN=${{ secrets.PUBLIC_MAPBOX_TOKEN }}" >> .env
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env
echo "ENV=staging" >> .env
cp ../sentry.properties.example sentry.properties
echo "auth.token=${{ secrets.SENTRY_AUTH_TOKEN }}" >> sentry.properties
cp sentry.properties.example ./ios/sentry.properties
echo "auth.token=${{ secrets.SENTRY_AUTH_TOKEN }}" >> ./ios/sentry.properties

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
4 changes: 2 additions & 2 deletions dev-client/ios/Terraso LandPKS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 66;
CURRENT_PROJECT_VERSION = 68;
DEVELOPMENT_TEAM = 2A8W5MT5NL;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 2A8W5MT5NL;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -579,7 +579,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 66;
CURRENT_PROJECT_VERSION = 68;
DEVELOPMENT_TEAM = 2A8W5MT5NL;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 2A8W5MT5NL;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
Expand Down
2 changes: 1 addition & 1 deletion dev-client/ios/Terraso LandPKS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>66</string>
<string>68</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
5 changes: 4 additions & 1 deletion dev-client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {SoilIdProjectSoilSettingsDepthIntervalPresetChoices} from 'terraso-client-shared/graphqlSchema/graphql';

/** Minimum distance to travel before Mapbox will update user location */
export const PACKAGE_NAME = 'org.terraso.landpks';
export const USER_DISPLACEMENT_MIN_DISTANCE_M = 1;
Expand All @@ -37,4 +39,5 @@ export const GEOSPATIAL_CONTEXT_USER_DISTANCE_CACHE = 5;
export const SITE_NOTE_MIN_LENGTH = 3;
export const LOCALE = 'en-US';

export const DepthPresets = ['landPks', 'nrcs', 'custom', 'none'];
export const DepthPresets: SoilIdProjectSoilSettingsDepthIntervalPresetChoices[] =
['LANDPKS', 'NRCS', 'CUSTOM', 'NONE'];
63 changes: 44 additions & 19 deletions dev-client/src/screens/ProjectInputScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ import {updateProject} from 'terraso-client-shared/project/projectSlice';
import {Icon, IconButton} from 'terraso-mobile-client/components/Icons';
import {Modal} from 'terraso-mobile-client/components/Modal';
import {AddIntervalModal} from 'terraso-mobile-client/components/AddIntervalModal';
import {useMemo, useCallback} from 'react';
import {useMemo, useCallback, useState} from 'react';
import {NativeStackScreenProps} from '@react-navigation/native-stack';
import {ScrollView, Switch} from 'react-native';
import {useInfoPress} from 'terraso-mobile-client/hooks/useInfoPress';
import {DepthPresets} from 'terraso-mobile-client/constants';
import {useNavigation} from 'terraso-mobile-client/navigation/hooks/useNavigation';
import {SoilIdProjectSoilSettingsDepthIntervalPresetChoices} from 'terraso-client-shared/graphqlSchema/graphql';
import {ConfirmModal} from 'terraso-mobile-client/components/ConfirmModal';

type Props = NativeStackScreenProps<TabStackParamList, TabRoutes.INPUTS>;

Expand Down Expand Up @@ -170,6 +172,10 @@ const SoilPitSettings = ({projectId}: {projectId: string}) => {
const settings = useSelector(
state => state.soilId.projectSettings[projectId],
);
const [selectedPreset, setSelectedPreset] =
useState<SoilIdProjectSoilSettingsDepthIntervalPresetChoices>(
settings.depthIntervalPreset,
);
const dispatch = useDispatch();
const existingIntervals = useMemo(
() => settings.depthIntervals.map(interval => interval.depthInterval),
Expand All @@ -183,30 +189,49 @@ const SoilPitSettings = ({projectId}: {projectId: string}) => {
[projectId, dispatch],
);

const onChangeDepthPreset = (value: string) => {
// TODO: need to add/change project depth intervals based on selected value
console.log(value);
};
const onChangeDepthPreset = useCallback(() => {
dispatch(
updateProjectSoilSettings({
projectId,
depthIntervalPreset: selectedPreset,
}),
);
}, [dispatch, projectId, selectedPreset]);

return (
<Box p={4}>
<Text color={'primary.main'}>
{t('projects.inputs.depth_intervals.title')}
</Text>
<Select
mb={5}
width={'60%'}
variant={'underlined'}
selectedValue={DepthPresets[0]}
onValueChange={value => onChangeDepthPreset(value)}>
{DepthPresets.map(preset => (
<Select.Item
label={t(`projects.inputs.depth_intervals.${preset}`)}
value={preset}
key={preset}
/>
))}
</Select>
<ConfirmModal
trigger={onOpen => (
<Select
mb={5}
width={'60%'}
variant={'underlined'}
selectedValue={settings.depthIntervalPreset}
onValueChange={value => {
setSelectedPreset(
value as SoilIdProjectSoilSettingsDepthIntervalPresetChoices,
);
onOpen();
}}>
{DepthPresets.map(preset => (
<Select.Item
label={t(
`projects.inputs.depth_intervals.${preset.toLowerCase()}`,
)}
value={preset}
key={preset}
/>
))}
</Select>
)}
title={t('projects.inputs.depth_intervals.confirm_preset.title')}
body={t('projects.inputs.depth_intervals.confirm_preset.body')}
actionName={t('projects.inputs.depth_intervals.confirm_preset.confirm')}
handleConfirm={onChangeDepthPreset}
/>
{settings.depthIntervals.map(({label, depthInterval}) => (
<Row key={`${depthInterval.start}:${depthInterval.end}`}>
<Text flex={1}>{label}</Text>
Expand Down
9 changes: 7 additions & 2 deletions dev-client/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,15 @@
},
"depth_intervals": {
"title": "Soil Pit Depth Intervals",
"landPks": "LandPKS",
"landpks": "LandPKS",
"nrcs": "NRCS",
"custom": "Custom…",
"none": "None specified"
"none": "None specified",
"confirm_preset": {
"title": "Change depths?",
"body": "Soil pit data that has been entered will be deleted. This action can’t be undone.",
paulschreiber marked this conversation as resolved.
Show resolved Hide resolved
"confirm": "Change"
}
}
},
"team": {
Expand Down