by codex: feat. General Improvements
This commit is contained in:
+34
-12
@@ -14,8 +14,11 @@ import { MaterialIcons } from "@expo/vector-icons";
|
||||
import { useClaudeUsage } from "@/hooks/useClaudeUsage";
|
||||
import { UsageStat } from "@/components/UsageStat";
|
||||
import { ErrorMessage } from "@/components/ErrorMessage";
|
||||
import { LastUpdated } from "@/components/LastUpdated";
|
||||
import { ScreenErrorBoundary } from "@/components/ScreenErrorBoundary";
|
||||
import { COLORS } from "@/lib/constants";
|
||||
|
||||
export default function ClaudeTab() {
|
||||
function ClaudeTabContent() {
|
||||
const {
|
||||
auth,
|
||||
pendingKey,
|
||||
@@ -23,15 +26,16 @@ export default function ClaudeTab() {
|
||||
pendingOrg,
|
||||
setPendingOrg,
|
||||
usage,
|
||||
lastFetchedAt,
|
||||
status,
|
||||
error,
|
||||
keyValidationError,
|
||||
canSaveKey,
|
||||
saveKey,
|
||||
refresh,
|
||||
clearKey,
|
||||
} = useClaudeUsage();
|
||||
|
||||
const canSave = pendingKey.trim().startsWith("sk-ant-");
|
||||
|
||||
return (
|
||||
<SafeAreaView
|
||||
className="flex-1 bg-neutral-50 dark:bg-neutral-950"
|
||||
@@ -49,7 +53,7 @@ export default function ClaudeTab() {
|
||||
<RefreshControl
|
||||
refreshing={status === "loading"}
|
||||
onRefresh={refresh}
|
||||
tintColor="#d97706"
|
||||
tintColor={COLORS.claude}
|
||||
/>
|
||||
}
|
||||
>
|
||||
@@ -57,9 +61,9 @@ export default function ClaudeTab() {
|
||||
<View className="flex-row items-center gap-x-3 py-5">
|
||||
<View
|
||||
className="w-9 h-9 rounded-xl items-center justify-center"
|
||||
style={{ backgroundColor: "#d9770622" }}
|
||||
style={{ backgroundColor: `${COLORS.claude}22` }}
|
||||
>
|
||||
<MaterialIcons name="psychology" size={18} color="#d97706" />
|
||||
<MaterialIcons name="psychology" size={18} color={COLORS.claude} />
|
||||
</View>
|
||||
<View>
|
||||
<Text className="text-xl font-bold text-neutral-900 dark:text-white tracking-tight">
|
||||
@@ -111,6 +115,11 @@ export default function ClaudeTab() {
|
||||
secureTextEntry
|
||||
className="border border-neutral-200 dark:border-neutral-700 rounded-xl px-3 py-3 text-sm text-neutral-900 dark:text-white bg-white dark:bg-neutral-800 mb-2"
|
||||
/>
|
||||
{keyValidationError && (
|
||||
<Text selectable className="mb-2 text-xs text-red-500">
|
||||
{keyValidationError}
|
||||
</Text>
|
||||
)}
|
||||
<TextInput
|
||||
value={pendingOrg}
|
||||
onChangeText={setPendingOrg}
|
||||
@@ -122,13 +131,15 @@ export default function ClaudeTab() {
|
||||
/>
|
||||
<TouchableOpacity
|
||||
onPress={saveKey}
|
||||
disabled={!canSave}
|
||||
disabled={!canSaveKey}
|
||||
className="py-3.5 px-4 rounded-xl items-center"
|
||||
style={{ backgroundColor: canSave ? "#d97706" : "#e5e5e5" }}
|
||||
style={{
|
||||
backgroundColor: canSaveKey ? COLORS.claude : COLORS.disabled,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
className="font-semibold text-sm"
|
||||
style={{ color: canSave ? "white" : "#a3a3a3" }}
|
||||
style={{ color: canSaveKey ? "white" : COLORS.muted }}
|
||||
>
|
||||
Save Session Key
|
||||
</Text>
|
||||
@@ -162,11 +173,11 @@ export default function ClaudeTab() {
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
{status === "loading" && (
|
||||
<ActivityIndicator color="#d97706" style={{ marginVertical: 24 }} />
|
||||
{status === "loading" && !usage && (
|
||||
<ActivityIndicator color={COLORS.claude} style={{ marginVertical: 24 }} />
|
||||
)}
|
||||
{status === "error" && error && <ErrorMessage message={error} />}
|
||||
{status === "success" && usage && (
|
||||
{usage && (
|
||||
<View>
|
||||
<UsageStat
|
||||
label="5-hour window"
|
||||
@@ -198,6 +209,9 @@ export default function ClaudeTab() {
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<View className="mt-4 border-t border-neutral-100 pt-3 dark:border-neutral-800">
|
||||
<LastUpdated timestamp={lastFetchedAt} />
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
@@ -206,3 +220,11 @@ export default function ClaudeTab() {
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
export default function ClaudeTab() {
|
||||
return (
|
||||
<ScreenErrorBoundary screenName="Claude">
|
||||
<ClaudeTabContent />
|
||||
</ScreenErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user