From 1733ae6c1d09031e618e716f91ea2021a0180a11 Mon Sep 17 00:00:00 2001 From: Pierre Bresson Date: Tue, 27 Apr 2021 10:22:20 +0200 Subject: [PATCH] fixes --- app.example.json | 4 +- .../Navigator/BottomTabNavigator.tsx | 1 - .../EmissionItemScreen.navigationOptions.tsx | 2 +- .../EmissionItem/EmissionItemScreen.styles.ts | 5 +- .../EmissionItem/EmissionItemScreen.tsx | 98 +++++++++---------- .../EmissionItemScreen.test.tsx.snap | 20 ++-- .../MonthlyBudget/MonthlyBudgetScreen.tsx | 2 +- .../MonthlyBudgetScreen.test.tsx.snap | 2 +- 8 files changed, 69 insertions(+), 65 deletions(-) diff --git a/app.example.json b/app.example.json index 0ba99eea..c086dda0 100644 --- a/app.example.json +++ b/app.example.json @@ -19,13 +19,13 @@ "icon": "./assets/images/ios.icon.png", "bundleIdentifier": "nmf.earth", "supportsTablet": true, - "buildNumber": "19" + "buildNumber": "20" }, "android": { "icon": "./assets/images/android.icon.png", "useNextNotificationsApi": true, "package": "nmf.earth", - "versionCode": 19 + "versionCode": 20 }, "userInterfaceStyle": "automatic", "hooks": { diff --git a/app/navigation/Navigator/BottomTabNavigator.tsx b/app/navigation/Navigator/BottomTabNavigator.tsx index 237cfc37..a20bb578 100644 --- a/app/navigation/Navigator/BottomTabNavigator.tsx +++ b/app/navigation/Navigator/BottomTabNavigator.tsx @@ -45,7 +45,6 @@ const BottomTabNavigator = (): React.ReactElement => { borderTopWidth: 2, borderTopColor: Colors.green10, paddingBottom: bottom / 2 + 6, - paddingTop: 2, }, }} > diff --git a/app/screens/EmissionItem/EmissionItemScreen.navigationOptions.tsx b/app/screens/EmissionItem/EmissionItemScreen.navigationOptions.tsx index 74446e52..feff594c 100644 --- a/app/screens/EmissionItem/EmissionItemScreen.navigationOptions.tsx +++ b/app/screens/EmissionItem/EmissionItemScreen.navigationOptions.tsx @@ -6,7 +6,7 @@ import { Text, InfoButton } from "components"; import { t } from "utils"; import { Colors, ComponentsStyle } from "style"; -const emissionsInfoAvailable = [FoodType.chocolate, FoodType.cheese]; +const emissionsInfoAvailable = [FoodType.cheese]; const navigationOptions = (prop) => { const emissionModelType = path(["route", "params", "emissionModelType"], prop); diff --git a/app/screens/EmissionItem/EmissionItemScreen.styles.ts b/app/screens/EmissionItem/EmissionItemScreen.styles.ts index a7c99390..1459f04c 100644 --- a/app/screens/EmissionItem/EmissionItemScreen.styles.ts +++ b/app/screens/EmissionItem/EmissionItemScreen.styles.ts @@ -8,11 +8,12 @@ export default StyleSheet.create({ paddingTop: 22, }, lastItem: { - paddingTop: 6, + alignItems: "flex-start", + paddingTop: 2, paddingBottom: 24, }, text: { - paddingTop: 6, + paddingTop: 2, }, date: { flexDirection: "row", diff --git a/app/screens/EmissionItem/EmissionItemScreen.tsx b/app/screens/EmissionItem/EmissionItemScreen.tsx index dc9a8cca..3411cff4 100644 --- a/app/screens/EmissionItem/EmissionItemScreen.tsx +++ b/app/screens/EmissionItem/EmissionItemScreen.tsx @@ -1,4 +1,4 @@ -import React, { Fragment, useEffect } from "react"; +import React, { useEffect } from "react"; import { useSelector, useDispatch } from "react-redux"; import { ScrollView, View, Switch } from "react-native"; import { isEmpty, pathOr } from "ramda"; @@ -44,60 +44,58 @@ const EmissionItemScreen = ({ language = "" }: LocalizationContextProps) => { if (!emission) navigator.goBack(); }, [navigator, emission]); + if (isEmpty(emission)) { + return null; + } + return ( - - {!isEmpty(emission) && ( - - {name.length ? ( - <> - {t("EMISSION_ITEM_SCREEN_NAME")} - - {name} - - - ) : null} - <> - {t("EMISSION_ITEM_SCREEN_TYPE")} - - {ui.getTranslationEmissionType(emissionType)} - {" - "} - {ui.getTranslationEmissionModelType(emissionModelType)} - - - {t("EMISSION_ITEM_SCREEN_QUANTITY")} + + {name.length ? ( + <> + {t("EMISSION_ITEM_SCREEN_NAME")} - 1 ? co2Emission : co2Emission * 1000} - />{" "} - {co2Emission > 1 ? " kgC02eq" : " gC02eq"} + {name} + + ) : null} + {t("EMISSION_ITEM_SCREEN_TYPE")} + + {ui.getTranslationEmissionType(emissionType)} + {" - "} + {ui.getTranslationEmissionModelType(emissionModelType)} + + {t("EMISSION_ITEM_SCREEN_QUANTITY")} + + 1 ? co2Emission : co2Emission * 1000} + />{" "} + {co2Emission > 1 ? " kgC02eq" : " gC02eq"} + - {t("EMISSION_ITEM_SCREEN_MITIGATED")} - - {isMitigated - ? t("EMISSION_ITEM_SCREEN_IS_MITIGATED") - : t("EMISSION_ITEM_SCREEN_IS_NOT_MITIGATED")} - - - - + {t("EMISSION_ITEM_SCREEN_MITIGATED")} + + {isMitigated + ? t("EMISSION_ITEM_SCREEN_IS_MITIGATED") + : t("EMISSION_ITEM_SCREEN_IS_NOT_MITIGATED")} + + + + - {t("EMISSION_ITEM_SCREEN_DATE")} - - - {day + " "} - - - {monthAndYear} - - - - {t("EMISSION_ITEM_SCREEN_DELETE_EMISSION")} - - - )} - + {t("EMISSION_ITEM_SCREEN_DATE")} + + + {day + " "} + + + {monthAndYear} + + + + {t("EMISSION_ITEM_SCREEN_DELETE_EMISSION")} + + ); }; diff --git a/app/screens/EmissionItem/__tests__/__snapshots__/EmissionItemScreen.test.tsx.snap b/app/screens/EmissionItem/__tests__/__snapshots__/EmissionItemScreen.test.tsx.snap index b93211ae..0cd488d3 100644 --- a/app/screens/EmissionItem/__tests__/__snapshots__/EmissionItemScreen.test.tsx.snap +++ b/app/screens/EmissionItem/__tests__/__snapshots__/EmissionItemScreen.test.tsx.snap @@ -19,8 +19,9 @@ exports[`EmissionsScreen renders correctly 1`] = ` darkGray={true} style={ Object { + "alignItems": "flex-start", "paddingBottom": 24, - "paddingTop": 6, + "paddingTop": 2, } } > @@ -33,8 +34,9 @@ exports[`EmissionsScreen renders correctly 1`] = ` darkGray={true} style={ Object { + "alignItems": "flex-start", "paddingBottom": 24, - "paddingTop": 6, + "paddingTop": 2, } } > @@ -48,8 +50,9 @@ exports[`EmissionsScreen renders correctly 1`] = ` darkGray={true} style={ Object { + "alignItems": "flex-start", "paddingBottom": 24, - "paddingTop": 6, + "paddingTop": 2, } } > @@ -67,7 +70,7 @@ exports[`EmissionsScreen renders correctly 1`] = ` darkGray={true} style={ Object { - "paddingTop": 6, + "paddingTop": 2, } } > @@ -76,8 +79,9 @@ exports[`EmissionsScreen renders correctly 1`] = ` @@ -110,8 +114,9 @@ exports[`EmissionsScreen renders correctly 1`] = ` style={ Array [ Object { + "alignItems": "flex-start", "paddingBottom": 24, - "paddingTop": 6, + "paddingTop": 2, }, Object { "textTransform": "capitalize", @@ -125,8 +130,9 @@ exports[`EmissionsScreen renders correctly 1`] = ` darkGray={true} style={ Object { + "alignItems": "flex-start", "paddingBottom": 24, - "paddingTop": 6, + "paddingTop": 2, } } > diff --git a/app/screens/MonthlyBudget/MonthlyBudgetScreen.tsx b/app/screens/MonthlyBudget/MonthlyBudgetScreen.tsx index 96930131..cc2ff684 100644 --- a/app/screens/MonthlyBudget/MonthlyBudgetScreen.tsx +++ b/app/screens/MonthlyBudget/MonthlyBudgetScreen.tsx @@ -85,7 +85,7 @@ const MonthlyBudgetScreen = ({ navigation }) => { {t("MONTHLY_BUDGET_SCREEN_PARIS_AGREEMENT")} - + {" 166 kg CO2"} diff --git a/app/screens/MonthlyBudget/__tests__/__snapshots__/MonthlyBudgetScreen.test.tsx.snap b/app/screens/MonthlyBudget/__tests__/__snapshots__/MonthlyBudgetScreen.test.tsx.snap index 71db45d9..bc585587 100644 --- a/app/screens/MonthlyBudget/__tests__/__snapshots__/MonthlyBudgetScreen.test.tsx.snap +++ b/app/screens/MonthlyBudget/__tests__/__snapshots__/MonthlyBudgetScreen.test.tsx.snap @@ -200,8 +200,8 @@ exports[`MonthlyBudgetScreen renders correctly 1`] = ` > If you wish to respect the Paris agreement (to keep the rise in global average temperature below 2 degrees), set your monthly budget at 166 kg CO2