-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.3] Add On-Ramp Aggregator What's new modal #4484
Changes from all commits
def2739
2859f2b
2349ff5
27b3fb7
330d8da
b63591f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import { | ||
StyleSheet, | ||
View, | ||
|
@@ -26,7 +26,11 @@ import compareVersions from 'compare-versions'; | |
import PropTypes from 'prop-types'; | ||
import { findRouteNameFromNavigatorState } from '../../../util/general'; | ||
import StyledButton from '../StyledButton'; | ||
import { useAppThemeFromContext, mockTheme } from '../../../util/theme'; | ||
import { | ||
useAppThemeFromContext, | ||
mockTheme, | ||
useAssetFromTheme, | ||
} from '../../../util/theme'; | ||
const modalMargin = 24; | ||
const modalPadding = 24; | ||
const screenWidth = Device.getDeviceWidth(); | ||
|
@@ -51,7 +55,13 @@ const createStyles = (colors) => | |
flex: 1, | ||
width: slideItemWidth, | ||
paddingHorizontal: modalPadding, | ||
}, | ||
slideItemContainerContent: { | ||
paddingBottom: 16, | ||
flexGrow: 1, | ||
}, | ||
slide: { | ||
flex: 1, | ||
}, | ||
progessContainer: { | ||
flexDirection: 'row', | ||
|
@@ -119,12 +129,13 @@ const createStyles = (colors) => | |
}); | ||
|
||
const WhatsNewModal = (props) => { | ||
const scrollViewRef = useRef(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ref is later used to scroll when indicators are pressed. |
||
const [featuresToShow, setFeaturesToShow] = useState(null); | ||
const [show, setShow] = useState(false); | ||
const routes = useNavigationState((state) => state.routes); | ||
const slideIds = [0, 1]; | ||
const [currentSlide, setCurrentSlide] = useState(slideIds[0]); | ||
const [currentSlide, setCurrentSlide] = useState(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. slides where fixed to be 2, this is now agnostic of the length of the slides coming from |
||
const { colors } = useAppThemeFromContext() || mockTheme; | ||
const imageKey = useAssetFromTheme('light', 'dark'); | ||
const styles = createStyles(colors); | ||
|
||
useEffect(() => { | ||
|
@@ -208,16 +219,23 @@ const WhatsNewModal = (props) => { | |
return (element = ( | ||
<Text style={styles.slideDescription}>{elementInfo.description}</Text> | ||
)); | ||
case 'image': | ||
case 'image': { | ||
let image; | ||
if (elementInfo.images) { | ||
image = elementInfo.images[imageKey]; | ||
} else { | ||
image = elementInfo.image; | ||
} | ||
return ( | ||
<View style={styles.slideImageContainer}> | ||
<Image | ||
source={elementInfo.image} | ||
source={image} | ||
style={styles.slideImage} | ||
resizeMode={'stretch'} | ||
/> | ||
</View> | ||
); | ||
} | ||
case 'button': | ||
return ( | ||
<View style={styles.button}> | ||
|
@@ -236,9 +254,13 @@ const WhatsNewModal = (props) => { | |
const renderSlide = (slideInfo, index) => { | ||
const key = `slide-info-${index}`; | ||
return ( | ||
<ScrollView key={key} style={styles.slideItemContainer}> | ||
<ScrollView | ||
key={key} | ||
style={styles.slideItemContainer} | ||
contentContainerStyle={styles.slideItemContainerContent} | ||
> | ||
<TouchableWithoutFeedback> | ||
<View> | ||
<View style={styles.slide}> | ||
Comment on lines
+257
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This allows slides to be full height |
||
{slideInfo.map((elementInfo, elIndex) => { | ||
const elKey = `${key}-${elIndex}`; | ||
return <View key={elKey}>{renderSlideElement(elementInfo)}</View>; | ||
|
@@ -276,13 +298,15 @@ const WhatsNewModal = (props) => { | |
onPress={closeModal} | ||
hitSlop={{ top: 10, left: 10, bottom: 10, right: 10 }} | ||
> | ||
<Icon name="times" size={16} /> | ||
<Icon name="times" size={16} color={colors.icon.default} /> | ||
</TouchableOpacity> | ||
</View> | ||
</View> | ||
{featuresToShow && ( | ||
{whatsNew.slides.length > 0 && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conditionally rendering based on |
||
<View style={styles.slideContent}> | ||
<ScrollView | ||
ref={scrollViewRef} | ||
scrollEnabled={whatsNew.slides.length > 1} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ref is used to scroll then indicators are pressed. Scroll is disabled if there's only one page. |
||
// This is not duplicate. Needed for Android. | ||
onScrollEndDrag={onScrollEnd} | ||
onMomentumScrollEnd={onScrollEnd} | ||
|
@@ -292,17 +316,30 @@ const WhatsNewModal = (props) => { | |
> | ||
{whatsNew.slides.map(renderSlide)} | ||
</ScrollView> | ||
<View style={styles.progessContainer}> | ||
{slideIds.map((id) => ( | ||
<View | ||
key={id} | ||
style={[ | ||
styles.slideCircle, | ||
currentSlide === id ? styles.slideSolidCircle : {}, | ||
]} | ||
/> | ||
))} | ||
</View> | ||
{whatsNew.slides.length > 1 && ( | ||
<View style={styles.progessContainer}> | ||
{whatsNew.slides.map((_, index) => ( | ||
<TouchableWithoutFeedback | ||
key={`slide-circle-${index}`} | ||
onPress={() => { | ||
scrollViewRef?.current?.scrollTo({ | ||
y: 0, | ||
x: index * slideItemWidth, | ||
}); | ||
setCurrentSlide(index); | ||
}} | ||
hitSlop={{ top: 8, left: 8, bottom: 8, right: 8 }} | ||
> | ||
<View | ||
style={[ | ||
styles.slideCircle, | ||
currentSlide === index && styles.slideSolidCircle, | ||
]} | ||
/> | ||
</TouchableWithoutFeedback> | ||
))} | ||
</View> | ||
)} | ||
</View> | ||
)} | ||
</View> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import Routes from '../../../constants/navigation/Routes'; | ||
import { strings } from '../../../../locales/i18n'; | ||
import { WhatsNew } from './types'; | ||
|
||
export const whatsNew: WhatsNew = { | ||
// All users that have <1.0.7 and are updating to >=1.0.7 should see | ||
onlyUpdates: true, // Only users who updated the app will see this, not newly installs | ||
maxLastAppVersion: '1.0.7', // Only users who had a previous version <1.0.7 version will see this | ||
minAppVersion: '1.0.7', // Only users who updated to a version >= 1.0.7 will see this | ||
slides: [[], [], []], | ||
// All users that have <5.3.0 and are updating to >=5.3.0 should see | ||
onlyUpdates: false, // Only users who updated the app will see this, not newly installs | ||
maxLastAppVersion: '5.3.0', // Only users who had a previous version <5.3.0 version will see this | ||
minAppVersion: '5.3.0', // Only users who updated to a version >=5.3.0 will see this | ||
slides: [ | ||
[ | ||
{ | ||
type: 'image', | ||
/* eslint-disable import/no-commonjs, @typescript-eslint/no-require-imports */ | ||
images: { | ||
light: require('../../../images/whats_new_onramp_agg_light.png'), | ||
dark: require('../../../images/whats_new_onramp_agg_dark.png'), | ||
}, | ||
}, | ||
{ | ||
type: 'title', | ||
title: strings('whats_new.feature_on_ramp_title'), | ||
}, | ||
{ | ||
type: 'description', | ||
description: strings('whats_new.feature_on_ramp_text'), | ||
}, | ||
{ | ||
type: 'button', | ||
buttonType: 'blue', | ||
buttonText: strings('whats_new.feature_on_ramp_button'), | ||
onPress: ({ navigation }) => | ||
navigation.navigate(Routes.FIAT_ON_RAMP_AGGREGATOR.ID), | ||
}, | ||
], | ||
], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows the slide to be full height