Skip to content

Commit 3554eb6

Browse files
committed
feat: profile user example for zustand usage
1 parent 5e73f81 commit 3554eb6

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

ios/Podfile.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ PODS:
7474
- fmt (6.2.1)
7575
- glog (0.3.5)
7676
- libevent (2.1.12)
77+
- MMKV (1.2.13):
78+
- MMKVCore (~> 1.2.13)
79+
- MMKVCore (1.2.14)
7780
- OpenSSL-Universal (1.1.1100)
7881
- RCT-Folly (2021.06.28.00-v2):
7982
- boost
@@ -284,6 +287,9 @@ PODS:
284287
- React-jsinspector (0.69.4)
285288
- React-logger (0.69.4):
286289
- glog
290+
- react-native-mmkv-storage (0.8.0):
291+
- MMKV (= 1.2.13)
292+
- React-Core
287293
- react-native-safe-area-context (4.3.1):
288294
- RCT-Folly
289295
- RCTRequired
@@ -447,6 +453,7 @@ DEPENDENCIES:
447453
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
448454
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
449455
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
456+
- react-native-mmkv-storage (from `../node_modules/react-native-mmkv-storage`)
450457
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
451458
- react-native-splash-screen (from `../node_modules/react-native-splash-screen`)
452459
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
@@ -484,6 +491,8 @@ SPEC REPOS:
484491
- FlipperKit
485492
- fmt
486493
- libevent
494+
- MMKV
495+
- MMKVCore
487496
- OpenSSL-Universal
488497
- SocketRocket
489498
- YogaKit
@@ -527,6 +536,8 @@ EXTERNAL SOURCES:
527536
:path: "../node_modules/react-native/ReactCommon/jsinspector"
528537
React-logger:
529538
:path: "../node_modules/react-native/ReactCommon/logger"
539+
react-native-mmkv-storage:
540+
:path: "../node_modules/react-native-mmkv-storage"
530541
react-native-safe-area-context:
531542
:path: "../node_modules/react-native-safe-area-context"
532543
react-native-splash-screen:
@@ -590,6 +601,8 @@ SPEC CHECKSUMS:
590601
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
591602
glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a
592603
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
604+
MMKV: aac95d817a100479445633f2b3ed8961b4ac5043
605+
MMKVCore: 89f5c8a66bba2dcd551779dea4d412eeec8ff5bb
593606
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
594607
RCT-Folly: b9d9fe1fc70114b751c076104e52f3b1b5e5a95a
595608
RCTRequired: bd9d2ab0fda10171fcbcf9ba61a7df4dc15a28f4
@@ -605,6 +618,7 @@ SPEC CHECKSUMS:
605618
React-jsiexecutor: a27badbbdbc0ff781813370736a2d1c7261181d4
606619
React-jsinspector: 8a3d3f5dcd23a91e8c80b1bf0e96902cd1dca999
607620
React-logger: 1088859f145b8f6dd0d3ed051a647ef0e3e80fad
621+
react-native-mmkv-storage: 8ba3c0216a6df283ece11205b442a3e435aec4e5
608622
react-native-safe-area-context: 6c12e3859b6f27b25de4fee8201cfb858432d8de
609623
react-native-splash-screen: 4312f786b13a81b5169ef346d76d33bc0c6dc457
610624
React-perflogger: cb386fd44c97ec7f8199c04c12b22066b0f2e1e0

src/screens/profile/ProfileScreen.style.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ViewStyle, StyleSheet } from "react-native";
33

44
interface Style {
55
container: ViewStyle;
6+
userContainer: ViewStyle;
7+
userButton: ViewStyle;
68
}
79

810
export default (theme: ExtendedTheme) => {
@@ -14,5 +16,19 @@ export default (theme: ExtendedTheme) => {
1416
alignItems: "center",
1517
justifyContent: "center",
1618
},
19+
userContainer: {
20+
marginTop: 16,
21+
alignItems: "center",
22+
justifyContent: "center",
23+
},
24+
userButton: {
25+
height: 35,
26+
width: 150,
27+
marginTop: 32,
28+
borderRadius: 16,
29+
alignItems: "center",
30+
justifyContent: "center",
31+
backgroundColor: "#135",
32+
},
1733
});
1834
};

src/screens/profile/ProfileScreen.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { useTheme } from "@react-navigation/native";
66
*/
77
import createStyles from "./ProfileScreen.style";
88
import Text from "@shared-components/text-wrapper/TextWrapper";
9+
import useStore from "@services/zustand/store";
10+
import RNBounceable from "@freakycoder/react-native-bounceable";
911

1012
interface ProfileScreenProps {}
1113

@@ -14,11 +16,26 @@ const ProfileScreen: React.FC<ProfileScreenProps> = () => {
1416
const { colors } = theme;
1517
const styles = useMemo(() => createStyles(theme), [theme]);
1618

19+
const userData = useStore((state) => state.userData);
20+
const setUserData = useStore((state) => state.setUserData);
21+
1722
return (
1823
<View style={styles.container}>
1924
<Text h1 color={colors.text}>
2025
Profile
2126
</Text>
27+
<View style={styles.userContainer}>
28+
<Text>{userData?.name}</Text>
29+
<Text>{userData?.email}</Text>
30+
</View>
31+
<RNBounceable
32+
style={styles.userButton}
33+
onPress={() => {
34+
setUserData({ name: "John Doe", email: "johndoe@gmail.com" });
35+
}}
36+
>
37+
<Text color="#fff">Set User</Text>
38+
</RNBounceable>
2239
</View>
2340
);
2441
};

0 commit comments

Comments
 (0)