@@ -2,13 +2,16 @@ import { Image, Pressable, Text, View, StyleSheet } from "react-native";
22import { useTheme } from "../theme/ThemeProvider" ;
33import Ionicons from "@expo/vector-icons/build/Ionicons" ;
44import { ProgressBar } from "react-native-paper" ;
5+ import { images } from "../constants/images" ;
6+ import { weaponType } from "../types/weaponTypes" ;
57
68export type WeaponCardProps = {
79 name : string ;
810 status : string ;
911 ammoCount : number ;
1012 totalAmmo : number ;
1113 dueDate : string ;
14+ weapon ?: weaponType ;
1215} ;
1316
1417const WeaponCard = ( {
@@ -17,8 +20,16 @@ const WeaponCard = ({
1720 ammoCount,
1821 totalAmmo,
1922 dueDate,
23+ weapon,
2024} : WeaponCardProps ) => {
2125 const { colors } = useTheme ( ) ;
26+ const displayName = name ?. trim ( ) ? name : "Unknown" ;
27+ const imageUri =
28+ weapon ?. imageUrl ?. trim ( ) ??
29+ (
30+ weapon as ( weaponType & { weapon ?: { imageUrl ?: string } } ) | undefined
31+ ) ?. weapon ?. imageUrl ?. trim ( ) ;
32+ const imageSource = imageUri ? { uri : imageUri } : images . logo ;
2233 const today = new Date ( ) ;
2334 const dueDateObj = new Date ( dueDate ) ;
2435 const isOverdue = dueDateObj < today ;
@@ -36,9 +47,10 @@ const WeaponCard = ({
3647 width : "100%" ,
3748 } }
3849 >
39- < View >
50+ < View style = { { backgroundColor : colors . border , padding : 2 , borderRadius : 10 } } >
4051 < Image
41- source = { { uri : "../../assets/images/logo.png" } }
52+ source = { imageSource }
53+ resizeMode = "contain"
4254 style = { { width : 150 , height : 150 } }
4355 />
4456 </ View >
@@ -61,11 +73,11 @@ const WeaponCard = ({
6173 < Text
6274 style = { { color : colors . text , fontWeight : "bold" , fontSize : 18 } }
6375 >
64- { name }
76+ { displayName }
6577 </ Text >
6678 < View
6779 style = { {
68- backgroundColor : colors . primaryAccent ,
80+ backgroundColor : colors . primaryAccent . concat ( "20" ) ,
6981 paddingHorizontal : 8 ,
7082 paddingVertical : 4 ,
7183 borderRadius : 10 ,
0 commit comments