Skip to content

Commit

Permalink
updated 0.0.7; changed option page and language
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason017 committed Dec 9, 2022
1 parent b58b87d commit 0609b06
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 196 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ android {
applicationId 'com.aceiotsolutions.connecting_mha_app'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 6
versionName "0.0.6"
versionCode 7
versionName "0.0.7"
}
splits {
abi {
Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "Connecting MHA",
"slug": "connecting-mha-app",
"version": "0.0.6",
"version": "0.0.7",
"orientation": "portrait",
"owner": "ace-iot",
"icon": "./assets/icon.png",
Expand All @@ -25,7 +25,7 @@
"foregroundImage": "./assets/icon.adaptive.foreground.png",
"backgroundImage": "./assets/icon.adaptive.background.png"
},
"versionCode": 6,
"versionCode": 7,
"package": "com.aceiotsolutions.connecting_mha_app"
},
"web": {
Expand Down
52 changes: 49 additions & 3 deletions assets/svg/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 39 additions & 39 deletions components/DemandResponse/OptedOutNotification.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import React from "react";
import { StyleSheet, Text, TouchableOpacity } from "react-native";
import { theme } from "../../theme";
import AlertCircle from "../../assets/svg/alert-circle.svg";

export function OptedOutNotification() {
return (
<TouchableOpacity testID="OptedOutNotification" style={styles.container}>
<AlertCircle style={styles.icon} />
<Text style={styles.label}>You have opted out of demand response</Text>
<Text style={styles.cta}></Text>
</TouchableOpacity>
);
}

const styles = StyleSheet.create({
container: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
minHeight: 45,
paddingVertical: theme.padding / 2,
backgroundColor: theme.colors.periwinkle,
borderRadius: 22,
},
icon: {
marginHorizontal: theme.padding,
marginRight: "auto",
},
label: {
color: theme.primary,
fontFamily: theme.fonts.title,
paddingHorizontal: theme.padding,
},
cta: {
marginLeft: "auto",
marginRight: theme.padding * 2,
},
});
import React from "react";
import { StyleSheet, Text, TouchableOpacity } from "react-native";
import { theme, typography } from "../../theme";
import AlertCircle from "../../assets/svg/alert-circle.svg";

export function OptedOutNotification() {
return (
<TouchableOpacity testID="OptedOutNotification" style={styles.container}>
<AlertCircle style={styles.icon} />
<Text style={styles.label}>Standard operation has resumed</Text>
<Text style={styles.cta}></Text>
</TouchableOpacity>
);
}

const styles = StyleSheet.create({
container: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
minHeight: 45,
paddingVertical: theme.padding / 2,
backgroundColor: theme.colors.periwinkle,
borderRadius: 22,
},
icon: {
marginHorizontal: theme.padding,
marginRight: "auto",
},
label: {
color: theme.primary,
fontFamily: theme.fonts.title,
paddingHorizontal: theme.padding,
},
cta: {
marginLeft: "auto",
marginRight: theme.padding * 2,
},
});
4 changes: 2 additions & 2 deletions ios/ConnectingMHA/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>0.0.6</string>
<string>0.0.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>6</string>
<string>7</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "connecting-mha-app",
"version": "0.0.6",
"version": "0.0.7",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
Expand Down
188 changes: 94 additions & 94 deletions screens/DemandResponseMessageScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
import React, { useEffect, useState } from "react";
import { StyleSheet, Text, View, SafeAreaView } from "react-native";
import { useHomeConfigData } from "../hooks/useHomeConfigData";
import { theme, typography } from "../theme";
import { useNavigation, useRoute } from "@react-navigation/native";
import { Button } from "../components/Button";
import { DemandResponseScreenRouteProps } from "../types";
import { useDeviceUpdateDerStatus } from "../hooks/api";
import { ErrorLabel } from "../components/ErrorLabel";
import { DataBoundary } from "../components/DataBoundary";

