Skip to content

Commit

Permalink
3.1.4 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragramimi authored Aug 1, 2024
1 parent 1550189 commit afaa825
Show file tree
Hide file tree
Showing 34 changed files with 287 additions and 94 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ PODS:
- React-jsi (= 0.73.2)
- React-logger (= 0.73.2)
- React-perflogger (= 0.73.2)
- ReactNativePassioSDK (3.1.1-3):
- ReactNativePassioSDK (3.1.4):
- React-Core
- RNCAsyncStorage (1.21.0):
- React-Core
Expand Down Expand Up @@ -1403,7 +1403,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: df8945a656356ff10f58f65a70820478bfcf33ad
React-utils: f5bc61e7ea3325c0732ae2d755f4441940163b85
ReactCommon: 45b5d4f784e869c44a6f5a8fad5b114ca8f78c53
ReactNativePassioSDK: 058706b380c8a0de2c73fb11fa2589f4bae60463
ReactNativePassioSDK: d1bc3d9c9d7b0b15389f333fbe257df82a7f3ac5
RNCAsyncStorage: 618d03a5f52fbccb3d7010076bc54712844c18ef
RNCPicker: b7873ba797dc586bfaf3307d737cbdc620a9ff3e
RNDateTimePicker: 7b38b71bcd7c4cfa1cb95f2dff9a4f1faed2dced
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@gorhom/bottom-sheet": "^4.6.1",
"@notifee/react-native": "^7.8.2",
"@passiolife/nutritionai-react-native-sdk-v3": "3.1.1-3",
"@passiolife/nutritionai-react-native-sdk-v3": "3.1.4",
"@react-native-async-storage/async-storage": "^1.21.0",
"@react-native-community/datetimepicker": "^7.6.3",
"@react-native-community/slider": "^4.5.0",
Expand Down
8 changes: 4 additions & 4 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1444,10 +1444,10 @@
resolved "https://registry.yarnpkg.com/@notifee/react-native/-/react-native-7.8.2.tgz#72d3199ae830b4128ddaef3c1c2f11604759c9c4"
integrity sha512-VG4IkWJIlOKqXwa3aExC3WFCVCGCC9BA55Ivg0SMRfEs+ruvYy/zlLANcrVGiPtgkUEryXDhA8SXx9+JcO8oLA==

"@passiolife/[email protected].1-3":
version "3.1.1-3"
resolved "https://npm.pkg.github.com/download/@passiolife/nutritionai-react-native-sdk-v3/3.1.1-3/3f405c758ccbf77ce27465ff69d48ab7a5b885d0#3f405c758ccbf77ce27465ff69d48ab7a5b885d0"
integrity sha512-zKsHmNpKfX8ugBdiEfau2vCvhWc615P3jdh/wEEtKVywR7EVol9Li/q+CUSXeCaIggJaHr61Hv3P5fV3TdxkCA==
"@passiolife/[email protected].4":
version "3.1.4"
resolved "https://npm.pkg.github.com/download/@passiolife/nutritionai-react-native-sdk-v3/3.1.4/3428561e2f5490df4bc3940301219e97876253e9#3428561e2f5490df4bc3940301219e97876253e9"
integrity sha512-hgDGR/tMzTfR0QFdg6RKXUZX8yVuTlUc73mFZwnXORJrWmZzoe9AxDwH0Dvj93VhNfilcgpFcp+x/kxS06O5Bg==

"@pkgjs/parseargs@^0.11.0":
version "0.11.0"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@babel/runtime": "^7.23.8",
"@gorhom/bottom-sheet": "^4.6.1",
"@notifee/react-native": "^7.8.2",
"@passiolife/nutritionai-react-native-sdk-v3": "3.1.1-3",
"@passiolife/nutritionai-react-native-sdk-v3": "3.1.4",
"@react-native-async-storage/async-storage": "^1.21.0",
"@react-native-community/datetimepicker": "^7.6.3",
"@react-native-community/slider": "^4.5.0",
Expand Down
33 changes: 32 additions & 1 deletion src/components/charts/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
VictoryChart,
VictoryTheme,
VictoryAxis,
VictoryLine,
} from 'victory-native';

import { Card } from '../cards';
Expand All @@ -39,18 +40,29 @@ export interface BarChartProps {
title?: string;
barChartContainerStyle?: StyleProp<ViewStyle>;
barData: ChartData[];
target?: number;
}

