From 35501b8d7e1b5c5b00cd8dd6f0d2f158766e8181 Mon Sep 17 00:00:00 2001 From: Ahmed-Ali Date: Fri, 21 Jun 2024 21:00:04 +0400 Subject: [PATCH] chore: Add QA settings screen --- example/src/App.tsx | 14 +++- example/src/components/navigation-button.tsx | 9 +- .../src/components/settings-nav-button.tsx | 1 + example/src/navigation/props.ts | 2 + example/src/screens/content-navigator.tsx | 6 ++ example/src/screens/home.tsx | 13 ++- example/src/screens/index.ts | 1 + example/src/screens/qa-settings.tsx | 83 +++++++++++++++++++ example/src/screens/settings.tsx | 13 +-- example/src/services/storage.ts | 76 ++++++++++++++--- 10 files changed, 187 insertions(+), 31 deletions(-) create mode 100644 example/src/screens/qa-settings.tsx diff --git a/example/src/App.tsx b/example/src/App.tsx index 65fa6f5e..80031297 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -7,7 +7,7 @@ import { ContentNavigator } from '@screens'; import { Storage } from '@services'; import { appTheme } from '@utils'; import { CustomerIO } from 'customerio-reactnative'; -import FlashMessage from 'react-native-flash-message'; +import FlashMessage, { showMessage } from 'react-native-flash-message'; export default function App({ moduleName }: { moduleName: string }) { const [isLoading, setIsLoading] = React.useState(true); @@ -48,8 +48,16 @@ export default function App({ moduleName }: { moduleName: string }) { CustomerIO.clearIdentify(); }, onTrackEvent: (eventPayload) => { - console.log('Tracking event', eventPayload); - CustomerIO.track(eventPayload.name, eventPayload.properties); + if (CustomerIO.isInitialized()) { + console.log('Tracking event', eventPayload); + CustomerIO.track(eventPayload.name, eventPayload.properties); + } else { + showMessage({ + message: 'CustomerIO not initialized', + description: 'Please set the CustomerIO config', + type: 'danger', + }); + } }, onProfileAttributes(attributes) { console.log('Setting profile attributes', attributes); diff --git a/example/src/components/navigation-button.tsx b/example/src/components/navigation-button.tsx index 5dca0939..b10e1b95 100644 --- a/example/src/components/navigation-button.tsx +++ b/example/src/components/navigation-button.tsx @@ -10,12 +10,19 @@ import { export const NavigationButton = ({ onPress, iconSource, + onLongPress, }: { onPress: () => void; + onLongPress?: () => void; iconSource: ImageSourcePropType; }) => { return ( - + { + onLongPress?.(); + }} + > { return ( navigation.navigate('Settings')} + onLongPress={() => navigation.navigate('QA Settings')} iconSource={require('@assets/images/settings.png')} /> ); diff --git a/example/src/navigation/props.ts b/example/src/navigation/props.ts index ae00f8ce..112c19e2 100644 --- a/example/src/navigation/props.ts +++ b/example/src/navigation/props.ts @@ -9,6 +9,7 @@ export const LoginScreenName = 'Login' as const; export const TrackScreenName = 'Track' as const; export const CustomProfileAttrScreenName = 'Profile Attributes' as const; export const CustomDeviceAttrScreenName = 'Device Attributes' as const; +export const QASettingsScreenName = 'QA Settings' as const; export type NavigationStackParamList = { [SettingsScreenName]: undefined; @@ -18,6 +19,7 @@ export type NavigationStackParamList = { [TrackScreenName]: undefined; [CustomProfileAttrScreenName]: undefined; [CustomDeviceAttrScreenName]: undefined; + [QASettingsScreenName]: undefined; }; export type NavigationProps = NavigationProp; diff --git a/example/src/screens/content-navigator.tsx b/example/src/screens/content-navigator.tsx index 124a4580..770312cb 100644 --- a/example/src/screens/content-navigator.tsx +++ b/example/src/screens/content-navigator.tsx @@ -5,6 +5,7 @@ import { LoginScreenName, NavigationCallbackContext, NavigationStackParamList, + QASettingsScreenName, SettingsScreenName, TrackScreenName, } from '@navigation'; @@ -17,6 +18,7 @@ import { CustomProfileAttrScreen, HomeScreen, LogingScreen, + QASettingsScreen, SettingsScreen, TrackScreen, } from '@screens'; @@ -53,6 +55,10 @@ export const ContentNavigator = ({ moduleName }: { moduleName: string }) => { }} > + ) => { const [user] = useState(Storage.instance.getUser()); + const { onTrackEvent } = useContext(NavigationCallbackContext); return ( <> @@ -25,11 +25,10 @@ export const HomeScreen = ({