export function DemandResponseMessageScreen() {
const { data, error, loading, getData } = useHomeConfigData();
const [optedOut, setOptedOut] = useState<boolean>(false);
const navigation = useNavigation();

const route = useRoute<DemandResponseScreenRouteProps>();
const { deviceId, showOptOutButton } = route.params;
const { update, error: updateError, loading: updateLoading } = useDeviceUpdateDerStatus(deviceId);

const message = data?.lpc_config.current_event_message.message;
const refresh = getData;

useEffect(() => {
getData();
}, []);

useEffect(() => {
if (!optedOut) {
return;
}

const optOut = async () => {
const response = await update({ status: "opted_out" });

if (response.success) {
navigation.goBack();
} else {
setOptedOut(false);
}
};

optOut();
}, [optedOut]);

return (
<DataBoundary
loading={loading}
error={error}
data={data}
onPressRetry={refresh}
errorMessage="We encountered an error while retrieving Demand Response data."
>
<SafeAreaView style={styles.container}>
{data && (
<View style={styles.content}>
<View style={styles.textBlock}>
<Text style={typography.headline2}>{message}</Text>
</View>
{updateError && <ErrorLabel message="Error Opting Out" />}
<View style={{ marginVertical: theme.padding }}>
{showOptOutButton && (
<Button
label="Opt Out of Power Event"
accessibilityLabel="Opt Out of Power Event"
onPress={() => setOptedOut(true)}
style={{ backgroundColor: theme.colors.red }}
activity={updateLoading}
/>
)}
</View>
<Button onPress={navigation.goBack} label="Close" />
</View>
)}
</SafeAreaView>
</DataBoundary>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: theme.background,
alignItems: "center",
},
content: {
height: "100%",
padding: theme.padding,
},
textBlock: {
flex: 1,
paddingTop: theme.padding,
},
});
import React, { useEffect, useState } from "react";
import { StyleSheet, Text, View, SafeAreaView } from "react-native";
import { useHomeConfigData } from "../hooks/useHomeConfigData";
import { theme, typography } from "../theme";
import { useNavigation, useRoute } from "@react-navigation/native";
import { Button } from "../components/Button";
import { DemandResponseScreenRouteProps } from "../types";
import { useDeviceUpdateDerStatus } from "../hooks/api";
import { ErrorLabel } from "../components/ErrorLabel";
import { DataBoundary } from "../components/DataBoundary";

export function DemandResponseMessageScreen() {
const { data, error, loading, getData } = useHomeConfigData();
const [optedOut, setOptedOut] = useState<boolean>(false);
const navigation = useNavigation();

const route = useRoute<DemandResponseScreenRouteProps>();
const { deviceId, showOptOutButton } = route.params;
const { update, error: updateError, loading: updateLoading } = useDeviceUpdateDerStatus(deviceId);

const message = data?.lpc_config.current_event_message.message;
const refresh = getData;

useEffect(() => {
getData();
}, []);

useEffect(() => {
if (!optedOut) {
return;
}

const optOut = async () => {
const response = await update({ status: "opted_out" });

if (response.success) {
navigation.goBack();
} else {
setOptedOut(false);
}
};

optOut();
}, [optedOut]);

return (
<DataBoundary
loading={loading}
error={error}
data={data}
onPressRetry={refresh}
errorMessage="We encountered an error while retrieving Demand Response data."
>
<SafeAreaView style={styles.container}>
{data && (
<View style={styles.content}>
<View style={styles.textBlock}>
<Text style={typography.headline2}>{message}</Text>
</View>
{updateError && <ErrorLabel message="Error Opting Out" />}
<View style={{ marginVertical: theme.padding }}>
{showOptOutButton && (
<Button
label="Resume Normal Settings"
accessibilityLabel="Resume Normal Settings"
onPress={() => setOptedOut(true)}
style={{ backgroundColor: theme.colors.red }}
activity={updateLoading}
/>
)}
</View>
<Button onPress={navigation.goBack} label="Close" />
</View>
)}
</SafeAreaView>
</DataBoundary>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: theme.background,
alignItems: "center",
},
content: {
height: "100%",
padding: theme.padding,
},
textBlock: {
flex: 1,
paddingTop: theme.padding,
},
});
Loading

0 comments on commit 0609b06

Please sign in to comment.