Skip to content

Commit 6ab3c74

Browse files
authored
Merge pull request #49 from LPK98/isira
Enhance weapon display logic and improve styling in components
2 parents cb62de7 + 182a46f commit 6ab3c74

5 files changed

Lines changed: 28 additions & 11 deletions

File tree

app/(screens)/Weapon.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,18 @@ const Weapon = () => {
180180
weapons.map((weapon, index) => (
181181
<WeaponCard
182182
key={`${String(weapon.id ?? "weapon")}-${index}`}
183-
name={weapon.weaponType ?? "Unknown"}
183+
name={
184+
weapon.weaponType ??
185+
(weapon as AssignedWeapon & {
186+
weapon?: { weaponType?: string };
187+
}).weapon?.weaponType ??
188+
"Unknown"
189+
}
184190
status={weapon.status ?? "N/A"}
185191
ammoCount={weapon.ammoCount ?? 0}
186192
totalAmmo={weapon.totalAmmo ?? 0}
187193
dueDate={weapon.dueDate ?? "N/A"}
194+
weapon={weapon}
188195
/>
189196
))
190197
)}

app/Translate.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ const LANGUAGE_OPTIONS: LanguageOption[] = [
3030
{ name: "Sinhala", flag: "🇱🇰" },
3131
{ name: "Tamil", flag: "🇱🇰" },
3232
{ name: "English", flag: "🇺🇸" },
33-
{ name: "Spanish", flag: "🇪🇸" },
34-
{ name: "French", flag: "🇫🇷" },
35-
{ name: "German", flag: "🇩🇪" },
36-
{ name: "Chinese", flag: "🇨🇳" },
3733
];
3834

3935
const Translate: React.FC = () => {

app/login.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ export default function LoginScreen() {
242242
{/* FORGOT PASSWORD */}
243243
<Pressable
244244
disabled={loading}
245-
onPress={() => console.log("Fogot Password pressed")}
245+
onPress={() =>
246+
alert("Please contact your administrator to reset your password.")
247+
}
246248
>
247249
<Text style={styles.forgot}>Forgot Password</Text>
248250
</Pressable>

src/components/WeaponCard.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import { Image, Pressable, Text, View, StyleSheet } from "react-native";
22
import { useTheme } from "../theme/ThemeProvider";
33
import Ionicons from "@expo/vector-icons/build/Ionicons";
44
import { ProgressBar } from "react-native-paper";
5+
import { images } from "../constants/images";
6+
import { weaponType } from "../types/weaponTypes";
57

68
export type WeaponCardProps = {
79
name: string;
810
status: string;
911
ammoCount: number;
1012
totalAmmo: number;
1113
dueDate: string;
14+
weapon?: weaponType;
1215
};
1316

1417
const 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,

src/components/WeaponRequestCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const WeaponRequestCard = ({
5858
width: 68,
5959
height: 68,
6060
borderRadius: 18,
61-
backgroundColor: colors.primaryAccent ?? colors.border,
61+
backgroundColor: colors.border,
6262
alignItems: "center",
6363
justifyContent: "center",
6464
}}

0 commit comments

Comments
 (0)