export const BarChart = ({
title = 'Calories',
barChartContainerStyle,
barData,
target,
}: BarChartProps) => {
const { calories, black } = useBranding();
const styles = barChartStyle(useBranding());

const maxValue = Math.max(...barData.map((o) => o.value));
let maxValue = Math.max(...barData.map((o) => o.value));

if (target) {
if (maxValue < target) {
maxValue = Math.round(target + (target % 20));
} else {
maxValue = maxValue > 0 ? Math.round(maxValue + 10) : 30;
}
}

maxValue = maxValue > 0 ? maxValue : 30;
return (
<View style={barChartContainerStyle}>
<Card style={styles.roundedAndShadowView}>
Expand Down Expand Up @@ -122,6 +134,25 @@ export const BarChart = ({
data: { fill: calories },
}}
/>

{/* Dotted Line for Target */}
{target && (
<VictoryLine
data={[
{ x: barData[0]?.label, y: target },
{ x: barData[barData.length - 1]?.label, y: target },
]}
style={{
data: {
stroke: 'rgba(16, 185, 129, 1)', // Set your preferred color for the dotted line
strokeDasharray: '5, 5', // Dotted line style
},
labels: { display: 'none' },
}}
x="x"
y="y"
/>
)}
</VictoryChart>
</View>
</Card>
Expand Down
4 changes: 3 additions & 1 deletion src/components/progressSliders/ProgressSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface Props {
sliderValue: number;
sliderMaxValue: number;
step: number;
minimumValue?: number;
minimumTrackTintColor: string;
maximumTrackTintColor: string;
thumbTintColor: string;
Expand All @@ -20,6 +21,7 @@ export const ProgressSlider = (props: Props) => {
minimumTrackTintColor,
maximumTrackTintColor,
thumbTintColor,
minimumValue = 0,
onChangeSliderValue,
sliderMaxValue,
step,
Expand All @@ -34,7 +36,7 @@ export const ProgressSlider = (props: Props) => {
maximumTrackTintColor={maximumTrackTintColor}
thumbTintColor={thumbTintColor}
vertical={isVertical}
minimumValue={0}
minimumValue={minimumValue}
step={step}
maximumValue={sliderMaxValue}
style={sliderStyle}
Expand Down
2 changes: 1 addition & 1 deletion src/components/svgs/scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { Dimensions } from 'react-native';
import { Path, Svg } from 'react-native-svg';

const ScanSVG = ({ margin = 20 }: { margin?: number }) => {
const ScanSVG = ({ margin = 32 }: { margin?: number }) => {
return (
<Svg
width={Dimensions.get('window').width - margin}
Expand Down
4 changes: 2 additions & 2 deletions src/components/timeStamp/TimeStampView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const TimeStampView = React.forwardRef(
) => {
const styles = timeStampViewStyle(useBranding());

const f = format ?? mode === 'time' ? 'HH:MM a' : 'MMM dd, yyyy';
const f = format ?? mode === 'time' ? 'hh:mm a' : 'MMM dd, yyyy';

useImperativeHandle(ref, () => {
return {
Expand Down Expand Up @@ -68,7 +68,7 @@ export const TimeStampView = React.forwardRef(
const timeStampViewStyle = ({ border, white }: Branding) =>
StyleSheet.create({
timeStampContainer: {
marginTop: scaleHeight(12),
marginTop: scaleHeight(6),
marginBottom: scaleHeight(12),
paddingHorizontal: 19,
borderColor: border,
Expand Down
16 changes: 5 additions & 11 deletions src/hooks/useNutritionAdvisor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,11 @@ export const useNutritionAdvisor = ({ key }: { key: string }) => {
useEffect(() => {
const initializeNutritionAdvisor = async () => {
try {
const status = await NutritionAdvisor.configure(key);
if (status?.status === 'Success') {
const conversationResponse =
await NutritionAdvisor.initConversation();
setConfigureStatus(
conversationResponse?.status === 'Success' ? 'Success' : 'Error'
);
} else {
setConfigureStatus('Error');
setSDKError(status?.message);
}
const conversationResponse = await NutritionAdvisor.initConversation();

setConfigureStatus(
conversationResponse?.status === 'Success' ? 'Success' : 'Error'
);
} catch (err) {
setConfigureStatus('Error');
setSDKError('Error');
Expand Down
7 changes: 4 additions & 3 deletions src/screens/advisor/useAdvisorScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Keyboard } from 'react-native';
import { PassioSDK } from '@passiolife/nutritionai-react-native-sdk-v3';
import {
ShowToast,
createFoodLogUsingPortionSize,
createFoodLogUsingWeightGram,
getLogToDate,
mealLabelByDate,
} from '../../utils';
Expand Down Expand Up @@ -108,10 +108,11 @@ export const useAdvisorScreen = () => {
for (const item of selected) {
if (item.foodDataInfo) {
const foodItem = await PassioSDK.fetchFoodItemForDataInfo(
item.foodDataInfo
item.foodDataInfo,
item.weightGrams
);
if (foodItem) {
let foodLog = createFoodLogUsingPortionSize(
let foodLog = createFoodLogUsingWeightGram(
foodItem,
logToDate,
meal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const MessageRecordItem = (props: Props) => {
<Text
weight="400"
size="_12px"
style={[styles.text, styles.secondaryText]}
style={[styles.bottom, styles.secondaryText]}
>
{bottom}
</Text>
Expand Down Expand Up @@ -127,6 +127,11 @@ const styles = StyleSheet.create({
marginVertical: 2,
marginRight: 10,
},
bottom: {
marginStart: 4,
marginVertical: 2,
marginRight: 10,
},
selectedAddIcon: {
borderWidth: 1,
borderColor: '#4F46E5',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const MessageRecords = ({
<MessageRecordItem
foodName={item?.recognisedName}
imageName={foodDataInfo?.iconID}
bottom={`${item?.portionSize} | ${Math.round(calories)} cal`}
bottom={`${item?.weightGrams} g | ${Math.round(calories)} cal`}
onFoodLogSelect={() => {
if (response.isLogged) {
return;
Expand Down
5 changes: 3 additions & 2 deletions src/screens/myFoods/MyFoodsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const MyFoodsScreen = () => {
onCreateFoodPress,
onEditorPress,
onDeletePress,
onCreateNewRecipe,
onLogPress,
} = useMyFoodScreen();

Expand Down Expand Up @@ -58,13 +59,13 @@ export const MyFoodsScreen = () => {
onPress={onCreateFoodPress}
/>
)}
{/* {tab !== 'Custom Foods' && (
{tab !== 'Custom Foods' && (
<BasicButton
text="Create New Recipe"
style={styles.button}
onPress={onCreateNewRecipe}
/>
)} */}
)}
</View>
);
};
61 changes: 56 additions & 5 deletions src/screens/quick/QuickScanningScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React, { useState } from 'react';
import { Image, StyleSheet, TouchableOpacity, View } from 'react-native';
import React, { useEffect, useState } from 'react';
import {
Image,
Platform,
StyleSheet,
TouchableOpacity,
View,
} from 'react-native';

import { DetectionCameraView } from '@passiolife/nutritionai-react-native-sdk-v3/src/sdk/v2';
import type { MealLabel } from '../../models';
Expand All @@ -17,6 +23,11 @@ import { VisualFoodScan } from './mode/visual/VisualFoodScan';
import { useBranding } from '../../contexts';
import { NutritionFactScan } from './mode/nutritionFact/NutritionFactScan';
import { ShowToast } from '../../utils';
import { ProgressSlider } from '../../components';
import {
PassioCameraZoomLevel,
PassioSDK,
} from '@passiolife/nutritionai-react-native-sdk-v3';

export interface ScanningScreenProps {
logToDate: Date | undefined;
Expand All @@ -35,13 +46,25 @@ export const QuickScanningScreen = gestureHandlerRootHOC(() => {
const [mode, setMode] = useState<ScanningMode>('Visual');
const navigation = useNavigation<ScanningScreenNavigationProps>();
const branding = useBranding();
const [level, setLevel] = useState<PassioCameraZoomLevel>();

useEffect(() => {
function init() {
setTimeout(() => {
PassioSDK.getMinMaxCameraZoomLevel().then((passioCameraZoomLevel) => {
setLevel(passioCameraZoomLevel);
});
}, 300);
}
init();
}, []);

const renderMode = () => {
return (
<View
style={{
position: 'absolute',
top: 120,
top: Platform.OS === 'android' ? 100 : 130,
right: 0,
left: 0,
justifyContent: 'center',
Expand Down Expand Up @@ -103,9 +126,27 @@ export const QuickScanningScreen = gestureHandlerRootHOC(() => {
);
};

const renderZoomIndicator = () => {
return (
<View style={[styles.slider]}>
<ProgressSlider
sliderValue={1}
minimumValue={level?.minZoomLevel ?? 0}
sliderMaxValue={level?.maxZoomLevel ?? 1}
step={0.1}
minimumTrackTintColor={branding.primaryColor}
maximumTrackTintColor={'white'}
thumbTintColor={branding.primaryColor}
onChangeSliderValue={function (val: number): void {
PassioSDK.setCameraZoomLevel(val);
}}
/>
</View>
);
};
return (
<View style={styles.container}>
<DetectionCameraView style={styles.camera} />
<DetectionCameraView style={styles.camera} volumeDetectionMode="none" />

{!info && (
<View style={styles.scanIcon}>
Expand Down Expand Up @@ -139,6 +180,8 @@ export const QuickScanningScreen = gestureHandlerRootHOC(() => {
/>
{info && <QuickScanInfo onOkPress={() => setInfo(false)} />}
{renderMode()}

{level && renderZoomIndicator()}
</View>
);
});
Expand All @@ -153,13 +196,21 @@ const styles = StyleSheet.create({
scanIcon: {
position: 'absolute',
top: 0,
bottom: 50,
bottom: Platform.OS === 'android' ? 100 : 80,
right: 0,
left: 0,
marginHorizontal: 16,
alignItems: 'center',
justifyContent: 'center',
},
slider: {
position: 'absolute',
bottom: Platform.OS === 'android' ? 230 : 250,
left: 0,
marginHorizontal: 16,
right: 0,
justifyContent: 'center',
},
icons: {
height: 24,
width: 24,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/takePicture/result/PictureLoggingResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const PictureLoggingResult = ({
<PictureLoggingResultItemView
foodName={item?.recognisedName}
imageName={foodDataInfo?.iconID}
bottom={`${item?.portionSize} | ${Math.round(calories)} cal`}
bottom={`${item?.weightGrams} g | ${Math.round(calories)} cal`}
onFoodLogSelect={() => {
onFoodSelect({ ...item, index: index });
}}
Expand Down
Loading

0 comments on commit afaa825

Please sign in to comment.