Files
timmy-tower/artifacts/mobile/app/(tabs)/_layout.tsx
Alexander Whitestone 6433d9172c feat: mobile Nostr identity — Amber NIP-55 + nsec fallback (Fixes #29)
- Add NostrIdentityContext with SecureStore-backed nsec storage
  and pure-JS bech32/secp256k1 for nsec→npub derivation; private key
  never enters React state or logs
- Android: NIP-55 Amber deep-link integration (get_public_key +
  sign_event) with install-prompt fallback to Play Store when Amber
  is absent; Android queries manifest entry for com.greenart7c3.nostrsigner
- iOS/both: manual nsec entry stored exclusively in expo-secure-store
- Settings tab (gear icon) added to both NativeTabLayout and
  ClassicTabLayout showing: connected npub (truncated), signing method
  badge, Disconnect button (with confirmation + SecureStore wipe)
- Root layout wrapped with NostrIdentityProvider
- app.json: add expo-secure-store plugin + Android intentFilters for
  mobile://amber-callback deep-link return path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 16:24:45 -04:00

129 lines
4.0 KiB
TypeScript

import { BlurView } from "expo-blur";
import { isLiquidGlassAvailable } from "expo-glass-effect";
import { Tabs } from "expo-router";
import { Icon, Label, NativeTabs } from "expo-router/unstable-native-tabs";
import { SymbolView } from "expo-symbols";
import { Feather, MaterialCommunityIcons } from "@expo/vector-icons";
import React from "react";
import { Platform, StyleSheet, View, useColorScheme } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Colors } from "@/constants/colors";
function NativeTabLayout() {
return (
<NativeTabs>
<NativeTabs.Trigger name="index">
<Icon sf={{ default: "face.smiling", selected: "face.smiling.fill" }} />
<Label>Timmy</Label>
</NativeTabs.Trigger>
<NativeTabs.Trigger name="matrix">
<Icon sf={{ default: "cube", selected: "cube.fill" }} />
<Label>Matrix</Label>
</NativeTabs.Trigger>
<NativeTabs.Trigger name="feed">
<Icon sf={{ default: "list.bullet", selected: "list.bullet.circle.fill" }} />
<Label>Feed</Label>
</NativeTabs.Trigger>
<NativeTabs.Trigger name="settings">
<Icon sf={{ default: "gearshape", selected: "gearshape.fill" }} />
<Label>Settings</Label>
</NativeTabs.Trigger>
</NativeTabs>
);
}
function ClassicTabLayout() {
const insets = useSafeAreaInsets();
const isIOS = Platform.OS === "ios";
const isWeb = Platform.OS === "web";
const C = Colors.dark;
return (
<Tabs
screenOptions={{
headerShown: false,
tabBarActiveTintColor: C.accentGlow,
tabBarInactiveTintColor: C.textMuted,
tabBarStyle: {
position: "absolute",
backgroundColor: isIOS ? "transparent" : C.surface,
borderTopWidth: 0,
elevation: 0,
...(isWeb ? { height: 84 } : {}),
},
tabBarBackground: () =>
isIOS ? (
<BlurView
intensity={80}
tint="dark"
style={[StyleSheet.absoluteFill, { borderTopWidth: 0.5, borderTopColor: C.border }]}
/>
) : isWeb ? (
<View
style={[StyleSheet.absoluteFill, { backgroundColor: C.surface, borderTopWidth: 0.5, borderTopColor: C.border }]}
/>
) : (
<View style={[StyleSheet.absoluteFill, { backgroundColor: C.surface, borderTopWidth: 0.5, borderTopColor: C.border }]} />
),
}}
>
<Tabs.Screen
name="index"
options={{
title: "Timmy",
tabBarIcon: ({ color, size }) =>
isIOS ? (
<SymbolView name="face.smiling" tintColor={color} size={size} />
) : (
<MaterialCommunityIcons name="emoticon-outline" size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="matrix"
options={{
title: "Matrix",
tabBarIcon: ({ color, size }) =>
isIOS ? (
<SymbolView name="cube" tintColor={color} size={size} />
) : (
<MaterialCommunityIcons name="cube-outline" size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="feed"
options={{
title: "Feed",
tabBarIcon: ({ color, size }) =>
isIOS ? (
<SymbolView name="list.bullet" tintColor={color} size={size} />
) : (
<Feather name="activity" size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="settings"
options={{
title: "Settings",
tabBarIcon: ({ color, size }) =>
isIOS ? (
<SymbolView name="gearshape" tintColor={color} size={size} />
) : (
<Feather name="settings" size={size} color={color} />
),
}}
/>
</Tabs>
);
}
export default function TabLayout() {
if (isLiquidGlassAvailable()) {
return <NativeTabLayout />;
}
return <ClassicTabLayout />;
}