Compare commits
246 Commits
1.16.0
...
jmaurice-u
Author | SHA1 | Date | |
---|---|---|---|
|
d5d05a40ed | ||
|
b50a7646e2 | ||
|
9e1bcd8557 | ||
|
cac197f5a6 | ||
|
65c57d6a01 | ||
|
83c6997f29 | ||
|
53872e2521 | ||
|
53a8842abb | ||
|
83cef5b12f | ||
|
9808358e08 | ||
|
7e96b65790 | ||
|
627255c0e4 | ||
|
c3291912b3 | ||
|
2359ccde78 | ||
|
9fe1e77274 | ||
|
cfc3696013 | ||
|
b0b255072c | ||
|
b842a9e1d9 | ||
|
98e25ea1ee | ||
|
045e6bc16d | ||
|
fb4917c03c | ||
|
287c48f7e3 | ||
|
1813748eaa | ||
|
8035456330 | ||
|
08eaae7223 | ||
|
894142d589 | ||
|
2f9959da26 | ||
|
ba27f9d1ec | ||
|
35f3335efc | ||
|
811b46ae63 | ||
|
5498d3ad61 | ||
|
707115ee7e | ||
|
49af711502 | ||
|
a1f4d2b8ed | ||
|
3614c8d82b | ||
|
eea87c3abc | ||
|
5a257aac85 | ||
|
efefc1eb7f | ||
|
8166c81135 | ||
|
40db73d1a8 | ||
|
ab6f3e1c60 | ||
|
5dd33acc91 | ||
|
e6a79d5c73 | ||
|
e9184c793e | ||
|
c2a0ccf0d4 | ||
|
8e29e7c1e1 | ||
|
f992e63ac5 | ||
|
582533dbc6 | ||
|
05dd228317 | ||
|
1daed063f3 | ||
|
260e60b4b1 | ||
|
efdcfec88f | ||
|
48cbf3802e | ||
|
94885d41f1 | ||
|
a1ce49534d | ||
|
c96564d23d | ||
|
276de5c122 | ||
|
585df10ee8 | ||
|
7a6f667bf1 | ||
|
0a6a184fed | ||
|
68c038579c | ||
|
e1b401ca36 | ||
|
ec0a829110 | ||
|
d16e918c52 | ||
|
7f854ec13e | ||
|
272eb940f1 | ||
|
bc4c8f9fd9 | ||
|
0faefad0c1 | ||
|
29c2151d8d | ||
|
572f525734 | ||
|
80c89a48a1 | ||
|
7986ca97a3 | ||
|
4ca1bfeff6 | ||
|
40c600434e | ||
|
29bb669adf | ||
|
206bf414ec | ||
|
5a18ccdbe2 | ||
|
fd180de774 | ||
|
7d37b2e84b | ||
|
97c8bbde12 | ||
|
fbf7a6feb5 | ||
|
64f865a639 | ||
|
c5a8f447b1 | ||
|
a9a21d0aa6 | ||
![]() |
88c9b046ed | ||
![]() |
22eb898e8c | ||
|
bfcd15e4a9 | ||
|
4d089ecc79 | ||
|
2e1fa58ea5 | ||
|
f174de70af | ||
|
44d8da2520 | ||
|
b4d144a546 | ||
|
fba952d5ec | ||
|
4d4918cdaf | ||
|
477fedd1b6 | ||
|
bd95b3d243 | ||
|
acbffc8485 | ||
|
8123124c80 | ||
|
b6c71ae58b | ||
|
a6a2209902 | ||
|
ef490a9921 | ||
|
cfe21e1a60 | ||
|
8a95fbe878 | ||
|
5c3837f5f3 | ||
|
578d197dd6 | ||
|
e5acf77eea | ||
|
f03129728f | ||
|
8a65d8b6dc | ||
|
0fcef77d7b | ||
|
e3a59aa50e | ||
|
13e079e8f3 | ||
|
508f4eacdf | ||
|
a999150c19 | ||
|
cbf6495d66 | ||
|
07eaeea7a4 | ||
|
638690255c | ||
|
6c2ba945be | ||
|
db6be5286e | ||
|
67b6c24d7b | ||
|
b2095801ba | ||
|
e87f429703 | ||
|
41384fab7b | ||
|
342aebe1d7 | ||
|
1745c23a12 | ||
|
ccdea0f31b | ||
|
c1a28f3f54 | ||
|
0429704d5e | ||
|
36e70c9ca0 | ||
|
de36e85004 | ||
|
651c527e94 | ||
|
2cb46cf3e2 | ||
|
584dfe961e | ||
|
a38ec3d7a4 | ||
|
b043669972 | ||
|
e65b1ef654 | ||
|
07eac0c6e2 | ||
|
64e2459427 | ||
|
f350c7a58e | ||
|
e0ae96368c | ||
|
e1c9d8800e | ||
|
084d5935e6 | ||
|
fc88b2f774 | ||
|
5ac5624e3f | ||
|
16f676eccf | ||
|
0767f4d105 | ||
|
a93e5d63c9 | ||
|
d74a1069a0 | ||
|
633cdc9088 | ||
|
ede65bbce4 | ||
|
4135420cba | ||
|
07c0d539bd | ||
|
ac7c85c0a6 | ||
|
83b27417ae | ||
|
884f147742 | ||
|
a96a36ef59 | ||
|
1bd4123df1 | ||
|
92b76447b7 | ||
|
e637cf2d72 | ||
|
9b96a5362a | ||
|
e5743e851b | ||
|
f7bc0ad248 | ||
|
8c53c2dcca | ||
|
be51bc44a4 | ||
|
5eba2d42bd | ||
|
2049c85a6c | ||
|
ecd7790dd8 | ||
|
0f08aa53da | ||
|
5bf93e81ba | ||
|
4f1231f411 | ||
|
b280a19b0a | ||
|
63a463d011 | ||
|
adb87e347f | ||
|
2d52b5a873 | ||
|
6c61cd5f05 | ||
|
bfc3b2f86f | ||
|
a1278cee05 | ||
|
e983c4a5ef | ||
|
7f97e8b232 | ||
|
089095f532 | ||
|
ac8eb111a9 | ||
|
073f49d0d0 | ||
|
67915b5905 | ||
|
015df9c512 | ||
|
f7f134274c | ||
|
aeb9549af7 | ||
|
f3498a2959 | ||
|
9d2ca758fa | ||
|
9650c1903d | ||
|
f4840a0148 | ||
|
198e99d30c | ||
|
cd0191c247 | ||
|
7ec0ef8470 | ||
|
b88cf7ff67 | ||
|
20fe53b254 | ||
|
f99da09716 | ||
|
5960dd888d | ||
|
b0a0007d6e | ||
|
73a4a6d29f | ||
|
0be0e9fc01 | ||
|
ddf748a99d | ||
|
4d16ee4ed4 | ||
|
b72efaaaca | ||
|
6327893b9b | ||
|
8c3ee81d6e | ||
|
fb07dcff40 | ||
|
27f42c90db | ||
|
688bd4ef72 | ||
|
42bba10894 | ||
|
495d8da596 | ||
|
869a33eb13 | ||
|
050893f15a | ||
|
8aa67abdb2 | ||
|
2e321fc69f | ||
|
aa2610c2dd | ||
|
293b657aef | ||
|
d6591439d1 | ||
|
2ef674edd3 | ||
|
22a60e82b0 | ||
|
34739ec652 | ||
|
b9b0217a07 | ||
|
7c2683fe52 | ||
|
ee73f556b4 | ||
|
34b68cf1d2 | ||
|
8975019269 | ||
|
6e6b1369ac | ||
|
25b8c94788 | ||
|
3fce27c48c | ||
|
32a973ebd1 | ||
|
c37f5956e4 | ||
|
0875b6b542 | ||
|
b29e144649 | ||
|
f00116c3a6 | ||
|
f1baf8336b | ||
|
36eae205e1 | ||
|
ad5b3410f0 | ||
|
e2dbff0ca6 | ||
|
96eb94afd0 | ||
|
9100019c0a | ||
|
21f814b2a6 | ||
|
499d28d021 | ||
|
d697bbe0a5 | ||
|
67a3841164 | ||
|
6ac38d188c | ||
|
8216c54b05 | ||
|
968c075e39 | ||
|
70369ae5d3 |
10
.buckconfig
10
.buckconfig
@@ -1,10 +0,0 @@
|
|||||||
[cxx]
|
|
||||||
gtest_dep = //lib/gtest:gtest
|
|
||||||
[android]
|
|
||||||
target = android-25
|
|
||||||
build_tools_version = 26.0.2
|
|
||||||
[ndk]
|
|
||||||
ndk_version = 15.2.4203891
|
|
||||||
compiler = clang
|
|
||||||
app_platform = android-21
|
|
||||||
cpu_abis = arm64, armv7, x86, x86_64
|
|
112
.clang-format
112
.clang-format
@@ -54,3 +54,115 @@ SpaceInEmptyParentheses: false
|
|||||||
SpacesBeforeTrailingComments: 1
|
SpacesBeforeTrailingComments: 1
|
||||||
Standard: Cpp11
|
Standard: Cpp11
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
---
|
||||||
|
Language: ObjC
|
||||||
|
AccessModifierOffset: -1
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
AlignConsecutiveMacros: false
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveBitFields: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: DontAlign
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: false
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- FOR_EACH
|
||||||
|
- FOR_EACH_R
|
||||||
|
- FOR_EACH_RANGE
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<.*\.h(pp)?>'
|
||||||
|
Priority: 1
|
||||||
|
- Regex: '^<.*'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 3
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentWidth: 2
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: false
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: true
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
Standard: Latest
|
||||||
|
TabWidth: 8
|
||||||
|
UseCRLF: false
|
||||||
|
UseTab: Never
|
||||||
|
...
|
||||||
|
25
.github/actions/black/action.yml
vendored
Normal file
25
.github/actions/black/action.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: Black Formatter
|
||||||
|
inputs:
|
||||||
|
directory:
|
||||||
|
description: Directory to Lint
|
||||||
|
required: true
|
||||||
|
version:
|
||||||
|
description: pypi version of "black" to use
|
||||||
|
required: false
|
||||||
|
default: 22.3.0
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Ensure supported Python selected
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '>=3.6.2'
|
||||||
|
|
||||||
|
- name: pip install
|
||||||
|
shell: bash
|
||||||
|
run: pip install black==${{ inputs.version }}
|
||||||
|
|
||||||
|
- name: black
|
||||||
|
shell: bash
|
||||||
|
run: black --check ${{ inputs.directory }}
|
23
.github/actions/clang-format/action.yml
vendored
Normal file
23
.github/actions/clang-format/action.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Clang Format
|
||||||
|
inputs:
|
||||||
|
directory:
|
||||||
|
description: Directory to Lint
|
||||||
|
required: true
|
||||||
|
version:
|
||||||
|
description: LLVM version to use # Should be kept roughly in sync with arcanist
|
||||||
|
required: false
|
||||||
|
default: 12
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install
|
||||||
|
shell: bash
|
||||||
|
run: sudo apt-get install -y clang-format-${{ inputs.version }}
|
||||||
|
|
||||||
|
- name: clang-format
|
||||||
|
working-directory: ${{ inputs.directory }}
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
BASHOPTS: extglob:nullglob
|
||||||
|
run: clang-format-${{ inputs.version }} --dry-run --Werror **/*.{h,hh,hpp,c,cpp,cc,m,mm}
|
23
.github/actions/install-emsdk/action.yml
vendored
Normal file
23
.github/actions/install-emsdk/action.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Install emsdk (including emcc)
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: EMCC Version to install
|
||||||
|
required: false
|
||||||
|
default: 3.1.28
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Clone emsdk repo
|
||||||
|
working-directory: ${{ runner.temp }}
|
||||||
|
shell: bash
|
||||||
|
run: git clone https://github.com/emscripten-core/emsdk.git
|
||||||
|
|
||||||
|
- name: emdsk install
|
||||||
|
working-directory: ${{ runner.temp }}/emsdk
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
./emsdk install ${{ inputs.version }}
|
||||||
|
./emsdk activate ${{ inputs.version }}
|
||||||
|
echo $RUNNER_TEMP/emsdk >> $GITHUB_PATH
|
||||||
|
echo $RUNNER_TEMP/emsdk/upstream/emscripten >> $GITHUB_PATH
|
14
.github/actions/install-ninja/action.yml
vendored
Normal file
14
.github/actions/install-ninja/action.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: Install Ninja
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install ninja (Linux)
|
||||||
|
if: ${{ runner.os == 'Linux' }}
|
||||||
|
shell: bash
|
||||||
|
run: sudo apt-get install -y ninja-build
|
||||||
|
|
||||||
|
- name: Install ninja (Windows)
|
||||||
|
if: ${{ runner.os == 'Windows' }}
|
||||||
|
shell: powershell
|
||||||
|
run: choco install ninja
|
10
.github/actions/setup-android/action.yml
vendored
Normal file
10
.github/actions/setup-android/action.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
name: Setup Android envirionment
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Select Java Version
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 11
|
9
.github/actions/setup-apple/action.yml
vendored
Normal file
9
.github/actions/setup-apple/action.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
name: Setup Apple envirionment
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
# TODO: This and Ruby should be versioned
|
||||||
|
- name: Install Cocoapods
|
||||||
|
shell: bash
|
||||||
|
run: sudo gem install cocoapods
|
12
.github/actions/setup-cpp/action.yml
vendored
Normal file
12
.github/actions/setup-cpp/action.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
name: Setup C++ envirionment
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install Ninja
|
||||||
|
if: ${{ runner.os != 'Windows' }}
|
||||||
|
uses: ./.github/actions/install-ninja
|
||||||
|
|
||||||
|
- name: Setup VS Developer Command Prompt
|
||||||
|
if: ${{ runner.os == 'Windows' }}
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
20
.github/actions/setup-js/action.yml
vendored
Normal file
20
.github/actions/setup-js/action.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Setup JavaScript envirionment
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 18.x
|
||||||
|
|
||||||
|
- name: Install emsdk
|
||||||
|
uses: ./.github/actions/install-emsdk
|
||||||
|
|
||||||
|
- name: Install Ninja
|
||||||
|
uses: ./.github/actions/install-ninja
|
||||||
|
|
||||||
|
- name: yarn install
|
||||||
|
shell: bash
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: javascript
|
18
.github/actions/setup-website/action.yml
vendored
Normal file
18
.github/actions/setup-website/action.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
name: Setup Website envirionment
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
# TODO: Update to latest when website is moved to the workspace version of
|
||||||
|
# yoga-layout
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12.x
|
||||||
|
|
||||||
|
# TODO: the website should be in a yarn workspace with the library, but the
|
||||||
|
# current version of gatsby is incompatible with hoisting.
|
||||||
|
- name: yarn install
|
||||||
|
shell: bash
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: website
|
29
.github/workflows/publish-android.yml
vendored
Normal file
29
.github/workflows/publish-android.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: Android
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- created
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish to Maven Central
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-android
|
||||||
|
|
||||||
|
- name: Publish and release
|
||||||
|
run: |
|
||||||
|
./gradlew :yoga:assembleRelease publish --info
|
||||||
|
./gradlew closeAndReleaseRepository
|
||||||
|
env:
|
||||||
|
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
|
||||||
|
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
|
||||||
|
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}
|
||||||
|
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
|
||||||
|
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
|
32
.github/workflows/publish-website.yml
vendored
Normal file
32
.github/workflows/publish-website.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Website
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish to GitHub Pages
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-website
|
||||||
|
|
||||||
|
- name: yarn build
|
||||||
|
run: yarn build
|
||||||
|
working-directory: website
|
||||||
|
|
||||||
|
- uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_branch: gh-pages
|
||||||
|
publish_dir: website/public
|
||||||
|
cname: yogalayout.com
|
||||||
|
keep_files: true
|
||||||
|
user_name: 'Yoga-bot'
|
||||||
|
user_email: 'yogabot@fb.com'
|
26
.github/workflows/validate-android.yml
vendored
Normal file
26
.github/workflows/validate-android.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Android
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build [${{ matrix.os }}][${{ matrix.mode }}]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
mode: [Debug, Release]
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-android
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: ./gradlew assemble${{ matrix.mode }} --stacktrace
|
55
.github/workflows/validate-apple.yml
vendored
Normal file
55
.github/workflows/validate-apple.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
name: Apple
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-pods:
|
||||||
|
name: Lint
|
||||||
|
runs-on: macos-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-apple
|
||||||
|
|
||||||
|
- name: pod spec lint
|
||||||
|
run: pod spec lint --verbose
|
||||||
|
continue-on-error: true # Apple Build is Broken
|
||||||
|
|
||||||
|
build-sample:
|
||||||
|
name: Build [${{ matrix.mode }}]
|
||||||
|
runs-on: macos-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
mode: [Debug, Release]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-apple
|
||||||
|
|
||||||
|
- name: pod install
|
||||||
|
run: pod install
|
||||||
|
working-directory: ./YogaKit/YogaKitSample
|
||||||
|
continue-on-error: true # Apple Build is Broken
|
||||||
|
|
||||||
|
# TODO: xcodebuild
|
||||||
|
|
||||||
|
clang-format:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: clang-format
|
||||||
|
uses: ./.github/actions/clang-format
|
||||||
|
with:
|
||||||
|
directory: ./YogaKit
|
64
.github/workflows/validate-cpp.yml
vendored
Normal file
64
.github/workflows/validate-cpp.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: C++
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
GTEST_COLOR: 1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Build and Test [${{ matrix.os }}][${{ matrix.mode }}]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
mode: [Debug, Release]
|
||||||
|
os: [ubuntu-latest] # TODO: fix issues building GTest Binary with MSVC in GitHub Actions
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-cpp
|
||||||
|
|
||||||
|
- name: Unit tests
|
||||||
|
run: ./unit_tests ${{ matrix.mode }}
|
||||||
|
|
||||||
|
benchmark:
|
||||||
|
name: Benchmark [${{ matrix.os }}]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-cpp
|
||||||
|
|
||||||
|
- name: Build benchmark
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build
|
||||||
|
working-directory: benchmark
|
||||||
|
|
||||||
|
- name: Run benchmark
|
||||||
|
run: ./build/benchmark
|
||||||
|
working-directory: benchmark
|
||||||
|
|
||||||
|
clang-format:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: clang-format
|
||||||
|
uses: ./.github/actions/clang-format
|
||||||
|
with:
|
||||||
|
directory: ./yoga
|
74
.github/workflows/validate-js.yml
vendored
Normal file
74
.github/workflows/validate-js.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
name: JavaScript
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_COLOR: 3
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
benchmark:
|
||||||
|
name: Benchmark [${{ matrix.os }}]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-js
|
||||||
|
|
||||||
|
- name: yarn benchmark
|
||||||
|
run: yarn benchmark
|
||||||
|
working-directory: javascript
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build [${{ matrix.os }}]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-js
|
||||||
|
|
||||||
|
- name: yarn build
|
||||||
|
run: yarn build
|
||||||
|
working-directory: javascript
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test [${{ matrix.os }}]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-js
|
||||||
|
|
||||||
|
- name: yarn test
|
||||||
|
run: yarn test
|
||||||
|
working-directory: javascript
|
||||||
|
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: yarn install
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: javascript
|
||||||
|
|
||||||
|
- name: yarn lint
|
||||||
|
run: yarn lint
|
||||||
|
working-directory: javascript
|
21
.github/workflows/validate-python.yml
vendored
Normal file
21
.github/workflows/validate-python.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: Python
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
format:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: black --check
|
||||||
|
uses: ./.github/actions/black
|
||||||
|
with:
|
||||||
|
directory: ${{ github.workspace }}
|
23
.github/workflows/validate-website.yml
vendored
Normal file
23
.github/workflows/validate-website.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Website
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
uses: ./.github/actions/setup-website
|
||||||
|
|
||||||
|
- name: yarn build
|
||||||
|
run: yarn build
|
||||||
|
working-directory: website
|
7
.gitignore
vendored
7
.gitignore
vendored
@@ -5,14 +5,15 @@
|
|||||||
/.buckconfig.local
|
/.buckconfig.local
|
||||||
/.buckd
|
/.buckd
|
||||||
/gentest/test.html
|
/gentest/test.html
|
||||||
.buckversion
|
.buck-java11
|
||||||
|
|
||||||
# Jekyll
|
# Jekyll
|
||||||
/.sass-cache/
|
/.sass-cache/
|
||||||
/_site/
|
/_site/
|
||||||
|
|
||||||
# Visual studio code
|
# Visual studio code
|
||||||
.vscode
|
!.vscode
|
||||||
|
|
||||||
*.pdb
|
*.pdb
|
||||||
*.tlog
|
*.tlog
|
||||||
*.obj
|
*.obj
|
||||||
@@ -63,5 +64,7 @@ Carthage/Build
|
|||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
.gradle
|
.gradle
|
||||||
|
|
||||||
# NDK/CMake
|
# NDK/CMake
|
||||||
|
.cxx
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "lib/gtest/googletest"]
|
|
||||||
path = lib/gtest/googletest
|
|
||||||
url = https://github.com/google/googletest.git
|
|
@@ -1 +0,0 @@
|
|||||||
4.0
|
|
77
.travis.yml
77
.travis.yml
@@ -1,77 +0,0 @@
|
|||||||
language: java
|
|
||||||
os: linux
|
|
||||||
dist: trusty
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- llvm-toolchain-trusty-6.0
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- clang-6.0
|
|
||||||
|
|
||||||
env:
|
|
||||||
- TARGET: website
|
|
||||||
- TARGET: android
|
|
||||||
|
|
||||||
install:
|
|
||||||
- cd website
|
|
||||||
- yarn --ignore-scripts
|
|
||||||
- cd ..
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/buck
|
|
||||||
- $HOME/.gradle
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- |
|
|
||||||
if [[ -n "$encrypted_d27e803291ff_iv" ]]; then
|
|
||||||
openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties;
|
|
||||||
fi
|
|
||||||
# Android
|
|
||||||
- |
|
|
||||||
if [[ $TARGET = "android" ]]; then
|
|
||||||
pushd $HOME
|
|
||||||
git clone --depth 1 https://github.com/facebook/buck.git
|
|
||||||
cd buck
|
|
||||||
ant
|
|
||||||
popd
|
|
||||||
export PATH=$PATH:$HOME/buck/bin/
|
|
||||||
buck --version
|
|
||||||
export TERMINAL=dumb
|
|
||||||
source scripts/android-setup.sh && installAndroidSDK
|
|
||||||
export ANDROID_SDK=$ANDROID_HOME
|
|
||||||
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
|
|
||||||
export ANDROID_NDK_HOME=$ANDROID_NDK_REPOSITORY/android-ndk-r15c
|
|
||||||
fi
|
|
||||||
# Website
|
|
||||||
- |
|
|
||||||
if [[ $TARGET = "website" ]]; then
|
|
||||||
nvm install 8
|
|
||||||
nvm use 8
|
|
||||||
fi
|
|
||||||
|
|
||||||
script:
|
|
||||||
- |
|
|
||||||
if [[ $TARGET = "android" ]]; then
|
|
||||||
./gradlew testDebugUnit && scripts/publish-snapshot.sh
|
|
||||||
fi
|
|
||||||
- |
|
|
||||||
if [[ $TARGET = "website" ]]; then
|
|
||||||
pushd website
|
|
||||||
yarn build
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
provider: pages
|
|
||||||
skip-cleanup: true
|
|
||||||
github-token: $GITHUB_TOKEN
|
|
||||||
fqdn: yogalayout.com
|
|
||||||
local-dir: website/public
|
|
||||||
email: yogabot@fb.com
|
|
||||||
name: Yoga-bot
|
|
||||||
keep-history: true
|
|
||||||
on:
|
|
||||||
branch: master
|
|
||||||
condition: $TARGET = website
|
|
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"EditorConfig.EditorConfig",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
]
|
||||||
|
}
|
25
.vscode/launch.json
vendored
Normal file
25
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug C++ Unit tests (lldb)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"MIMode": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/tests/build/yogatests",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"preLaunchTask": "Build Unit Tests"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug C++ Unit tests (vsdbg)",
|
||||||
|
"type": "cppvsdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/tests/build/yogatests",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"preLaunchTask": "Build Unit Tests"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
20
.vscode/settings.json
vendored
Normal file
20
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": true
|
||||||
|
},
|
||||||
|
"eslint.format.enable": true,
|
||||||
|
"eslint.packageManager": "yarn",
|
||||||
|
"eslint.enable": true,
|
||||||
|
"eslint.validate": [
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact"
|
||||||
|
],
|
||||||
|
"eslint.workingDirectories": [
|
||||||
|
{
|
||||||
|
"mode": "auto"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
23
.vscode/tasks.json
vendored
Normal file
23
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build Unit Tests",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "(which ninja && cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug -G Ninja || cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug) && cmake --build build",
|
||||||
|
"windows": {
|
||||||
|
"command": "(where ninja && cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug -G Ninja || cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug) && cmake --build build",
|
||||||
|
},
|
||||||
|
"group": "build",
|
||||||
|
"options": {
|
||||||
|
"cwd": "tests"
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "new"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
58
BUCK
58
BUCK
@@ -1,58 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep")
|
|
||||||
|
|
||||||
GMOCK_OVERRIDE_FLAGS = [
|
|
||||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
|
||||||
"-Wno-inconsistent-missing-override",
|
|
||||||
]
|
|
||||||
|
|
||||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
|
||||||
"-DDEBUG",
|
|
||||||
"-DYG_ENABLE_EVENTS",
|
|
||||||
]
|
|
||||||
|
|
||||||
yoga_cxx_library(
|
|
||||||
name = "yoga",
|
|
||||||
srcs = glob(["yoga/**/*.cpp"]),
|
|
||||||
compiler_flags = LIBRARY_COMPILER_FLAGS,
|
|
||||||
public_include_directories = ["."],
|
|
||||||
raw_headers = glob(["yoga/**/*.h"]),
|
|
||||||
soname = "libyogacore.$(ext)",
|
|
||||||
tests = [":YogaTests"],
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
yoga_dep("lib/fb:ndklog"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_cxx_library(
|
|
||||||
name = "yogaForDebug",
|
|
||||||
srcs = glob(["yoga/**/*.cpp"]),
|
|
||||||
compiler_flags = TEST_COMPILER_FLAGS,
|
|
||||||
public_include_directories = ["."],
|
|
||||||
raw_headers = glob(["yoga/**/*.h"]),
|
|
||||||
soname = "libyogacore.$(ext)",
|
|
||||||
tests = [":YogaTests"],
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
":yoga",
|
|
||||||
yoga_dep("lib/fb:ndklog"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_cxx_test(
|
|
||||||
name = "YogaTests",
|
|
||||||
srcs = glob(["tests/*.cpp"]),
|
|
||||||
headers = subdir_glob([("", "yoga/**/*.h")]),
|
|
||||||
compiler_flags = TEST_COMPILER_FLAGS,
|
|
||||||
contacts = ["emilsj@fb.com"],
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
":yogaForDebug",
|
|
||||||
yoga_dep("testutil:testutil"),
|
|
||||||
GTEST_TARGET,
|
|
||||||
],
|
|
||||||
)
|
|
@@ -1,17 +1,52 @@
|
|||||||
#
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
#
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4.1)
|
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
project(yoga-all)
|
||||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||||
|
|
||||||
file(GLOB_RECURSE yogacore_SRC yoga/*.cpp)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/project-defaults.cmake)
|
||||||
add_library(yogacore STATIC ${yogacore_SRC})
|
|
||||||
|
|
||||||
target_include_directories(yogacore PUBLIC .)
|
add_subdirectory(yoga)
|
||||||
target_link_libraries(yogacore android log)
|
add_subdirectory(tests)
|
||||||
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)
|
|
||||||
|
# cmake install config
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
# declare target to install
|
||||||
|
install(TARGETS yogacore EXPORT yoga-targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# install header files
|
||||||
|
install(DIRECTORY
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/yoga"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
# install target config
|
||||||
|
install(EXPORT yoga-targets
|
||||||
|
FILE yogaTargets.cmake
|
||||||
|
NAMESPACE yoga::
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yoga
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# generate config file
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/yoga-config.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/yogaConfig.cmake
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yoga
|
||||||
|
)
|
||||||
|
|
||||||
|
# install config file
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/yogaConfig.cmake
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yoga
|
||||||
|
)
|
||||||
|
@@ -74,4 +74,3 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
|
|||||||
|
|
||||||
For answers to common questions about this code of conduct, see
|
For answers to common questions about this code of conduct, see
|
||||||
https://www.contributor-covenant.org/faq
|
https://www.contributor-covenant.org/faq
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ Facebook has adopted a Code of Conduct that we expect project participants to ad
|
|||||||
|
|
||||||
## Pull Requests
|
## Pull Requests
|
||||||
We actively welcome your pull requests.
|
We actively welcome your pull requests.
|
||||||
1. Fork the repo and create your branch from `master`.
|
1. Fork the repo and create your branch from `main`.
|
||||||
2. If you've added code that should be tested, add tests
|
2. If you've added code that should be tested, add tests
|
||||||
3. If you've changed APIs, update the documentation.
|
3. If you've changed APIs, update the documentation.
|
||||||
4. Ensure the test suite passes.
|
4. Ensure the test suite passes.
|
||||||
|
54
README.md
54
README.md
@@ -1,14 +1,24 @@
|
|||||||
# Yoga [](http://cocoapods.org/pods/YogaKit) [](https://www.npmjs.com/package/yoga-layout) [](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [](https://www.nuget.org/packages/Facebook.Yoga)
|
# Yoga [](https://opensource.fb.com/support-ukraine) [](http://cocoapods.org/pods/YogaKit) [](https://www.npmjs.com/package/yoga-layout) [](https://search.maven.org/artifact/com.facebook.yoga/yoga)
|
||||||
|
|
||||||
|
Yoga is an embeddable and performant flexbox layout engine with bindings for multiple languages.
|
||||||
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C++, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
|
Yoga's main implementation targets C++ 14 with accompanying build logic in CMake. A wrapper is provided to build the main library and run unit tests.
|
||||||
|
|
||||||
## Testing
|
```sh
|
||||||
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
|
./unit_tests <Debug|Release>
|
||||||
|
```
|
||||||
|
|
||||||
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
|
While not required, this script will use [ninja](https://ninja-build.org/) if it is installed for faster builds.
|
||||||
|
|
||||||
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generate a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
|
Yoga is additionally part of the [vcpkg](https://github.com/Microsoft/vcpkg/) collection of ports maintained by Microsoft and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Adding Tests
|
||||||
|
|
||||||
|
Many of Yoga's tests are automatically generated, using HTML fixtures describing node structure. These are rendered in Chrome to generate an expected layout result for the tree. New fixtures can be added to `gentest/fixtures`.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
|
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
|
||||||
@@ -16,33 +26,11 @@ Instead of manually writing a test which ensures parity with web implementations
|
|||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
Run `gentest/gentest.rb` to generate test code and re-run `buck test //:yoga` to validate the behavior. One test case will be generated for every root `div` in the input html.
|
To generate new tests from added fixtures:
|
||||||
|
1. Run `bundle install` in the `gentest` directory to install dependencies of the test generator.
|
||||||
|
2. Run `ruby gentest.rb` in the `gentest` directory.
|
||||||
|
|
||||||
You may need to install the latest watir-webdriver gem (`gem install watir-webdriver`) and [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) to run `gentest/gentest.rb` Ruby script.
|
|
||||||
|
|
||||||
### .NET
|
## Debugging
|
||||||
.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.Yoga/test_macos.sh`.
|
|
||||||
|
|
||||||
## Benchmarks
|
Yoga provides a VSCode "launch.json" configuration which allows debugging unit tests. Simply add your breakpoints, and run "Debug C++ Unit tests (lldb)" (or "Debug C++ Unit tests (vsdbg)" on Windows).
|
||||||
Benchmarks are located in `benchmark/YGBenchmark.c` and can be run with `buck run //benchmark:benchmark`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.
|
|
||||||
|
|
||||||
### JavaScript
|
|
||||||
Installing through NPM
|
|
||||||
```sh
|
|
||||||
npm install yoga-layout
|
|
||||||
```
|
|
||||||
By default this will install the library and try to build for all platforms (node, browser asm, and standalone webpack). You may receive errors if you do not have the required platform development tools already installed. To preset the platform you'd like to build for you can set a .npmrc property first.
|
|
||||||
```sh
|
|
||||||
npm config set yoga-layout:platform standalone
|
|
||||||
```
|
|
||||||
This will now only run the standalone webpack build upon install.
|
|
||||||
|
|
||||||
## Build Platforms
|
|
||||||
|
|
||||||
| name | description |
|
|
||||||
|----------------|-------------------------------------------------|
|
|
||||||
| all (default) | Builds all of these platforms. |
|
|
||||||
| browser | Builds asm js browser version. |
|
|
||||||
| node | Builds node js version. |
|
|
||||||
| standalone | Runs webpack. |
|
|
||||||
| none | Does nothing. You can use the prepackaged libs. |
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
14
Yoga.podspec
14
Yoga.podspec
@@ -1,9 +1,9 @@
|
|||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
#
|
#
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# This source code is licensed under the MIT license found in the
|
||||||
#
|
# LICENSE file in the root directory of this source tree.
|
||||||
# This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
# file in the root directory of this source tree.
|
|
||||||
#
|
|
||||||
Pod::Spec.new do |spec|
|
Pod::Spec.new do |spec|
|
||||||
spec.name = 'Yoga'
|
spec.name = 'Yoga'
|
||||||
spec.version = '1.14.0'
|
spec.version = '1.14.0'
|
||||||
@@ -30,10 +30,10 @@ Pod::Spec.new do |spec|
|
|||||||
'-fexceptions',
|
'-fexceptions',
|
||||||
'-Wall',
|
'-Wall',
|
||||||
'-Werror',
|
'-Werror',
|
||||||
'-std=c++1y',
|
'-std=c++14',
|
||||||
'-fPIC'
|
'-fPIC'
|
||||||
]
|
]
|
||||||
spec.source_files = 'yoga/**/*.{c,h,cpp}'
|
spec.source_files = 'yoga/**/*.{c,h,cpp}'
|
||||||
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
|
spec.public_header_files = 'yoga/*.h'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
10
YogaDev.xcworkspace/contents.xcworkspacedata
generated
10
YogaDev.xcworkspace/contents.xcworkspacedata
generated
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Workspace
|
|
||||||
version = "1.0">
|
|
||||||
<FileRef
|
|
||||||
location = "group:YogaDev/YogaDev.xcodeproj">
|
|
||||||
</FileRef>
|
|
||||||
<FileRef
|
|
||||||
location = "group:ReactYoga.xcodeproj">
|
|
||||||
</FileRef>
|
|
||||||
</Workspace>
|
|
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>IDEDidComputeMac32BitWarning</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
@@ -1,350 +0,0 @@
|
|||||||
// !$*UTF8*$!
|
|
||||||
{
|
|
||||||
archiveVersion = 1;
|
|
||||||
classes = {
|
|
||||||
};
|
|
||||||
objectVersion = 50;
|
|
||||||
objects = {
|
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
|
||||||
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F892249476700CBB1EC /* YGMarker.cpp */; };
|
|
||||||
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F8B2249476700CBB1EC /* YGValue.cpp */; };
|
|
||||||
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F902249476700CBB1EC /* YGLayout.cpp */; };
|
|
||||||
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */; };
|
|
||||||
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F992249476800CBB1EC /* YGStyle.cpp */; };
|
|
||||||
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9A2249476800CBB1EC /* log.cpp */; };
|
|
||||||
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9B2249476800CBB1EC /* YGNode.cpp */; };
|
|
||||||
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9C2249476800CBB1EC /* Yoga.cpp */; };
|
|
||||||
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9D2249476800CBB1EC /* Utils.cpp */; };
|
|
||||||
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */; };
|
|
||||||
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7FA32249476800CBB1EC /* YGConfig.cpp */; };
|
|
||||||
/* End PBXBuildFile section */
|
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
|
||||||
6D4C7F76224945B200CBB1EC /* CopyFiles */ = {
|
|
||||||
isa = PBXCopyFilesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
dstPath = "include/$(PRODUCT_NAME)";
|
|
||||||
dstSubfolderSpec = 16;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXCopyFilesBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
|
||||||
6D4C7F78224945B200CBB1EC /* libYogaDev.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libYogaDev.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
||||||
6D4C7F892249476700CBB1EC /* YGMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGMarker.cpp; path = ../yoga/YGMarker.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8A2249476700CBB1EC /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = ../yoga/Utils.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGValue.cpp; path = ../yoga/YGValue.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8C2249476700CBB1EC /* instrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = instrumentation.h; path = ../yoga/instrumentation.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8D2249476700CBB1EC /* YGStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGStyle.h; path = ../yoga/YGStyle.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNodePrint.h; path = ../yoga/YGNodePrint.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8F2249476700CBB1EC /* YGMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMarker.h; path = ../yoga/YGMarker.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F902249476700CBB1EC /* YGLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGLayout.cpp; path = ../yoga/YGLayout.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F912249476700CBB1EC /* YGEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGEnums.h; path = ../yoga/YGEnums.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNodePrint.cpp; path = ../yoga/YGNodePrint.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F932249476700CBB1EC /* YGMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMacros.h; path = ../yoga/YGMacros.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F942249476700CBB1EC /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = log.h; path = ../yoga/log.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGFloatOptional.h; path = ../yoga/YGFloatOptional.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F962249476800CBB1EC /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNode.h; path = ../yoga/YGNode.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F972249476800CBB1EC /* YGLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGLayout.h; path = ../yoga/YGLayout.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F982249476800CBB1EC /* CompactValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactValue.h; path = ../yoga/CompactValue.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F992249476800CBB1EC /* YGStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGStyle.cpp; path = ../yoga/YGStyle.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9A2249476800CBB1EC /* log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = log.cpp; path = ../yoga/log.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNode.cpp; path = ../yoga/YGNode.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Yoga.cpp; path = ../yoga/Yoga.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9D2249476800CBB1EC /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Utils.cpp; path = ../yoga/Utils.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGEnums.cpp; path = ../yoga/YGEnums.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Yoga-internal.h"; path = "../yoga/Yoga-internal.h"; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA02249476800CBB1EC /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGValue.h; path = ../yoga/YGValue.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA12249476800CBB1EC /* Yoga.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Yoga.h; path = ../yoga/Yoga.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA22249476800CBB1EC /* YGConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGConfig.h; path = ../yoga/YGConfig.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGConfig.cpp; path = ../yoga/YGConfig.cpp; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
|
||||||
6D4C7F75224945B200CBB1EC /* Frameworks */ = {
|
|
||||||
isa = PBXFrameworksBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXFrameworksBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
|
||||||
6D4C7F6F224945B200CBB1EC = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
6D4C7F982249476800CBB1EC /* CompactValue.h */,
|
|
||||||
6D4C7F8C2249476700CBB1EC /* instrumentation.h */,
|
|
||||||
6D4C7F9A2249476800CBB1EC /* log.cpp */,
|
|
||||||
6D4C7F942249476700CBB1EC /* log.h */,
|
|
||||||
6D4C7F9D2249476800CBB1EC /* Utils.cpp */,
|
|
||||||
6D4C7F8A2249476700CBB1EC /* Utils.h */,
|
|
||||||
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */,
|
|
||||||
6D4C7FA22249476800CBB1EC /* YGConfig.h */,
|
|
||||||
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */,
|
|
||||||
6D4C7F912249476700CBB1EC /* YGEnums.h */,
|
|
||||||
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */,
|
|
||||||
6D4C7F902249476700CBB1EC /* YGLayout.cpp */,
|
|
||||||
6D4C7F972249476800CBB1EC /* YGLayout.h */,
|
|
||||||
6D4C7F932249476700CBB1EC /* YGMacros.h */,
|
|
||||||
6D4C7F892249476700CBB1EC /* YGMarker.cpp */,
|
|
||||||
6D4C7F8F2249476700CBB1EC /* YGMarker.h */,
|
|
||||||
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */,
|
|
||||||
6D4C7F962249476800CBB1EC /* YGNode.h */,
|
|
||||||
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */,
|
|
||||||
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */,
|
|
||||||
6D4C7F992249476800CBB1EC /* YGStyle.cpp */,
|
|
||||||
6D4C7F8D2249476700CBB1EC /* YGStyle.h */,
|
|
||||||
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */,
|
|
||||||
6D4C7FA02249476800CBB1EC /* YGValue.h */,
|
|
||||||
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */,
|
|
||||||
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */,
|
|
||||||
6D4C7FA12249476800CBB1EC /* Yoga.h */,
|
|
||||||
6D4C7F79224945B200CBB1EC /* Products */,
|
|
||||||
);
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
6D4C7F79224945B200CBB1EC /* Products */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
6D4C7F78224945B200CBB1EC /* libYogaDev.a */,
|
|
||||||
);
|
|
||||||
name = Products;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
/* End PBXGroup section */
|
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
|
||||||
6D4C7F77224945B200CBB1EC /* YogaDev */ = {
|
|
||||||
isa = PBXNativeTarget;
|
|
||||||
buildConfigurationList = 6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */;
|
|
||||||
buildPhases = (
|
|
||||||
6D4C7F74224945B200CBB1EC /* Sources */,
|
|
||||||
6D4C7F75224945B200CBB1EC /* Frameworks */,
|
|
||||||
6D4C7F76224945B200CBB1EC /* CopyFiles */,
|
|
||||||
);
|
|
||||||
buildRules = (
|
|
||||||
);
|
|
||||||
dependencies = (
|
|
||||||
);
|
|
||||||
name = YogaDev;
|
|
||||||
productName = YogaDev;
|
|
||||||
productReference = 6D4C7F78224945B200CBB1EC /* libYogaDev.a */;
|
|
||||||
productType = "com.apple.product-type.library.static";
|
|
||||||
};
|
|
||||||
/* End PBXNativeTarget section */
|
|
||||||
|
|
||||||
/* Begin PBXProject section */
|
|
||||||
6D4C7F70224945B200CBB1EC /* Project object */ = {
|
|
||||||
isa = PBXProject;
|
|
||||||
attributes = {
|
|
||||||
LastUpgradeCheck = 1010;
|
|
||||||
ORGANIZATIONNAME = "Will Wilson";
|
|
||||||
TargetAttributes = {
|
|
||||||
6D4C7F77224945B200CBB1EC = {
|
|
||||||
CreatedOnToolsVersion = 10.1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
buildConfigurationList = 6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */;
|
|
||||||
compatibilityVersion = "Xcode 9.3";
|
|
||||||
developmentRegion = en;
|
|
||||||
hasScannedForEncodings = 0;
|
|
||||||
knownRegions = (
|
|
||||||
en,
|
|
||||||
);
|
|
||||||
mainGroup = 6D4C7F6F224945B200CBB1EC;
|
|
||||||
productRefGroup = 6D4C7F79224945B200CBB1EC /* Products */;
|
|
||||||
projectDirPath = "";
|
|
||||||
projectRoot = "";
|
|
||||||
targets = (
|
|
||||||
6D4C7F77224945B200CBB1EC /* YogaDev */,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
/* End PBXProject section */
|
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
|
||||||
6D4C7F74224945B200CBB1EC /* Sources */ = {
|
|
||||||
isa = PBXSourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */,
|
|
||||||
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */,
|
|
||||||
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */,
|
|
||||||
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */,
|
|
||||||
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */,
|
|
||||||
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */,
|
|
||||||
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */,
|
|
||||||
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */,
|
|
||||||
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */,
|
|
||||||
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */,
|
|
||||||
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXSourcesBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
|
||||||
6D4C7F7F224945B200CBB1EC /* Debug */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
|
||||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
|
||||||
CLANG_ENABLE_MODULES = YES;
|
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
|
||||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
|
||||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_COMMA = YES;
|
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
||||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
|
||||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
||||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
||||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
|
||||||
COPY_PHASE_STRIP = NO;
|
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
||||||
ENABLE_TESTABILITY = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
||||||
"DEBUG=1",
|
|
||||||
"$(inherited)",
|
|
||||||
);
|
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
||||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
|
||||||
MTL_FAST_MATH = YES;
|
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
|
||||||
SDKROOT = iphoneos;
|
|
||||||
};
|
|
||||||
name = Debug;
|
|
||||||
};
|
|
||||||
6D4C7F80224945B200CBB1EC /* Release */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
|
||||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
|
||||||
CLANG_ENABLE_MODULES = YES;
|
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
|
||||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
|
||||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_COMMA = YES;
|
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
||||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
|
||||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
||||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
||||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
|
||||||
COPY_PHASE_STRIP = NO;
|
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
||||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
|
||||||
MTL_FAST_MATH = YES;
|
|
||||||
SDKROOT = iphoneos;
|
|
||||||
VALIDATE_PRODUCT = YES;
|
|
||||||
};
|
|
||||||
name = Release;
|
|
||||||
};
|
|
||||||
6D4C7F82224945B200CBB1EC /* Debug */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
||||||
SKIP_INSTALL = YES;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
|
||||||
};
|
|
||||||
name = Debug;
|
|
||||||
};
|
|
||||||
6D4C7F83224945B200CBB1EC /* Release */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
||||||
SKIP_INSTALL = YES;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
|
||||||
};
|
|
||||||
name = Release;
|
|
||||||
};
|
|
||||||
/* End XCBuildConfiguration section */
|
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
|
||||||
6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */ = {
|
|
||||||
isa = XCConfigurationList;
|
|
||||||
buildConfigurations = (
|
|
||||||
6D4C7F7F224945B200CBB1EC /* Debug */,
|
|
||||||
6D4C7F80224945B200CBB1EC /* Release */,
|
|
||||||
);
|
|
||||||
defaultConfigurationIsVisible = 0;
|
|
||||||
defaultConfigurationName = Release;
|
|
||||||
};
|
|
||||||
6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */ = {
|
|
||||||
isa = XCConfigurationList;
|
|
||||||
buildConfigurations = (
|
|
||||||
6D4C7F82224945B200CBB1EC /* Debug */,
|
|
||||||
6D4C7F83224945B200CBB1EC /* Release */,
|
|
||||||
);
|
|
||||||
defaultConfigurationIsVisible = 0;
|
|
||||||
defaultConfigurationName = Release;
|
|
||||||
};
|
|
||||||
/* End XCConfigurationList section */
|
|
||||||
};
|
|
||||||
rootObject = 6D4C7F70224945B200CBB1EC /* Project object */;
|
|
||||||
}
|
|
@@ -1,12 +1,11 @@
|
|||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
#
|
#
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# This source code is licensed under the MIT license found in the
|
||||||
#
|
# LICENSE file in the root directory of this source tree.
|
||||||
# This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
# file in the root directory of this source tree.
|
|
||||||
#
|
|
||||||
podspec = Pod::Spec.new do |spec|
|
podspec = Pod::Spec.new do |spec|
|
||||||
spec.name = 'YogaKit'
|
spec.name = 'YogaKit'
|
||||||
spec.version = '1.14.0'
|
spec.version = '1.18.1'
|
||||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/'
|
spec.documentation_url = 'https://facebook.github.io/yoga/docs/'
|
||||||
@@ -17,17 +16,22 @@ podspec = Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => spec.version.to_s,
|
:tag => "1.18.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.platform = :ios
|
spec.platform = :ios
|
||||||
spec.ios.deployment_target = '8.0'
|
spec.ios.deployment_target = '8.0'
|
||||||
spec.ios.frameworks = 'UIKit'
|
spec.ios.frameworks = 'UIKit'
|
||||||
|
spec.module_name = 'YogaKit'
|
||||||
spec.dependency 'Yoga', '~> 1.14'
|
spec.dependency 'Yoga', '~> 1.14'
|
||||||
|
# Fixes the bug related the xcode 11 not able to find swift related frameworks.
|
||||||
|
# https://github.com/Carthage/Carthage/issues/2825
|
||||||
|
# https://twitter.com/krzyzanowskim/status/1151549874653081601?s=21
|
||||||
|
spec.pod_target_xcconfig = {"LD_VERIFY_BITCODE": "NO"}
|
||||||
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
||||||
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||||
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||||
spec.swift_version = '4.0'
|
spec.swift_version = '5.1'
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/facebook/yoga/pull/366
|
# See https://github.com/facebook/yoga/pull/366
|
||||||
|
64
YogaKit/BUCK
64
YogaKit/BUCK
@@ -1,64 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_apple_library", "yoga_apple_test", "yoga_dep")
|
|
||||||
|
|
||||||
COMPILER_FLAGS = [
|
|
||||||
"-fobjc-arc",
|
|
||||||
"-Wconditional-uninitialized",
|
|
||||||
"-Wdangling-else",
|
|
||||||
"-Wdeprecated-declarations",
|
|
||||||
"-Wimplicit-retain-self",
|
|
||||||
"-Wincomplete-implementation",
|
|
||||||
"-Wobjc-method-access",
|
|
||||||
"-Wobjc-missing-super-calls",
|
|
||||||
"-Wmismatched-return-types",
|
|
||||||
"-Wreturn-type",
|
|
||||||
"-Wno-global-constructors",
|
|
||||||
"-Wno-shadow",
|
|
||||||
"-Wunused-const-variable",
|
|
||||||
"-Wunused-function",
|
|
||||||
"-Wunused-property-ivar",
|
|
||||||
"-Wunused-result",
|
|
||||||
"-Wunused-value",
|
|
||||||
]
|
|
||||||
|
|
||||||
yoga_apple_library(
|
|
||||||
name = "YogaKit",
|
|
||||||
srcs = glob(["Source/**/*.m"]),
|
|
||||||
header_namespace = "",
|
|
||||||
exported_headers = subdir_glob(
|
|
||||||
[
|
|
||||||
("", "Source/**/*.h"),
|
|
||||||
("Source", "**/*.h"),
|
|
||||||
],
|
|
||||||
prefix = "YogaKit",
|
|
||||||
),
|
|
||||||
compiler_flags = COMPILER_FLAGS,
|
|
||||||
frameworks = [
|
|
||||||
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
|
||||||
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
|
|
||||||
],
|
|
||||||
header_path_prefix = "",
|
|
||||||
link_whole = True,
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
yoga_dep(":yoga"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_apple_test(
|
|
||||||
name = "YogaKitTests",
|
|
||||||
srcs = glob(["Tests/**/*.m"]),
|
|
||||||
compiler_flags = COMPILER_FLAGS,
|
|
||||||
frameworks = [
|
|
||||||
"$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework",
|
|
||||||
"$SDKROOT/System/Library/Frameworks/CoreGraphics.framework",
|
|
||||||
],
|
|
||||||
info_plist = "Tests/Info.plist",
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
":YogaKit",
|
|
||||||
],
|
|
||||||
)
|
|
@@ -12,11 +12,10 @@ pod 'YogaKit', '~> 1.7'
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
Checkout the docs [here](https://facebook.github.io/yoga/docs/api/yogakit/).
|
|
||||||
|
|
||||||
We also have a sample project. To try it out, clone this repo and open `YogaKitSample.xcodeproj` in the [YogaKitSample](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample) directory.
|
We have a sample project. To try it out, clone this repo and open `YogaKitSample.xcodeproj` in the [YogaKitSample](https://github.com/facebook/yoga/tree/main/YogaKit/YogaKitSample) directory.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
|
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
|
||||||
|
|
||||||
See the [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) file for how to help out.
|
See the [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/main/CONTRIBUTING.md) file for how to help out.
|
||||||
|
@@ -1,31 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
#import "YGLayout.h"
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "YGLayout.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
typedef void (^YGLayoutConfigurationBlock)(YGLayout *layout);
|
typedef void (^YGLayoutConfigurationBlock)(YGLayout* layout);
|
||||||
|
|
||||||
@interface UIView (Yoga)
|
@interface UIView (Yoga)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The YGLayout that is attached to this view. It is lazily created.
|
The YGLayout that is attached to this view. It is lazily created.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly, strong) YGLayout *yoga;
|
@property(nonatomic, readonly, strong) YGLayout* yoga;
|
||||||
/**
|
/**
|
||||||
Indicates whether or not Yoga is enabled
|
Indicates whether or not Yoga is enabled
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly, assign) BOOL isYogaEnabled;
|
@property(nonatomic, readonly, assign) BOOL isYogaEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend`
|
In ObjC land, every time you access `view.yoga.*` you are adding another
|
||||||
to your code. If you plan on making multiple changes to YGLayout, it's more performant
|
`objc_msgSend` to your code. If you plan on making multiple changes to
|
||||||
to use this method, which uses a single objc_msgSend call.
|
YGLayout, it's more performant to use this method, which uses a single
|
||||||
|
objc_msgSend call.
|
||||||
*/
|
*/
|
||||||
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
|
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
|
||||||
NS_SWIFT_NAME(configureLayout(block:));
|
NS_SWIFT_NAME(configureLayout(block:));
|
||||||
|
@@ -1,36 +1,34 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <objc/runtime.h>
|
||||||
#import "UIView+Yoga.h"
|
#import "UIView+Yoga.h"
|
||||||
#import "YGLayout+Private.h"
|
#import "YGLayout+Private.h"
|
||||||
#import <objc/runtime.h>
|
|
||||||
|
|
||||||
static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
|
static const void* kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
|
||||||
|
|
||||||
@implementation UIView (YogaKit)
|
@implementation UIView (YogaKit)
|
||||||
|
|
||||||
- (YGLayout *)yoga
|
- (YGLayout*)yoga {
|
||||||
{
|
YGLayout* yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
|
||||||
YGLayout *yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
|
|
||||||
if (!yoga) {
|
if (!yoga) {
|
||||||
yoga = [[YGLayout alloc] initWithView:self];
|
yoga = [[YGLayout alloc] initWithView:self];
|
||||||
objc_setAssociatedObject(self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
objc_setAssociatedObject(
|
||||||
|
self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
return yoga;
|
return yoga;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isYogaEnabled
|
- (BOOL)isYogaEnabled {
|
||||||
{
|
|
||||||
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
|
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
|
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block {
|
||||||
{
|
|
||||||
if (block != nil) {
|
if (block != nil) {
|
||||||
block(self.yoga);
|
block(self.yoga);
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
#import "YGLayout.h"
|
|
||||||
#import <yoga/Yoga.h>
|
#import <yoga/Yoga.h>
|
||||||
|
#import "YGLayout.h"
|
||||||
|
|
||||||
@interface YGLayout ()
|
@interface YGLayout ()
|
||||||
|
|
||||||
@property (nonatomic, assign, readonly) YGNodeRef node;
|
@property(nonatomic, assign, readonly) YGNodeRef node;
|
||||||
|
|
||||||
- (instancetype)initWithView:(UIView *)view;
|
- (instancetype)initWithView:(UIView*)view;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <yoga/YGEnums.h>
|
#import <yoga/YGEnums.h>
|
||||||
#import <yoga/Yoga.h>
|
|
||||||
#import <yoga/YGMacros.h>
|
#import <yoga/YGMacros.h>
|
||||||
|
#import <yoga/Yoga.h>
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
extern YGValue YGPointValue(CGFloat value)
|
extern YGValue YGPointValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
|
||||||
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
|
"Use the swift Int and FloatingPoint extensions instead");
|
||||||
extern YGValue YGPercentValue(CGFloat value)
|
extern YGValue YGPercentValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
|
||||||
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
|
"Use the swift Int and FloatingPoint extensions instead");
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
|
||||||
@@ -43,103 +44,107 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
|
|||||||
The property that decides if we should include this view when calculating
|
The property that decides if we should include this view when calculating
|
||||||
layout. Defaults to YES.
|
layout. Defaults to YES.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
|
@property(nonatomic, readwrite, assign, setter=setIncludedInLayout:)
|
||||||
|
BOOL isIncludedInLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The property that decides during layout/sizing whether or not styling properties should be applied.
|
The property that decides during layout/sizing whether or not styling
|
||||||
Defaults to NO.
|
properties should be applied. Defaults to NO.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
|
@property(nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) YGDirection direction;
|
@property(nonatomic, readwrite, assign) YGDirection direction;
|
||||||
@property (nonatomic, readwrite, assign) YGFlexDirection flexDirection;
|
@property(nonatomic, readwrite, assign) YGFlexDirection flexDirection;
|
||||||
@property (nonatomic, readwrite, assign) YGJustify justifyContent;
|
@property(nonatomic, readwrite, assign) YGJustify justifyContent;
|
||||||
@property (nonatomic, readwrite, assign) YGAlign alignContent;
|
@property(nonatomic, readwrite, assign) YGAlign alignContent;
|
||||||
@property (nonatomic, readwrite, assign) YGAlign alignItems;
|
@property(nonatomic, readwrite, assign) YGAlign alignItems;
|
||||||
@property (nonatomic, readwrite, assign) YGAlign alignSelf;
|
@property(nonatomic, readwrite, assign) YGAlign alignSelf;
|
||||||
@property (nonatomic, readwrite, assign) YGPositionType position;
|
@property(nonatomic, readwrite, assign) YGPositionType position;
|
||||||
@property (nonatomic, readwrite, assign) YGWrap flexWrap;
|
@property(nonatomic, readwrite, assign) YGWrap flexWrap;
|
||||||
@property (nonatomic, readwrite, assign) YGOverflow overflow;
|
@property(nonatomic, readwrite, assign) YGOverflow overflow;
|
||||||
@property (nonatomic, readwrite, assign) YGDisplay display;
|
@property(nonatomic, readwrite, assign) YGDisplay display;
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat flex;
|
@property(nonatomic, readwrite, assign) CGFloat flex;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
|
@property(nonatomic, readwrite, assign) CGFloat flexGrow;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
|
@property(nonatomic, readwrite, assign) CGFloat flexShrink;
|
||||||
@property (nonatomic, readwrite, assign) YGValue flexBasis;
|
@property(nonatomic, readwrite, assign) YGValue flexBasis;
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) YGValue left;
|
@property(nonatomic, readwrite, assign) YGValue left;
|
||||||
@property (nonatomic, readwrite, assign) YGValue top;
|
@property(nonatomic, readwrite, assign) YGValue top;
|
||||||
@property (nonatomic, readwrite, assign) YGValue right;
|
@property(nonatomic, readwrite, assign) YGValue right;
|
||||||
@property (nonatomic, readwrite, assign) YGValue bottom;
|
@property(nonatomic, readwrite, assign) YGValue bottom;
|
||||||
@property (nonatomic, readwrite, assign) YGValue start;
|
@property(nonatomic, readwrite, assign) YGValue start;
|
||||||
@property (nonatomic, readwrite, assign) YGValue end;
|
@property(nonatomic, readwrite, assign) YGValue end;
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginLeft;
|
@property(nonatomic, readwrite, assign) YGValue marginLeft;
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginTop;
|
@property(nonatomic, readwrite, assign) YGValue marginTop;
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginRight;
|
@property(nonatomic, readwrite, assign) YGValue marginRight;
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginBottom;
|
@property(nonatomic, readwrite, assign) YGValue marginBottom;
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginStart;
|
@property(nonatomic, readwrite, assign) YGValue marginStart;
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginEnd;
|
@property(nonatomic, readwrite, assign) YGValue marginEnd;
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginHorizontal;
|
@property(nonatomic, readwrite, assign) YGValue marginHorizontal;
|
||||||
@property (nonatomic, readwrite, assign) YGValue marginVertical;
|
@property(nonatomic, readwrite, assign) YGValue marginVertical;
|
||||||
@property (nonatomic, readwrite, assign) YGValue margin;
|
@property(nonatomic, readwrite, assign) YGValue margin;
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingLeft;
|
@property(nonatomic, readwrite, assign) YGValue paddingLeft;
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingTop;
|
@property(nonatomic, readwrite, assign) YGValue paddingTop;
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingRight;
|
@property(nonatomic, readwrite, assign) YGValue paddingRight;
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingBottom;
|
@property(nonatomic, readwrite, assign) YGValue paddingBottom;
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingStart;
|
@property(nonatomic, readwrite, assign) YGValue paddingStart;
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingEnd;
|
@property(nonatomic, readwrite, assign) YGValue paddingEnd;
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingHorizontal;
|
@property(nonatomic, readwrite, assign) YGValue paddingHorizontal;
|
||||||
@property (nonatomic, readwrite, assign) YGValue paddingVertical;
|
@property(nonatomic, readwrite, assign) YGValue paddingVertical;
|
||||||
@property (nonatomic, readwrite, assign) YGValue padding;
|
@property(nonatomic, readwrite, assign) YGValue padding;
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
|
@property(nonatomic, readwrite, assign) CGFloat borderLeftWidth;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
|
@property(nonatomic, readwrite, assign) CGFloat borderTopWidth;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderRightWidth;
|
@property(nonatomic, readwrite, assign) CGFloat borderRightWidth;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderBottomWidth;
|
@property(nonatomic, readwrite, assign) CGFloat borderBottomWidth;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderStartWidth;
|
@property(nonatomic, readwrite, assign) CGFloat borderStartWidth;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
|
@property(nonatomic, readwrite, assign) CGFloat borderEndWidth;
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
|
@property(nonatomic, readwrite, assign) CGFloat borderWidth;
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) YGValue width;
|
@property(nonatomic, readwrite, assign) YGValue width;
|
||||||
@property (nonatomic, readwrite, assign) YGValue height;
|
@property(nonatomic, readwrite, assign) YGValue height;
|
||||||
@property (nonatomic, readwrite, assign) YGValue minWidth;
|
@property(nonatomic, readwrite, assign) YGValue minWidth;
|
||||||
@property (nonatomic, readwrite, assign) YGValue minHeight;
|
@property(nonatomic, readwrite, assign) YGValue minHeight;
|
||||||
@property (nonatomic, readwrite, assign) YGValue maxWidth;
|
@property(nonatomic, readwrite, assign) YGValue maxWidth;
|
||||||
@property (nonatomic, readwrite, assign) YGValue maxHeight;
|
@property(nonatomic, readwrite, assign) YGValue maxHeight;
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
|
@property(nonatomic, readwrite, assign) CGFloat aspectRatio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the resolved direction of this node. This won't be YGDirectionInherit
|
Get the resolved direction of this node. This won't be YGDirectionInherit
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly, assign) YGDirection resolvedDirection;
|
@property(nonatomic, readonly, assign) YGDirection resolvedDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
|
Perform a layout calculation and update the frames of the views in the
|
||||||
If the origin is not preserved, the root view's layout results will applied from {0,0}.
|
hierarchy with the results. If the origin is not preserved, the root view's
|
||||||
|
layout results will applied from {0,0}.
|
||||||
*/
|
*/
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
|
Perform a layout calculation and update the frames of the views in the
|
||||||
If the origin is not preserved, the root view's layout results will applied from {0,0}.
|
hierarchy with the results. If the origin is not preserved, the root view's
|
||||||
|
layout results will applied from {0,0}.
|
||||||
*/
|
*/
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||||
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self
|
Returns the size of the view if no constraints were given. This could
|
||||||
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly, assign) CGSize intrinsicSize;
|
@property(nonatomic, readonly, assign) CGSize intrinsicSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the size of the view based on provided constraints. Pass NaN for an unconstrained dimension.
|
Returns the size of the view based on provided constraints. Pass NaN for an
|
||||||
|
unconstrained dimension.
|
||||||
*/
|
*/
|
||||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||||
NS_SWIFT_NAME(calculateLayout(with:));
|
NS_SWIFT_NAME(calculateLayout(with:));
|
||||||
@@ -147,19 +152,19 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
|
|||||||
/**
|
/**
|
||||||
Returns the number of children that are using Flexbox.
|
Returns the number of children that are using Flexbox.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly, assign) NSUInteger numberOfChildren;
|
@property(nonatomic, readonly, assign) NSUInteger numberOfChildren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a BOOL indiciating whether or not we this node contains any subviews that are included in
|
Return a BOOL indiciating whether or not we this node contains any subviews
|
||||||
Yoga's layout.
|
that are included in Yoga's layout.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly, assign) BOOL isLeaf;
|
@property(nonatomic, readonly, assign) BOOL isLeaf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return's a BOOL indicating if a view is dirty. When a node is dirty
|
Return's a BOOL indicating if a view is dirty. When a node is dirty
|
||||||
it usually indicates that it will be remeasured on the next layout pass.
|
it usually indicates that it will be remeasured on the next layout pass.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly, assign) BOOL isDirty;
|
@property(nonatomic, readonly, assign) BOOL isDirty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Mark that a view's layout needs to be recalculated. Only works for leaf views.
|
Mark that a view's layout needs to be recalculated. Only works for leaf views.
|
||||||
|
@@ -1,157 +1,188 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "YGLayout+Private.h"
|
|
||||||
#import "UIView+Yoga.h"
|
#import "UIView+Yoga.h"
|
||||||
|
#import "YGLayout+Private.h"
|
||||||
|
|
||||||
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
|
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
|
||||||
- (type)lowercased_name \
|
-(type)lowercased_name { \
|
||||||
{ \
|
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
} \
|
||||||
} \
|
\
|
||||||
\
|
-(void)set##capitalized_name : (type)lowercased_name { \
|
||||||
- (void)set##capitalized_name:(type)lowercased_name \
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
|
||||||
{ \
|
}
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
|
|
||||||
|
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
||||||
|
-(YGValue)lowercased_name { \
|
||||||
|
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
-(void)set##capitalized_name : (YGValue)lowercased_name { \
|
||||||
|
switch (lowercased_name.unit) { \
|
||||||
|
case YGUnitUndefined: \
|
||||||
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
case YGUnitPoint: \
|
||||||
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
case YGUnitPercent: \
|
||||||
|
YGNodeStyleSet##capitalized_name##Percent( \
|
||||||
|
self.node, lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
default: \
|
||||||
|
NSAssert(NO, @"Not implemented"); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
||||||
|
-(YGValue)lowercased_name { \
|
||||||
|
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
-(void)set##capitalized_name : (YGValue)lowercased_name { \
|
||||||
|
switch (lowercased_name.unit) { \
|
||||||
|
case YGUnitPoint: \
|
||||||
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
case YGUnitPercent: \
|
||||||
|
YGNodeStyleSet##capitalized_name##Percent( \
|
||||||
|
self.node, lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
case YGUnitAuto: \
|
||||||
|
YGNodeStyleSet##capitalized_name##Auto(self.node); \
|
||||||
|
break; \
|
||||||
|
default: \
|
||||||
|
NSAssert(NO, @"Not implemented"); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define YG_EDGE_PROPERTY_GETTER( \
|
||||||
|
type, lowercased_name, capitalized_name, property, edge) \
|
||||||
|
-(type)lowercased_name { \
|
||||||
|
return YGNodeStyleGet##property(self.node, edge); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define YG_EDGE_PROPERTY_SETTER( \
|
||||||
|
lowercased_name, capitalized_name, property, edge) \
|
||||||
|
-(void)set##capitalized_name : (CGFloat)lowercased_name { \
|
||||||
|
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
||||||
|
YG_EDGE_PROPERTY_GETTER( \
|
||||||
|
CGFloat, lowercased_name, capitalized_name, property, edge) \
|
||||||
|
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
||||||
|
|
||||||
|
#define YG_VALUE_EDGE_PROPERTY_SETTER( \
|
||||||
|
objc_lowercased_name, objc_capitalized_name, c_name, edge) \
|
||||||
|
-(void)set##objc_capitalized_name : (YGValue)objc_lowercased_name { \
|
||||||
|
switch (objc_lowercased_name.unit) { \
|
||||||
|
case YGUnitUndefined: \
|
||||||
|
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
case YGUnitPoint: \
|
||||||
|
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
case YGUnitPercent: \
|
||||||
|
YGNodeStyleSet##c_name##Percent( \
|
||||||
|
self.node, edge, objc_lowercased_name.value); \
|
||||||
|
break; \
|
||||||
|
default: \
|
||||||
|
NSAssert(NO, @"Not implemented"); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name, capitalized_name, property, edge) \
|
||||||
|
YG_EDGE_PROPERTY_GETTER( \
|
||||||
|
YGValue, lowercased_name, capitalized_name, property, edge) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY_SETTER( \
|
||||||
|
lowercased_name, capitalized_name, property, edge)
|
||||||
|
|
||||||
|
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##Left, \
|
||||||
|
capitalized_name##Left, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeLeft) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##Top, \
|
||||||
|
capitalized_name##Top, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeTop) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##Right, \
|
||||||
|
capitalized_name##Right, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeRight) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##Bottom, \
|
||||||
|
capitalized_name##Bottom, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeBottom) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##Start, \
|
||||||
|
capitalized_name##Start, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeStart) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##End, \
|
||||||
|
capitalized_name##End, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeEnd) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##Horizontal, \
|
||||||
|
capitalized_name##Horizontal, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeHorizontal) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name##Vertical, \
|
||||||
|
capitalized_name##Vertical, \
|
||||||
|
capitalized_name, \
|
||||||
|
YGEdgeVertical) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY( \
|
||||||
|
lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
|
||||||
|
|
||||||
|
YGValue YGPointValue(CGFloat value) {
|
||||||
|
return (YGValue){.value = value, .unit = YGUnitPoint};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
YGValue YGPercentValue(CGFloat value) {
|
||||||
- (YGValue)lowercased_name \
|
return (YGValue){.value = value, .unit = YGUnitPercent};
|
||||||
{ \
|
|
||||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
- (void)set##capitalized_name:(YGValue)lowercased_name \
|
|
||||||
{ \
|
|
||||||
switch (lowercased_name.unit) { \
|
|
||||||
case YGUnitUndefined: \
|
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
case YGUnitPoint: \
|
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
case YGUnitPercent: \
|
|
||||||
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
default: \
|
|
||||||
NSAssert(NO, @"Not implemented"); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
|
||||||
- (YGValue)lowercased_name \
|
|
||||||
{ \
|
|
||||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
- (void)set##capitalized_name:(YGValue)lowercased_name \
|
|
||||||
{ \
|
|
||||||
switch (lowercased_name.unit) { \
|
|
||||||
case YGUnitPoint: \
|
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
case YGUnitPercent: \
|
|
||||||
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
case YGUnitAuto: \
|
|
||||||
YGNodeStyleSet##capitalized_name##Auto(self.node); \
|
|
||||||
break; \
|
|
||||||
default: \
|
|
||||||
NSAssert(NO, @"Not implemented"); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \
|
|
||||||
- (type)lowercased_name \
|
|
||||||
{ \
|
|
||||||
return YGNodeStyleGet##property(self.node, edge); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) \
|
|
||||||
- (void)set##capitalized_name:(CGFloat)lowercased_name \
|
|
||||||
{ \
|
|
||||||
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
|
||||||
YG_EDGE_PROPERTY_GETTER(CGFloat, lowercased_name, capitalized_name, property, edge) \
|
|
||||||
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
|
||||||
|
|
||||||
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
|
|
||||||
- (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \
|
|
||||||
{ \
|
|
||||||
switch (objc_lowercased_name.unit) { \
|
|
||||||
case YGUnitUndefined: \
|
|
||||||
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
case YGUnitPoint: \
|
|
||||||
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
case YGUnitPercent: \
|
|
||||||
YGNodeStyleSet##c_name##Percent(self.node, edge, objc_lowercased_name.value); \
|
|
||||||
break; \
|
|
||||||
default: \
|
|
||||||
NSAssert(NO, @"Not implemented"); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
|
||||||
YG_EDGE_PROPERTY_GETTER(YGValue, lowercased_name, capitalized_name, property, edge) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
|
||||||
|
|
||||||
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
|
|
||||||
|
|
||||||
YGValue YGPointValue(CGFloat value)
|
|
||||||
{
|
|
||||||
return (YGValue) { .value = value, .unit = YGUnitPoint };
|
|
||||||
}
|
|
||||||
|
|
||||||
YGValue YGPercentValue(CGFloat value)
|
|
||||||
{
|
|
||||||
return (YGValue) { .value = value, .unit = YGUnitPercent };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static YGConfigRef globalConfig;
|
static YGConfigRef globalConfig;
|
||||||
|
|
||||||
@interface YGLayout ()
|
@interface YGLayout ()
|
||||||
|
|
||||||
@property (nonatomic, weak, readonly) UIView *view;
|
@property(nonatomic, weak, readonly) UIView* view;
|
||||||
@property(nonatomic, assign, readonly) BOOL isUIView;
|
@property(nonatomic, assign, readonly) BOOL isUIView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation YGLayout
|
@implementation YGLayout
|
||||||
|
|
||||||
@synthesize isEnabled=_isEnabled;
|
@synthesize isEnabled = _isEnabled;
|
||||||
@synthesize isIncludedInLayout=_isIncludedInLayout;
|
@synthesize isIncludedInLayout = _isIncludedInLayout;
|
||||||
@synthesize node=_node;
|
@synthesize node = _node;
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize {
|
||||||
{
|
|
||||||
globalConfig = YGConfigNew();
|
globalConfig = YGConfigNew();
|
||||||
YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true);
|
YGConfigSetExperimentalFeatureEnabled(
|
||||||
|
globalConfig, YGExperimentalFeatureWebFlexBasis, true);
|
||||||
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
|
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithView:(UIView*)view
|
- (instancetype)initWithView:(UIView*)view {
|
||||||
{
|
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
_view = view;
|
_view = view;
|
||||||
_node = YGNodeNewWithConfig(globalConfig);
|
_node = YGNodeNewWithConfig(globalConfig);
|
||||||
YGNodeSetContext(_node, (__bridge void *) view);
|
YGNodeSetContext(_node, (__bridge void*)view);
|
||||||
_isEnabled = NO;
|
_isEnabled = NO;
|
||||||
_isIncludedInLayout = YES;
|
_isIncludedInLayout = YES;
|
||||||
_isUIView = [view isMemberOfClass:[UIView class]];
|
_isUIView = [view isMemberOfClass:[UIView class]];
|
||||||
@@ -160,18 +191,15 @@ static YGConfigRef globalConfig;
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc {
|
||||||
{
|
|
||||||
YGNodeFree(self.node);
|
YGNodeFree(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isDirty
|
- (BOOL)isDirty {
|
||||||
{
|
|
||||||
return YGNodeIsDirty(self.node);
|
return YGNodeIsDirty(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)markDirty
|
- (void)markDirty {
|
||||||
{
|
|
||||||
if (self.isDirty || !self.isLeaf) {
|
if (self.isDirty || !self.isLeaf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -187,17 +215,17 @@ static YGConfigRef globalConfig;
|
|||||||
YGNodeMarkDirty(node);
|
YGNodeMarkDirty(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUInteger)numberOfChildren
|
- (NSUInteger)numberOfChildren {
|
||||||
{
|
|
||||||
return YGNodeGetChildCount(self.node);
|
return YGNodeGetChildCount(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isLeaf
|
- (BOOL)isLeaf {
|
||||||
{
|
NSAssert(
|
||||||
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
|
[NSThread isMainThread],
|
||||||
|
@"This method must be called on the main thread.");
|
||||||
if (self.isEnabled) {
|
if (self.isEnabled) {
|
||||||
for (UIView *subview in self.view.subviews) {
|
for (UIView* subview in self.view.subviews) {
|
||||||
YGLayout *const yoga = subview.yoga;
|
YGLayout* const yoga = subview.yoga;
|
||||||
if (yoga.isEnabled && yoga.isIncludedInLayout) {
|
if (yoga.isEnabled && yoga.isIncludedInLayout) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -209,13 +237,11 @@ static YGConfigRef globalConfig;
|
|||||||
|
|
||||||
#pragma mark - Style
|
#pragma mark - Style
|
||||||
|
|
||||||
- (YGPositionType)position
|
- (YGPositionType)position {
|
||||||
{
|
|
||||||
return YGNodeStyleGetPositionType(self.node);
|
return YGNodeStyleGetPositionType(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPosition:(YGPositionType)position
|
- (void)setPosition:(YGPositionType)position {
|
||||||
{
|
|
||||||
YGNodeStyleSetPositionType(self.node, position);
|
YGNodeStyleSetPositionType(self.node, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,27 +285,29 @@ YG_VALUE_PROPERTY(maxWidth, MaxWidth)
|
|||||||
YG_VALUE_PROPERTY(maxHeight, MaxHeight)
|
YG_VALUE_PROPERTY(maxHeight, MaxHeight)
|
||||||
YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
||||||
|
|
||||||
|
YG_EDGE_PROPERTY(columnGap, ColumnGap, Gap, YGGutterColumn)
|
||||||
|
YG_EDGE_PROPERTY(rowGap, RowGap, Gap, YGGutterRow)
|
||||||
|
YG_EDGE_PROPERTY(gap, Gap, Gap, YGGutterAll)
|
||||||
|
|
||||||
#pragma mark - Layout and Sizing
|
#pragma mark - Layout and Sizing
|
||||||
|
|
||||||
- (YGDirection)resolvedDirection
|
- (YGDirection)resolvedDirection {
|
||||||
{
|
|
||||||
return YGNodeLayoutGetDirection(self.node);
|
return YGNodeLayoutGetDirection(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyLayout
|
- (void)applyLayout {
|
||||||
{
|
|
||||||
[self calculateLayoutWithSize:self.view.bounds.size];
|
[self calculateLayoutWithSize:self.view.bounds.size];
|
||||||
YGApplyLayoutToViewHierarchy(self.view, NO);
|
YGApplyLayoutToViewHierarchy(self.view, NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin {
|
||||||
{
|
|
||||||
[self calculateLayoutWithSize:self.view.bounds.size];
|
[self calculateLayoutWithSize:self.view.bounds.size];
|
||||||
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
{
|
dimensionFlexibility:
|
||||||
|
(YGDimensionFlexibility)dimensionFlexibility {
|
||||||
CGSize size = self.view.bounds.size;
|
CGSize size = self.view.bounds.size;
|
||||||
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
|
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
|
||||||
size.width = YGUndefined;
|
size.width = YGUndefined;
|
||||||
@@ -291,18 +319,15 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
|||||||
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (CGSize)intrinsicSize {
|
||||||
- (CGSize)intrinsicSize
|
|
||||||
{
|
|
||||||
const CGSize constrainedSize = {
|
const CGSize constrainedSize = {
|
||||||
.width = YGUndefined,
|
.width = YGUndefined,
|
||||||
.height = YGUndefined,
|
.height = YGUndefined,
|
||||||
};
|
};
|
||||||
return [self calculateLayoutWithSize:constrainedSize];
|
return [self calculateLayoutWithSize:constrainedSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
- (CGSize)calculateLayoutWithSize:(CGSize)size {
|
||||||
{
|
|
||||||
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
|
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
|
||||||
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
|
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
|
||||||
|
|
||||||
@@ -310,30 +335,28 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
|||||||
|
|
||||||
const YGNodeRef node = self.node;
|
const YGNodeRef node = self.node;
|
||||||
YGNodeCalculateLayout(
|
YGNodeCalculateLayout(
|
||||||
node,
|
node, size.width, size.height, YGNodeStyleGetDirection(node));
|
||||||
size.width,
|
|
||||||
size.height,
|
|
||||||
YGNodeStyleGetDirection(node));
|
|
||||||
|
|
||||||
return (CGSize) {
|
return (CGSize){
|
||||||
.width = YGNodeLayoutGetWidth(node),
|
.width = YGNodeLayoutGetWidth(node),
|
||||||
.height = YGNodeLayoutGetHeight(node),
|
.height = YGNodeLayoutGetHeight(node),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Private
|
#pragma mark - Private
|
||||||
|
|
||||||
static YGSize YGMeasureView(
|
static YGSize YGMeasureView(
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
float width,
|
float width,
|
||||||
YGMeasureMode widthMode,
|
YGMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
YGMeasureMode heightMode)
|
YGMeasureMode heightMode) {
|
||||||
{
|
const CGFloat constrainedWidth =
|
||||||
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
(widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
||||||
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
|
const CGFloat constrainedHeight =
|
||||||
|
(heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : height;
|
||||||
|
|
||||||
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
|
UIView* view = (__bridge UIView*)YGNodeGetContext(node);
|
||||||
CGSize sizeThatFits = CGSizeZero;
|
CGSize sizeThatFits = CGSizeZero;
|
||||||
|
|
||||||
// The default implementation of sizeThatFits: returns the existing size of
|
// The default implementation of sizeThatFits: returns the existing size of
|
||||||
@@ -349,17 +372,18 @@ static YGSize YGMeasureView(
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (YGSize) {
|
return (YGSize){
|
||||||
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
.width = YGSanitizeMeasurement(
|
||||||
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
constrainedWidth, sizeThatFits.width, widthMode),
|
||||||
|
.height = YGSanitizeMeasurement(
|
||||||
|
constrainedHeight, sizeThatFits.height, heightMode),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat YGSanitizeMeasurement(
|
static CGFloat YGSanitizeMeasurement(
|
||||||
CGFloat constrainedSize,
|
CGFloat constrainedSize,
|
||||||
CGFloat measuredSize,
|
CGFloat measuredSize,
|
||||||
YGMeasureMode measureMode)
|
YGMeasureMode measureMode) {
|
||||||
{
|
|
||||||
CGFloat result;
|
CGFloat result;
|
||||||
if (measureMode == YGMeasureModeExactly) {
|
if (measureMode == YGMeasureModeExactly) {
|
||||||
result = constrainedSize;
|
result = constrainedSize;
|
||||||
@@ -372,13 +396,14 @@ static CGFloat YGSanitizeMeasurement(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
|
static BOOL YGNodeHasExactSameChildren(
|
||||||
{
|
const YGNodeRef node,
|
||||||
|
NSArray<UIView*>* subviews) {
|
||||||
if (YGNodeGetChildCount(node) != subviews.count) {
|
if (YGNodeGetChildCount(node) != subviews.count) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<subviews.count; i++) {
|
for (int i = 0; i < subviews.count; i++) {
|
||||||
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
|
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -387,9 +412,8 @@ static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGAttachNodesFromViewHierachy(UIView *const view)
|
static void YGAttachNodesFromViewHierachy(UIView* const view) {
|
||||||
{
|
YGLayout* const yoga = view.yoga;
|
||||||
YGLayout *const yoga = view.yoga;
|
|
||||||
const YGNodeRef node = yoga.node;
|
const YGNodeRef node = yoga.node;
|
||||||
|
|
||||||
// Only leaf nodes should have a measure function
|
// Only leaf nodes should have a measure function
|
||||||
@@ -399,8 +423,9 @@ static void YGAttachNodesFromViewHierachy(UIView *const view)
|
|||||||
} else {
|
} else {
|
||||||
YGNodeSetMeasureFunc(node, NULL);
|
YGNodeSetMeasureFunc(node, NULL);
|
||||||
|
|
||||||
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
NSMutableArray<UIView*>* subviewsToInclude =
|
||||||
for (UIView *subview in view.subviews) {
|
[[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
||||||
|
for (UIView* subview in view.subviews) {
|
||||||
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
|
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
|
||||||
[subviewsToInclude addObject:subview];
|
[subviewsToInclude addObject:subview];
|
||||||
}
|
}
|
||||||
@@ -408,19 +433,18 @@ static void YGAttachNodesFromViewHierachy(UIView *const view)
|
|||||||
|
|
||||||
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
|
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
|
||||||
YGRemoveAllChildren(node);
|
YGRemoveAllChildren(node);
|
||||||
for (int i=0; i<subviewsToInclude.count; i++) {
|
for (int i = 0; i < subviewsToInclude.count; i++) {
|
||||||
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
|
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UIView *const subview in subviewsToInclude) {
|
for (UIView* const subview in subviewsToInclude) {
|
||||||
YGAttachNodesFromViewHierachy(subview);
|
YGAttachNodesFromViewHierachy(subview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGRemoveAllChildren(const YGNodeRef node)
|
static void YGRemoveAllChildren(const YGNodeRef node) {
|
||||||
{
|
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -428,52 +452,56 @@ static void YGRemoveAllChildren(const YGNodeRef node)
|
|||||||
YGNodeRemoveAllChildren(node);
|
YGNodeRemoveAllChildren(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat YGRoundPixelValue(CGFloat value)
|
static CGFloat YGRoundPixelValue(CGFloat value) {
|
||||||
{
|
|
||||||
static CGFloat scale;
|
static CGFloat scale;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^(){
|
dispatch_once(&onceToken, ^() {
|
||||||
scale = [UIScreen mainScreen].scale;
|
scale = [UIScreen mainScreen].scale;
|
||||||
});
|
});
|
||||||
|
|
||||||
return roundf(value * scale) / scale;
|
return roundf(value * scale) / scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
|
static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
|
||||||
{
|
NSCAssert(
|
||||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
[NSThread isMainThread],
|
||||||
|
@"Framesetting should only be done on the main thread.");
|
||||||
|
|
||||||
const YGLayout *yoga = view.yoga;
|
const YGLayout* yoga = view.yoga;
|
||||||
|
|
||||||
if (!yoga.isIncludedInLayout) {
|
if (!yoga.isIncludedInLayout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGNodeRef node = yoga.node;
|
YGNodeRef node = yoga.node;
|
||||||
const CGPoint topLeft = {
|
const CGPoint topLeft = {
|
||||||
YGNodeLayoutGetLeft(node),
|
YGNodeLayoutGetLeft(node),
|
||||||
YGNodeLayoutGetTop(node),
|
YGNodeLayoutGetTop(node),
|
||||||
};
|
};
|
||||||
|
|
||||||
const CGPoint bottomRight = {
|
const CGPoint bottomRight = {
|
||||||
topLeft.x + YGNodeLayoutGetWidth(node),
|
topLeft.x + YGNodeLayoutGetWidth(node),
|
||||||
topLeft.y + YGNodeLayoutGetHeight(node),
|
topLeft.y + YGNodeLayoutGetHeight(node),
|
||||||
};
|
};
|
||||||
|
|
||||||
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
|
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
|
||||||
view.frame = (CGRect) {
|
view.frame = (CGRect){
|
||||||
.origin = {
|
.origin =
|
||||||
.x = YGRoundPixelValue(topLeft.x + origin.x),
|
{
|
||||||
.y = YGRoundPixelValue(topLeft.y + origin.y),
|
.x = YGRoundPixelValue(topLeft.x + origin.x),
|
||||||
},
|
.y = YGRoundPixelValue(topLeft.y + origin.y),
|
||||||
.size = {
|
},
|
||||||
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
.size =
|
||||||
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
|
{
|
||||||
},
|
.width = YGRoundPixelValue(bottomRight.x) -
|
||||||
|
YGRoundPixelValue(topLeft.x),
|
||||||
|
.height = YGRoundPixelValue(bottomRight.y) -
|
||||||
|
YGRoundPixelValue(topLeft.y),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!yoga.isLeaf) {
|
if (!yoga.isLeaf) {
|
||||||
for (NSUInteger i=0; i<view.subviews.count; i++) {
|
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||||
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
|
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import yoga;
|
||||||
postfix operator %
|
postfix operator %
|
||||||
|
|
||||||
extension Int {
|
extension Int {
|
||||||
@@ -29,15 +30,15 @@ extension YGValue : ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
|
|||||||
public init(integerLiteral value: Int) {
|
public init(integerLiteral value: Int) {
|
||||||
self = YGValue(value: Float(value), unit: .point)
|
self = YGValue(value: Float(value), unit: .point)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(floatLiteral value: Float) {
|
public init(floatLiteral value: Float) {
|
||||||
self = YGValue(value: value, unit: .point)
|
self = YGValue(value: value, unit: .point)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ value: Float) {
|
public init(_ value: Float) {
|
||||||
self = YGValue(value: value, unit: .point)
|
self = YGValue(value: value, unit: .point)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ value: CGFloat) {
|
public init(_ value: CGFloat) {
|
||||||
self = YGValue(value: Float(value), unit: .point)
|
self = YGValue(value: Float(value), unit: .point)
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -16,17 +16,15 @@
|
|||||||
|
|
||||||
@implementation YogaKitTests
|
@implementation YogaKitTests
|
||||||
|
|
||||||
- (void)testConfigureLayoutIsNoOpWithNilBlock
|
- (void)testConfigureLayoutIsNoOpWithNilBlock {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
id block = nil;
|
id block = nil;
|
||||||
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
|
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testConfigureLayoutBlockWorksWithValidBlock
|
- (void)testConfigureLayoutBlockWorksWithValidBlock {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
[view configureLayoutWithBlock:^(YGLayout* layout) {
|
||||||
[view configureLayoutWithBlock:^(YGLayout *layout){
|
|
||||||
XCTAssertNotNil(layout);
|
XCTAssertNotNil(layout);
|
||||||
layout.isEnabled = YES;
|
layout.isEnabled = YES;
|
||||||
layout.width = YGPointValue(25);
|
layout.width = YGPointValue(25);
|
||||||
@@ -36,12 +34,11 @@
|
|||||||
XCTAssertEqual(view.yoga.width.value, 25);
|
XCTAssertEqual(view.yoga.width.value, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testNodesAreDeallocedWithSingleView
|
- (void)testNodesAreDeallocedWithSingleView {
|
||||||
{
|
__weak YGLayout* layoutRef = nil;
|
||||||
__weak YGLayout *layoutRef = nil;
|
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
view.yoga.flexBasis = YGPointValue(1);
|
view.yoga.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
layoutRef = view.yoga;
|
layoutRef = view.yoga;
|
||||||
@@ -53,17 +50,16 @@
|
|||||||
XCTAssertNil(layoutRef);
|
XCTAssertNil(layoutRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testNodesAreDeallocedCascade
|
- (void)testNodesAreDeallocedCascade {
|
||||||
{
|
__weak YGLayout* topLayout = nil;
|
||||||
__weak YGLayout *topLayout = nil;
|
__weak YGLayout* subviewLayout = nil;
|
||||||
__weak YGLayout *subviewLayout = nil;
|
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
topLayout = view.yoga;
|
topLayout = view.yoga;
|
||||||
topLayout.flexBasis = YGPointValue(1);
|
topLayout.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subviewLayout = subview.yoga;
|
subviewLayout = subview.yoga;
|
||||||
subviewLayout.flexBasis = YGPointValue(1);
|
subviewLayout.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
@@ -74,9 +70,8 @@
|
|||||||
XCTAssertNil(subviewLayout);
|
XCTAssertNil(subviewLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testIsEnabled
|
- (void)testIsEnabled {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
XCTAssertFalse(view.yoga.isEnabled);
|
XCTAssertFalse(view.yoga.isEnabled);
|
||||||
|
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
@@ -86,30 +81,31 @@
|
|||||||
XCTAssertFalse(view.yoga.isEnabled);
|
XCTAssertFalse(view.yoga.isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testSizeThatFitsAsserts
|
- (void)testSizeThatFitsAsserts {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
dispatch_sync(
|
||||||
dispatch_sync(dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL), ^(void){
|
dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL),
|
||||||
XCTAssertThrows(view.yoga.intrinsicSize);
|
^(void) {
|
||||||
});
|
XCTAssertThrows(view.yoga.intrinsicSize);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testSizeThatFitsSmoke
|
- (void)testSizeThatFitsSmoke {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
container.yoga.alignItems = YGAlignFlexStart;
|
container.yoga.alignItems = YGAlignFlexStart;
|
||||||
|
|
||||||
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
UILabel* longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||||
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
|
longTextLabel.text =
|
||||||
|
@"This is a very very very very very very very very long piece of text.";
|
||||||
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||||
longTextLabel.numberOfLines = 1;
|
longTextLabel.numberOfLines = 1;
|
||||||
longTextLabel.yoga.isEnabled = YES;
|
longTextLabel.yoga.isEnabled = YES;
|
||||||
longTextLabel.yoga.flexShrink = 1;
|
longTextLabel.yoga.flexShrink = 1;
|
||||||
[container addSubview:longTextLabel];
|
[container addSubview:longTextLabel];
|
||||||
|
|
||||||
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
textBadgeView.yoga.isEnabled = YES;
|
textBadgeView.yoga.isEnabled = YES;
|
||||||
textBadgeView.yoga.margin = YGPointValue(0);
|
textBadgeView.yoga.margin = YGPointValue(0);
|
||||||
textBadgeView.yoga.width = YGPointValue(10);
|
textBadgeView.yoga.width = YGPointValue(10);
|
||||||
@@ -124,7 +120,9 @@
|
|||||||
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
|
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
|
||||||
|
|
||||||
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
|
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
|
||||||
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
|
XCTAssertEqual(
|
||||||
|
longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width,
|
||||||
|
containerSize.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testSizeThatFitsEmptyView {
|
- (void)testSizeThatFitsEmptyView {
|
||||||
@@ -136,18 +134,17 @@
|
|||||||
XCTAssertEqual(viewSize.width, 0);
|
XCTAssertEqual(viewSize.width, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPreservingOrigin
|
- (void)testPreservingOrigin {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 75)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.flexBasis = YGPointValue(0);
|
view.yoga.flexBasis = YGPointValue(0);
|
||||||
view.yoga.flexGrow = 1;
|
view.yoga.flexGrow = 1;
|
||||||
[container addSubview:view];
|
[container addSubview:view];
|
||||||
|
|
||||||
UIView *view2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* view2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
view2.yoga.isEnabled = YES;
|
view2.yoga.isEnabled = YES;
|
||||||
view2.yoga.marginTop = YGPointValue(25);
|
view2.yoga.marginTop = YGPointValue(25);
|
||||||
view2.yoga.flexBasis = YGPointValue(0);
|
view2.yoga.flexBasis = YGPointValue(0);
|
||||||
@@ -161,28 +158,28 @@
|
|||||||
XCTAssertEqual(25, view2.frame.origin.y);
|
XCTAssertEqual(25, view2.frame.origin.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testContainerWithFlexibleWidthGetsCorrectlySized
|
- (void)testContainerWithFlexibleWidthGetsCorrectlySized {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.width = YGPointValue(100);
|
view.yoga.width = YGPointValue(100);
|
||||||
view.yoga.height = YGPointValue(100);
|
view.yoga.height = YGPointValue(100);
|
||||||
[container addSubview:view];
|
[container addSubview:view];
|
||||||
|
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
|
[container.yoga
|
||||||
|
applyLayoutPreservingOrigin:YES
|
||||||
|
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
|
||||||
XCTAssertEqual(100, container.frame.size.width);
|
XCTAssertEqual(100, container.frame.size.width);
|
||||||
XCTAssertEqual(200, container.frame.size.height);
|
XCTAssertEqual(200, container.frame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testContainerWithFlexibleHeightGetsCorrectlySized
|
- (void)testContainerWithFlexibleHeightGetsCorrectlySized {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.width = YGPointValue(100);
|
view.yoga.width = YGPointValue(100);
|
||||||
view.yoga.height = YGPointValue(100);
|
view.yoga.height = YGPointValue(100);
|
||||||
@@ -195,12 +192,11 @@
|
|||||||
XCTAssertEqual(100, container.frame.size.height);
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized
|
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.width = YGPointValue(100);
|
view.yoga.width = YGPointValue(100);
|
||||||
view.yoga.height = YGPointValue(100);
|
view.yoga.height = YGPointValue(100);
|
||||||
@@ -214,12 +210,11 @@
|
|||||||
XCTAssertEqual(100, container.frame.size.height);
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
|
- (void)testMarkingDirtyOnlyWorksOnLeafNodes {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview.yoga.isEnabled = YES;
|
subview.yoga.isEnabled = YES;
|
||||||
[container addSubview:subview];
|
[container addSubview:subview];
|
||||||
|
|
||||||
@@ -232,14 +227,13 @@
|
|||||||
XCTAssertTrue(subview.yoga.isDirty);
|
XCTAssertTrue(subview.yoga.isDirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
|
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
container.yoga.alignItems = YGAlignFlexStart;
|
container.yoga.alignItems = YGAlignFlexStart;
|
||||||
|
|
||||||
UILabel *view = [[UILabel alloc] initWithFrame:CGRectZero];
|
UILabel* view = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||||
view.text = @"This is a short text.";
|
view.text = @"This is a short text.";
|
||||||
view.numberOfLines = 1;
|
view.numberOfLines = 1;
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
@@ -257,61 +251,70 @@
|
|||||||
XCTAssertFalse(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
|
XCTAssertFalse(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testFrameAndOriginPlacement
|
- (void)testFrameAndOriginPlacement {
|
||||||
{
|
|
||||||
const CGSize containerSize = CGSizeMake(320, 50);
|
const CGSize containerSize = CGSizeMake(320, 50);
|
||||||
|
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
UIView* container = [[UIView alloc]
|
||||||
|
initWithFrame:CGRectMake(
|
||||||
|
0, 0, containerSize.width, containerSize.height)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
|
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertEqualWithAccuracy(subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
|
XCTAssertEqualWithAccuracy(
|
||||||
XCTAssertEqualWithAccuracy(subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
|
subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
|
||||||
|
XCTAssertEqualWithAccuracy(
|
||||||
|
subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
|
||||||
|
|
||||||
CGFloat totalWidth = 0;
|
CGFloat totalWidth = 0;
|
||||||
for (UIView *view in container.subviews) {
|
for (UIView* view in container.subviews) {
|
||||||
totalWidth += view.bounds.size.width;
|
totalWidth += view.bounds.size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
|
XCTAssertEqual(
|
||||||
|
containerSize.width,
|
||||||
|
totalWidth,
|
||||||
|
@"The container's width is %.6f, the subviews take up %.6f",
|
||||||
|
containerSize.width,
|
||||||
|
totalWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
|
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder {
|
||||||
{
|
|
||||||
const CGSize containerSize = CGSizeMake(300, 50);
|
const CGSize containerSize = CGSizeMake(300, 50);
|
||||||
|
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
UIView* container = [[UIView alloc]
|
||||||
|
initWithFrame:CGRectMake(
|
||||||
|
0, 0, containerSize.width, containerSize.height)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
@@ -333,32 +336,33 @@
|
|||||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatWeRespectIncludeInLayoutFlag
|
- (void)testThatWeRespectIncludeInLayoutFlag {
|
||||||
{
|
|
||||||
const CGSize containerSize = CGSizeMake(300, 50);
|
const CGSize containerSize = CGSizeMake(300, 50);
|
||||||
|
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
UIView* container = [[UIView alloc]
|
||||||
|
initWithFrame:CGRectMake(
|
||||||
|
0, 0, containerSize.width, containerSize.height)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
|
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
for (UIView *subview in container.subviews) {
|
for (UIView* subview in container.subviews) {
|
||||||
XCTAssertEqual(subview.bounds.size.width, 100);
|
XCTAssertEqual(subview.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,27 +372,27 @@
|
|||||||
XCTAssertEqual(subview1.bounds.size.width, 150);
|
XCTAssertEqual(subview1.bounds.size.width, 150);
|
||||||
XCTAssertEqual(subview2.bounds.size.width, 150);
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
|
|
||||||
// We don't set the frame to zero, so, it should be set to what it was previously at.
|
// We don't set the frame to zero, so, it should be set to what it was
|
||||||
|
// previously at.
|
||||||
XCTAssertEqual(subview3.bounds.size.width, 100);
|
XCTAssertEqual(subview3.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
|
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.isIncludedInLayout = NO;
|
subview1.yoga.isIncludedInLayout = NO;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.isIncludedInLayout = NO;
|
subview2.yoga.isIncludedInLayout = NO;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.isIncludedInLayout = YES;
|
subview3.yoga.isIncludedInLayout = YES;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
@@ -401,23 +405,22 @@
|
|||||||
XCTAssertEqual(container.yoga.numberOfChildren, 2);
|
XCTAssertEqual(container.yoga.numberOfChildren, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
|
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
subview3.yoga.isIncludedInLayout = NO;
|
subview3.yoga.isIncludedInLayout = NO;
|
||||||
@@ -437,13 +440,12 @@
|
|||||||
XCTAssertEqual(subview3.bounds.size.width, 100);
|
XCTAssertEqual(subview3.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testIsLeafFlag
|
- (void)testIsLeafFlag {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
XCTAssertTrue(view.yoga.isLeaf);
|
XCTAssertTrue(view.yoga.isLeaf);
|
||||||
|
|
||||||
for (int i=0; i<10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
[view addSubview:subview];
|
[view addSubview:subview];
|
||||||
}
|
}
|
||||||
XCTAssertTrue(view.yoga.isLeaf);
|
XCTAssertTrue(view.yoga.isLeaf);
|
||||||
@@ -452,99 +454,95 @@
|
|||||||
view.yoga.width = YGPointValue(50);
|
view.yoga.width = YGPointValue(50);
|
||||||
XCTAssertTrue(view.yoga.isLeaf);
|
XCTAssertTrue(view.yoga.isLeaf);
|
||||||
|
|
||||||
UIView *const subview = view.subviews[0];
|
UIView* const subview = view.subviews[0];
|
||||||
subview.yoga.isEnabled = YES;
|
subview.yoga.isEnabled = YES;
|
||||||
subview.yoga.width = YGPointValue(50);
|
subview.yoga.width = YGPointValue(50);
|
||||||
XCTAssertFalse(view.yoga.isLeaf);
|
XCTAssertFalse(view.yoga.isLeaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatWeCorrectlyAttachNestedViews
|
- (void)testThatWeCorrectlyAttachNestedViews {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.flexDirection = YGFlexDirectionColumn;
|
||||||
container.yoga.flexDirection = YGFlexDirectionColumn;
|
|
||||||
|
|
||||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.width = YGPointValue(100);
|
subview1.yoga.width = YGPointValue(100);
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
subview1.yoga.flexDirection = YGFlexDirectionColumn;
|
subview1.yoga.flexDirection = YGFlexDirectionColumn;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.width = YGPointValue(150);
|
subview2.yoga.width = YGPointValue(150);
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
subview2.yoga.flexDirection = YGFlexDirectionColumn;
|
subview2.yoga.flexDirection = YGFlexDirectionColumn;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
for (UIView *view in @[subview1, subview2]) {
|
for (UIView* view in @[ subview1, subview2 ]) {
|
||||||
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* someView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
someView.yoga.isEnabled = YES;
|
someView.yoga.isEnabled = YES;
|
||||||
someView.yoga.flexGrow = 1;
|
someView.yoga.flexGrow = 1;
|
||||||
[view addSubview:someView];
|
[view addSubview:someView];
|
||||||
}
|
}
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
// Add the same amount of new views, reapply layout.
|
// Add the same amount of new views, reapply layout.
|
||||||
for (UIView *view in @[subview1, subview2]) {
|
for (UIView* view in @[ subview1, subview2 ]) {
|
||||||
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* someView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
someView.yoga.isEnabled = YES;
|
someView.yoga.isEnabled = YES;
|
||||||
someView.yoga.flexGrow = 1;
|
someView.yoga.flexGrow = 1;
|
||||||
[view addSubview:someView];
|
[view addSubview:someView];
|
||||||
}
|
}
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertEqual(subview1.bounds.size.width, 100);
|
XCTAssertEqual(subview1.bounds.size.width, 100);
|
||||||
XCTAssertEqual(subview1.bounds.size.height, 25);
|
XCTAssertEqual(subview1.bounds.size.height, 25);
|
||||||
for (UIView *subview in subview1.subviews) {
|
for (UIView* subview in subview1.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertNotEqual(subviewSize.width, 0);
|
XCTAssertNotEqual(subviewSize.width, 0);
|
||||||
XCTAssertNotEqual(subviewSize.height, 0);
|
XCTAssertNotEqual(subviewSize.height, 0);
|
||||||
XCTAssertFalse(isnan(subviewSize.height));
|
XCTAssertFalse(isnan(subviewSize.height));
|
||||||
XCTAssertFalse(isnan(subviewSize.width));
|
XCTAssertFalse(isnan(subviewSize.width));
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(subview2.bounds.size.width, 150);
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
XCTAssertEqual(subview2.bounds.size.height, 25);
|
XCTAssertEqual(subview2.bounds.size.height, 25);
|
||||||
for (UIView *subview in subview2.subviews) {
|
for (UIView* subview in subview2.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertNotEqual(subviewSize.width, 0);
|
XCTAssertNotEqual(subviewSize.width, 0);
|
||||||
XCTAssertNotEqual(subviewSize.height, 0);
|
XCTAssertNotEqual(subviewSize.height, 0);
|
||||||
XCTAssertFalse(isnan(subviewSize.height));
|
XCTAssertFalse(isnan(subviewSize.height));
|
||||||
XCTAssertFalse(isnan(subviewSize.width));
|
XCTAssertFalse(isnan(subviewSize.width));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatANonLeafNodeCanBecomeALeafNode
|
- (void)testThatANonLeafNodeCanBecomeALeafNode {
|
||||||
{
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.isEnabled = YES;
|
|
||||||
|
|
||||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
[subview1 addSubview:subview2];
|
[subview1 addSubview:subview2];
|
||||||
|
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
[subview2 removeFromSuperview];
|
[subview2 removeFromSuperview];
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPointPercent
|
- (void)testPointPercent {
|
||||||
{
|
|
||||||
XCTAssertEqual(YGPointValue(1).value, 1);
|
XCTAssertEqual(YGPointValue(1).value, 1);
|
||||||
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
|
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
|
||||||
XCTAssertEqual(YGPercentValue(2).value, 2);
|
XCTAssertEqual(YGPercentValue(2).value, 2);
|
||||||
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
|
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPositionalPropertiesWork
|
- (void)testPositionalPropertiesWork {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
|
|
||||||
view.yoga.left = YGPointValue(1);
|
view.yoga.left = YGPointValue(1);
|
||||||
XCTAssertEqual(view.yoga.left.value, 1);
|
XCTAssertEqual(view.yoga.left.value, 1);
|
||||||
@@ -589,9 +587,8 @@
|
|||||||
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
|
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testMarginPropertiesWork
|
- (void)testMarginPropertiesWork {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
|
|
||||||
view.yoga.margin = YGPointValue(1);
|
view.yoga.margin = YGPointValue(1);
|
||||||
XCTAssertEqual(view.yoga.margin.value, 1);
|
XCTAssertEqual(view.yoga.margin.value, 1);
|
||||||
@@ -657,9 +654,8 @@
|
|||||||
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
|
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPaddingPropertiesWork
|
- (void)testPaddingPropertiesWork {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
|
|
||||||
view.yoga.padding = YGPointValue(1);
|
view.yoga.padding = YGPointValue(1);
|
||||||
XCTAssertEqual(view.yoga.padding.value, 1);
|
XCTAssertEqual(view.yoga.padding.value, 1);
|
||||||
@@ -725,9 +721,8 @@
|
|||||||
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
|
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testBorderWidthPropertiesWork
|
- (void)testBorderWidthPropertiesWork {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
|
|
||||||
view.yoga.borderWidth = 1;
|
view.yoga.borderWidth = 1;
|
||||||
XCTAssertEqual(view.yoga.borderWidth, 1);
|
XCTAssertEqual(view.yoga.borderWidth, 1);
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE-examples file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE-examples file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE-examples file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE-examples file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "ViewController.h"
|
#import "ViewController.h"
|
||||||
@@ -12,45 +11,41 @@
|
|||||||
|
|
||||||
@implementation ViewController
|
@implementation ViewController
|
||||||
|
|
||||||
- (void)viewDidLoad
|
- (void)viewDidLoad {
|
||||||
{
|
UIView* root = self.view;
|
||||||
UIView *root = self.view;
|
root.backgroundColor = [UIColor redColor];
|
||||||
root.backgroundColor = [UIColor redColor];
|
root.yoga.isEnabled = YES;
|
||||||
root.yoga.isEnabled = YES;
|
root.yoga.width = YGPointValue(self.view.bounds.size.width);
|
||||||
root.yoga.width = YGPointValue(self.view.bounds.size.width);
|
root.yoga.height = YGPointValue(self.view.bounds.size.height);
|
||||||
root.yoga.height = YGPointValue(self.view.bounds.size.height);
|
root.yoga.alignItems = YGAlignCenter;
|
||||||
root.yoga.alignItems = YGAlignCenter;
|
root.yoga.justifyContent = YGJustifyCenter;
|
||||||
root.yoga.justifyContent = YGJustifyCenter;
|
|
||||||
|
|
||||||
UIView *child1 = [UIView new];
|
UIView* child1 = [UIView new];
|
||||||
child1.backgroundColor = [UIColor blueColor];
|
child1.backgroundColor = [UIColor blueColor];
|
||||||
child1.yoga.isEnabled = YES;
|
child1.yoga.isEnabled = YES;
|
||||||
child1.yoga.width = YGPointValue(100);
|
child1.yoga.width = YGPointValue(100);
|
||||||
child1.yoga.height = YGPointValue(100);
|
child1.yoga.height = YGPointValue(100);
|
||||||
|
|
||||||
UIView *child2 = [UIView new];
|
UIView* child2 = [UIView new];
|
||||||
child2.backgroundColor = [UIColor greenColor];
|
child2.backgroundColor = [UIColor greenColor];
|
||||||
child2.frame = (CGRect) {
|
child2.frame = (CGRect){
|
||||||
.size = {
|
.size = {
|
||||||
.width = 200,
|
.width = 200,
|
||||||
.height = 100,
|
.height = 100,
|
||||||
}
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
UIView *child3 = [UIView new];
|
UIView* child3 = [UIView new];
|
||||||
child3.backgroundColor = [UIColor yellowColor];
|
child3.backgroundColor = [UIColor yellowColor];
|
||||||
child3.frame = (CGRect) {
|
child3.frame = (CGRect){
|
||||||
.size = {
|
.size = {
|
||||||
.width = 100,
|
.width = 100,
|
||||||
.height = 100,
|
.height = 100,
|
||||||
}
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
[child2 addSubview:child3];
|
[child2 addSubview:child3];
|
||||||
[root addSubview:child1];
|
[root addSubview:child1];
|
||||||
[root addSubview:child2];
|
[root addSubview:child2];
|
||||||
[root.yoga applyLayoutPreservingOrigin:NO];
|
[root.yoga applyLayoutPreservingOrigin:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE-examples file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE-examples file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE-examples file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
30
android/BUCK
30
android/BUCK
@@ -1,30 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
|
|
||||||
|
|
||||||
yoga_android_aar(
|
|
||||||
name = "android",
|
|
||||||
manifest_skeleton = "src/main/AndroidManifest.xml",
|
|
||||||
visibility = [
|
|
||||||
"PUBLIC",
|
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
ANDROID_JAVA_TARGET,
|
|
||||||
ANDROID_RES_TARGET,
|
|
||||||
INFER_ANNOTATIONS_TARGET,
|
|
||||||
JAVA_TARGET,
|
|
||||||
PROGRUARD_ANNOTATIONS_TARGET,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_android_resource(
|
|
||||||
name = "res",
|
|
||||||
package = "com.facebook.yoga.android",
|
|
||||||
res = "src/main/res",
|
|
||||||
visibility = [
|
|
||||||
"PUBLIC",
|
|
||||||
],
|
|
||||||
)
|
|
@@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
YogaLayout is available via jcenter:
|
YogaLayout is available via jcenter:
|
||||||
|
|
||||||
compile 'com.facebook.yoga.android:yoga-layout:1.2.0'
|
implementation 'com.facebook.yoga.android:yoga-layout:1.16.0'
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
Check out the docs [here](https://facebook.github.io/yoga/docs/api/android/).
|
Check out the docs [here](https://yogalayout.com/getting-started/standalone/).
|
||||||
|
|
||||||
We also have a sample project. To try it, clone the repo and run (with a device attached)
|
We also have a sample project. To try it, clone the repo and run (with a device attached)
|
||||||
|
|
||||||
|
@@ -1,21 +1,18 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
apply plugin: 'com.jfrog.bintray'
|
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'com.github.dcendents.android-maven'
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
|
|
||||||
version = VERSION_NAME
|
|
||||||
group = GROUP
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
namespace 'com.facebook.yoga.android'
|
||||||
|
|
||||||
compileSdkVersion rootProject.compileSdkVersion
|
compileSdkVersion rootProject.compileSdkVersion
|
||||||
buildToolsVersion rootProject.buildToolsVersion
|
buildToolsVersion rootProject.buildToolsVersion
|
||||||
|
ndkVersion rootProject.ndkVersion
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion rootProject.minSdkVersion
|
minSdkVersion rootProject.minSdkVersion
|
||||||
@@ -32,21 +29,10 @@ dependencies {
|
|||||||
api project(':yoga')
|
api project(':yoga')
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
// We don't build Javadoc at this time as we can't disable "BUCK" files
|
||||||
classifier = 'source'
|
// from mistakenly getting parsed as Java.
|
||||||
from android.sourceSets.main.java.srcDirs
|
tasks.withType(Javadoc).all {
|
||||||
|
enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
task javadoc(type: Javadoc) {
|
apply plugin: 'com.vanniktech.maven.publish'
|
||||||
failOnError false
|
|
||||||
source = android.sourceSets.main.java.sourceFiles
|
|
||||||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
|
||||||
classpath += configurations.compile
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/release.gradle')
|
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.facebook.samples.yoga"
|
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0"
|
android:versionName="1.0"
|
||||||
>
|
>
|
||||||
@@ -17,11 +16,6 @@
|
|||||||
<variable name="applicationId" value="com.facebook.yoga"/>
|
<variable name="applicationId" value="com.facebook.yoga"/>
|
||||||
<variable name="app_label" value="Yoga Sample App"/>
|
<variable name="app_label" value="Yoga Sample App"/>
|
||||||
|
|
||||||
<uses-sdk
|
|
||||||
android:minSdkVersion="15"
|
|
||||||
android:targetSdkVersion="19"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
@@ -1,36 +0,0 @@
|
|||||||
# Copyright 2014-present, Facebook, Inc.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the license found in the
|
|
||||||
# LICENSE-examples file in the root directory of this source tree.
|
|
||||||
|
|
||||||
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
|
|
||||||
|
|
||||||
yoga_android_binary(
|
|
||||||
name = "sample",
|
|
||||||
keystore = ":debug_keystore",
|
|
||||||
manifest = "AndroidManifest.xml",
|
|
||||||
deps = [
|
|
||||||
ANDROID_SAMPLE_JAVA_TARGET,
|
|
||||||
ANDROID_SAMPLE_RES_TARGET,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_android_resource(
|
|
||||||
name = "res",
|
|
||||||
package = "com.facebook.samples.yoga",
|
|
||||||
res = "res",
|
|
||||||
visibility = [
|
|
||||||
"PUBLIC",
|
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
ANDROID_RES_TARGET,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
fb_native.keystore(
|
|
||||||
name = "debug_keystore",
|
|
||||||
properties = "debug.keystore.properties",
|
|
||||||
store = "debug.keystore",
|
|
||||||
)
|
|
@@ -1,21 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the license found in the
|
|
||||||
# LICENSE-examples file in the root directory of this source tree.
|
|
||||||
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
|
||||||
|
|
||||||
yoga_android_library(
|
|
||||||
name = "yoga",
|
|
||||||
srcs = glob(["**/*.java"]),
|
|
||||||
visibility = [
|
|
||||||
"PUBLIC",
|
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
ANDROID_JAVA_TARGET,
|
|
||||||
ANDROID_SAMPLE_RES_TARGET,
|
|
||||||
ANDROID_SUPPORT_TARGET,
|
|
||||||
APPCOMPAT_TARGET,
|
|
||||||
SOLOADER_TARGET,
|
|
||||||
],
|
|
||||||
)
|
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@@ -2,21 +2,12 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) Facebook, Inc. and its affiliates.
|
Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
|
||||||
This source code is licensed under the MIT license found in the
|
This source code is licensed under the MIT license found in the
|
||||||
LICENSE file in the root directory of this source tree.
|
LICENSE file in the root directory of this source tree.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
package="com.facebook.yoga.android"
|
|
||||||
android:versionCode="1"
|
|
||||||
android:versionName="1.0"
|
|
||||||
>
|
|
||||||
|
|
||||||
<uses-sdk
|
|
||||||
android:minSdkVersion="15"
|
|
||||||
android:targetSdkVersion="21"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<application/>
|
<application/>
|
||||||
|
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
|
||||||
|
|
||||||
yoga_android_library(
|
|
||||||
name = "android",
|
|
||||||
srcs = glob(["**/*.java"]),
|
|
||||||
visibility = [
|
|
||||||
"PUBLIC",
|
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
ANDROID_RES_TARGET,
|
|
||||||
INFER_ANNOTATIONS_TARGET,
|
|
||||||
JAVA_TARGET,
|
|
||||||
JSR_305_TARGET,
|
|
||||||
SOLOADER_TARGET,
|
|
||||||
],
|
|
||||||
)
|
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga.android;
|
package com.facebook.yoga.android;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -17,6 +18,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
|
import com.facebook.yoga.YogaNodeFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Much like a {@link YogaLayout}, except this class does not render itself (the container) to the
|
* Much like a {@link YogaLayout}, except this class does not render itself (the container) to the
|
||||||
@@ -32,7 +34,7 @@ public class VirtualYogaLayout extends ViewGroup {
|
|||||||
|
|
||||||
final private List<View> mChildren = new LinkedList<>();
|
final private List<View> mChildren = new LinkedList<>();
|
||||||
final private Map<View, YogaNode> mYogaNodes = new HashMap<>();
|
final private Map<View, YogaNode> mYogaNodes = new HashMap<>();
|
||||||
final private YogaNode mYogaNode = YogaNode.create();
|
final private YogaNode mYogaNode = YogaNodeFactory.create();
|
||||||
|
|
||||||
public VirtualYogaLayout(Context context) {
|
public VirtualYogaLayout(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -72,7 +74,7 @@ public class VirtualYogaLayout extends ViewGroup {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
YogaNode node = YogaNode.create();
|
YogaNode node = YogaNodeFactory.create();
|
||||||
YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params);
|
YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params);
|
||||||
YogaLayout.applyLayoutParams(lp, node, child);
|
YogaLayout.applyLayoutParams(lp, node, child);
|
||||||
node.setData(child);
|
node.setData(child);
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga.android;
|
package com.facebook.yoga.android;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -28,6 +29,7 @@ import com.facebook.yoga.YogaMeasureFunction;
|
|||||||
import com.facebook.yoga.YogaMeasureMode;
|
import com.facebook.yoga.YogaMeasureMode;
|
||||||
import com.facebook.yoga.YogaMeasureOutput;
|
import com.facebook.yoga.YogaMeasureOutput;
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
|
import com.facebook.yoga.YogaNodeFactory;
|
||||||
import com.facebook.yoga.YogaOverflow;
|
import com.facebook.yoga.YogaOverflow;
|
||||||
import com.facebook.yoga.YogaPositionType;
|
import com.facebook.yoga.YogaPositionType;
|
||||||
import com.facebook.yoga.YogaWrap;
|
import com.facebook.yoga.YogaWrap;
|
||||||
@@ -77,7 +79,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
mYogaNode = YogaNode.create();
|
mYogaNode = YogaNodeFactory.create();
|
||||||
mYogaNodes = new HashMap<>();
|
mYogaNodes = new HashMap<>();
|
||||||
|
|
||||||
mYogaNode.setData(this);
|
mYogaNode.setData(this);
|
||||||
@@ -154,7 +156,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
if(mYogaNodes.containsKey(child)) {
|
if(mYogaNodes.containsKey(child)) {
|
||||||
childNode = mYogaNodes.get(child);
|
childNode = mYogaNodes.get(child);
|
||||||
} else {
|
} else {
|
||||||
childNode = YogaNode.create();
|
childNode = YogaNodeFactory.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
childNode.setData(child);
|
childNode.setData(child);
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga.android;
|
package com.facebook.yoga.android;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) Facebook, Inc. and its affiliates.
|
Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
|
||||||
This source code is licensed under the MIT license found in the
|
This source code is licensed under the MIT license found in the
|
||||||
LICENSE file in the root directory of this source tree.
|
LICENSE file in the root directory of this source tree.
|
||||||
-->
|
-->
|
||||||
@@ -130,8 +130,14 @@
|
|||||||
<attr name="yg_positionAll" format="dimension|string"/>
|
<attr name="yg_positionAll" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_positionType" format="enum">
|
<attr name="yg_positionType" format="enum">
|
||||||
<enum name="relative" value="0"/>
|
<!-- "static" is a reserved keyword
|
||||||
<enum name="absolute" value="1"/>
|
<enum name="static" value="0"/>
|
||||||
|
-->
|
||||||
|
<enum name="relative" value="1"/>
|
||||||
|
<enum name="absolute" value="2"/>
|
||||||
|
<enum name="position_static" value="0"/>
|
||||||
|
<enum name="position_relative" value="1"/>
|
||||||
|
<enum name="position_absolute" value="2"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<attr name="yg_width" format="dimension|string"/>
|
<attr name="yg_width" format="dimension|string"/>
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_cxx_binary", "yoga_dep")
|
|
||||||
|
|
||||||
yoga_cxx_binary(
|
|
||||||
name = "benchmark",
|
|
||||||
srcs = glob(["*.c"]),
|
|
||||||
headers = subdir_glob([("", "*.h")]),
|
|
||||||
header_namespace = "",
|
|
||||||
compiler_flags = [
|
|
||||||
"-fno-omit-frame-pointer",
|
|
||||||
"-fexceptions",
|
|
||||||
"-Wall",
|
|
||||||
"-Werror",
|
|
||||||
"-O3",
|
|
||||||
"-std=c11",
|
|
||||||
],
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
yoga_dep(":yoga"),
|
|
||||||
],
|
|
||||||
)
|
|
19
benchmark/CMakeLists.txt
Normal file
19
benchmark/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the MIT license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
project(benchmark)
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||||
|
|
||||||
|
set(YOGA_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||||
|
include(${YOGA_ROOT}/cmake/project-defaults.cmake)
|
||||||
|
|
||||||
|
add_subdirectory(${YOGA_ROOT}/yoga ${CMAKE_CURRENT_BINARY_DIR}/yoga)
|
||||||
|
|
||||||
|
file(GLOB SOURCES CONFIGURE_DEPENDS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
||||||
|
add_executable(benchmark ${SOURCES})
|
||||||
|
target_link_libraries(benchmark yogacore)
|
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
52
build.gradle
52
build.gradle
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -10,14 +10,11 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
maven { url 'https://maven.google.com/' }
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.1.0'
|
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
|
||||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
@@ -26,46 +23,21 @@ buildscript {
|
|||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
minSdkVersion = 14
|
buildToolsVersion = "33.0.0"
|
||||||
targetSdkVersion = 25
|
ndkVersion = "23.1.7779620" // Corresponds to AGP 7.3
|
||||||
compileSdkVersion = 26
|
cmakeVersion = "3.18.1+"
|
||||||
buildToolsVersion = '26.0.2'
|
minSdkVersion = 21
|
||||||
|
compileSdkVersion = 33
|
||||||
|
targetSdkVersion = 33
|
||||||
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
|
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||||
targetCompatibilityVersion = JavaVersion.VERSION_1_7
|
targetCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you have an idea on how to avoid this, please get in touch or
|
|
||||||
// answer https://stackoverflow.com/questions/43867014/how-to-use-the-gradle-ndk-build-to-compile-for-the-host-machine.
|
|
||||||
task copyNativeLibs(type: Copy, dependsOn: ':buckBuildNative') {
|
|
||||||
from "${rootDir}/buck-out/gen/java/tests#default,shared-library-symlink-tree/"
|
|
||||||
include '*.so'
|
|
||||||
include '*.dylib'
|
|
||||||
into "$buildDir/jniLibs"
|
|
||||||
}
|
|
||||||
|
|
||||||
task buckBuildNative(type: Exec) {
|
|
||||||
workingDir rootDir
|
|
||||||
environment BUCKVERSION: 'last'
|
|
||||||
commandLine 'buck', 'build', '//java/...'
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
afterEvaluate {
|
|
||||||
tasks.withType(Test) {
|
|
||||||
dependsOn copyNativeLibs
|
|
||||||
def libDir = "${rootDir}/build/jniLibs"
|
|
||||||
systemProperty 'java.library.path', libDir
|
|
||||||
environment 'LD_LIBRARY_PATH', libDir
|
|
||||||
environment 'DYLD_LIBRARY_PATH', libDir
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
50
cmake/project-defaults.cmake
Normal file
50
cmake/project-defaults.cmake
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the MIT license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
add_compile_definitions($<$<CONFIG:DEBUG>:DEBUG>)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
# Don't omit frame pointers (e.g. for crash dumps)
|
||||||
|
/Oy-
|
||||||
|
# "Standard C++ exception handling" (C++ stack unwinding including extern c)
|
||||||
|
/EHsc
|
||||||
|
# Enable warnings and warnings as errors
|
||||||
|
/W3
|
||||||
|
/WX
|
||||||
|
# Disable RTTI
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:/GR->
|
||||||
|
# Use /O2 (Maximize Speed)
|
||||||
|
$<$<CONFIG:RELEASE>:/O2>)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
# Don't omit frame pointers (e.g. for crash dumps)
|
||||||
|
-fno-omit-frame-pointer
|
||||||
|
# Enable exception handling
|
||||||
|
-fexceptions
|
||||||
|
# Enable warnings and warnings as errors
|
||||||
|
-Wall
|
||||||
|
-Werror
|
||||||
|
# Disable RTTI
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
||||||
|
# Use -O2 (prioritize speed)
|
||||||
|
$<$<CONFIG:RELEASE>:-O2>
|
||||||
|
# Enable separate sections per function/data item
|
||||||
|
$<$<CONFIG:RELEASE>:-ffunction-sections>
|
||||||
|
$<$<CONFIG:RELEASE>:-fdata-sections>)
|
||||||
|
|
||||||
|
add_link_options(
|
||||||
|
# Discard unused sections
|
||||||
|
$<$<CONFIG:RELEASE>:$<$<CXX_COMPILER_ID:Clang,GNU>:-Wl,--gc-sections>>
|
||||||
|
$<$<CONFIG:RELEASE>:$<$<CXX_COMPILER_ID:AppleClang>:-Wl,-dead_strip>>)
|
||||||
|
|
||||||
|
endif()
|
10
cmake/yoga-config.cmake.in
Normal file
10
cmake/yoga-config.cmake.in
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the MIT license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/yogaTargets.cmake")
|
||||||
|
|
||||||
|
check_required_components(yoga)
|
272
csharp/.hgignore
272
csharp/.hgignore
@@ -1,272 +0,0 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
|
||||||
## files generated by popular Visual Studio add-ons.
|
|
||||||
|
|
||||||
# User-specific files
|
|
||||||
*.suo
|
|
||||||
*.user
|
|
||||||
*.userosscache
|
|
||||||
*.sln.docstates
|
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
|
||||||
*.userprefs
|
|
||||||
|
|
||||||
# Build results
|
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
x64/
|
|
||||||
x86/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
[Ll]og/
|
|
||||||
|
|
||||||
# Visual Studio 2015 cache/options directory
|
|
||||||
.vs/
|
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
|
||||||
#wwwroot/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
# NUNIT
|
|
||||||
*.VisualState.xml
|
|
||||||
TestResult.xml
|
|
||||||
tests/Facebook.Yoga/NUnit-[0-9\.]*/
|
|
||||||
tests/Facebook.Yoga/YogaTest.dll
|
|
||||||
tests/Facebook.Yoga/YogaTest.dll.mdb
|
|
||||||
tests/Facebook.Yoga/libyoga.dylib
|
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
|
||||||
dlldata.c
|
|
||||||
|
|
||||||
# DNX
|
|
||||||
project.lock.json
|
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
|
||||||
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*_i.h
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# JustCode is a .NET coding add-in
|
|
||||||
.JustCode
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# Visual Studio code coverage results
|
|
||||||
*.coverage
|
|
||||||
*.coveragexml
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/packages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/packages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/packages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignoreable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
node_modules/
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# JetBrains Rider
|
|
||||||
.idea/
|
|
||||||
*.sln.iml
|
|
||||||
|
|
||||||
# CodeRush
|
|
||||||
.cr/
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# local buck build
|
|
||||||
lib/
|
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
42
csharp/BUCK
42
csharp/BUCK
@@ -1,42 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
|
|
||||||
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
|
|
||||||
load(
|
|
||||||
"//tools/build_defs/oss:yoga_defs.bzl",
|
|
||||||
"BASE_COMPILER_FLAGS",
|
|
||||||
"yoga_apple_binary",
|
|
||||||
"yoga_cxx_library",
|
|
||||||
"yoga_dep",
|
|
||||||
)
|
|
||||||
|
|
||||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
|
|
||||||
|
|
||||||
fb_native.csharp_library(
|
|
||||||
name = "yogalibnet46",
|
|
||||||
srcs = glob(["**/*.cs"]),
|
|
||||||
dll_name = "Facebook.Yoga.dll",
|
|
||||||
framework_ver = "net46",
|
|
||||||
)
|
|
||||||
|
|
||||||
fb_native.csharp_library(
|
|
||||||
name = "yogalibnet45",
|
|
||||||
srcs = glob(["**/*.cs"]),
|
|
||||||
dll_name = "Facebook.Yoga.dll",
|
|
||||||
framework_ver = "net45",
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_cxx_library(
|
|
||||||
name = "yoganet",
|
|
||||||
srcs = ["Yoga/YGInterop.cpp"],
|
|
||||||
compiler_flags = COMPILER_FLAGS,
|
|
||||||
link_style = "static",
|
|
||||||
link_whole = True,
|
|
||||||
soname = "libyoga.$(ext)",
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [yoga_dep(":yoga")],
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_apple_binary()
|
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -293,6 +293,12 @@ namespace Facebook.Yoga
|
|||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node);
|
public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node);
|
||||||
|
|
||||||
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void YGNodeStyleSetGap(YGNodeHandle node, YogaGutter gutter, float gapLength);
|
||||||
|
|
||||||
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern float YGNodeStyleGetGap(YGNodeHandle node, YogaGutter gutter);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region YG_NODE_STYLE_EDGE_PROPERTY
|
#region YG_NODE_STYLE_EDGE_PROPERTY
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public enum YogaAlign
|
public enum YogaAlign
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public enum YogaDimension
|
public enum YogaDimension
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public enum YogaDirection
|
public enum YogaDirection
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public enum YogaDisplay
|
public enum YogaDisplay
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public enum YogaEdge
|
public enum YogaEdge
|
||||||
|
@@ -1,14 +1,18 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public enum YogaExperimentalFeature
|
public enum YogaExperimentalFeature
|
||||||
{
|
{
|
||||||
WebFlexBasis,
|
WebFlexBasis,
|
||||||
|
AbsolutePercentageAgainstPaddingEdge,
|
||||||
|
FixAbsoluteTrailingColumnMargin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public enum YogaFlexDirection
|
public enum YogaFlexDirection
|
||||||
|
18
csharp/Facebook.Yoga/YogaGutter.cs
Normal file
18
csharp/Facebook.Yoga/YogaGutter.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
|
||||||
|
namespace Facebook.Yoga
|
||||||
|
{
|
||||||
|
public enum YogaGutter
|
||||||
|
{
|
||||||
|
Column,
|
||||||
|
Row,
|
||||||
|
All,
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user