Skip to content

Commit aa92c7f

Browse files
authored
Merge pull request #474 from Iterable/revert-453-evan/MOB-5333-linting-changes-for-sample-apps
Revert "[MOB-5333] linting changes to sample apps"
2 parents 8747aa3 + fe711d7 commit aa92c7f

33 files changed

Lines changed: 5555 additions & 7140 deletions

SampleApp/javascript/.eslintrc.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

SampleApp/javascript/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @format
33
*/
44

5-
import { AppRegistry } from 'react-native'
6-
import App from './js/App'
7-
import { name as appName } from './app.json'
5+
import {AppRegistry} from 'react-native';
6+
import App from './js/App';
7+
import {name as appName} from './app.json';
88

9-
AppRegistry.registerComponent(appName, () => App)
9+
AppRegistry.registerComponent(appName, () => App);

SampleApp/javascript/js/App.d.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React from 'react'
2-
1+
import React from 'react';
2+
interface Props {
3+
}
34
export default class App extends React.Component {
4-
constructor (props: Props)
5-
render (): JSX.Element
6-
private readonly homeTabRef
7-
private readonly navigate
8-
private readonly urlHandler
5+
constructor(props: Props);
6+
render(): JSX.Element;
7+
private homeTabRef;
8+
private navigate;
9+
private urlHandler;
910
}
10-
export {}
11+
export {};

SampleApp/javascript/js/App.js

Lines changed: 81 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,97 @@
1-
import React from 'react'
2-
import { NavigationContainer } from '@react-navigation/native'
3-
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
4-
import Icon from 'react-native-vector-icons/Ionicons'
5-
import HomeTab from './HomeTab'
6-
import SettingsTab from './SettingsTab'
7-
import { coffees } from './Data'
8-
9-
// Step 1:
10-
// Import the Iterable and IterableConfig class.
1+
import React from 'react';
2+
import { NavigationContainer } from '@react-navigation/native';
3+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
4+
import Icon from 'react-native-vector-icons/Ionicons';
5+
import HomeTab from './HomeTab';
6+
import SettingsTab from './SettingsTab';
7+
import { coffees } from './Data';
8+
9+
// Step 1:
10+
// Import the Iterable and IterableConfig class.
1111
// Refer to "Installing Iterable's React Native SDK" of the developer guide.
1212
// (https://support.iterable.com/hc/en-us/articles/360045714132-Installing-Iterable-s-React-Native-SDK-#step-5-import-iterable-sdk-classes-wherever-needed)
1313

14-
import { Iterable, IterableConfig } from '@iterable/react-native-sdk'
14+
import { Iterable, IterableConfig, } from '@iterable/react-native-sdk';
1515

16-
// Step 2:
16+
// Step 2:
1717
// Create a Config.js and add your apiKey as "iterableAPIKey".
18-
// Refer to "Creating API Keys" under "API Keys" of the developer guide
18+
// Refer to "Creating API Keys" under "API Keys" of the developer guide
1919
// to create an API key for your Iterable project.
2020
// (https://support.iterable.com/hc/en-us/articles/360043464871#creating-api-keys)
2121

22-
import { iterableAPIKey } from './Config'
22+
import { iterableAPIKey } from './Config';
2323

