Skip to content

Commit

Permalink
News push notification screen
Browse files Browse the repository at this point in the history
  • Loading branch information
devkudasov committed May 6, 2024
1 parent b2a5765 commit f6f1477
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/components/popup/dismiss-popup-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const DismissPopupButton = () => {
style={page.container}
testID="dismissPopupButton"
onPress={() => {
if (navigation.canGoBack()) {
try {
navigation.pop();
} catch (e) {
navigation.goBack();
}
}}>
Expand Down
17 changes: 7 additions & 10 deletions src/event-actions/on-push-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {News} from '@app/models/news';
import {VariablesBool} from '@app/models/variables-bool';
import {Wallet} from '@app/models/wallet';
import {navigator} from '@app/navigator';
import {NewsStackRoutes} from '@app/route-types';
import {HomeStackRoutes} from '@app/route-types';
import {Backend} from '@app/services/backend';
import {MarketingEvents, RaffleStatus, RemoteMessage} from '@app/types';
import {WEI} from '@app/variables/common';
Expand Down Expand Up @@ -51,15 +51,12 @@ export async function onPushNotification(message: RemoteMessage<Data>) {

VariablesBool.set('isNewNews', true);
}
navigator.navigate('homeNews', {
// @ts-ignore
screen: NewsStackRoutes.NewsDetail,
params: {
id: id,
openEvent: MarketingEvents.newsOpenPushItem,
linkEvent: MarketingEvents.newsOpenPushLink,
scrollEvent: MarketingEvents.newsScrolledPushItem,
},

navigator.navigate(HomeStackRoutes.NewsDetailPushNotification, {
id: id,
openEvent: MarketingEvents.newsOpenPushItem,
linkEvent: MarketingEvents.newsOpenPushLink,
scrollEvent: MarketingEvents.newsScrolledPushItem,
});
break;
case PushNotificationTypes.raffle:
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/get-news-detail-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function getNewsDetailTitle(props: {
}

export function getNewsDetailAppTitle(props: {
route: RouteProp<RootStackParamList, 'newsDetail'>;
route: RouteProp<
RootStackParamList,
'newsDetail' | 'newsDetailsPushNotification'
>;
navigation: any;
}): NativeStackNavigationOptions {
const news = News.getById(props.route.params.id);
Expand Down
7 changes: 7 additions & 0 deletions src/route-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export enum HomeStackRoutes {
ValueSelector = 'valueSelector',
BrowserPrivacyPopupStack = 'browserPrivacyPopupStack',
Device = '_device',
NewsDetailPushNotification = 'newsDetailsPushNotification',
}

export type HomeStackParamList = {
Expand Down Expand Up @@ -453,6 +454,12 @@ export type HomeStackParamList = {
screen: 'browserPrivacyDetails' | 'browserPrivacy';
params?: RootStackParamList[RootStackParamList['browserPrivacyPopupStack']['screen']];
};
[HomeStackRoutes.NewsDetailPushNotification]: {
id: string;
openEvent: MarketingEvents;
linkEvent: MarketingEvents;
scrollEvent: MarketingEvents;
};
};

export enum NftStackRoutes {
Expand Down
12 changes: 12 additions & 0 deletions src/screens/HomeStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {Color} from '@app/colors';
import {DismissPopupButton} from '@app/components/popup/dismiss-popup-button';
import {Spacer} from '@app/components/ui';
import {popupScreenOptionsWithMargin} from '@app/helpers';
import {getNewsDetailAppTitle} from '@app/helpers/get-news-detail-title';
import {getWalletTitle} from '@app/helpers/get-wallet-title';
import {themeUpdaterHOC} from '@app/helpers/theme-updater-hoc';
import {I18N, getText} from '@app/i18n';
Expand Down Expand Up @@ -43,6 +44,8 @@ import {WalletSelectorScreen} from '@app/screens/wallet-selector-screen';
import {Web3BrowserPopup as Web3BrowserPopupScreen} from '@app/screens/web3-browser-popup';
import {SignInStack} from '@app/screens/WelcomeStack/SignInStack';

import {NewsDetailScreen} from './HomeNewsStack/news-detail';

const navigatorOptions: NativeStackNavigationOptions = {
gestureEnabled: false,
freezeOnBlur: true,
Expand Down Expand Up @@ -247,6 +250,15 @@ const HomeStack = memo(() => {
component={themeUpdaterHOC(InAppBrowserScreen)}
options={inAppBrowserOptions}
/>

<Stack.Screen
name={HomeStackRoutes.NewsDetailPushNotification}
component={themeUpdaterHOC(NewsDetailScreen)}
options={props => ({
...getNewsDetailAppTitle(props),
disableMargin: false,
})}
/>
</Stack.Navigator>
);
});
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@ export type RootStackParamList = {
nftItemDetails: {
item: NftItem;
};
newsDetailsPushNotification: {
id: string;
openEvent: MarketingEvents;
linkEvent: MarketingEvents;
scrollEvent: MarketingEvents;
};
};

export type StackPresentationTypes =
Expand Down

0 comments on commit f6f1477

Please sign in to comment.