Using percentages for layout does not correctly display the required space when there is a gap??? #1691

Closed
opened 2024-08-26 03:12:27 -07:00 by CtrlJone · 0 comments
CtrlJone commented 2024-08-26 03:12:27 -07:00 (Migrated from github.com)

Report

Issues and Steps to Reproduce

this is my code

rootFlexContainer.flex.direction(.row).define { (flex) in
            flex.addItem().direction(.row).define { flex in
                flex.addItem().width(50%).backgroundColor(.red)
                flex.addItem().width(50%).backgroundColor(.green)
            }.paddingHorizontal(15).backgroundColor(.systemGray5).height(25).columnGap(15)
        }
        addSubview(rootFlexContainer)
        rootFlexContainer.backgroundColor = .gray

Expected Behavior

The actual width of red and green is half of the full width minus 45.

Actual Behavior

image

How do I use percentages correctly?

# Report - [x] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate # Issues and Steps to Reproduce this is my code ```swift rootFlexContainer.flex.direction(.row).define { (flex) in flex.addItem().direction(.row).define { flex in flex.addItem().width(50%).backgroundColor(.red) flex.addItem().width(50%).backgroundColor(.green) }.paddingHorizontal(15).backgroundColor(.systemGray5).height(25).columnGap(15) } addSubview(rootFlexContainer) rootFlexContainer.backgroundColor = .gray ``` # Expected Behavior The actual width of red and green is half of the full width minus 45. # Actual Behavior ![image](https://github.com/user-attachments/assets/89161265-b7ea-4001-9d73-5fbf109800ac) How do I use percentages correctly?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1691
No description provided.