2424
export default class App extends React.Component {
25-
constructor (props) {
26-
super(props)
27-
28-
this.homeTabRef = React.createRef()
29-
30-
// Step 3: Initialize the React Native SDK here.
31-
// Create an IterableConfig object with various properties set.
32-
// The config object is used to customize various features of the SDK such as the URL handler and custom action handler.
33-
// If a config object is not defined, the React Native SDK defaults to the default configuration.
34-
35-
// The IterableConfig.js file is linked to the documentation.
36-
// Refer to Step 6 of "Installing Iterable's React Native SDK" of the developer guide.
37-
// (https://support.iterable.com/hc/en-us/articles/360045714132-Installing-Iterable-s-React-Native-SDK-#step-6-initialize-iterable-s-react-native-sdk)
38-
39-
// Below is a sample implementation of the config object where we set the urlHAndler and inAppDisplayInterval
40-
41-
const config = new IterableConfig()
42-
43-
// inAppDisplayInterval sets the number of seconds to wait between displaying multiple in-app messages in sequence
44-
config.inAppDisplayInterval = 1.0
45-
46-
// urlHandler is set up here to handle deep link URLs and in-app message buttons and link URLs
47-
config.urlHandler = this.urlHandler
25+
constructor(props) {
26+
super(props);
27+
28+
this.homeTabRef = React.createRef();
29+
30+
// Step 3: Initialize the React Native SDK here.
31+
// Create an IterableConfig object with various properties set.
32+
// The config object is used to customize various features of the SDK such as the URL handler and custom action handler.
33+
// If a config object is not defined, the React Native SDK defaults to the default configuration.
34+
35+
// The IterableConfig.js file is linked to the documentation.
36+
// Refer to Step 6 of "Installing Iterable's React Native SDK" of the developer guide.
37+
// (https://support.iterable.com/hc/en-us/articles/360045714132-Installing-Iterable-s-React-Native-SDK-#step-6-initialize-iterable-s-react-native-sdk)
38+
39+
// Below is a sample implementation of the config object where we set the urlHAndler and inAppDisplayInterval
40+
41+
const config = new IterableConfig();
42+
43+
// inAppDisplayInterval sets the number of seconds to wait between displaying multiple in-app messages in sequence
44+
config.inAppDisplayInterval = 1.0;
45+
46+
// urlHandler is set up here to handle deep link URLs and in-app message buttons and link URLs
47+
config.urlHandler = this.urlHandler;
48+
49+
// Initialize by calling the Iterable.initialize method passing in your API key and the optional config object.
50+
Iterable.initialize(iterableAPIKey, config);
51+
}
52+
render() {
53+
const Tab = createBottomTabNavigator();
54+
return (React.createElement(NavigationContainer, null,
55+
React.createElement(Tab.Navigator, { screenOptions: ({ route }) => ({
56+
tabBarIcon: ({ focused, color, size }) => {
57+
if (route.name == 'Home') {
58+
return React.createElement(Icon, { name: "ios-home", size: size, color: color });
59+
}
60+
else {
61+
return React.createElement(Icon, { name: "ios-settings", size: size, color: color });
62+
}
63+
},
64+
}), tabBarOptions: {
65+
activeTintColor: 'tomato',
66+
inactiveTintColor: 'gray',
67+
showIcon: true,
68+
} },
69+
React.createElement(Tab.Screen, { name: "Home", options: { title: "Coffees" } }, props => React.createElement(HomeTab, Object.assign({ ref: this.homeTabRef }, props))),
70+
React.createElement(Tab.Screen, { name: "Settings", component: SettingsTab }))));
71+
}
4872

49-
// Initialize by calling the Iterable.initialize method passing in your API key and the optional config object.
50-
Iterable.initialize(iterableAPIKey, config)
51-
}
73+
navigate(coffee) {
74+
if (this.homeTabRef && this.homeTabRef.current) {
75+
this.homeTabRef.current.navigate(coffee);
76+
}
77+
}
5278

53-
render () {
54-
const Tab = createBottomTabNavigator()
55-
return (React.createElement(NavigationContainer, null,
56-
React.createElement(Tab.Navigator, {
57-
screenOptions: ({ route }) => ({
58-
tabBarIcon: ({ focused, color, size }) => {
59-
if (route.name === 'Home') {
60-
return React.createElement(Icon, { name: 'ios-home', size, color })
79+
// urlHandler is defined here
80+
urlHandler = (url, context) => {
81+
console.log(`urlHandler, url: ${url}`);
82+
let match = url.match(/coffee\/([^\/]+)/i);
83+
if (match && match.length > 1) {
84+
const id = match[1];
85+
const foundCoffee = coffees.find(coffee => coffee.id == id);
86+
if (foundCoffee) {
87+
this.navigate(foundCoffee);
6188
} else {
62-
return React.createElement(Icon, { name: 'ios-settings', size, color })
89+
console.log(`could not find coffee with id: ${id}`);
6390
}
64-
}
65-
}),
66-
tabBarOptions: {
67-
activeTintColor: 'tomato',
68-
inactiveTintColor: 'gray',
69-
showIcon: true
91+
return true;
92+
} else {
93+
console.log("opening external url");
94+
return false;
7095
}
71-
},
72-
React.createElement(Tab.Screen, { name: 'Home', options: { title: 'Coffees' } }, props => React.createElement(HomeTab, Object.assign({ ref: this.homeTabRef }, props))),
73-
React.createElement(Tab.Screen, { name: 'Settings', component: SettingsTab }))))
74-
}
75-
76-
navigate (coffee) {
77-
if (this.homeTabRef && this.homeTabRef.current) {
78-
this.homeTabRef.current.navigate(coffee)
79-
}
80-
}
81-
82-
// urlHandler is defined here
83-
urlHandler = (url, context) => {
84-
console.log(`urlHandler, url: ${url}`)
85-
const match = url.match(/coffee\/([^]+)/i)
86-
if (match && match.length > 1) {
87-
const id = match[1]
88-
const foundCoffee = coffees.find(coffee => coffee.id === id)
89-
if (foundCoffee) {
90-
this.navigate(foundCoffee)
91-
} else {
92-
console.log(`could not find coffee with id: ${id}`)
93-
}
94-
return true
95-
} else {
96-
console.log('opening external url')
97-
return false
9896
}
99-
}
100-
}
97+
}

SampleApp/javascript/js/Data.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export declare interface Coffee {
2-
id: string
3-
name: string
4-
icon: any
5-
subtitle: string
6-
}
7-
export declare const coffees: Coffee[]
1+
export declare type Coffee = {
2+
id: string;
3+
name: string;
4+
icon: any;
5+
subtitle: string;
6+
};
7+
export declare const coffees: Array<Coffee>;

SampleApp/javascript/js/Data.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
export const coffees = [{
2-
id: 'black',
3-
name: 'Black Coffee',
4-
icon: require('../img/black-coffee.png'),
5-
subtitle: 'It\'s great for weight loss'
6-
}, {
7-
id: 'cappuccino',
8-
name: 'Cappuccino',
9-
icon: require('../img/cappuccino.png'),
10-
subtitle: 'It is tasty'
11-
}, {
12-
id: 'mocha',
13-
name: 'Mocha',
14-
icon: require('../img/mocha.png'),
15-
subtitle: 'Indulge yourself'
16-
}
17-
]
2+
id: "black",
3+
name: 'Black Coffee',
4+
icon: require('../img/black-coffee.png'),
5+
subtitle: 'It\'s great for weight loss'
6+
}, {
7+
id: "cappuccino",
8+
name: 'Cappuccino',
9+
icon: require('../img/cappuccino.png'),
10+
subtitle: 'It is tasty'
11+
}, {
12+
id: 'mocha',
13+
name: 'Mocha',
14+
icon: require('../img/mocha.png'),
15+
subtitle: 'Indulge yourself'
16+
},
17+
];
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Component } from 'react'
2-
import { RouteProp } from '@react-navigation/native'
3-
import { StackNavigationProp } from '@react-navigation/stack'
4-
import { Screens } from './HomeTab'
5-
declare interface DetailScreenProps {
6-
route: RouteProp<Screens, 'Detail'>
7-
navigation: StackNavigationProp<Screens>
8-
}
1+
import { Component } from 'react';
2+
import { RouteProp } from '@react-navigation/native';
3+
import { StackNavigationProp } from '@react-navigation/stack';
4+
import { Screens } from './HomeTab';
5+
declare type DetailScreenProps = {
6+
route: RouteProp<Screens, 'Detail'>;
7+
navigation: StackNavigationProp<Screens>;
8+
};
99
export default class DetailScreen extends Component<DetailScreenProps> {
10-
constructor (props: DetailScreenProps)
11-
render (): JSX.Element
12-
private readonly buyTapped
10+
constructor(props: DetailScreenProps);
11+
render(): JSX.Element;
12+
private buyTapped;
1313
}
14-
export {}
14+
export {};

0 commit comments

Comments
 (0)