Skip to content
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

fix(native-app): more license fixes #17699

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions apps/native/app/src/screens/wallet-pass/wallet-pass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export const WalletPassScreen: NavigationFunctionComponent<{
const intl = useIntl()
const [addingToWallet, setAddingToWallet] = useState(false)
const isBarcodeEnabled = useFeatureFlag('isBarcodeEnabled', false)
const isAddToWalletButtonEnabled = useFeatureFlag(
'isAddToWalletButtonEnabled',
true,
)
const fadeInAnim = useRef(new Animated.Value(0)).current
const isConnected = useOfflineStore(({ isConnected }) => isConnected)

Expand Down Expand Up @@ -183,15 +187,27 @@ export const WalletPassScreen: NavigationFunctionComponent<{
const informationTopSpacing =
(allowLicenseBarcode && ((loading && !data?.barcode) || data?.barcode)) ||
((!isConnected || res.error) && isBarcodeEnabled)
? barcodeHeight + LICENSE_CARD_ROW_GAP + theme.spacing[5]
? barcodeHeight + LICENSE_CARD_ROW_GAP + theme.spacing[4]
: theme.spacing[2]

// Calculate bottom inset based on the content
const bottomInset =
informationTopSpacing || (!isConnected && isBarcodeEnabled)
? isTablet
? 340
: !allowLicenseBarcode
? 80 // less spacing needed if no barcode available (expired or not available)
: isAddToWalletButtonEnabled
? 182
: 192 // Extra spacing needed at bottom if no button is shown
: 0

const [key, setKey] = useState(0)
useEffect(() => {
// Used to rerender ScrollView to have correct ContentInset based on barcode/no barcode
// Remove once barcodes are live
setKey((prev) => prev + 1)
}, [isBarcodeEnabled])
}, [isBarcodeEnabled, isAddToWalletButtonEnabled])

const fadeIn = () => {
Animated.timing(fadeInAnim, {
Expand Down Expand Up @@ -425,12 +441,7 @@ export const WalletPassScreen: NavigationFunctionComponent<{
</LicenseCardWrapper>
<Information
contentInset={{
bottom:
informationTopSpacing || (!isConnected && isBarcodeEnabled)
? isTablet
? 340
: 162
: 0,
bottom: bottomInset,
}}
key={key}
topSpacing={informationTopSpacing}
Expand Down Expand Up @@ -481,7 +492,7 @@ export const WalletPassScreen: NavigationFunctionComponent<{
)}
</SafeAreaView>

{pkPassAllowed && isBarcodeEnabled && (
{isAddToWalletButtonEnabled && pkPassAllowed && isBarcodeEnabled && (
<ButtonWrapper>{renderButtons()}</ButtonWrapper>
)}
{isAndroid && <Spacer />}
Expand All @@ -491,7 +502,7 @@ export const WalletPassScreen: NavigationFunctionComponent<{
The reason for the animation is to avoid rendering flicker.
The component will on first render the isBarcodeEnabled flag to be false and then set it to true after Configcat has fetched the flag.
*/}
{pkPassAllowed && !isBarcodeEnabled && (
{isAddToWalletButtonEnabled && pkPassAllowed && !isBarcodeEnabled && (
<ButtonWrapper floating>
<Animated.View style={{ opacity: fadeInAnim }}>
{renderButtons()}
Expand Down
7 changes: 3 additions & 4 deletions apps/native/app/src/ui/lib/card/license-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const Host = styled(Animated.View)`
justify-content: center;
`

const ContentContainer = styled.View`
const ContentContainer = styled.View<{ marginBottom: number }>`
flex-direction: row;
justify-content: space-between;
margin-bottom: ${({ theme }) => theme.spacing[1]}px;
margin-bottom: ${({ marginBottom }) => marginBottom}px;
`

const BarcodeWrapper = styled.View<{ minHeight?: number }>`
Expand Down Expand Up @@ -182,7 +182,7 @@ export function LicenseCard({
color={backgroundColor}
resizeMode="cover"
/>
<ContentContainer>
<ContentContainer marginBottom={barcode ? theme.spacing[1] : 0}>
<Content>
<Title
numberOfLines={1}
Expand All @@ -202,7 +202,6 @@ export function LicenseCard({
width: 62,
borderRadius: 4,
opacity: 0.5,
marginBottom: theme.spacing.smallGutter,
}}
/>
) : (
Expand Down
Loading