Skip to content

Added an If condition for QRCode.Builder#68

Merged
dagronf merged 1 commit intodagronf:mainfrom
vicvoh:main
Nov 16, 2025
Merged

Added an If condition for QRCode.Builder#68
dagronf merged 1 commit intodagronf:mainfrom
vicvoh:main

Conversation

@vicvoh
Copy link
Contributor

@vicvoh vicvoh commented Nov 16, 2025

This can be used for conditionally applying modifiers for QRCode.Builder

let qrcodebuilder = try! QRCode.build
   .text("Sample QR-code")
   .if(condition: true, configure: { builder in
      builder.background.cornerRadius(0.75)
   })

@dagronf dagronf merged commit 8e72f4e into dagronf:main Nov 16, 2025
2 checks passed
@dagronf
Copy link
Owner

dagronf commented Nov 16, 2025

I've just made some small changes to your request now that its merged :-

  1. I removed the label requirement from the 'if' implementation, so that the if condition looks more 'natural'
 let qrcodebuilder = try QRCode.build
    .text("Sample QR-code")
    .if(<some_condition>) { builder in
        builder.background.cornerRadius(0.75)
    }
  1. Added a 'discardableResult' to the function definition to be in line with the other builder functions
  2. Added some basic tests to make sure the condition is handled correctly

Thank you so much for your work!

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