Skip to content

Commit

Permalink
Merge pull request #505 from devcsomnicg/MB_CardView
Browse files Browse the repository at this point in the history
Mb card view
  • Loading branch information
evantk91 authored Mar 22, 2024
2 parents a5b6e7f + 59e5755 commit f5a9bc6
Show file tree
Hide file tree
Showing 16 changed files with 403 additions and 81 deletions.
43 changes: 16 additions & 27 deletions SampleApp/javascript/js/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Icon from 'react-native-vector-icons/Ionicons';
import HomeTab from './HomeTab';
import SettingsTab from './SettingsTab';
import { coffees } from './Data';
import { createStackNavigator } from '@react-navigation/stack';
import HomeScreen from './HomeScreen';
import CardViewScreen from './CardViewScreen';

const Stack = createStackNavigator();

// Step 1:
// Import the Iterable and IterableConfig class.
Expand All @@ -26,7 +27,7 @@ export default class App extends React.Component {
super(props);

this.homeTabRef = React.createRef();

// Step 3: Initialize the React Native SDK here.
// Create an IterableConfig object with various properties set.
// The config object is used to customize various features of the SDK such as the URL handler and custom action handler.
Expand All @@ -37,37 +38,25 @@ export default class App extends React.Component {
// (https://support.iterable.com/hc/en-us/articles/360045714132-Installing-Iterable-s-React-Native-SDK-#step-6-initialize-iterable-s-react-native-sdk)

// Below is a sample implementation of the config object where we set the urlHAndler and inAppDisplayInterval

const config = new IterableConfig();

// inAppDisplayInterval sets the number of seconds to wait between displaying multiple in-app messages in sequence
config.inAppDisplayInterval = 1.0;

// urlHandler is set up here to handle deep link URLs and in-app message buttons and link URLs
config.urlHandler = this.urlHandler;

// Initialize by calling the Iterable.initialize method passing in your API key and the optional config object.
Iterable.initialize(iterableAPIKey, config);
}
render() {
const Tab = createBottomTabNavigator();
return (React.createElement(NavigationContainer, null,
React.createElement(Tab.Navigator, { screenOptions: ({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
if (route.name == 'Home') {
return React.createElement(Icon, { name: "ios-home", size: size, color: color });
}
else {
return React.createElement(Icon, { name: "ios-settings", size: size, color: color });
}
},
}), tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
showIcon: true,
} },
React.createElement(Tab.Screen, { name: "Home", options: { title: "Coffees" } }, props => React.createElement(HomeTab, Object.assign({ ref: this.homeTabRef }, props))),
React.createElement(Tab.Screen, { name: "Settings", component: SettingsTab }))));
return (<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="CardView" component={CardViewScreen} />
</Stack.Navigator>
</NavigationContainer>)
}

navigate(coffee) {
Expand Down
13 changes: 13 additions & 0 deletions SampleApp/javascript/js/CardViewScreen.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from 'react';
import { RouteProp } from '@react-navigation/native';
import { StackNavigationProp } from '@react-navigation/stack';

declare type CardViewScreenProps = {
route: RouteProp<any>;
navigation: StackNavigationProp<any>;
};
export default class CardViewScreen extends Component<CardViewScreenProps> {
constructor(props: CardViewScreenProps);
render(): JSX.Element;
}
export {};
25 changes: 25 additions & 0 deletions SampleApp/javascript/js/CardViewScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { Component } from 'react';
import { View } from 'react-native';
import IterableCardView from './components/IterableCardView';

export default class CardViewScreen extends Component {
constructor(props) {
super(props);
}

render() {
return <View style={{ flex: 1, padding: 10 }}>
<IterableCardView
titleText='Card View 1'
subTitleText='Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum'
isShowbtnSecondary={true}
/>
<IterableCardView
titleText='Card View 2'
subTitleText='Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum 2233'
imgSrc='https://codesymphony.in/assets/projects/sonetel/Sonetel%205.png'
isShowbtnSecondary={true}
/>
</View>
}
}
4 changes: 2 additions & 2 deletions SampleApp/javascript/js/HomeScreen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Component } from 'react';
import { RouteProp } from '@react-navigation/native';
import { StackNavigationProp } from '@react-navigation/stack';
import { Screens } from './HomeTab';
import { Coffee } from './Data';

