Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBresson committed Apr 27, 2021
1 parent c1c7b28 commit 1733ae6
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 65 deletions.
4 changes: 2 additions & 2 deletions app.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 0 additions & 1 deletion app/navigation/Navigator/BottomTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const BottomTabNavigator = (): React.ReactElement => {
borderTopWidth: 2,
borderTopColor: Colors.green10,
paddingBottom: bottom / 2 + 6,
paddingTop: 2,
},
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions app/screens/EmissionItem/EmissionItemScreen.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
98 changes: 48 additions & 50 deletions app/screens/EmissionItem/EmissionItemScreen.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -44,60 +44,58 @@ const EmissionItemScreen = ({ language = "" }: LocalizationContextProps) => {
if (!emission) navigator.goBack();
}, [navigator, emission]);

if (isEmpty(emission)) {
return null;
}

return (
<Fragment>
{!isEmpty(emission) && (
<ScrollView style={styles.container}>
{name.length ? (
<>
<Text.H3>{t("EMISSION_ITEM_SCREEN_NAME")}</Text.H3>
<Text.Primary darkGray style={styles.lastItem}>
{name}
</Text.Primary>
</>
) : null}
<>
<Text.H3>{t("EMISSION_ITEM_SCREEN_TYPE")}</Text.H3>
<Text.Primary darkGray style={styles.lastItem}>
{ui.getTranslationEmissionType(emissionType)}
{" - "}
{ui.getTranslationEmissionModelType(emissionModelType)}
</Text.Primary>
</>
<Text.H3>{t("EMISSION_ITEM_SCREEN_QUANTITY")}</Text.H3>
<ScrollView style={styles.container}>
{name.length ? (
<>
<Text.H3>{t("EMISSION_ITEM_SCREEN_NAME")}</Text.H3>
<Text.Primary darkGray style={styles.lastItem}>
<FormattedNumber
maximumFractionDigits={2}
value={co2Emission > 1 ? co2Emission : co2Emission * 1000}
/>{" "}
{co2Emission > 1 ? " kgC02eq" : " gC02eq"}
{name}
</Text.Primary>
</>
) : null}
<Text.H3>{t("EMISSION_ITEM_SCREEN_TYPE")}</Text.H3>
<Text.Primary darkGray style={styles.lastItem}>
{ui.getTranslationEmissionType(emissionType)}
{" - "}
{ui.getTranslationEmissionModelType(emissionModelType)}
</Text.Primary>
<Text.H3>{t("EMISSION_ITEM_SCREEN_QUANTITY")}</Text.H3>
<Text.Primary darkGray style={styles.lastItem}>
<FormattedNumber
maximumFractionDigits={2}
value={co2Emission > 1 ? co2Emission : co2Emission * 1000}
/>{" "}
{co2Emission > 1 ? " kgC02eq" : " gC02eq"}
</Text.Primary>

<Text.H3>{t("EMISSION_ITEM_SCREEN_MITIGATED")}</Text.H3>
<Text.Primary darkGray style={styles.text}>
{isMitigated
? t("EMISSION_ITEM_SCREEN_IS_MITIGATED")
: t("EMISSION_ITEM_SCREEN_IS_NOT_MITIGATED")}
</Text.Primary>
<View style={styles.lastItem}>
<Switch value={isMitigated} onValueChange={toggleIsMitigated} />
</View>
<Text.H3>{t("EMISSION_ITEM_SCREEN_MITIGATED")}</Text.H3>
<Text.Primary darkGray style={styles.text}>
{isMitigated
? t("EMISSION_ITEM_SCREEN_IS_MITIGATED")
: t("EMISSION_ITEM_SCREEN_IS_NOT_MITIGATED")}
</Text.Primary>
<View style={styles.lastItem}>
<Switch value={isMitigated} onValueChange={toggleIsMitigated} />
</View>

<Text.H3>{t("EMISSION_ITEM_SCREEN_DATE")}</Text.H3>
<View style={styles.date}>
<Text.Primary darkGray style={[styles.lastItem, styles.day]}>
{day + " "}
</Text.Primary>
<Text.Primary darkGray style={styles.lastItem}>
{monthAndYear}
</Text.Primary>
</View>
<Button.Primary red fullWidth onPress={deleteEmission} textType={"Primary"}>
<Text.Primary white>{t("EMISSION_ITEM_SCREEN_DELETE_EMISSION")}</Text.Primary>
</Button.Primary>
</ScrollView>
)}
</Fragment>
<Text.H3>{t("EMISSION_ITEM_SCREEN_DATE")}</Text.H3>
<View style={styles.date}>
<Text.Primary darkGray style={[styles.lastItem, styles.day]}>
{day + " "}
</Text.Primary>
<Text.Primary darkGray style={styles.lastItem}>
{monthAndYear}
</Text.Primary>
</View>
<Button.Primary red fullWidth onPress={deleteEmission} textType={"Primary"}>
<Text.Primary white>{t("EMISSION_ITEM_SCREEN_DELETE_EMISSION")}</Text.Primary>
</Button.Primary>
</ScrollView>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ exports[`EmissionsScreen renders correctly 1`] = `
darkGray={true}
style={
Object {
"alignItems": "flex-start",
"paddingBottom": 24,
"paddingTop": 6,
"paddingTop": 2,
}
}
>
Expand All @@ -33,8 +34,9 @@ exports[`EmissionsScreen renders correctly 1`] = `
darkGray={true}
style={
Object {
"alignItems": "flex-start",
"paddingBottom": 24,
"paddingTop": 6,
"paddingTop": 2,
}
}
>
Expand All @@ -48,8 +50,9 @@ exports[`EmissionsScreen renders correctly 1`] = `
darkGray={true}
style={
Object {
"alignItems": "flex-start",
"paddingBottom": 24,
"paddingTop": 6,
"paddingTop": 2,
}
}
>
Expand All @@ -67,7 +70,7 @@ exports[`EmissionsScreen renders correctly 1`] = `
darkGray={true}
style={
Object {
"paddingTop": 6,
"paddingTop": 2,
}
}
>
Expand All @@ -76,8 +79,9 @@ exports[`EmissionsScreen renders correctly 1`] = `
<View
style={
Object {
"alignItems": "flex-start",
"paddingBottom": 24,
"paddingTop": 6,
"paddingTop": 2,
}
}
>
Expand Down Expand Up @@ -110,8 +114,9 @@ exports[`EmissionsScreen renders correctly 1`] = `
style={
Array [
Object {
"alignItems": "flex-start",
"paddingBottom": 24,
"paddingTop": 6,
"paddingTop": 2,
},
Object {
"textTransform": "capitalize",
Expand All @@ -125,8 +130,9 @@ exports[`EmissionsScreen renders correctly 1`] = `
darkGray={true}
style={
Object {
"alignItems": "flex-start",
"paddingBottom": 24,
"paddingTop": 6,
"paddingTop": 2,
}
}
>
Expand Down
2 changes: 1 addition & 1 deletion app/screens/MonthlyBudget/MonthlyBudgetScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const MonthlyBudgetScreen = ({ navigation }) => {
<View style={styles.parisAgreement}>
<Text.Secondary center>
{t("MONTHLY_BUDGET_SCREEN_PARIS_AGREEMENT")}
<Text.Secondary bold blue>
<Text.Secondary bold darkGray>
{" 166 kg CO2"}
</Text.Secondary>
</Text.Secondary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
<Text.Secondary
blue={true}
bold={true}
darkGray={true}
>
166 kg CO2
</Text.Secondary>
Expand Down

0 comments on commit 1733ae6

Please sign in to comment.