summaryrefslogtreecommitdiff
path: root/components/ui
diff options
context:
space:
mode:
Diffstat (limited to 'components/ui')
-rw-r--r--components/ui/IconSymbol.ios.tsx32
-rw-r--r--components/ui/IconSymbol.tsx41
-rw-r--r--components/ui/TabBarBackground.ios.tsx19
-rw-r--r--components/ui/TabBarBackground.tsx6
4 files changed, 98 insertions, 0 deletions
diff --git a/components/ui/IconSymbol.ios.tsx b/components/ui/IconSymbol.ios.tsx
new file mode 100644
index 0000000..9177f4d
--- /dev/null
+++ b/components/ui/IconSymbol.ios.tsx
@@ -0,0 +1,32 @@
+import { SymbolView, SymbolViewProps, SymbolWeight } from 'expo-symbols';
+import { StyleProp, ViewStyle } from 'react-native';
+
+export function IconSymbol({
+ name,
+ size = 24,
+ color,
+ style,
+ weight = 'regular',
+}: {
+ name: SymbolViewProps['name'];
+ size?: number;
+ color: string;
+ style?: StyleProp<ViewStyle>;
+ weight?: SymbolWeight;
+}) {
+ return (
+ <SymbolView
+ weight={weight}
+ tintColor={color}
+ resizeMode="scaleAspectFit"
+ name={name}
+ style={[
+ {
+ width: size,
+ height: size,
+ },
+ style,
+ ]}
+ />
+ );
+}
diff --git a/components/ui/IconSymbol.tsx b/components/ui/IconSymbol.tsx
new file mode 100644
index 0000000..b7ece6b
--- /dev/null
+++ b/components/ui/IconSymbol.tsx
@@ -0,0 +1,41 @@
+// Fallback for using MaterialIcons on Android and web.
+
+import MaterialIcons from '@expo/vector-icons/MaterialIcons';
+import { SymbolWeight, SymbolViewProps } from 'expo-symbols';
+import { ComponentProps } from 'react';
+import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native';
+
+type IconMapping = Record<SymbolViewProps['name'], ComponentProps<typeof MaterialIcons>['name']>;
+type IconSymbolName = keyof typeof MAPPING;
+
+/**
+ * Add your SF Symbols to Material Icons mappings here.
+ * - see Material Icons in the [Icons Directory](https://icons.expo.fyi).
+ * - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app.
+ */
+const MAPPING = {
+ 'house.fill': 'home',
+ 'paperplane.fill': 'send',
+ 'chevron.left.forwardslash.chevron.right': 'code',
+ 'chevron.right': 'chevron-right',
+} as IconMapping;
+
+/**
+ * An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web.
+ * This ensures a consistent look across platforms, and optimal resource usage.
+ * Icon `name`s are based on SF Symbols and require manual mapping to Material Icons.
+ */
+export function IconSymbol({
+ name,
+ size = 24,
+ color,
+ style,
+}: {
+ name: IconSymbolName;
+ size?: number;
+ color: string | OpaqueColorValue;
+ style?: StyleProp<TextStyle>;
+ weight?: SymbolWeight;
+}) {
+ return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
+}
diff --git a/components/ui/TabBarBackground.ios.tsx b/components/ui/TabBarBackground.ios.tsx
new file mode 100644
index 0000000..495b2d4
--- /dev/null
+++ b/components/ui/TabBarBackground.ios.tsx
@@ -0,0 +1,19 @@
+import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs';
+import { BlurView } from 'expo-blur';
+import { StyleSheet } from 'react-native';
+
+export default function BlurTabBarBackground() {
+ return (
+ <BlurView
+ // System chrome material automatically adapts to the system's theme
+ // and matches the native tab bar appearance on iOS.
+ tint="systemChromeMaterial"
+ intensity={100}
+ style={StyleSheet.absoluteFill}
+ />
+ );
+}
+
+export function useBottomTabOverflow() {
+ return useBottomTabBarHeight();
+}
diff --git a/components/ui/TabBarBackground.tsx b/components/ui/TabBarBackground.tsx
new file mode 100644
index 0000000..70d1c3c
--- /dev/null
+++ b/components/ui/TabBarBackground.tsx
@@ -0,0 +1,6 @@
+// This is a shim for web and Android where the tab bar is generally opaque.
+export default undefined;
+
+export function useBottomTabOverflow() {
+ return 0;
+}