Skip to content

Commit 6b302bf

Browse files
authored
Merge pull request #407 from getAlby/fix/screen-title
fix: center screen title in android
2 parents 6ce2fee + 13d8f2b commit 6b302bf

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

components/Screen.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,28 @@ type ScreenProps = {
1717

1818
function Screen({ title, className, animation, right, left }: ScreenProps) {
1919
const { background } = useThemeColor("background");
20-
20+
const canGoBack = router.canGoBack();
2121
return (
2222
<Stack.Screen
2323
options={{
2424
title,
2525
animation: animation ? animation : "slide_from_right",
2626
headerLeft: left
2727
? left
28-
: ({ canGoBack }) => {
28+
: () => {
2929
return (
3030
canGoBack && (
31-
<TouchableOpacity onPress={() => router.back()}>
32-
<ChevronLeftIcon className="text-secondary-foreground p-4 mr-4" />
31+
<TouchableOpacity
32+
onPressIn={() => {
33+
router.back();
34+
}}
35+
className="-ml-4 py-2 px-6"
36+
>
37+
<ChevronLeftIcon
38+
className="text-secondary-foreground"
39+
width={24}
40+
height={24}
41+
/>
3342
</TouchableOpacity>
3443
)
3544
);
@@ -38,9 +47,7 @@ function Screen({ title, className, animation, right, left }: ScreenProps) {
3847
<Text
3948
className={cn(
4049
Platform.OS === "android" &&
41-
(right
42-
? "ml-4"
43-
: "mr-[42.18]") /* this translates to width of headerLeft button */,
50+
(right ? (left || canGoBack ? "" : "ml-[52px]") : "mr-[52px]"),
4451
"text-xl sm:text-2xl text-center font-semibold2",
4552
className,
4653
)}

pages/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function Home() {
100100
onPressIn={() => {
101101
router.navigate("/settings");
102102
}}
103-
className="-ml-4 px-6"
103+
className="-ml-4 py-2 px-6"
104104
>
105105
<SettingsLineIcon
106106
className="text-secondary-foreground"

0 commit comments

Comments
 (0)