summaryrefslogtreecommitdiff
path: root/src/react-native-app/app/(tabs)/_layout.tsx
diff options
context:
space:
mode:
authorSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
committerSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
commit82e03978b89938219958032efb1448cc76baa181 (patch)
tree626f3e54d52ecd49be0ed3bee30abacc0453d081 /src/react-native-app/app/(tabs)/_layout.tsx
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'src/react-native-app/app/(tabs)/_layout.tsx')
-rw-r--r--src/react-native-app/app/(tabs)/_layout.tsx62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/react-native-app/app/(tabs)/_layout.tsx b/src/react-native-app/app/(tabs)/_layout.tsx
new file mode 100644
index 0000000..ba2a7b0
--- /dev/null
+++ b/src/react-native-app/app/(tabs)/_layout.tsx
@@ -0,0 +1,62 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+import { Tabs } from "expo-router";
+import React from "react";
+import { TabBarIcon } from "@/components/navigation/TabBarIcon";
+import { useCart } from "@/providers/Cart.provider";
+
+export default function TabLayout() {
+ const {
+ cart: { items },
+ } = useCart();
+
+ let itemsInCart = 0;
+ items.forEach((item) => {
+ itemsInCart += item.quantity;
+ });
+
+ return (
+ <Tabs>
+ <Tabs.Screen
+ name="index"
+ options={{
+ title: "Products",
+ tabBarShowLabel: false,
+ tabBarIcon: ({ color, focused }) => (
+ <TabBarIcon
+ name={focused ? "list" : "list-outline"}
+ color={color}
+ />
+ ),
+ }}
+ />
+ <Tabs.Screen
+ name="cart"
+ options={{
+ title: "Cart",
+ tabBarShowLabel: false,
+ tabBarBadge: itemsInCart || undefined,
+ tabBarIcon: ({ color, focused }) => (
+ <TabBarIcon
+ name={focused ? "cart" : "cart-outline"}
+ color={color}
+ />
+ ),
+ }}
+ />
+ <Tabs.Screen
+ name="settings"
+ options={{
+ title: "Settings",
+ tabBarShowLabel: false,
+ tabBarIcon: ({ color, focused }) => (
+ <TabBarIcon
+ name={focused ? "settings" : "settings-outline"}
+ color={color}
+ />
+ ),
+ }}
+ />
+ </Tabs>
+ );
+}