Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 19 additions & 2 deletions app/(tabs)/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const GET_FILTERED_SUPERMARKETS = gql(`
`);

const NavigationScreen = () => {
const { id, currentListId } = useAuth();
const { currentListId } = useAuth();
const { toast, toastOnError } = useToast();
const router = useRouter();
const { setState: setBackground } = useBackground();
Expand Down Expand Up @@ -116,7 +116,7 @@ const NavigationScreen = () => {
};

getLocation().catch(toastOnError);
}, [toast, toastOnError]);
}, [currentListId, refetch, toast, toastOnError]);

const { totalQuantity, totalPrice } = useMemo(() => {
let quantity = 0;
Expand All @@ -140,6 +140,23 @@ const NavigationScreen = () => {
return () => setBackground(false);
}, [debouncedLoading, setBackground]);

if (!currentListId) {
return (
<View className="flex-1">
<Header title="In-Store Navigation" />
<View className="h-full w-full items-center justify-center gap-2 px-4">
<ThemedText type="h2" className="text-center" color={"gradient"}>
Oops, hold on!
</ThemedText>
<ThemedText type="body" className="text-center">
It seems you don't have a shopping list selected. Create or select a
list to start in-store navigation.
</ThemedText>
</View>
</View>
);
}

if (debouncedLoading) {
return (
<View className="h-full w-full items-center justify-center gap-4">
Expand Down
14 changes: 0 additions & 14 deletions app/navigation-in-store/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
FillExtrusionLayer,
FillExtrusionLayerStyle,
Images,
Light,
LineLayer,
Logger,
MapView,
Expand Down Expand Up @@ -157,7 +156,6 @@ const NavigationInStore = () => {
feature.geometry.coordinates[0] === point.geometry.coordinates[0] &&
feature.geometry.coordinates[1] === point.geometry.coordinates[1],
);
// TODO: Add and EAN
return {
...productData
.filter((p) => !picked.includes(p.ean))
Expand Down Expand Up @@ -232,7 +230,6 @@ const NavigationInStore = () => {
};

useEffect(() => {
let isMounted = true;
let resultListener: EmitterSubscription | null = null;
let errorListener: EmitterSubscription | null = null;
const a = async () => {
Expand All @@ -256,16 +253,6 @@ const NavigationInStore = () => {
const beaconId = data.id;

let filteredDistance = data.distance;
//
// if (!kalmanStates.current[beaconId]) {
// // Inicialização do filtro
// kalmanStates.current[beaconId] = {
// x: filteredDistance,
// P: INITIAL_P,
// lastUpdate: now,
//
// };
// }
if (!kalmanStates.current[beaconId]) {
// Inicialização com média de 3 leituras
const initialReadings = [filteredDistance];
Expand Down Expand Up @@ -338,7 +325,6 @@ const NavigationInStore = () => {
delete refs[key];
}
});
isMounted = false;
resultListener?.remove();
errorListener?.remove();
stopScan().catch(toastOnError);
Expand Down
2 changes: 1 addition & 1 deletion app/productSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Search = () => {
const insets = useSafeAreaInsets();
const router = useRouter();
const { toast, toastOnError } = useToast();
const { id: userId, currentListId } = useAuth();
const { currentListId } = useAuth();

const nutriScoreBottomSheetRef = useRef<BottomSheetModal>(null);
const brandBottomSheetRef = useRef<BottomSheetModal>(null);
Expand Down
1 change: 0 additions & 1 deletion components/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const ListItem = (props: ListItemProps) => {

const ContentWrapper =
item.type && item.type !== "NORMAL" ? LinearGradient : View;
const ItemWrapper = type === "search" ? TouchableOpacity : View;

return (
<Pressable
Expand Down
5 changes: 4 additions & 1 deletion eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
},
"production": {
"autoIncrement": true,
"channel": "production"
"channel": "production",
"android": {
"buildType": "apk"
}
}
},
"submit": {
Expand Down
4 changes: 0 additions & 4 deletions utils/navigation-in-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const calculatePosition = (distances: Record<string, number>) => {
...beaconPositions[id],
distance: distance * Math.pow(10, -5),
}));
// console.log("MA pooints", points);
if (points.length < 3) return null;

// Implementação do algoritmo de mínimos quadrados
Expand All @@ -33,9 +32,6 @@ export const calculatePosition = (distances: Record<string, number>) => {
let x = solution[0];
let y = solution[1];

// Limitar aos limites do retângulo
// TODO

return { x, y };
} catch (error) {
console.error("Erro ao calcular a posição:", error);
Expand Down
Loading