Skip to content

Commit adbf6c2

Browse files
committed
Fixed back button exitting from app issue
1 parent 563f46d commit adbf6c2

13 files changed

Lines changed: 63 additions & 12 deletions

app/(screens)/BulletRequest.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ const BulletRequest = () => {
4646
]}
4747
>
4848
<Pressable
49-
onPress={() => router.replace("/(screens)/Weapon")}
49+
onPress={() =>
50+
router.canGoBack()
51+
? router.back()
52+
: router.push("/(screens)/Weapon")
53+
}
5054
style={[
5155
styles.backButton,
5256
{

app/(screens)/Duty.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,9 @@ export default function DutyCalendarScreen({ route }: Props) {
455455
]}
456456
>
457457
<Pressable
458-
onPress={() => router.replace("/Dashboard")}
458+
onPress={() =>
459+
router.canGoBack() ? router.back() : router.push("/Dashboard")
460+
}
459461
style={[
460462
styles.backButton,
461463
{

app/(screens)/Plate.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ export default function PlateRegistryScreen() {
131131
>
132132
<View style={styles.titleRow}>
133133
<Pressable
134-
onPress={() => router.replace("/Dashboard")}
134+
onPress={() =>
135+
router.canGoBack() ? router.back() : router.push("/Dashboard")
136+
}
135137
style={[
136138
styles.backButton,
137139
{

app/(screens)/SafetyZone.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ const SafetyZone = () => {
226226
]}
227227
>
228228
<Pressable
229-
onPress={() => router.replace("/Dashboard")}
229+
onPress={() =>
230+
router.canGoBack() ? router.back() : router.push("/Dashboard")
231+
}
230232
style={styles.backButton}
231233
>
232234
<Ionicons name="chevron-back" size={22} color={colors.primary} />

app/(screens)/Weapon.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ const Weapon = () => {
9191
]}
9292
>
9393
<Pressable
94-
onPress={() => router.replace("/Dashboard")}
94+
onPress={() =>
95+
router.canGoBack() ? router.back() : router.push("/Dashboard")
96+
}
9597
style={[
9698
styles.backButton,
9799
{

app/(screens)/WeaponRequest.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ const WeaponRequest = () => {
5353
]}
5454
>
5555
<Pressable
56-
onPress={() => router.replace("/(screens)/Weapon")}
56+
onPress={() =>
57+
router.canGoBack()
58+
? router.back()
59+
: router.push("/(screens)/Weapon")
60+
}
5761
style={[
5862
styles.backButton,
5963
{

app/(screens)/[serialNo].tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ const WeaponRequest = () => {
9898
]}
9999
>
100100
<Pressable
101-
onPress={() => router.replace("/(screens)/WeaponRequest")}
101+
onPress={() =>
102+
router.canGoBack()
103+
? router.back()
104+
: router.push("/(screens)/WeaponRequest")
105+
}
102106
style={[
103107
styles.backButton,
104108
{

app/Chat.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ const Chat = () => {
100100
<View style={styles.header}>
101101
<SafeAreaView>
102102
<View style={styles.headerContent}>
103-
<Pressable onPress={() => router.replace("/Dashboard")}>
103+
<Pressable
104+
onPress={() =>
105+
router.canGoBack() ? router.back() : router.push("/Dashboard")
106+
}
107+
>
104108
<Text style={{ color: "#fff", fontSize: 16, marginRight: 15 }}>
105109
Back
106110
</Text>

app/Dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ const Dashboard = () => {
268268
<Pressable
269269
key={index}
270270
style={styles.menuButton}
271-
onPress={() => router.replace(item.route)}
271+
onPress={() => router.push(item.route)}
272272
>
273273
<View
274274
style={[

app/Settings.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ export default function Settings() {
160160
]}
161161
>
162162
<TouchableOpacity
163-
onPress={() => router.replace("/Dashboard")}
163+
onPress={() =>
164+
router.canGoBack() ? router.back() : router.push("/Dashboard")
165+
}
164166
style={[
165167
styles.backButton,
166168
{

0 commit comments

Comments
 (0)