Skip to content

Commit 38f790e

Browse files
authored
Style the Account Name screen with ui-kitten (#136)
1 parent 45d5ee4 commit 38f790e

File tree

1 file changed

+56
-33
lines changed
  • packages/mobile-app/app/(drawer)/account/account-settings/account-name

1 file changed

+56
-33
lines changed
Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,78 @@
1-
import { StatusBar } from "expo-status-bar";
2-
import { Button, StyleSheet, Text, TextInput, View } from "react-native";
3-
import { useRouter } from "expo-router";
1+
import { StyleSheet } from "react-native";
2+
import { Stack, useRouter } from "expo-router";
43
import { useFacade } from "@/data/facades";
5-
import { useState } from "react";
4+
import { useState, useEffect } from "react";
5+
import { Layout, Button, Input, Text } from "@ui-kitten/components";
66

77
export default function AccountName() {
88
const router = useRouter();
99
const facade = useFacade();
10+
const activeAccount = facade.getAccount.useQuery({});
11+
const renameAccount = facade.renameAccount.useMutation({
12+
onSuccess: () => {
13+
router.dismissAll();
14+
},
15+
});
1016

1117
const [newName, setNewName] = useState("");
1218

13-
const activeAccount = facade.getAccount.useQuery({});
14-
15-
const renameAccount = facade.renameAccount.useMutation();
19+
useEffect(() => {
20+
if (activeAccount.data?.name) {
21+
setNewName(activeAccount.data.name);
22+
}
23+
}, [activeAccount.data?.name]);
1624

1725
return (
18-
<View style={styles.container}>
19-
<Button title="Back" onPress={() => router.dismiss()} />
26+
<Layout style={styles.container}>
27+
<Layout style={styles.contentContainer}>
28+
<Stack.Screen
29+
options={{
30+
headerTitle: "Account Name",
31+
}}
32+
/>
2033

21-
<View>
22-
<Text>Account Name</Text>
23-
<Text>Current name: {activeAccount.data?.name}</Text>
24-
<TextInput
25-
placeholder="New Name"
34+
<Text category="s1" appearance="hint" style={styles.explanationText}>
35+
Change the name of your account. This name is only visible to you.
36+
</Text>
37+
<Input
38+
style={styles.input}
39+
label="Account Name"
40+
placeholder="Enter account name"
2641
value={newName}
2742
onChangeText={setNewName}
2843
/>
29-
</View>
30-
<Button
31-
title="Save"
32-
onPress={async () => {
33-
if (!activeAccount.data) {
34-
return;
35-
}
36-
await renameAccount.mutateAsync({
37-
name: activeAccount.data?.name,
38-
newName: newName,
39-
});
40-
router.dismissAll();
41-
}}
42-
/>
43-
<StatusBar style="auto" />
44-
</View>
44+
<Button
45+
onPress={async () => {
46+
if (!activeAccount.data) return;
47+
renameAccount.mutate({
48+
name: activeAccount.data?.name,
49+
newName: newName,
50+
});
51+
}}
52+
disabled={renameAccount.isPending}
53+
>
54+
{renameAccount.isPending ? "Saving..." : "Save"}
55+
</Button>
56+
</Layout>
57+
</Layout>
4558
);
4659
}
4760

4861
const styles = StyleSheet.create({
4962
container: {
5063
flex: 1,
51-
backgroundColor: "#fff",
52-
alignItems: "center",
53-
justifyContent: "center",
64+
},
65+
contentContainer: {
66+
flex: 1,
67+
padding: 16,
68+
paddingTop: 32,
69+
},
70+
input: {
71+
marginBottom: 16,
72+
},
73+
explanationText: {
74+
textAlign: "center",
75+
marginBottom: 24,
76+
paddingHorizontal: 16,
5477
},
5578
});

0 commit comments

Comments
 (0)