From 872a2dc190eb4208774ff69d125d47b4a4bea7d4 Mon Sep 17 00:00:00 2001 From: Cal Leung Date: Wed, 8 Jun 2022 12:57:50 -0700 Subject: [PATCH] Change whatsNewList to ts --- app/components/UI/WhatsNewModal/types.ts | 47 +++++++++++++++++++ .../{whatsNewList.js => whatsNewList.ts} | 0 2 files changed, 47 insertions(+) create mode 100644 app/components/UI/WhatsNewModal/types.ts rename app/components/UI/WhatsNewModal/{whatsNewList.js => whatsNewList.ts} (100%) diff --git a/app/components/UI/WhatsNewModal/types.ts b/app/components/UI/WhatsNewModal/types.ts new file mode 100644 index 00000000000..e125eb09b4e --- /dev/null +++ b/app/components/UI/WhatsNewModal/types.ts @@ -0,0 +1,47 @@ +import { ImageSourcePropType } from 'react-native'; + +interface SlideImage { + type: 'image'; + image: ImageSourcePropType; +} + +interface SlideTitle { + type: 'title'; + title: string; +} + +interface SlideDescription { + type: 'description'; + description: string; +} + +type SlideButtonType = 'normal' | 'blue'; + +interface SlideButton { + type: 'button'; + buttonType: SlideButtonType; + buttonText: string; + onPress: (props: { navigation: any }) => void; +} + +type SlideContentType = + | SlideImage + | SlideTitle + | SlideDescription + | SlideButton; + +type WhatsNewSlides = SlideContentType[][]; + +export interface WhatsNew { + onlyUpdates: boolean; + maxLastAppVersion: string; + minAppVersion: string; + /** + * Slides utilizes a templating system in the form of a 2D array, which is eventually rendered within app/components/UI/WhatsNewModal/index.js. + * The root layer determines the number of slides. Ex. To display 3 slides, the root layer should contain 3 arrays. + * The inner layer determines the content that will be rendered within each slide. + * The slide content takes the form of union types, where the possible types are `image`, `title`, `description`, or `button`. + * Both slide count and slide content will be rendered in the same order as the data set. + */ + slides: WhatsNewSlides; +} diff --git a/app/components/UI/WhatsNewModal/whatsNewList.js b/app/components/UI/WhatsNewModal/whatsNewList.ts similarity index 100% rename from app/components/UI/WhatsNewModal/whatsNewList.js rename to app/components/UI/WhatsNewModal/whatsNewList.ts