Skip to content

Commit

Permalink
Fix the flex property on iOS not being respected.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrtwhite committed Dec 5, 2023
1 parent 1dcb543 commit 90e6141
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 30 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ abstract class AbstractFlexContainerTest<T : Any> {
fun testFlexDistributesWeightEqually() {
val container = flexContainer(FlexDirection.Row)
container.width(Constraint.Fill)
container.height(Constraint.Fill)
container.height(Constraint.Wrap)
container.add(widget("REALLY LONG TEXT", FlexImpl(1.0)))
container.add(widget("SHORTER TEXT", FlexImpl(1.0)))
container.add(widget("A", FlexImpl(1.0)))
Expand All @@ -513,7 +513,7 @@ abstract class AbstractFlexContainerTest<T : Any> {
fun testFlexDistributesWeightUnequally() {
val container = flexContainer(FlexDirection.Row)
container.width(Constraint.Fill)
container.height(Constraint.Fill)
container.height(Constraint.Wrap)
container.add(widget("REALLY LONG TEXT", FlexImpl(3.0)))
container.add(widget("SHORTER TEXT", FlexImpl(1.0)))
container.add(widget("A", FlexImpl(1.0)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ final class SnapshotTestingCallback : UIViewSnapshotCallback {
func verifySnapshot(view: UIView, name: String?) {
// Set `record` to true to generate new snapshots. Be sure to revert that before committing!
// Note that tests always fail when `record` is true.
assertSnapshot(of: view, as: .image, named: name, record: false, file: fileName, testName: testName)
assertSnapshot(of: view, as: .image, named: name, record: true, file: fileName, testName: testName)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import platform.UIKit.UIView
import platform.darwin.NSInteger

internal class UIViewFlexContainer(
private val direction: FlexDirection,
direction: FlexDirection,
) : FlexContainer<UIView>, ChangeListener {
private val yogaView: YogaUIView = YogaUIView(
applyModifier = { node, index ->
Expand All @@ -42,7 +42,7 @@ internal class UIViewFlexContainer(
)
override val value: UIView get() = yogaView
override val children = UIViewChildren(
value,
parent = value,
insert = { view, index ->
yogaView.rootNode.children.add(index, view.asNode())
value.insertSubview(view, index.convert<NSInteger>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import platform.CoreGraphics.CGRectZero
import platform.CoreGraphics.CGSize
import platform.CoreGraphics.CGSizeMake
import platform.UIKit.UIScrollView
import platform.UIKit.UIScrollViewContentInsetAdjustmentBehavior
import platform.UIKit.UIScrollViewContentInsetAdjustmentBehavior.UIScrollViewContentInsetAdjustmentNever
import platform.UIKit.UIView
import platform.UIKit.UIViewNoIntrinsicMetric

Expand All @@ -31,10 +31,11 @@ internal class YogaUIView(
var height = Constraint.Wrap

init {
// TODO: Support Scroll Indicators
// TODO: Support scroll indicators.
scrollEnabled = false
showsVerticalScrollIndicator = false
showsHorizontalScrollIndicator = false
contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.UIScrollViewContentInsetAdjustmentNever
contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever
}

override fun intrinsicContentSize(): CValue<CGSize> {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -1595,14 +1595,14 @@ internal object Yoga {
)
val isMainAxisRow = YGFlexDirectionIsRow(mainAxis)
val mainAxisSize = if (isMainAxisRow) width else height
val mainAxisownerSize = if (isMainAxisRow) ownerWidth else ownerHeight
val mainAxisOwnerSize = if (isMainAxisRow) ownerWidth else ownerHeight
var childWidth: Float
var childHeight: Float
var childWidthMeasureMode: YGMeasureMode
var childHeightMeasureMode: YGMeasureMode
val resolvedFlexBasis = YGResolveValue(
child.resolveFlexBasisPtr(),
mainAxisownerSize,
mainAxisOwnerSize,
)
val isRowStyleDimDefined = YGNodeIsStyleDimDefined(
child, YGFlexDirection.YGFlexDirectionRow,
Expand Down

0 comments on commit 90e6141

Please sign in to comment.