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

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

merged 3 commits into from
Jan 28, 2025

Conversation

thoreyjona
Copy link
Contributor

@thoreyjona thoreyjona commented Jan 28, 2025

What

  • Add feature flag to hide add to wallet button on license screen
  • Decrease spacing above license information
  • Increase spacing below add to wallet button
  • Make sure loader for status takes up the same space as the content
  • Equal margin top and bottom for licenses that do not have barcodes

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a feature flag to control the visibility of the "Add to Wallet" button
    • Enhanced flexibility of license card layout with dynamic margin configuration
  • Improvements

    • Updated rendering logic for wallet pass screen
    • Improved component adaptability based on feature flags and prop states

These changes provide more control over UI elements and enhance the overall user experience with more dynamic component rendering.

@thoreyjona thoreyjona requested a review from a team as a code owner January 28, 2025 17:13
Copy link
Contributor

coderabbitai bot commented Jan 28, 2025

Walkthrough

This pull request introduces a new feature flag isAddToWalletButtonEnabled in the WalletPassScreen component, which controls the visibility of the "Add to Wallet" button. The changes modify the layout and rendering logic to accommodate this flag, ensuring dynamic button display and appropriate spacing. Additionally, the LicenseCard component's ContentContainer has been updated to support more flexible margin configuration based on the presence of a barcode prop.

Changes

File Change Summary
apps/native/app/src/screens/wallet-pass/wallet-pass.tsx - Added feature flag isAddToWalletButtonEnabled
- Updated informationTopSpacing calculation
- Modified useEffect hook to depend on new flag
- Conditionally render "Add to Wallet" button
apps/native/app/src/ui/lib/card/license-card.tsx - Updated ContentContainer styled component
- Added dynamic marginBottom prop
- Conditional margin setting based on barcode prop

Sequence Diagram

sequenceDiagram
    participant User
    participant WalletPassScreen
    participant FeatureFlag
    
    User->>WalletPassScreen: Loads screen
    WalletPassScreen->>FeatureFlag: Check isAddToWalletButtonEnabled
    FeatureFlag-->>WalletPassScreen: Return flag status
    alt Flag is true
        WalletPassScreen->>User: Display "Add to Wallet" button
    else Flag is false
        WalletPassScreen->>User: Hide "Add to Wallet" button
    end
Loading

Possibly related PRs

Suggested labels

automerge, autoupdate

Suggested reviewers

  • snaerseljan
  • eirikurn

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/native/app/src/screens/wallet-pass/wallet-pass.tsx (1)

190-204: Consider extracting spacing calculations into separate functions.

The spacing calculations are complex and would be more maintainable if extracted into named functions.

+const calculateInformationTopSpacing = (
+  allowLicenseBarcode: boolean,
+  loading: boolean,
+  hasBarcode: boolean,
+  isConnected: boolean,
+  error: boolean,
+  isBarcodeEnabled: boolean,
+  barcodeHeight: number,
+  theme: Theme
+) => {
+  return (allowLicenseBarcode && ((loading && !hasBarcode) || hasBarcode)) ||
+    ((!isConnected || error) && isBarcodeEnabled)
+    ? barcodeHeight + LICENSE_CARD_ROW_GAP + theme.spacing[4]
+    : theme.spacing[2]
+}
+
+const calculateBottomInset = (
+  informationTopSpacing: number,
+  isConnected: boolean,
+  isBarcodeEnabled: boolean,
+  isTablet: boolean,
+  allowLicenseBarcode: boolean,
+  isAddToWalletButtonEnabled: boolean
+) => {
+  return informationTopSpacing || (!isConnected && isBarcodeEnabled)
+    ? isTablet
+      ? 340
+      : !allowLicenseBarcode
+      ? 80
+      : isAddToWalletButtonEnabled
+      ? 182
+      : 192
+    : 0
+}

-  const informationTopSpacing =
-    (allowLicenseBarcode && ((loading && !data?.barcode) || data?.barcode)) ||
-    ((!isConnected || res.error) && isBarcodeEnabled)
-      ? barcodeHeight + LICENSE_CARD_ROW_GAP + theme.spacing[4]
-      : theme.spacing[2]
-
-  const bottomInset =
-    informationTopSpacing || (!isConnected && isBarcodeEnabled)
-      ? isTablet
-        ? 340
-        : !allowLicenseBarcode
-        ? 80
-        : isAddToWalletButtonEnabled
-        ? 182
-        : 192
-      : 0
+  const informationTopSpacing = calculateInformationTopSpacing(
+    allowLicenseBarcode,
+    loading,
+    !!data?.barcode,
+    isConnected,
+    !!res.error,
+    isBarcodeEnabled,
+    barcodeHeight,
+    theme
+  )
+
+  const bottomInset = calculateBottomInset(
+    informationTopSpacing,
+    isConnected,
+    isBarcodeEnabled,
+    isTablet,
+    allowLicenseBarcode,
+    isAddToWalletButtonEnabled
+  )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 414edc7 and a41db93.

📒 Files selected for processing (2)
  • apps/native/app/src/screens/wallet-pass/wallet-pass.tsx (5 hunks)
  • apps/native/app/src/ui/lib/card/license-card.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/native/app/src/ui/lib/card/license-card.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/native/app/src/screens/wallet-pass/wallet-pass.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (6)
apps/native/app/src/ui/lib/card/license-card.tsx (2)

40-43: LGTM! Well-implemented dynamic margin.

The styled component now properly handles dynamic margin based on props, improving layout flexibility.


185-185: LGTM! Proper usage of the dynamic margin.

The margin is correctly calculated using theme spacing and conditional logic.

apps/native/app/src/screens/wallet-pass/wallet-pass.tsx (4)

152-155: LGTM! Well-implemented feature flag.

The feature flag follows the existing pattern and maintains backward compatibility with a default value of true.


210-210: LGTM! Proper useEffect dependency update.

The isAddToWalletButtonEnabled flag is correctly added to the dependencies array since it affects the layout.


444-444: LGTM! Proper usage of bottomInset.

The contentInset is correctly updated to use the calculated bottomInset value.


495-495: LGTM! Proper implementation of the feature flag in button rendering.

The button visibility is correctly controlled by the isAddToWalletButtonEnabled flag while maintaining the existing animation logic.

Also applies to: 505-505

@thoreyjona thoreyjona added this pull request to the merge queue Jan 28, 2025
Merged via the queue into main with commit d0b3355 Jan 28, 2025
29 checks passed
@thoreyjona thoreyjona deleted the fix/more-license-fixes branch January 28, 2025 17:32
robertaandersen pushed a commit that referenced this pull request Jan 29, 2025
* fix: spacing for license info and add to wallet button

* feat: add feature flag to show/hide add to wallet button

* fix: spacing on license card
RunarVestmann pushed a commit that referenced this pull request Jan 29, 2025
* fix: spacing for license info and add to wallet button

* feat: add feature flag to show/hide add to wallet button

* fix: spacing on license card
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants