Skip to content

Commit

Permalink
feature: Show character class in the header (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelBreslaw authored Apr 8, 2024
1 parent 50827f0 commit 76c763b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions native/app/screens/MainDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getFullProfile } from "@/app/bungie/BungieApi.ts";
import type { GuardianClassType } from "@/app/bungie/Hashes.ts";
import { LOGO_DARK } from "@/app/inventory/Common.ts";
import InventoryHeader from "@/app/screens/InventoryHeader.tsx";
import HomeScreen from "@/app/screens/InventoryPages";
import InventoryPages from "@/app/screens/InventoryPages";
import { useGGStore } from "@/app/store/GGStore.ts";
import { type DrawerContentComponentProps, createDrawerNavigator } from "@react-navigation/drawer";
import { Image, StyleSheet, Text, View } from "react-native";
Expand Down Expand Up @@ -72,7 +73,26 @@ const CustomDrawerContent = (props: DrawerContentComponentProps) => {
);
};

function getGuardianClassType(classType: GuardianClassType | undefined) {
switch (classType) {
case 0:
return "Titan";
case 1:
return "Hunter";
case 2:
return "Warlock";
case 100:
return "Vault";
default:
return "";
}
}

export default function MainDrawer() {
const ggGuardians = useGGStore((state) => state.ggCharacters);
const currentListIndex = useGGStore((state) => state.currentListIndex);
const guardianClassType = getGuardianClassType(ggGuardians[currentListIndex]?.guardianClassType);

return (
<Drawer.Navigator
drawerContent={(props) => <CustomDrawerContent {...props} />}
Expand All @@ -82,8 +102,9 @@ export default function MainDrawer() {
>
<Drawer.Screen
name="Inventory"
component={HomeScreen}
component={InventoryPages}
options={{
title: `${guardianClassType}`,
drawerType: "back",
drawerStyle: {
backgroundColor: "black",
Expand Down
2 changes: 1 addition & 1 deletion native/app/store/AccountLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getCharactersAndVault(guardians: Record<string, Guardian>): GGCh

const vaultData: GGCharacterUiData = {
characterId: VAULT_CHARACTER_ID,
guardianClassType: GuardianClassType.Unknown,
guardianClassType: GuardianClassType.Vault,
genderType: 0,
raceType: 0,
emblemPath: "",
Expand Down

0 comments on commit 76c763b

Please sign in to comment.