Skip to content

Commit

Permalink
chore: adding fastlane files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Ali committed Jun 23, 2024
1 parent 640b1a5 commit bdc6909
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 51 deletions.
1 change: 1 addition & 0 deletions example/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
'@components': './src/components',
'@constants': './src/constants',
'@screens': './src/screens',
'@screens-context': './src/screens/context.ts',
'@services': './src/services',
'@colors': './src/colors',
'@utils': './src/utils',
Expand Down
3 changes: 3 additions & 0 deletions example/fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Include all of the bundle identifiers for your iOS app and for your rich push target.
# You find the bundle identifier of each app inside of Xcode - https://stackoverflow.com/a/59131511
app_identifier(["io.customer.ami", "io.customer.ami.richpush", "io.customer.rn-sample.fcm", "io.customer.rn-sample.fcm.richpush"])
11 changes: 11 additions & 0 deletions example/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# Import functions for setting up code signing in development as well as CI server.
# See this README (https://github.com/customerio/apple-code-signing) for list of all fastlane functions that this imports and you can run.
import_from_git(
url: "https://github.com/customerio/apple-code-signing.git",
branch: "main",
path: "fastlane/Fastfile"
)

# That is all we have for now.
# See the iOS SDK fastlane files for more functionality that we could add to this project in the future.
4 changes: 3 additions & 1 deletion example/ios/Shared/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.moduleName = MODULE_NAME;
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
self.initialProps = @{
@"moduleName": MODULE_NAME
};

// 1. Setup CioMessagingPush
[CioMessagingPush setup];
Expand Down
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { appTheme } from '@utils';
import { CustomerIO } from 'customerio-reactnative';
import FlashMessage from 'react-native-flash-message';

export default function App() {
export default function App({ moduleName }: { moduleName: string }) {
const [isLoading, setIsLoading] = React.useState(true);
const storage = Storage.instance;
useEffect(() => {
Expand Down Expand Up @@ -69,7 +69,7 @@ export default function App() {
}}
>
<NavigationContainer theme={appTheme}>
<ContentNavigator />
<ContentNavigator moduleName={moduleName} />
<FlashMessage position="top" duration={4000} />
</NavigationContainer>
</NavigationCallbackContext.Provider>
Expand Down
24 changes: 17 additions & 7 deletions example/src/components/BuildInfoText.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import React, { useEffect, useState } from 'react';
import { ScreensContext } from '@screens-context';
import React, { useContext, useEffect, useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { getBuildNumber, getVersion } from 'react-native-device-info';
import { systemWeights } from 'react-native-typography';
import { SmallFootnote } from './text';

export const BuildInfoText = () => {
const [buildInfo, setBuildInfo] = useState('');

const { moduleName } = useContext(ScreensContext);
useEffect(() => {
const sdkPackageJson = require('customerio-reactnative/package.json');

const value =
`Customer.io` +
` React Native SDK ${sdkPackageJson.version}` +
` Sample App ${getVersion()} (${getBuildNumber()})`;
const value = `Customer.io` + ` SDK version ${sdkPackageJson.version}`;
setBuildInfo(value);
}, [buildInfo]);

return (
<View style={styles.container}>
<SmallFootnote>
Running the
<SmallFootnote style={styles.flavorText}>
{' '}
{moduleName}
</SmallFootnote>{' '}
App
</SmallFootnote>
<SmallFootnote>{buildInfo}</SmallFootnote>
</View>
);
Expand All @@ -29,6 +35,10 @@ const styles = StyleSheet.create({
justifyContent: 'center',
marginVertical: 16,
},

flavorText: {
...systemWeights.bold,
},
});

export default BuildInfoText;
85 changes: 44 additions & 41 deletions example/src/screens/content-navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,57 +23,60 @@ import {

import { Storage } from '@services';
import React, { useContext, useState } from 'react';
import { ScreensContext } from './context';

const Stack = createNativeStackNavigator<NavigationStackParamList>();

export const ContentNavigator = () => {
export const ContentNavigator = ({ moduleName }: { moduleName: string }) => {
const [prevScreenName, setPrevScreenName] = useState<string | null>(null);
const user = Storage.instance.getUser();
const { onScreenChange } = useContext(NavigationCallbackContext);
return (
<Stack.Navigator
initialRouteName={user ? HomeScreenName : LoginScreenName}
screenOptions={screenStylingOptions}
screenListeners={{
state: (event) => {
if (event.data.state.type === 'stack') {
const currentRoute =
event.data.state.routes[event.data.state.index];
<ScreensContext.Provider value={{ moduleName }}>
<Stack.Navigator
initialRouteName={user ? HomeScreenName : LoginScreenName}
screenOptions={screenStylingOptions}
screenListeners={{
state: (event) => {
if (event.data.state.type === 'stack') {
const currentRoute =
event.data.state.routes[event.data.state.index];

if (currentRoute.name !== prevScreenName) {
if (prevScreenName) {
onScreenChange(currentRoute.name);
if (currentRoute.name !== prevScreenName) {
if (prevScreenName) {
onScreenChange(currentRoute.name);
}
setPrevScreenName(currentRoute.name);
}
setPrevScreenName(currentRoute.name);
}
}
},
}}
>
<Stack.Screen name={SettingsScreenName} component={SettingsScreen} />
<Stack.Screen
name={HomeScreenName}
component={HomeScreen}
options={{
headerRight: SettingsNavButton,
},
}}
/>
<Stack.Screen
name={LoginScreenName}
component={LogingScreen}
options={{
headerRight: SettingsNavButton,
}}
/>
<Stack.Screen name={TrackScreenName} component={TrackScreen} />
<Stack.Screen
name={CustomProfileAttrScreenName}
component={CustomProfileAttrScreen}
/>
<Stack.Screen
name={CustomDeviceAttrScreenName}
component={CustomDeviceAttrScreen}
/>
</Stack.Navigator>
>
<Stack.Screen name={SettingsScreenName} component={SettingsScreen} />
<Stack.Screen
name={HomeScreenName}
component={HomeScreen}
options={{
headerRight: SettingsNavButton,
}}
/>
<Stack.Screen
name={LoginScreenName}
component={LogingScreen}
options={{
headerRight: SettingsNavButton,
}}
/>
<Stack.Screen name={TrackScreenName} component={TrackScreen} />
<Stack.Screen
name={CustomProfileAttrScreenName}
component={CustomProfileAttrScreen}
/>
<Stack.Screen
name={CustomDeviceAttrScreenName}
component={CustomDeviceAttrScreen}
/>
</Stack.Navigator>
</ScreensContext.Provider>
);
};
5 changes: 5 additions & 0 deletions example/src/screens/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createContext } from 'react';

export const ScreensContext = createContext<{ moduleName: string }>({
moduleName: '',
});
1 change: 1 addition & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@assets/*": ["./src/assets/*"],
"@components": ["./src/components"],
"@screens": ["./src/screens"],
"@screens-context": ["./src/screens/context"],
"@services": ["./src/services"],
"@colors": ["./src/colors"],
"@utils": ["./src/utils"],
Expand Down

0 comments on commit bdc6909

Please sign in to comment.