declare type HomeScreenProps = {
route: RouteProp<Screens, 'Home'>;
navigation: StackNavigationProp<Screens>;
};
export default class HomeScreen extends Component<HomeScreenProps> {
constructor(props: HomeScreenProps);
navigate(coffee: Coffee): void;
navigate(): void;
render(): JSX.Element;
}
export {};
35 changes: 27 additions & 8 deletions SampleApp/javascript/js/HomeScreen.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import React, { Component } from 'react';
import { View, } from 'react-native';
import { ListItem } from 'react-native-elements';
import { coffees } from './Data';
import { TouchableOpacity, View, Text } from 'react-native';

export default class HomeScreen extends Component {
constructor(props) {
super(props);
}
navigate(coffee) {
this.props.navigation.navigate('Detail', { coffee: coffee });

navigateToCardView() {
this.props.navigation.navigate('CardView');
}

navigateToNotificationView() {
console.log("Notification View");
}

navigateToBannerView() {
console.log("Banner View");
}

render() {
return (React.createElement(View, null, coffees.map((coffee, i) => (React.createElement(ListItem, { onPress: () => {
this.props.navigation.navigate('Detail', { coffee: coffee });
}, key: i, leftAvatar: { source: coffee.icon }, title: coffee.name, subtitle: coffee.subtitle, bottomDivider: true, chevron: true })))));
return <View style={{ flex: 1, padding: 10 }}>
<TouchableOpacity style={{ padding: 10, width: '100%', justifyContent: 'center' }} onPress={() => this.navigateToCardView()}>
<Text style={{ textAlign: 'center', color: 'blue', fontSize: 16 }}>{"Card View Demo"}</Text>
</TouchableOpacity>

<TouchableOpacity style={{ padding: 10, width: '100%', justifyContent: 'center' }} onPress={() => this.navigateToNotificationView()}>
<Text style={{ textAlign: 'center', color: 'blue', fontSize: 16 }}>{"Notification View Demo"}</Text>
</TouchableOpacity>

<TouchableOpacity style={{ padding: 10, width: '100%', justifyContent: 'center' }} onPress={() => this.navigateToBannerView()}>
<Text style={{ textAlign: 'center', color: 'blue', fontSize: 16 }}>{"Banner View Demo"}</Text>
</TouchableOpacity>
</View>
}
}
2 changes: 1 addition & 1 deletion SampleApp/javascript/js/HomeTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class HomeTab extends Component {
render() {
const HomeStack = createStackNavigator();
return (React.createElement(HomeStack.Navigator, null,
React.createElement(HomeStack.Screen, { name: "Home", options: { headerTitle: "Coffees" } }, props => React.createElement(HomeScreen, Object.assign({}, props, { ref: this.homeScreenRef }))),
React.createElement(HomeStack.Screen, { name: "Home", options: { headerTitle: "Home" } }, props => React.createElement(HomeScreen, Object.assign({}, props, { ref: this.homeScreenRef }))),
React.createElement(HomeStack.Screen, { name: "Detail", options: { headerTitle: "Coffee" }, component: DetailScreen })));
}
}
74 changes: 74 additions & 0 deletions SampleApp/javascript/js/components/IterableCardView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// @ts-nocheck
import React from 'react'
import {
View,
Text,
StyleSheet,
Image,
TouchableOpacity
} from 'react-native'
import {
containerProps,
imageProps,
titleLabelProps,
subTitleLabelProps,
btnPrimaryProps,
btnSecondaryProps
} from '../types/commonType';

type cardViewProps = containerProps & imageProps & titleLabelProps & subTitleLabelProps & btnPrimaryProps & btnSecondaryProps

const IterableCardView = (props: cardViewProps) => {

const imgURI = props?.imgSrc ? props.imgSrc : 'https://codesymphony.in/assets/projects/noobstrom/noob-web-4.png';
const cardBorderRadius = props.borderRadius ? props.borderRadius : 10;

return (
<View style={{
marginBottom: 10,
borderRadius: cardBorderRadius,
backgroundColor: props?.backgroundColor ? props?.backgroundColor : '#E4E4E4',
shadowColor: props?.shadowColor ? props?.shadowColor : '#470000',
shadowOffset: {
width: props?.shadowWidth ? props?.shadowWidth : 0,
height: props?.shadowHeight ? props?.shadowHeight : 1
},
shadowOpacity: props?.shadowOpacity ? props?.shadowOpacity : 0.2,
elevation: 1
}}>
<View style={{ height: 150, width: '100%' }}>
<Image source={{ uri: imgURI }} style={{ height: props?.imgHeight ? props?.imgHeight : '100%', width: props?.imgWidth ? props?.imgWidth : '100%' }} />
</View>
<View style={{ marginLeft: 20 }}>
<Text style={{ fontSize: props?.titleFontSize ? props?.titleFontSize : 18, color: props?.titleTextColor ? props?.titleTextColor : 'black', marginVertical: 10, fontWeight: '700' }}>
{props?.titleText ? props?.titleText : 'Card View Title'}
</Text>
<Text style={{ fontSize: props?.subTitleFontSize ? props?.subTitleFontSize : 16, color: props?.subTitleTextColor ? props?.subTitleTextColor : 'black', marginVertical: 6 }}>
{props?.subTitleText ? props?.subTitleText : "Lorem ipsum dummy text, Lorem ipsum dummy text, Lorem ipsum dummy text, Lorem ipsum dummy text"}
</Text>
<View style={{ flexDirection: 'row', alignItems: 'center', marginVertical: 18 }}>
<TouchableOpacity onPress={() => props?.btnPrimaryOnClick ? props?.btnPrimaryOnClick() : null} style={{ justifyContent: 'center', alignItems: 'center' }}>
<Text style={{
fontSize: props?.btnPrimaryFontSize ? props?.btnPrimaryFontSize : 14,
color: props?.btnPrimaryTextColor ? props?.btnPrimaryTextColor : 'black',
fontWeight: 'bold'
}}>
{props?.btnPrimaryText ? props.btnPrimaryText : "Learn more"}
</Text>
</TouchableOpacity>
{props?.isShowbtnSecondary ? <TouchableOpacity onPress={() => props?.btnSecondaryOnClick ? props?.btnSecondaryOnClick() : null} style={{ justifyContent: 'center', alignItems: 'center', marginLeft: 20 }}>
<Text style={{
fontSize: props?.btnSecondaryFontSize ? props?.btnSecondaryFontSize : 14,
color: props?.btnSecondaryTextColor ? props?.btnSecondaryTextColor : 'black',
fontWeight: 'bold'
}}>
{props?.btnSecondaryText ? props?.btnSecondaryText : "action"}
</Text>
</TouchableOpacity> : null}
</View>
</View>
</View>
)
}

export default IterableCardView
45 changes: 45 additions & 0 deletions SampleApp/javascript/js/types/commonType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export type containerProps = {
borderRadius?: number,
backgroundColor?: string,
shadowColor?: string,
shadowWidth?: number,
shadowHeight?: number,
shadowOpacity?: number
}

export type imageProps = {
imgHeight?: number,
imgWidth?: number,
imgSrc: string
}

export type titleLabelProps = {
titleText: string,
titleFontSize?: number,
titleTextColor?: string,
}

export type subTitleLabelProps = {
subTitleText: string,
subTitleFontSize?: number,
subTitleTextColor?: string,
}

export type btnPrimaryProps = {
btnPrimaryText: string,
btnPrimaryFontSize?: number,
btnPrimaryTextColor?: string,
btnPrimaryBorderRadius?: number,
btnPrimaryBgColor?: string,
btnPrimaryOnClick?: Function
}

export type btnSecondaryProps = {
btnSecondaryText: string,
btnSecondaryFontSize?: number,
btnSecondaryTextColor?: string,
btnSecondaryBorderRadius?: number,
btnSecondaryBgColor?: string,
isShowbtnSecondary?: boolean,
btnSecondaryOnClick?: Function
}
7 changes: 4 additions & 3 deletions SampleApp/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
"@react-navigation/bottom-tabs": "^5.4.5",
"@react-navigation/native": "^5.4.0",
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"@react-navigation/stack": "^5.3.7",
"react": "^17.0.2",
"react-native": "^0.64.1",
"react-native-elements": "^1.2.7",
"react-native-gesture-handler": "^1.6.1",
"react-native-ionicons": "^5.0.0-rc",
"react-native-reanimated": "^1.8.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.7.0",
"react-native-safe-area-context": "^4.7.1",
"react-native-screens": "^3.22.1",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^4.3.9",
"react-navigation-tabs": "^2.8.13"
Expand Down
Loading

0 comments on commit f5a9bc6

Please sign in to comment.