Compare commits
1259 Commits
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 | ||
|
26dbe8b4ff | ||
|
a5c2f7f27a | ||
|
10811e1a94 | ||
|
10f4bceac0 | ||
|
47717324d4 | ||
|
1043c35f2b | ||
|
fde89b056d | ||
|
a08a57b33c | ||
|
31de91bbac | ||
|
e6e224ce48 | ||
|
a04a6b5e8f | ||
|
442d84ccfc | ||
|
4a2ccc658e | ||
|
58622fa747 | ||
|
90cded3819 | ||
|
d1e188341b | ||
|
0f2350308e | ||
|
9b120eded9 | ||
|
a218880216 | ||
|
1a2802028b | ||
|
a37b286bae | ||
|
dcfdb955b3 | ||
|
72cefead02 | ||
|
884e064a99 | ||
|
3ed9bec05c | ||
|
dadf0473b7 | ||
|
947230958d | ||
|
095c991b85 | ||
|
825da1e868 | ||
|
5a25805cb5 | ||
|
adff8d96dd | ||
|
8c270e68cc | ||
|
a2aa1b7fca | ||
|
ae956f06fb | ||
|
8c0eed3c75 | ||
|
4e4ef06de1 | ||
|
a53c14dc75 | ||
|
c99fc9c4da | ||
|
2fb857d73d | ||
|
e6dfe04388 | ||
|
5e40e4b682 | ||
|
7c891db9af | ||
|
6d916ab063 | ||
|
59d680f4e9 | ||
|
be305b5d0f | ||
|
d676d917e3 | ||
|
838fc3f019 | ||
|
296982a29e | ||
|
1d0668692b | ||
|
39e512f691 | ||
|
0f250490d4 | ||
|
eeae39d707 | ||
|
ce517689ff | ||
|
9c82ba783f | ||
|
1c8e8d3aec | ||
|
cc27d85110 | ||
|
cd5324378d | ||
|
c6ae314202 | ||
|
73224c62b5 | ||
|
2c6a4485f5 | ||
|
cf005df828 | ||
|
f539d68049 | ||
|
39996512fc | ||
|
2dc5a16d1f | ||
|
d667ebd66e | ||
|
2b8217ce8d | ||
|
9dac56e824 | ||
|
a7e8aec3d9 | ||
|
6b5bf570c8 | ||
|
a130ac2f9c | ||
|
19fd066507 | ||
|
204e849218 | ||
|
8ff13c922a | ||
|
af219f8836 | ||
|
e33123f955 | ||
|
755fa07b39 | ||
|
2701d80078 | ||
|
c393ed1381 | ||
|
a4bdd9cd9b | ||
|
4a4325afb6 | ||
|
586eb6102a | ||
|
b1e6793460 | ||
|
8b17459254 | ||
|
195c166efe | ||
|
0908d3a173 | ||
|
f304990656 | ||
|
cea3865c74 | ||
|
b74c0d4766 | ||
|
54e863cef2 | ||
|
1938792517 | ||
|
aa71dbb5bd | ||
|
8dc46c0a87 | ||
|
1180afed9c | ||
|
1562bce9b4 | ||
|
a9514513a7 | ||
|
cf809b8e8b | ||
|
d7ff5c0689 | ||
|
e3156279fc | ||
|
0ce42d83e0 | ||
|
afc1108659 | ||
|
a15bf6e701 | ||
|
74fc37efc8 | ||
|
5824dbda66 | ||
|
e96a09e5ff | ||
|
9e20dfeea1 | ||
|
6e04631862 | ||
|
88b23ebb3d | ||
|
018916403e | ||
|
af38fd31f8 | ||
|
1e0ebdae2f | ||
|
1adbafe950 | ||
|
e51ca95713 | ||
|
a803421739 | ||
|
011c1964a0 | ||
|
05d205cf89 | ||
|
0a4f7bd558 | ||
|
cea862a6bf | ||
|
cc02a20c9e | ||
|
98fda9c587 | ||
|
2eed95f3e4 | ||
|
e5d3baca81 | ||
|
dee93017f7 | ||
|
e167642672 | ||
|
e9bb1efb03 | ||
|
3f7d03b443 | ||
|
ffce716557 | ||
|
fcfb19e9cf | ||
|
c5f105a7b6 | ||
|
b062d23947 | ||
|
7fc6fcb38c | ||
|
bc7e504b29 | ||
|
3d8afa9e90 | ||
|
a1e47e37ae | ||
|
e0bc0ebe29 | ||
|
498c0ff4bf | ||
|
d42d43e90f | ||
|
bfc6319daa | ||
|
74ce5afd9e | ||
|
c11faf2d56 | ||
|
5fad8008ab | ||
|
948ade4b1c | ||
|
b1a7f2b4d9 | ||
|
d44a6d936f | ||
|
1fc8472d35 | ||
|
c235301b52 | ||
|
2fb81500c1 | ||
|
68d9209dd9 | ||
|
e91569cdad | ||
|
f31917aa01 | ||
|
74202aecff | ||
|
9c2108c69e | ||
|
3d2836a947 | ||
|
e4856a2264 | ||
|
a2ee0f65bd | ||
|
85352c4e45 | ||
|
7d7b7b9e18 | ||
|
62d8a911ff | ||
|
ca46c67e9e | ||
|
5bb2265083 | ||
|
ab3bf40c7d | ||
|
f273e80c77 | ||
|
1471be54e3 | ||
|
f039835249 | ||
|
f793ba2d6b | ||
|
9f72ad05ce | ||
|
14f3827491 | ||
|
0d96098fd9 | ||
|
42e3b78f04 | ||
|
3ad49d27d9 | ||
|
3331a9e480 | ||
|
7890672ecc | ||
|
d7bfbf3646 | ||
|
6d271c05f6 | ||
|
a9bddf87ff | ||
|
88994129ae | ||
|
888892885e | ||
|
de79f2a1d4 | ||
|
6368416178 | ||
|
a935a222b5 | ||
|
7c4da0a341 | ||
|
b047af25ca | ||
|
2abd9dd91b | ||
|
afadc5cf6b | ||
|
8823cc357a | ||
|
8b8d9a05b7 | ||
|
15668aceb6 | ||
|
e25fe994b3 | ||
|
47abe1c482 | ||
|
95169c3150 | ||
|
7331de78bd | ||
|
05f36a835a | ||
|
dcd9438488 | ||
|
d38db1292c | ||
|
4463fe0856 | ||
|
2156de5fb5 | ||
|
b1c749075d | ||
|
367a93de88 | ||
|
2643b96589 | ||
|
016a10df26 | ||
|
cbcf07f08a | ||
|
59bcac3289 | ||
|
bd90192df9 | ||
|
e7fcf1ee65 | ||
|
f86c74ce7e | ||
|
d5ad51bccc | ||
|
0bdf36f5d1 | ||
|
1b9053bc5d | ||
|
446101a168 | ||
|
f0324035bf | ||
|
a2f94cbf9a | ||
|
d21fa68033 | ||
|
5a6d84abc9 | ||
|
61ae484316 | ||
|
42657017bd | ||
|
9b9a344934 | ||
|
5f92ba49a7 | ||
|
2e564c21cd | ||
|
ca7d4d1633 | ||
|
3645f43cea | ||
|
9378a7a439 | ||
|
d3e02b15fa | ||
|
80d527814e | ||
|
5121fef5d8 | ||
|
0d026bd1a0 | ||
|
719fa3cca3 | ||
|
307cf09434 | ||
|
8691cdaed6 | ||
|
4a6b1e19b8 | ||
|
31ce3ab866 | ||
|
0846439c8e | ||
|
000d1436b4 | ||
|
1bc97a5e48 | ||
|
68f7001ed4 | ||
|
59446294b3 | ||
|
460370b7d3 | ||
|
cbea5d44b8 | ||
|
b4b009c2d8 | ||
|
74dd627495 | ||
|
58f0cca7c7 | ||
|
3de3575ac4 | ||
|
390fade8c0 | ||
|
96dfe068ee | ||
|
e0eb37fce0 | ||
|
79355ab72d | ||
|
5a9f29debb | ||
|
8b8932811e | ||
|
604a9a98a9 | ||
|
71321f763a | ||
|
7fa0816d81 | ||
|
4840495d3f | ||
|
866bf101b2 | ||
|
3467308874 | ||
|
ef2c693b05 | ||
|
efac22a508 | ||
|
4b97375524 | ||
|
ab9d06abf5 | ||
|
5ee32fbefc | ||
|
899664dddd | ||
|
b66642cb86 | ||
|
b9ae948ce9 | ||
|
138521ccc2 | ||
|
5514722ce2 | ||
|
56e133ab4c | ||
|
f6415889ca | ||
|
885b4cbdfb | ||
|
8461aeaef0 | ||
|
3df41aefdb | ||
|
8bc89651d6 | ||
|
c5f2444048 | ||
|
130a9a2aa2 | ||
|
dd97fcc968 | ||
|
4f51871fa8 | ||
|
e96d14395c | ||
|
852db1d885 | ||
|
3f79439718 | ||
|
96d93f2982 | ||
|
236bcc1a39 | ||
|
4b5ae211da | ||
|
aaa018bbea | ||
|
6bdd39d0ed | ||
|
da678ef971 | ||
|
e9078374c9 | ||
|
f23a669ed0 | ||
|
9ddda3c630 | ||
|
8ab01fde6e | ||
|
440c719190 | ||
|
e522b2dee4 | ||
|
b26e637c81 | ||
|
6b7f6980f9 | ||
|
4248fd9d4c | ||
|
5a65261a55 | ||
|
5719132f58 | ||
|
10b316f315 | ||
|
b6498987fa | ||
|
9680ae98a6 | ||
|
59755d2874 | ||
|
64c37767c2 | ||
|
50ec35575f | ||
|
ed3b54b603 | ||
|
ed5c5a799f | ||
|
d19da9e528 | ||
|
0962c5220c | ||
|
b9972cee6e | ||
|
98c1c180af | ||
|
6f6e0ce339 | ||
|
bdae838516 | ||
|
6d8ee77791 | ||
|
9725d5b21b | ||
|
8e48edaa0b | ||
|
89394a2dd6 | ||
|
02a2309b2a | ||
|
8f181c7259 | ||
|
339c5574b8 | ||
|
8d5bbecd3d | ||
|
dd12907632 | ||
|
7d7d9a7ef0 | ||
|
63570613d3 | ||
|
4e2011c381 | ||
|
7a60399b2b | ||
|
a0b3586fb3 | ||
|
a2ef8978cd | ||
|
d02f4a94de | ||
|
b7890fa2a8 | ||
|
1e4d0abc66 | ||
|
eb2aeb3adb | ||
|
fad2ee1a64 | ||
|
ba9bd4eae3 | ||
|
e12b78f99b | ||
|
5d1cee2bf0 | ||
|
5c711a7076 | ||
|
838ef47847 | ||
|
786ccddd7b | ||
|
b747286c1d | ||
|
bb3c2b2498 | ||
|
36e732aabd | ||
|
d6517ae288 | ||
|
93d327acfb | ||
|
01c6c79efb | ||
|
357ca78f9f | ||
|
6e46eec58f | ||
|
554d8cdf76 | ||
|
328ec7dc4d | ||
|
2e66f8d828 | ||
|
e224a29d1c | ||
|
238d7ba98f | ||
|
d6ba8326d1 | ||
|
f7df575746 | ||
|
2b52c73d70 | ||
|
7a45fb39bf | ||
|
1080cf22e3 | ||
|
1d09227374 | ||
|
85031baaf2 | ||
|
7f71cac3b0 | ||
|
48a8f883ba | ||
|
6132a59772 | ||
|
8309cfc976 | ||
|
abc9fdb37c | ||
|
b872751d68 | ||
|
8368338c93 | ||
|
45c44d293c | ||
|
b4a889553c | ||
|
78cdf3cadc | ||
|
be78bfbd8c | ||
|
c5d4485db3 | ||
|
71f1d99494 | ||
|
0e99980206 | ||
|
292bfed102 | ||
|
78d6988461 | ||
|
3499e2e0ef | ||
|
b1821ab4cd | ||
|
006f6460a9 | ||
|
db5bc092aa | ||
|
9fe20fd2fc | ||
|
7b87ded288 | ||
|
eaaf0fdfe2 | ||
|
4caed8feb5 | ||
|
4be229059c | ||
|
389f2fd85d | ||
|
f95e3b49e9 | ||
|
f172d5d41c | ||
|
7be9fd1a79 | ||
|
5e1796505d | ||
|
51a4601e18 | ||
|
0bc4d23e2e | ||
|
4c47dcbd0f | ||
|
c1a9f6120a | ||
|
1b32c4f054 | ||
|
896cfbdfde | ||
|
910aa77c01 | ||
|
2562c029b1 | ||
|
0b1780a081 | ||
|
e9e2ae28e0 | ||
|
4ed3dd4b82 | ||
|
a7f430a5ef | ||
|
89ba4f282d | ||
|
b6231ee0ed | ||
|
e384002878 | ||
|
9ceed4b601 | ||
|
765bb85d1e | ||
|
6548dddec3 | ||
|
966f5ece4a | ||
|
ede2888326 | ||
|
2eda444bbf | ||
|
7c4319181b | ||
|
f4d29e6f11 | ||
|
77ea79490f | ||
|
46c96ee2cb | ||
|
a67c555320 | ||
|
cdb1ee21a0 | ||
|
2ce219ef42 | ||
|
c5f826de83 | ||
|
526ca42d04 | ||
|
b47f0ce41a | ||
|
eb7cb11ffd | ||
|
f9df990177 | ||
|
684dccb7b9 | ||
|
6c51eb4f72 | ||
|
ca485dfb50 | ||
|
50e3714b21 | ||
|
c52c7cdd1e | ||
|
11200f3d75 | ||
|
5dbe3c128b | ||
|
3564ccf6e4 | ||
|
e1c19cecad | ||
|
8e4f3a3084 | ||
|
9b8323ff38 | ||
|
5b7adda620 | ||
|
ba2a3b8c91 | ||
|
eb15939c23 | ||
|
b9fa60fd74 | ||
|
d397aa04d7 | ||
|
adb1b11055 | ||
|
2e234473ca | ||
|
6b08db68bb | ||
|
9550126f76 | ||
|
bad262b961 | ||
|
3c6c10075a | ||
|
6a77a6939e | ||
|
b725a4a140 | ||
|
2b714a5b5d | ||
|
572546088f | ||
|
5b109578d3 | ||
|
77b720f9a5 | ||
|
de954eb9cc | ||
|
3e322e60e4 | ||
|
a3642541d0 | ||
|
bb139d3f91 | ||
|
08743a42e2 | ||
|
cb6e76973d | ||
|
4b760fa9bc | ||
|
5730be093e | ||
|
d85e2ee9c3 | ||
|
fe433b012f | ||
|
5e3ffb39a2 | ||
|
f0edefdbb7 | ||
|
17901ea5c2 | ||
|
187fc54596 | ||
|
c951ad7c7b | ||
|
9785975f77 | ||
|
79281049f2 | ||
|
7d2b84aab6 | ||
|
cda328fa7e | ||
|
5d7b75a47a | ||
|
ae86824636 | ||
|
0dde40ce0b | ||
|
369c9ad12a | ||
|
cfb9eeca20 | ||
|
3dfb68887d | ||
|
d567885070 | ||
|
877c275a13 | ||
|
8aadae8ce4 | ||
|
2232d7603a | ||
|
b3f8851bc2 | ||
|
47ad3f63cf | ||
|
c75adb0671 | ||
|
178b8f5f64 | ||
|
a874992e7c | ||
|
31fc287d35 | ||
|
892913a69d | ||
|
99026e42a9 | ||
|
3a82d2b1a8 | ||
|
b28292e454 | ||
|
2ff18bc948 | ||
|
d0bee487e0 | ||
|
419e29c5a6 | ||
|
295d111f0e | ||
|
da5eb2db67 | ||
|
3408e4d4fa | ||
|
6d7eca8e42 | ||
|
5726a71b62 | ||
|
f73b5057ac | ||
|
51051aad7f | ||
|
91d3c08248 | ||
|
52f2cf319a | ||
|
bbdb62e654 | ||
|
e024943c4b | ||
|
7f44ec512e | ||
|
a2b6ddb7b1 | ||
|
bdc37b0797 | ||
|
82aaebfea2 | ||
|
48d82224ee | ||
|
100afcfdb0 | ||
|
b3436d5eba | ||
|
c5371aca64 | ||
|
269619a419 | ||
|
9b3104577c | ||
|
a1697d2307 | ||
|
056b75858c | ||
|
c84ed90272 | ||
|
b21dd9891a | ||
|
bba81781af | ||
|
0c74a72fac | ||
|
1822bc5eaf | ||
|
01ffe10c2f | ||
|
7f99a547f5 | ||
|
0e5651fb80 | ||
|
0ca44f3001 | ||
|
3f85763797 | ||
|
b318c4c5c9 | ||
|
ae9703712a | ||
|
d617ab6662 | ||
|
4c3eebd3e5 | ||
|
10061af491 | ||
|
91621641e6 | ||
|
35c6931ade | ||
|
44622912a2 | ||
|
aac40cf89b | ||
|
d4b20f5793 | ||
|
89df2d9475 | ||
|
79fa6f8d58 | ||
|
69242938f7 | ||
|
1b66b5d941 | ||
|
fb30f7ddcb | ||
|
747c2a4208 | ||
|
43fda26275 | ||
|
b1222bf83e | ||
|
3ec41b656f | ||
|
740ef6cd9e | ||
|
8c5cbf698b | ||
|
5f2cf6623f | ||
|
4b7efb73d7 | ||
|
a6b7e34187 | ||
|
e50308e823 | ||
|
b6a13ce43a | ||
|
96a87a811d | ||
|
025ee03cb1 | ||
|
c06ee92251 | ||
|
3aca5965dc | ||
|
cac77e5ffa | ||
|
49f1d7b5f6 | ||
|
82e44dbf04 | ||
|
9b501dd9eb | ||
|
8ba663f6f4 | ||
|
8f35484262 | ||
|
1e3143656d | ||
|
699b1f5012 | ||
|
9c877a621e | ||
|
a3144150e0 | ||
|
c830083df3 | ||
|
9eb03b1bcd | ||
|
7e3136c347 | ||
|
c3de8016c0 | ||
|
af45863f8e | ||
|
08d7d1673e | ||
|
e7c56ccd1e | ||
|
de8cab8e60 | ||
|
9e0f751464 | ||
|
951a429ac5 | ||
|
e43bb9da19 | ||
|
b08bd572ef | ||
|
402ee11273 | ||
|
6e38a26f32 | ||
|
d66239bea8 | ||
|
7eb8df2777 | ||
|
75473fd924 | ||
|
c94ade8ffd | ||
|
61afbd43c9 | ||
|
64f6ea37bd | ||
|
dc0609d153 | ||
|
bd46344a4e | ||
|
7199902316 | ||
|
250873abf2 | ||
|
1e775ecb83 | ||
|
9718c517d9 | ||
|
afc215aa66 | ||
|
5df8157863 | ||
|
802fe6bb29 | ||
|
27d2ad198e | ||
|
63be3ff84c | ||
|
66045bd13d | ||
|
f5f8105b57 | ||
|
4f92ae46ef | ||
|
80f8aa3c7e | ||
|
42778f687b | ||
|
7b27a58b97 | ||
|
a40ba9d350 | ||
|
9ecdff14fa | ||
|
288adc49c9 | ||
|
b8c2428b31 | ||
|
92bfcbafc0 | ||
|
130b5beca2 | ||
|
adb2e0fdd6 | ||
|
0a04bd7f2f | ||
|
9d6af5b314 | ||
|
6efb4b90d4 | ||
|
5806f1728c | ||
|
a9dd527748 | ||
|
db3d20b7b7 | ||
|
acd4e01aaf | ||
|
b217f23ba5 | ||
|
76875af207 | ||
|
f2ba14c309 | ||
|
a65b79a944 | ||
|
681b580fd8 | ||
|
b985b6c377 | ||
|
92eda21e78 | ||
|
0cfdb50477 | ||
|
1eb9a5edd9 | ||
|
383b881748 | ||
|
47543c8fba | ||
|
dc6ed89bfa | ||
|
348dd368b5 | ||
|
40eeefd4f7 | ||
|
47892c17ce | ||
|
f2a369fb73 | ||
|
61dc10ef66 | ||
|
7d01f4d8b1 | ||
|
c7a5e1e290 | ||
|
fbd332dee8 | ||
|
70369ae5d3 | ||
|
dbf6a12134 | ||
|
dbc47ae383 | ||
|
f22cfd52e0 | ||
|
2a10337344 | ||
|
836eaa62df | ||
|
a01c7adcfb | ||
|
5133faa1ad | ||
|
6a8c2960ad | ||
|
0c98e89fdb | ||
|
5f78181911 | ||
|
03dd1d23fa | ||
|
91683be798 | ||
|
109cb1a562 | ||
|
ad1240e276 | ||
|
2e468d9c8c | ||
|
6caa94b779 | ||
|
429a7eeee3 | ||
|
dec1172f38 | ||
|
afaafb4126 | ||
|
e566fcca08 | ||
|
c7f7ba250c | ||
|
7e3be21811 | ||
|
5e39f1a57c | ||
|
5aa0f44a9b | ||
|
55c767ba7f | ||
|
5502a97f7f | ||
|
8ab1d81917 | ||
|
942543f6a5 | ||
|
a69545a6ae | ||
|
0b13a0c168 | ||
|
d8341ca3b0 | ||
|
34ac314101 | ||
|
02c00f2711 | ||
|
15231c3304 | ||
|
d98e5aef97 | ||
|
5b0dfa471f | ||
|
26481a6553 | ||
|
64e08aa98b | ||
|
0c3168f150 | ||
|
40861c699e | ||
|
d8fee24778 | ||
|
5c617a5947 | ||
|
ff0a3f39d9 | ||
|
bfb4dabf0c | ||
|
58d14ee557 | ||
|
c5182c4bf5 | ||
|
132b016bae | ||
|
4785e95a0c | ||
|
be94a5ef8d | ||
|
208b70a93c | ||
|
6c3155ae3b | ||
|
32f071c2ad | ||
|
fdd1dbe3a9 | ||
|
1ca5bb694d | ||
|
b4cfaa916c | ||
|
fc6c85996e | ||
|
969f055f47 | ||
|
58328d01ef | ||
|
d90914f3dc | ||
|
3a0a86788e | ||
|
a77aa9a41e | ||
|
7217471427 | ||
|
bcc36cc1b2 | ||
|
16052085d0 | ||
|
c20f2864ab | ||
|
4185a44393 | ||
|
c79c5e3c9d | ||
|
35a9f33abb | ||
|
32f128640b | ||
|
18d19af7ec | ||
|
2ee2dd439f | ||
|
5edfb679e7 | ||
|
f45059e1e6 | ||
|
c9384762ee | ||
|
7ea50439ce | ||
|
154e67adbc | ||
|
570a193b7e | ||
|
79e294c927 | ||
|
5d75c7c4c8 | ||
|
7c688cea68 | ||
|
7640cd667f | ||
|
24e2fc95dd | ||
|
ce3f99939f | ||
|
11bc97b16c | ||
|
4804bcd594 | ||
|
ca2c607f90 | ||
|
6c67684fa6 | ||
|
835b2bbae8 | ||
|
47edd2586c | ||
|
ca483cae00 | ||
|
a20bde8444 | ||
|
ac885626b3 | ||
|
976ecc6816 | ||
|
d2f22283bb | ||
|
56b10fc35b | ||
|
5a3ceffba1 | ||
|
b378a685a4 | ||
|
fa50f048f1 | ||
|
f68b50bb4b | ||
|
aad1c3055c | ||
|
cd1dbc3f0f | ||
|
bf4ff0769d | ||
|
a141ebfb50 | ||
|
2fb01daf70 | ||
|
e9e1e084da | ||
|
629e401deb | ||
|
f4c2b6ae63 | ||
|
4487862227 | ||
|
927eca6604 | ||
|
f2612192c5 | ||
|
49bccf47fa | ||
|
fa54167a20 | ||
|
50feb21cb3 | ||
|
52ce5828c9 | ||
|
9cdaedfcb5 | ||
|
adad054cad | ||
|
b2b0c7ee37 | ||
|
488a7c1fe0 | ||
|
85c2e406e4 | ||
|
dcf57d2f7e | ||
|
3fefe9fc49 | ||
|
626a05fb6f | ||
|
ffcd2cfc8a | ||
|
181101c92d | ||
|
3db6804202 | ||
|
3fb135829d | ||
|
2c91e1e7d2 | ||
|
c3982b6c1e | ||
|
ae33c6c19c | ||
|
bcd68b997f | ||
|
fcfa1b9f01 | ||
|
d9a0822517 | ||
|
097e99b699 | ||
|
ff7bec703b | ||
|
c7ab004922 | ||
|
91230ae177 | ||
|
40eba60cf5 | ||
|
fb4cfed20d | ||
|
d3a9a84ac4 | ||
|
accad5366f | ||
|
8eca67e257 | ||
|
40e1bf6ce3 | ||
|
7b89a1dd48 | ||
|
203577724e | ||
|
e3dbef7cbd | ||
|
0ee3303791 | ||
|
83fddd8af6 | ||
|
77c05b5ff6 | ||
|
7c324f058c | ||
|
3db38f2a80 | ||
|
f6b17183c5 | ||
|
8f9d7e243e | ||
|
fde4db9383 | ||
|
3178e3bf15 | ||
|
cdfd05c742 | ||
|
76f6a54327 | ||
|
c91e4b3566 | ||
|
e24561bcef | ||
|
363e941867 | ||
|
3fb2c1888c | ||
|
aa5b296ac7 | ||
|
f2b5d0fef7 | ||
|
0684795a89 | ||
|
2ffc23f400 | ||
|
dc4d16401f | ||
|
849de89a58 | ||
|
f8a2903d02 | ||
|
60977de242 | ||
|
cb612bcfbe | ||
|
6be1c2cdb4 | ||
|
034ab0b3b1 | ||
|
8c50347f3c | ||
|
9f76fb6980 | ||
|
8b0ff0a25c | ||
|
8891ea1a7a | ||
|
ede2ad94bc | ||
|
eacf3cdbb4 | ||
|
3569a13b74 | ||
|
b2a96ec744 | ||
|
a505adb2b7 | ||
|
906b6e52f8 | ||
|
3292337754 | ||
|
eb4af86e3c | ||
|
1b3e971549 | ||
|
4615eee2d8 | ||
|
7c57245943 | ||
|
0d100ad7e9 | ||
|
0235789863 | ||
|
c080a46571 | ||
|
5f050cb590 | ||
|
25f14a1917 | ||
|
e9927377b5 | ||
|
3ea76f8a9b | ||
|
8a45ed9671 | ||
|
1520749351 | ||
|
f66f52d1ba | ||
|
49e18738c3 | ||
|
586b57009a | ||
|
5112564f08 | ||
|
34726a9926 | ||
|
5884ab7b76 | ||
|
60db018ce4 | ||
|
6b002bad3d | ||
|
5b173c1b61 | ||
|
bc2fb5c7ab | ||
|
ebdf82f491 | ||
|
36f6fa9861 | ||
|
91a34bb875 | ||
|
d342fb1879 | ||
|
b283572453 | ||
|
62a74a5ef9 | ||
|
a14aeb27bb | ||
|
249d010dad | ||
|
9b13fdeae4 | ||
|
794b6b35ce | ||
|
dcff4d3db2 | ||
|
b94466e502 | ||
|
11052053d8 | ||
|
6ab3984bba | ||
|
136e0c7e52 | ||
|
7e2ef926ea | ||
|
061981fb23 | ||
|
3d6fb2f2e5 | ||
|
a8e6123d47 | ||
|
406c8a2117 | ||
|
0445962bd4 | ||
|
09f0c2d8ce | ||
|
8dea884a69 | ||
|
57898762a2 | ||
|
01bf8d7b6c | ||
|
af8d55c08e | ||
|
53398b42c6 | ||
|
1bf142e048 | ||
|
0405c4f77d | ||
|
61595763b0 | ||
|
f6ecc8da7b | ||
|
32792a0de5 | ||
|
c3d60b55bd | ||
|
17be6718ee | ||
|
abf912b729 | ||
|
5bc0197c78 | ||
|
62f47190fb | ||
|
a706f4c97c | ||
|
feb365a77b | ||
|
b2a4e67fee | ||
|
e7d2792009 | ||
|
0fde1424f0 | ||
|
29fd447f0c | ||
|
7047d96087 | ||
|
6336e641f4 | ||
|
ecabe757a2 | ||
|
37c48257ae | ||
|
8668e43f6d | ||
|
785713c9c0 | ||
|
b523402eda | ||
|
3790635af1 | ||
|
b940fadb7e | ||
|
3ef2970032 | ||
|
4372aa16d3 | ||
|
3346f9511a | ||
|
1cd7363bea | ||
|
17e3dca9f9 | ||
|
533f560ce0 | ||
|
6a60d4893e | ||
|
51dd082682 | ||
|
47d8d9d22b | ||
|
d6d4dcb141 | ||
|
37ec1774a7 | ||
|
3ad4d7dd6e | ||
|
e596091fa2 | ||
|
4f5c7ed6af | ||
|
60ffa1953b | ||
|
5519a73087 | ||
|
67717a7872 | ||
|
4522d4b8aa | ||
|
d7ca339c27 | ||
|
6b39165801 | ||
|
78ade6cfb5 | ||
|
3f68b4f76b | ||
|
521aab5fcc | ||
|
42492596b3 | ||
|
b24e728666 | ||
|
4fe0b810e1 | ||
|
8deed174f5 | ||
|
2184547094 | ||
|
8eda4dc040 | ||
|
4d4db92a46 | ||
|
ea8b7e0c91 | ||
|
6928957096 | ||
|
b680b726d1 | ||
|
fbd692c449 | ||
|
2199a7908d | ||
|
59704f1508 | ||
|
20536923d6 | ||
|
bba7289537 | ||
|
04d1ccc085 | ||
|
a7e7c5eb52 | ||
|
9d2839f8ca | ||
|
1146013e9e | ||
|
8a91c0a0e5 | ||
|
a1c75454e9 | ||
|
ad3963daa6 | ||
|
a66339d63c | ||
|
d0bdd4dc91 | ||
|
d24078be31 | ||
|
f251648726 | ||
|
b587ecb30f | ||
|
a580712b2f | ||
|
ce5d52b54e | ||
|
55fe6f0bc9 | ||
|
abf142ea3f | ||
|
ae9f89b5d1 | ||
|
058761e16e | ||
|
ad8c6225fd | ||
|
1cbadf5f54 | ||
|
e7021715b8 | ||
|
0d2749a3fd | ||
|
76fbd628e1 | ||
|
15309d2bdd | ||
|
4f6924a0c1 | ||
|
063f65d065 | ||
|
adf8691093 | ||
|
6a7ad2125d | ||
|
247aa26d3e | ||
|
3c9f620c77 | ||
|
e0e2a61dfc | ||
|
168ae4099d | ||
|
6ceb4af2d4 | ||
|
240c2dd657 | ||
|
a5b94ebd0c | ||
|
5037c2f365 | ||
|
ef05404bee | ||
|
3db493665e | ||
|
737f1cc67c | ||
|
b5c2b09780 | ||
|
46817a38c3 | ||
|
52f3471405 | ||
|
e567502750 | ||
|
c1cdc1de58 | ||
|
f2c41f366f | ||
|
56d06e27cf | ||
|
93e327f4a5 | ||
|
687668a4b3 | ||
|
cfeac79130 | ||
|
4227e36ca5 | ||
|
be1c9f249e | ||
|
511a129a7e | ||
|
d62ca8c518 | ||
|
30413265c7 | ||
|
bd5d8a77c9 | ||
|
326ae15532 | ||
|
9afb65da34 | ||
|
fe7643c84a | ||
|
6daad3ae66 | ||
|
44590b8907 | ||
|
4400b52aab | ||
|
c217553cf8 | ||
|
6ad5003149 | ||
|
7c77b0e48c | ||
|
7b36118df4 | ||
|
7f0dbe5356 | ||
|
b87fc217df | ||
|
625dc4bf44 | ||
|
34736a4929 | ||
|
4f37cde043 | ||
|
7df60376ff | ||
|
7fa4adb0d9 | ||
|
abb91ae77b | ||
|
a4b1ac83f4 | ||
|
8775cdc13f | ||
|
db732ce9fa | ||
|
7c09244c39 | ||
|
2cc2a5f2ff | ||
|
e4b50f2a8d | ||
|
a2a84532ff | ||
|
d391323129 | ||
|
ab28ecf31b | ||
|
a4bab68802 | ||
|
e3cfacf0cb | ||
|
8d74e01f41 | ||
|
5404bb13d4 | ||
|
be8773fee0 | ||
|
0bcec80dfe | ||
|
2c8c2bffda |
@@ -1,2 +0,0 @@
|
|||||||
[cxx]
|
|
||||||
gtest_dep = //lib/gtest:gtest
|
|
168
.clang-format
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
Language: Cpp
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: false
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BreakBeforeBinaryOperators: false
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 80
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 2
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 2000
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: false
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
Standard: Cpp11
|
||||||
|
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
|
||||||
|
...
|
1
.clang-format-ignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
^lib/.*
|
11
.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
17
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Report
|
||||||
|
|
||||||
|
- [ ] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate
|
||||||
|
|
||||||
|
# Issues and Steps to Reproduce
|
||||||
|
***Replaces this with steps to repro your issue.***
|
||||||
|
|
||||||
|
# Expected Behavior
|
||||||
|
***Describe what you expected would happen.***
|
||||||
|
|
||||||
|
# Actual Behavior
|
||||||
|
***Describe what actually happened.***
|
||||||
|
|
||||||
|
# Link to Code
|
||||||
|
***If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.***
|
||||||
|
|
||||||
|
***When applicable, use this [fiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) to post a web repro.***
|
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
|
12
.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
|
||||||
@@ -60,3 +61,10 @@ Pods/
|
|||||||
# Carthage/Checkouts
|
# Carthage/Checkouts
|
||||||
|
|
||||||
Carthage/Build
|
Carthage/Build
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.gradle
|
||||||
|
|
||||||
|
# NDK/CMake
|
||||||
|
.cxx
|
||||||
|
.externalNativeBuild
|
||||||
|
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "lib/gtest/googletest"]
|
|
||||||
path = lib/gtest/googletest
|
|
||||||
url = https://github.com/google/googletest.git
|
|
42
.travis.yml
@@ -1,42 +0,0 @@
|
|||||||
# Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the BSD-style license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
|
|
||||||
os: osx
|
|
||||||
osx_image: xcode7.3
|
|
||||||
language: cpp
|
|
||||||
compiler: clang
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- brew update
|
|
||||||
- brew tap facebook/fb
|
|
||||||
- brew install buck
|
|
||||||
- brew cask install java
|
|
||||||
- brew outdated xctool || brew upgrade xctool
|
|
||||||
- brew install mono
|
|
||||||
|
|
||||||
- export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
|
|
||||||
- export PATH=$JAVA_HOME/bin:$PATH
|
|
||||||
|
|
||||||
install:
|
|
||||||
- cd javascript
|
|
||||||
- npm install
|
|
||||||
- cd $TRAVIS_BUILD_DIR
|
|
||||||
|
|
||||||
script:
|
|
||||||
- buck test //:yoga
|
|
||||||
- buck test //java:java
|
|
||||||
- buck test //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI
|
|
||||||
- sh csharp/tests/Facebook.Yoga/test_macos.sh
|
|
||||||
|
|
||||||
- cd javascript
|
|
||||||
- npm run test:all
|
|
||||||
- npm run bench
|
|
||||||
- cd $TRAVIS_BUILD_DIR
|
|
||||||
|
|
||||||
- buck run //benchmark:benchmark
|
|
||||||
- git checkout HEAD^
|
|
||||||
- buck run //benchmark:benchmark
|
|
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
@@ -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
@@ -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
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
42
BUCK
@@ -1,42 +0,0 @@
|
|||||||
# Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the BSD-style license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
|
|
||||||
include_defs('//YOGA_DEFS')
|
|
||||||
|
|
||||||
GMOCK_OVERRIDE_FLAGS = [
|
|
||||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
|
||||||
'-Wno-inconsistent-missing-override',
|
|
||||||
]
|
|
||||||
|
|
||||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11', '-fPIC']
|
|
||||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11']
|
|
||||||
|
|
||||||
cxx_library(
|
|
||||||
name = 'yoga',
|
|
||||||
soname = 'libyogacore.$(ext)',
|
|
||||||
srcs = glob(['yoga/*.c']),
|
|
||||||
tests=[':YogaTests'],
|
|
||||||
exported_headers = subdir_glob([('', 'yoga/*.h')]),
|
|
||||||
header_namespace = '',
|
|
||||||
compiler_flags = COMPILER_FLAGS,
|
|
||||||
deps = [] if THIS_IS_FBOBJC else [
|
|
||||||
yoga_dep('lib/fb:ndklog'),
|
|
||||||
],
|
|
||||||
visibility = ['PUBLIC'],
|
|
||||||
)
|
|
||||||
|
|
||||||
cxx_test(
|
|
||||||
name = 'YogaTests',
|
|
||||||
contacts = ['emilsj@fb.com'],
|
|
||||||
srcs = glob(['tests/*.cpp']),
|
|
||||||
compiler_flags = TEST_COMPILER_FLAGS,
|
|
||||||
deps = [
|
|
||||||
':yoga',
|
|
||||||
GTEST_TARGET,
|
|
||||||
],
|
|
||||||
visibility = ['PUBLIC'],
|
|
||||||
)
|
|
52
CMakeLists.txt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# 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(yoga-all)
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/project-defaults.cmake)
|
||||||
|
|
||||||
|
add_subdirectory(yoga)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
)
|
76
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to make participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||||
|
level of experience, education, socio-economic status, nationality, personal
|
||||||
|
appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all project spaces, and it also applies when
|
||||||
|
an individual is representing the project or its community in public spaces.
|
||||||
|
Examples of representing a project or community include using an official
|
||||||
|
project e-mail address, posting via an official social media account, or acting
|
||||||
|
as an appointed representative at an online or offline event. Representation of
|
||||||
|
a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at <opensource-conduct@fb.com>. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
@@ -2,9 +2,13 @@
|
|||||||
We want to make contributing to this project as easy and transparent as
|
We want to make contributing to this project as easy and transparent as
|
||||||
possible.
|
possible.
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
|
||||||
|
|
||||||
## 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.
|
||||||
@@ -25,9 +29,6 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
|
|||||||
disclosure of security bugs. In those cases, please go through the process
|
disclosure of security bugs. In those cases, please go through the process
|
||||||
outlined on that page and do not file a public issue.
|
outlined on that page and do not file a public issue.
|
||||||
|
|
||||||
## Coding Style
|
|
||||||
* format.sh
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
By contributing to yoga, you agree that your contributions will be licensed
|
By contributing to yoga, you agree that your contributions will be licensed
|
||||||
under its BSD license.
|
under its MIT license.
|
43
LICENSE
@@ -1,30 +1,21 @@
|
|||||||
BSD License
|
MIT License
|
||||||
|
|
||||||
For yoga software
|
Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
|
||||||
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
The above copyright notice and this permission notice shall be included in all
|
||||||
are permitted provided that the following conditions are met:
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
list of conditions and the following disclaimer.
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
this list of conditions and the following disclaimer in the documentation
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
and/or other materials provided with the distribution.
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
* Neither the name Facebook nor the names of its contributors may be used to
|
|
||||||
endorse or promote products derived from this software without specific
|
|
||||||
prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
33
PATENTS
@@ -1,33 +0,0 @@
|
|||||||
Additional Grant of Patent Rights Version 2
|
|
||||||
|
|
||||||
"Software" means the yoga software distributed by Facebook, Inc.
|
|
||||||
|
|
||||||
Facebook, Inc. (“Facebook”) hereby grants to each recipient of the Software
|
|
||||||
(“you”) a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
|
||||||
(subject to the termination provision below) license under any Necessary
|
|
||||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
|
||||||
transfer the Software. For avoidance of doubt, no license is granted under
|
|
||||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
|
||||||
to the Software made by you or any third party or (ii) the Software in
|
|
||||||
combination with any software or other technology.
|
|
||||||
|
|
||||||
The license granted hereunder will terminate, automatically and without notice,
|
|
||||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
|
||||||
directly or indirectly, or take a direct financial interest in, any Patent
|
|
||||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
|
||||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
|
||||||
in part from any software, technology, product or service of Facebook or any of
|
|
||||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
|
||||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
|
||||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
|
||||||
infringement against you in the first instance, and you respond by filing a
|
|
||||||
patent infringement counterclaim in that lawsuit against that party that is
|
|
||||||
unrelated to the Software, the license granted hereunder will not terminate
|
|
||||||
under section (i) of this paragraph due to such counterclaim.
|
|
||||||
|
|
||||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
|
||||||
necessarily infringed by the Software standing alone.
|
|
||||||
|
|
||||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
|
||||||
or contributory infringement or inducement to infringe any patent, including a
|
|
||||||
cross-claim or counterclaim.
|
|
36
README.md
@@ -1,14 +1,24 @@
|
|||||||
# Yoga [](https://travis-ci.org/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 generated 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,15 +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`.
|
|
||||||
|
|
||||||
## Code style
|
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).
|
||||||
For the main C implementation of Yoga clang-format is used to ensure a consistent code style. Please run `bash format.sh` before submitting a pull request. For other languages just try to follow the current code style.
|
|
||||||
|
|
||||||
## Benchmarks
|
|
||||||
Benchmarks are located in `benchmarks/YGBenchmark.c` and can be run with `buck run //benchmarks:benchmarks`. 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.
|
|
||||||
|
35
YOGA_DEFS
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
YOGA_ROOT = '//...'
|
|
||||||
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations'
|
|
||||||
JSR_305_TARGET = '//lib/jsr-305:jsr-305'
|
|
||||||
JUNIT_TARGET = '//lib/junit:junit'
|
|
||||||
PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations'
|
|
||||||
SOLOADER_TARGET = '//lib/soloader:soloader'
|
|
||||||
GTEST_TARGET = '//lib/gtest:gtest'
|
|
||||||
JNI_TARGET = '//lib/jni:jni'
|
|
||||||
FBJNI_TARGET = '//lib/fb:fbjni'
|
|
||||||
|
|
||||||
THIS_IS_FBOBJC = False
|
|
||||||
|
|
||||||
CXX_LIBRARY_WHITELIST = [
|
|
||||||
'//:yoga',
|
|
||||||
'//lib/fb:fbjni',
|
|
||||||
'//java:jni',
|
|
||||||
]
|
|
||||||
|
|
||||||
BASE_COMPILER_FLAGS = [
|
|
||||||
'-fno-omit-frame-pointer',
|
|
||||||
'-fexceptions',
|
|
||||||
'-Wall',
|
|
||||||
'-Werror',
|
|
||||||
'-O3',
|
|
||||||
]
|
|
||||||
|
|
||||||
def yoga_dep(dep):
|
|
||||||
return '//' + dep
|
|
||||||
|
|
||||||
class allow_unsafe_import:
|
|
||||||
def __enter__(self):
|
|
||||||
pass
|
|
||||||
def __exit__(self, type, value, traceback):
|
|
||||||
pass
|
|
39
Yoga.podspec
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
Pod::Spec.new do |spec|
|
||||||
|
spec.name = 'Yoga'
|
||||||
|
spec.version = '1.14.0'
|
||||||
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
|
spec.homepage = 'https://yogalayout.com/'
|
||||||
|
spec.documentation_url = 'https://yogalayout.com/docs'
|
||||||
|
|
||||||
|
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
|
||||||
|
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
|
||||||
|
|
||||||
|
spec.authors = 'Facebook'
|
||||||
|
spec.source = {
|
||||||
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
|
:tag => spec.version.to_s,
|
||||||
|
}
|
||||||
|
spec.platforms = { :ios => "8.0", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" }
|
||||||
|
spec.module_name = 'yoga'
|
||||||
|
spec.requires_arc = false
|
||||||
|
spec.pod_target_xcconfig = {
|
||||||
|
'DEFINES_MODULE' => 'YES'
|
||||||
|
}
|
||||||
|
spec.compiler_flags = [
|
||||||
|
'-fno-omit-frame-pointer',
|
||||||
|
'-fexceptions',
|
||||||
|
'-Wall',
|
||||||
|
'-Werror',
|
||||||
|
'-std=c++14',
|
||||||
|
'-fPIC'
|
||||||
|
]
|
||||||
|
spec.source_files = 'yoga/**/*.{c,h,cpp}'
|
||||||
|
spec.public_header_files = 'yoga/*.h'
|
||||||
|
|
||||||
|
end
|
39
YogaKit.podspec
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
podspec = Pod::Spec.new do |spec|
|
||||||
|
spec.name = 'YogaKit'
|
||||||
|
spec.version = '1.18.1'
|
||||||
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
|
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||||
|
spec.documentation_url = 'https://facebook.github.io/yoga/docs/'
|
||||||
|
|
||||||
|
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
|
||||||
|
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
|
||||||
|
|
||||||
|
spec.authors = 'Facebook'
|
||||||
|
spec.source = {
|
||||||
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
|
:tag => "1.18.0",
|
||||||
|
}
|
||||||
|
|
||||||
|
spec.platform = :ios
|
||||||
|
spec.ios.deployment_target = '8.0'
|
||||||
|
spec.ios.frameworks = 'UIKit'
|
||||||
|
spec.module_name = 'YogaKit'
|
||||||
|
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.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||||
|
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||||
|
spec.swift_version = '5.1'
|
||||||
|
end
|
||||||
|
|
||||||
|
# See https://github.com/facebook/yoga/pull/366
|
||||||
|
podspec.attributes_hash["readme"] = "YogaKit/README.md"
|
||||||
|
podspec
|
1
YogaKit/.swift-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0.2
|
58
YogaKit/BUCK
@@ -1,58 +0,0 @@
|
|||||||
# Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the BSD-style license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
|
|
||||||
include_defs('//YOGA_DEFS')
|
|
||||||
|
|
||||||
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',
|
|
||||||
]
|
|
||||||
|
|
||||||
apple_library(
|
|
||||||
name = 'YogaKit',
|
|
||||||
compiler_flags = COMPILER_FLAGS,
|
|
||||||
srcs = glob(['*.m']),
|
|
||||||
exported_headers = glob(['*.h']),
|
|
||||||
frameworks = [
|
|
||||||
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
|
|
||||||
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
|
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
yoga_dep(':yoga'),
|
|
||||||
],
|
|
||||||
visibility = ['PUBLIC'],
|
|
||||||
)
|
|
||||||
|
|
||||||
apple_test(
|
|
||||||
name = 'YogaKitTests',
|
|
||||||
compiler_flags = COMPILER_FLAGS,
|
|
||||||
info_plist = 'Tests/Info.plist',
|
|
||||||
srcs = glob(['Tests/**/*.m']),
|
|
||||||
frameworks = [
|
|
||||||
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
|
|
||||||
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
|
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
':YogaKit',
|
|
||||||
],
|
|
||||||
visibility = ['PUBLIC'],
|
|
||||||
)
|
|
21
YogaKit/README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# YogaKit
|
||||||
|
|
||||||
|
[](https://cocoapods.org/pods/YogaKit)
|
||||||
|
[](https://facebook.github.io/yoga/docs/api/yogakit/)
|
||||||
|
[](https://facebook.github.io/yoga/docs/api/yogakit/)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
|
||||||
|
|
||||||
|
```
|
||||||
|
pod 'YogaKit', '~> 1.7'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
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
|
||||||
|
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/main/CONTRIBUTING.md) file for how to help out.
|
37
YogaKit/Source/UIView+Yoga.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "YGLayout.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
typedef void (^YGLayoutConfigurationBlock)(YGLayout* layout);
|
||||||
|
|
||||||
|
@interface UIView (Yoga)
|
||||||
|
|
||||||
|
/**
|
||||||
|
The YGLayout that is attached to this view. It is lazily created.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, strong) YGLayout* yoga;
|
||||||
|
/**
|
||||||
|
Indicates whether or not Yoga is enabled
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, assign) BOOL isYogaEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
In ObjC land, every time you access `view.yoga.*` you are adding another
|
||||||
|
`objc_msgSend` to your code. If you plan on making multiple changes to
|
||||||
|
YGLayout, it's more performant to use this method, which uses a single
|
||||||
|
objc_msgSend call.
|
||||||
|
*/
|
||||||
|
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
|
||||||
|
NS_SWIFT_NAME(configureLayout(block:));
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
37
YogaKit/Source/UIView+Yoga.m
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
#import "UIView+Yoga.h"
|
||||||
|
#import "YGLayout+Private.h"
|
||||||
|
|
||||||
|
static const void* kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
|
||||||
|
|
||||||
|
@implementation UIView (YogaKit)
|
||||||
|
|
||||||
|
- (YGLayout*)yoga {
|
||||||
|
YGLayout* yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
|
||||||
|
if (!yoga) {
|
||||||
|
yoga = [[YGLayout alloc] initWithView:self];
|
||||||
|
objc_setAssociatedObject(
|
||||||
|
self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
return yoga;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isYogaEnabled {
|
||||||
|
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block {
|
||||||
|
if (block != nil) {
|
||||||
|
block(self.yoga);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
17
YogaKit/Source/YGLayout+Private.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <yoga/Yoga.h>
|
||||||
|
#import "YGLayout.h"
|
||||||
|
|
||||||
|
@interface YGLayout ()
|
||||||
|
|
||||||
|
@property(nonatomic, assign, readonly) YGNodeRef node;
|
||||||
|
|
||||||
|
- (instancetype)initWithView:(UIView*)view;
|
||||||
|
|
||||||
|
@end
|
174
YogaKit/Source/YGLayout.h
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <yoga/YGEnums.h>
|
||||||
|
#import <yoga/YGMacros.h>
|
||||||
|
#import <yoga/Yoga.h>
|
||||||
|
|
||||||
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
extern YGValue YGPointValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
|
||||||
|
"Use the swift Int and FloatingPoint extensions instead");
|
||||||
|
extern YGValue YGPercentValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
|
||||||
|
"Use the swift Int and FloatingPoint extensions instead");
|
||||||
|
|
||||||
|
YG_EXTERN_C_END
|
||||||
|
|
||||||
|
typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
|
||||||
|
YGDimensionFlexibilityFlexibleWidth = 1 << 0,
|
||||||
|
YGDimensionFlexibilityFlexibleHeight = 1 << 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
@interface YGLayout : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make default init unavailable, as it will not initialise YGNode which is
|
||||||
|
required for the setters and getters of YGLayout's properties to work properly.
|
||||||
|
*/
|
||||||
|
- (instancetype)init
|
||||||
|
__attribute__((unavailable("you are not meant to initialise YGLayout")));
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make default init unavailable, as it will not initialise YGNode which is
|
||||||
|
required for the setters and getters of YGLayout's properties to work properly.
|
||||||
|
*/
|
||||||
|
+ (instancetype)new
|
||||||
|
__attribute__((unavailable("you are not meant to initialise YGLayout")));
|
||||||
|
|
||||||
|
/**
|
||||||
|
The property that decides if we should include this view when calculating
|
||||||
|
layout. Defaults to YES.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readwrite, assign, setter=setIncludedInLayout:)
|
||||||
|
BOOL isIncludedInLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The property that decides during layout/sizing whether or not styling
|
||||||
|
properties should be applied. Defaults to NO.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
|
||||||
|
|
||||||
|
@property(nonatomic, readwrite, assign) YGDirection direction;
|
||||||
|
@property(nonatomic, readwrite, assign) YGFlexDirection flexDirection;
|
||||||
|
@property(nonatomic, readwrite, assign) YGJustify justifyContent;
|
||||||
|
@property(nonatomic, readwrite, assign) YGAlign alignContent;
|
||||||
|
@property(nonatomic, readwrite, assign) YGAlign alignItems;
|
||||||
|
@property(nonatomic, readwrite, assign) YGAlign alignSelf;
|
||||||
|
@property(nonatomic, readwrite, assign) YGPositionType position;
|
||||||
|
@property(nonatomic, readwrite, assign) YGWrap flexWrap;
|
||||||
|
@property(nonatomic, readwrite, assign) YGOverflow overflow;
|
||||||
|
@property(nonatomic, readwrite, assign) YGDisplay display;
|
||||||
|
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat flex;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat flexGrow;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat flexShrink;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue flexBasis;
|
||||||
|
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue left;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue top;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue right;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue bottom;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue start;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue end;
|
||||||
|
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginLeft;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginTop;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginRight;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginBottom;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginStart;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginEnd;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginHorizontal;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue marginVertical;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue margin;
|
||||||
|
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingLeft;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingTop;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingRight;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingBottom;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingStart;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingEnd;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingHorizontal;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue paddingVertical;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue padding;
|
||||||
|
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat borderLeftWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat borderTopWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat borderRightWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat borderBottomWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat borderStartWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat borderEndWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat borderWidth;
|
||||||
|
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue width;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue height;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue minWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue minHeight;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue maxWidth;
|
||||||
|
@property(nonatomic, readwrite, assign) YGValue maxHeight;
|
||||||
|
|
||||||
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
|
@property(nonatomic, readwrite, assign) CGFloat aspectRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the resolved direction of this node. This won't be YGDirectionInherit
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, assign) YGDirection resolvedDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a layout calculation and update the frames of the views in the
|
||||||
|
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
|
||||||
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a layout calculation and update the frames of the views in the
|
||||||
|
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
|
||||||
|
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||||
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the size of the view if no constraints were given. This could
|
||||||
|
equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, assign) CGSize intrinsicSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the size of the view based on provided constraints. Pass NaN for an
|
||||||
|
unconstrained dimension.
|
||||||
|
*/
|
||||||
|
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||||
|
NS_SWIFT_NAME(calculateLayout(with:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the number of children that are using Flexbox.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, assign) NSUInteger numberOfChildren;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return a BOOL indiciating whether or not we this node contains any subviews
|
||||||
|
that are included in Yoga's layout.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, assign) BOOL isLeaf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly, assign) BOOL isDirty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Mark that a view's layout needs to be recalculated. Only works for leaf views.
|
||||||
|
*/
|
||||||
|
- (void)markDirty;
|
||||||
|
|
||||||
|
@end
|
510
YogaKit/Source/YGLayout.m
Normal file
@@ -0,0 +1,510 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "UIView+Yoga.h"
|
||||||
|
#import "YGLayout+Private.h"
|
||||||
|
|
||||||
|
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
|
||||||
|
-(type)lowercased_name { \
|
||||||
|
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
-(void)set##capitalized_name : (type)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};
|
||||||
|
}
|
||||||
|
|
||||||
|
YGValue YGPercentValue(CGFloat value) {
|
||||||
|
return (YGValue){.value = value, .unit = YGUnitPercent};
|
||||||
|
}
|
||||||
|
|
||||||
|
static YGConfigRef globalConfig;
|
||||||
|
|
||||||
|
@interface YGLayout ()
|
||||||
|
|
||||||
|
@property(nonatomic, weak, readonly) UIView* view;
|
||||||
|
@property(nonatomic, assign, readonly) BOOL isUIView;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation YGLayout
|
||||||
|
|
||||||
|
@synthesize isEnabled = _isEnabled;
|
||||||
|
@synthesize isIncludedInLayout = _isIncludedInLayout;
|
||||||
|
@synthesize node = _node;
|
||||||
|
|
||||||
|
+ (void)initialize {
|
||||||
|
globalConfig = YGConfigNew();
|
||||||
|
YGConfigSetExperimentalFeatureEnabled(
|
||||||
|
globalConfig, YGExperimentalFeatureWebFlexBasis, true);
|
||||||
|
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithView:(UIView*)view {
|
||||||
|
if (self = [super init]) {
|
||||||
|
_view = view;
|
||||||
|
_node = YGNodeNewWithConfig(globalConfig);
|
||||||
|
YGNodeSetContext(_node, (__bridge void*)view);
|
||||||
|
_isEnabled = NO;
|
||||||
|
_isIncludedInLayout = YES;
|
||||||
|
_isUIView = [view isMemberOfClass:[UIView class]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
YGNodeFree(self.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isDirty {
|
||||||
|
return YGNodeIsDirty(self.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)markDirty {
|
||||||
|
if (self.isDirty || !self.isLeaf) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Yoga is not happy if we try to mark a node as "dirty" before we have set
|
||||||
|
// the measure function. Since we already know that this is a leaf,
|
||||||
|
// this *should* be fine. Forgive me Hack Gods.
|
||||||
|
const YGNodeRef node = self.node;
|
||||||
|
if (!YGNodeHasMeasureFunc(node)) {
|
||||||
|
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||||
|
}
|
||||||
|
|
||||||
|
YGNodeMarkDirty(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUInteger)numberOfChildren {
|
||||||
|
return YGNodeGetChildCount(self.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isLeaf {
|
||||||
|
NSAssert(
|
||||||
|
[NSThread isMainThread],
|
||||||
|
@"This method must be called on the main thread.");
|
||||||
|
if (self.isEnabled) {
|
||||||
|
for (UIView* subview in self.view.subviews) {
|
||||||
|
YGLayout* const yoga = subview.yoga;
|
||||||
|
if (yoga.isEnabled && yoga.isIncludedInLayout) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Style
|
||||||
|
|
||||||
|
- (YGPositionType)position {
|
||||||
|
return YGNodeStyleGetPositionType(self.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPosition:(YGPositionType)position {
|
||||||
|
YGNodeStyleSetPositionType(self.node, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
YG_PROPERTY(YGDirection, direction, Direction)
|
||||||
|
YG_PROPERTY(YGFlexDirection, flexDirection, FlexDirection)
|
||||||
|
YG_PROPERTY(YGJustify, justifyContent, JustifyContent)
|
||||||
|
YG_PROPERTY(YGAlign, alignContent, AlignContent)
|
||||||
|
YG_PROPERTY(YGAlign, alignItems, AlignItems)
|
||||||
|
YG_PROPERTY(YGAlign, alignSelf, AlignSelf)
|
||||||
|
YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
|
||||||
|
YG_PROPERTY(YGOverflow, overflow, Overflow)
|
||||||
|
YG_PROPERTY(YGDisplay, display, Display)
|
||||||
|
|
||||||
|
YG_PROPERTY(CGFloat, flex, Flex)
|
||||||
|
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
|
||||||
|
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
|
||||||
|
YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
|
||||||
|
|
||||||
|
YG_VALUE_EDGE_PROPERTY(left, Left, Position, YGEdgeLeft)
|
||||||
|
YG_VALUE_EDGE_PROPERTY(top, Top, Position, YGEdgeTop)
|
||||||
|
YG_VALUE_EDGE_PROPERTY(right, Right, Position, YGEdgeRight)
|
||||||
|
YG_VALUE_EDGE_PROPERTY(bottom, Bottom, Position, YGEdgeBottom)
|
||||||
|
YG_VALUE_EDGE_PROPERTY(start, Start, Position, YGEdgeStart)
|
||||||
|
YG_VALUE_EDGE_PROPERTY(end, End, Position, YGEdgeEnd)
|
||||||
|
YG_VALUE_EDGES_PROPERTIES(margin, Margin)
|
||||||
|
YG_VALUE_EDGES_PROPERTIES(padding, Padding)
|
||||||
|
|
||||||
|
YG_EDGE_PROPERTY(borderLeftWidth, BorderLeftWidth, Border, YGEdgeLeft)
|
||||||
|
YG_EDGE_PROPERTY(borderTopWidth, BorderTopWidth, Border, YGEdgeTop)
|
||||||
|
YG_EDGE_PROPERTY(borderRightWidth, BorderRightWidth, Border, YGEdgeRight)
|
||||||
|
YG_EDGE_PROPERTY(borderBottomWidth, BorderBottomWidth, Border, YGEdgeBottom)
|
||||||
|
YG_EDGE_PROPERTY(borderStartWidth, BorderStartWidth, Border, YGEdgeStart)
|
||||||
|
YG_EDGE_PROPERTY(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd)
|
||||||
|
YG_EDGE_PROPERTY(borderWidth, BorderWidth, Border, YGEdgeAll)
|
||||||
|
|
||||||
|
YG_AUTO_VALUE_PROPERTY(width, Width)
|
||||||
|
YG_AUTO_VALUE_PROPERTY(height, Height)
|
||||||
|
YG_VALUE_PROPERTY(minWidth, MinWidth)
|
||||||
|
YG_VALUE_PROPERTY(minHeight, MinHeight)
|
||||||
|
YG_VALUE_PROPERTY(maxWidth, MaxWidth)
|
||||||
|
YG_VALUE_PROPERTY(maxHeight, MaxHeight)
|
||||||
|
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
|
||||||
|
|
||||||
|
- (YGDirection)resolvedDirection {
|
||||||
|
return YGNodeLayoutGetDirection(self.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applyLayout {
|
||||||
|
[self calculateLayoutWithSize:self.view.bounds.size];
|
||||||
|
YGApplyLayoutToViewHierarchy(self.view, NO);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin {
|
||||||
|
[self calculateLayoutWithSize:self.view.bounds.size];
|
||||||
|
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
|
dimensionFlexibility:
|
||||||
|
(YGDimensionFlexibility)dimensionFlexibility {
|
||||||
|
CGSize size = self.view.bounds.size;
|
||||||
|
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
|
||||||
|
size.width = YGUndefined;
|
||||||
|
}
|
||||||
|
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleHeight) {
|
||||||
|
size.height = YGUndefined;
|
||||||
|
}
|
||||||
|
[self calculateLayoutWithSize:size];
|
||||||
|
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGSize)intrinsicSize {
|
||||||
|
const CGSize constrainedSize = {
|
||||||
|
.width = YGUndefined,
|
||||||
|
.height = YGUndefined,
|
||||||
|
};
|
||||||
|
return [self calculateLayoutWithSize:constrainedSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGSize)calculateLayoutWithSize:(CGSize)size {
|
||||||
|
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
|
||||||
|
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
|
||||||
|
|
||||||
|
YGAttachNodesFromViewHierachy(self.view);
|
||||||
|
|
||||||
|
const YGNodeRef node = self.node;
|
||||||
|
YGNodeCalculateLayout(
|
||||||
|
node, size.width, size.height, YGNodeStyleGetDirection(node));
|
||||||
|
|
||||||
|
return (CGSize){
|
||||||
|
.width = YGNodeLayoutGetWidth(node),
|
||||||
|
.height = YGNodeLayoutGetHeight(node),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
static YGSize YGMeasureView(
|
||||||
|
YGNodeRef node,
|
||||||
|
float width,
|
||||||
|
YGMeasureMode widthMode,
|
||||||
|
float height,
|
||||||
|
YGMeasureMode heightMode) {
|
||||||
|
const CGFloat constrainedWidth =
|
||||||
|
(widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
||||||
|
const CGFloat constrainedHeight =
|
||||||
|
(heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : height;
|
||||||
|
|
||||||
|
UIView* view = (__bridge UIView*)YGNodeGetContext(node);
|
||||||
|
CGSize sizeThatFits = CGSizeZero;
|
||||||
|
|
||||||
|
// The default implementation of sizeThatFits: returns the existing size of
|
||||||
|
// the view. That means that if we want to layout an empty UIView, which
|
||||||
|
// already has got a frame set, its measured size should be CGSizeZero, but
|
||||||
|
// UIKit returns the existing size.
|
||||||
|
//
|
||||||
|
// See https://github.com/facebook/yoga/issues/606 for more information.
|
||||||
|
if (!view.yoga.isUIView || [view.subviews count] > 0) {
|
||||||
|
sizeThatFits = [view sizeThatFits:(CGSize){
|
||||||
|
.width = constrainedWidth,
|
||||||
|
.height = constrainedHeight,
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (YGSize){
|
||||||
|
.width = YGSanitizeMeasurement(
|
||||||
|
constrainedWidth, sizeThatFits.width, widthMode),
|
||||||
|
.height = YGSanitizeMeasurement(
|
||||||
|
constrainedHeight, sizeThatFits.height, heightMode),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static CGFloat YGSanitizeMeasurement(
|
||||||
|
CGFloat constrainedSize,
|
||||||
|
CGFloat measuredSize,
|
||||||
|
YGMeasureMode measureMode) {
|
||||||
|
CGFloat result;
|
||||||
|
if (measureMode == YGMeasureModeExactly) {
|
||||||
|
result = constrainedSize;
|
||||||
|
} else if (measureMode == YGMeasureModeAtMost) {
|
||||||
|
result = MIN(constrainedSize, measuredSize);
|
||||||
|
} else {
|
||||||
|
result = measuredSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL YGNodeHasExactSameChildren(
|
||||||
|
const YGNodeRef node,
|
||||||
|
NSArray<UIView*>* subviews) {
|
||||||
|
if (YGNodeGetChildCount(node) != subviews.count) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < subviews.count; i++) {
|
||||||
|
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YGAttachNodesFromViewHierachy(UIView* const view) {
|
||||||
|
YGLayout* const yoga = view.yoga;
|
||||||
|
const YGNodeRef node = yoga.node;
|
||||||
|
|
||||||
|
// Only leaf nodes should have a measure function
|
||||||
|
if (yoga.isLeaf) {
|
||||||
|
YGRemoveAllChildren(node);
|
||||||
|
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||||
|
} else {
|
||||||
|
YGNodeSetMeasureFunc(node, NULL);
|
||||||
|
|
||||||
|
NSMutableArray<UIView*>* subviewsToInclude =
|
||||||
|
[[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
||||||
|
for (UIView* subview in view.subviews) {
|
||||||
|
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
|
||||||
|
[subviewsToInclude addObject:subview];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
|
||||||
|
YGRemoveAllChildren(node);
|
||||||
|
for (int i = 0; i < subviewsToInclude.count; i++) {
|
||||||
|
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UIView* const subview in subviewsToInclude) {
|
||||||
|
YGAttachNodesFromViewHierachy(subview);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YGRemoveAllChildren(const YGNodeRef node) {
|
||||||
|
if (node == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGNodeRemoveAllChildren(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CGFloat YGRoundPixelValue(CGFloat value) {
|
||||||
|
static CGFloat scale;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^() {
|
||||||
|
scale = [UIScreen mainScreen].scale;
|
||||||
|
});
|
||||||
|
|
||||||
|
return roundf(value * scale) / scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
|
||||||
|
NSCAssert(
|
||||||
|
[NSThread isMainThread],
|
||||||
|
@"Framesetting should only be done on the main thread.");
|
||||||
|
|
||||||
|
const YGLayout* yoga = view.yoga;
|
||||||
|
|
||||||
|
if (!yoga.isIncludedInLayout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGNodeRef node = yoga.node;
|
||||||
|
const CGPoint topLeft = {
|
||||||
|
YGNodeLayoutGetLeft(node),
|
||||||
|
YGNodeLayoutGetTop(node),
|
||||||
|
};
|
||||||
|
|
||||||
|
const CGPoint bottomRight = {
|
||||||
|
topLeft.x + YGNodeLayoutGetWidth(node),
|
||||||
|
topLeft.y + YGNodeLayoutGetHeight(node),
|
||||||
|
};
|
||||||
|
|
||||||
|
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
|
||||||
|
view.frame = (CGRect){
|
||||||
|
.origin =
|
||||||
|
{
|
||||||
|
.x = YGRoundPixelValue(topLeft.x + origin.x),
|
||||||
|
.y = YGRoundPixelValue(topLeft.y + origin.y),
|
||||||
|
},
|
||||||
|
.size =
|
||||||
|
{
|
||||||
|
.width = YGRoundPixelValue(bottomRight.x) -
|
||||||
|
YGRoundPixelValue(topLeft.x),
|
||||||
|
.height = YGRoundPixelValue(bottomRight.y) -
|
||||||
|
YGRoundPixelValue(topLeft.y),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!yoga.isLeaf) {
|
||||||
|
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||||
|
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
45
YogaKit/Source/YGLayoutExtensions.swift
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import yoga;
|
||||||
|
postfix operator %
|
||||||
|
|
||||||
|
extension Int {
|
||||||
|
public static postfix func %(value: Int) -> YGValue {
|
||||||
|
return YGValue(value: Float(value), unit: .percent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float {
|
||||||
|
public static postfix func %(value: Float) -> YGValue {
|
||||||
|
return YGValue(value: value, unit: .percent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGFloat {
|
||||||
|
public static postfix func %(value: CGFloat) -> YGValue {
|
||||||
|
return YGValue(value: Float(value), unit: .percent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension YGValue : ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
|
||||||
|
public init(integerLiteral value: Int) {
|
||||||
|
self = YGValue(value: Float(value), unit: .point)
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(floatLiteral value: Float) {
|
||||||
|
self = YGValue(value: value, unit: .point)
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(_ value: Float) {
|
||||||
|
self = YGValue(value: value, unit: .point)
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(_ value: CGFloat) {
|
||||||
|
self = YGValue(value: Float(value), unit: .point)
|
||||||
|
}
|
||||||
|
}
|
@@ -1,58 +1,77 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
* All rights reserved.
|
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style 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. An additional grant
|
* LICENSE file in the root directory of this source tree.
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <XCTest/XCTest.h>
|
#import <XCTest/XCTest.h>
|
||||||
|
|
||||||
#import <YogaKit/UIView+Yoga.h>
|
#import <YogaKit/UIView+Yoga.h>
|
||||||
|
#import <YogaKit/YGLayout+Private.h>
|
||||||
|
#import <yoga/Yoga.h>
|
||||||
|
|
||||||
@interface YogaKitTests : XCTestCase
|
@interface YogaKitTests : XCTestCase
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation YogaKitTests
|
@implementation YogaKitTests
|
||||||
|
|
||||||
#ifndef TRAVIS_CI
|
- (void)testConfigureLayoutIsNoOpWithNilBlock {
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
- (void)testNodesAreDeallocedWithSingleView
|
id block = nil;
|
||||||
{
|
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
view.yoga.flexBasis = 1;
|
|
||||||
XCTAssertEqual(1, YGNodeGetInstanceCount());
|
|
||||||
view = nil;
|
|
||||||
|
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testNodesAreDeallocedCascade
|
- (void)testConfigureLayoutBlockWorksWithValidBlock {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
[view configureLayoutWithBlock:^(YGLayout* layout) {
|
||||||
|
XCTAssertNotNil(layout);
|
||||||
|
layout.isEnabled = YES;
|
||||||
|
layout.width = YGPointValue(25);
|
||||||
|
}];
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
XCTAssertTrue(view.yoga.isEnabled);
|
||||||
view.yoga.flexBasis = 1;
|
XCTAssertEqual(view.yoga.width.value, 25);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<10; i++) {
|
- (void)testNodesAreDeallocedWithSingleView {
|
||||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
__weak YGLayout* layoutRef = nil;
|
||||||
subview.yoga.flexBasis = 1;
|
|
||||||
[view addSubview:subview];
|
@autoreleasepool {
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
view.yoga.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
|
layoutRef = view.yoga;
|
||||||
|
XCTAssertNotNil(layoutRef);
|
||||||
|
|
||||||
|
view = nil;
|
||||||
}
|
}
|
||||||
XCTAssertEqual(11, YGNodeGetInstanceCount());
|
|
||||||
view = nil;
|
|
||||||
|
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
XCTAssertNil(layoutRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
- (void)testNodesAreDeallocedCascade {
|
||||||
|
__weak YGLayout* topLayout = nil;
|
||||||
|
__weak YGLayout* subviewLayout = nil;
|
||||||
|
|
||||||
- (void)testUsesYoga
|
@autoreleasepool {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
topLayout = view.yoga;
|
||||||
|
topLayout.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
|
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
subviewLayout = subview.yoga;
|
||||||
|
subviewLayout.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
|
view = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertNil(topLayout);
|
||||||
|
XCTAssertNil(subviewLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testIsEnabled {
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
XCTAssertFalse(view.yoga.isEnabled);
|
XCTAssertFalse(view.yoga.isEnabled);
|
||||||
|
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
@@ -62,124 +81,253 @@
|
|||||||
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),
|
||||||
|
^(void) {
|
||||||
XCTAssertThrows(view.yoga.intrinsicSize);
|
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.marginLeft = 3.0;
|
textBadgeView.yoga.margin = YGPointValue(0);
|
||||||
textBadgeView.yoga.width = 10;
|
textBadgeView.yoga.width = YGPointValue(10);
|
||||||
textBadgeView.yoga.height = 10;
|
textBadgeView.yoga.height = YGPointValue(10);
|
||||||
[container addSubview:textBadgeView];
|
[container addSubview:textBadgeView];
|
||||||
|
|
||||||
|
const CGSize textBadgeViewSize = textBadgeView.yoga.intrinsicSize;
|
||||||
|
XCTAssertEqual(textBadgeViewSize.height, 10);
|
||||||
|
XCTAssertEqual(textBadgeViewSize.width, 10);
|
||||||
|
|
||||||
const CGSize containerSize = container.yoga.intrinsicSize;
|
const CGSize containerSize = container.yoga.intrinsicSize;
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize));
|
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
|
||||||
|
|
||||||
|
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
|
||||||
|
XCTAssertEqual(
|
||||||
|
longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width,
|
||||||
|
containerSize.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
|
- (void)testSizeThatFitsEmptyView {
|
||||||
{
|
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
|
view.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
const CGSize viewSize = view.yoga.intrinsicSize;
|
||||||
|
XCTAssertEqual(viewSize.height, 0);
|
||||||
|
XCTAssertEqual(viewSize.width, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testPreservingOrigin {
|
||||||
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 75)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
view.yoga.flexBasis = YGPointValue(0);
|
||||||
|
view.yoga.flexGrow = 1;
|
||||||
|
[container addSubview:view];
|
||||||
|
|
||||||
|
UIView* view2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
view2.yoga.isEnabled = YES;
|
||||||
|
view2.yoga.marginTop = YGPointValue(25);
|
||||||
|
view2.yoga.flexBasis = YGPointValue(0);
|
||||||
|
view2.yoga.flexGrow = 1;
|
||||||
|
[container addSubview:view2];
|
||||||
|
|
||||||
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
XCTAssertEqual(50, view2.frame.origin.y);
|
||||||
|
|
||||||
|
[view2.yoga applyLayoutPreservingOrigin:NO];
|
||||||
|
XCTAssertEqual(25, view2.frame.origin.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testContainerWithFlexibleWidthGetsCorrectlySized {
|
||||||
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
view.yoga.width = YGPointValue(100);
|
||||||
|
view.yoga.height = YGPointValue(100);
|
||||||
|
[container addSubview:view];
|
||||||
|
|
||||||
|
[container.yoga
|
||||||
|
applyLayoutPreservingOrigin:YES
|
||||||
|
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
|
||||||
|
XCTAssertEqual(100, container.frame.size.width);
|
||||||
|
XCTAssertEqual(200, container.frame.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testContainerWithFlexibleHeightGetsCorrectlySized {
|
||||||
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
view.yoga.width = YGPointValue(100);
|
||||||
|
view.yoga.height = YGPointValue(100);
|
||||||
|
[container addSubview:view];
|
||||||
|
|
||||||
|
[container.yoga
|
||||||
|
applyLayoutPreservingOrigin:YES
|
||||||
|
dimensionFlexibility:YGDimensionFlexibilityFlexibleHeight];
|
||||||
|
XCTAssertEqual(200, container.frame.size.width);
|
||||||
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized {
|
||||||
|
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
view.yoga.width = YGPointValue(100);
|
||||||
|
view.yoga.height = YGPointValue(100);
|
||||||
|
[container addSubview:view];
|
||||||
|
|
||||||
|
[container.yoga
|
||||||
|
applyLayoutPreservingOrigin:YES
|
||||||
|
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth |
|
||||||
|
YGDimensionFlexibilityFlexibleHeight];
|
||||||
|
XCTAssertEqual(100, container.frame.size.width);
|
||||||
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testMarkingDirtyOnlyWorksOnLeafNodes {
|
||||||
|
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
subview.yoga.isEnabled = YES;
|
||||||
|
[container addSubview:subview];
|
||||||
|
|
||||||
|
XCTAssertFalse(container.yoga.isDirty);
|
||||||
|
[container.yoga markDirty];
|
||||||
|
XCTAssertFalse(container.yoga.isDirty);
|
||||||
|
|
||||||
|
XCTAssertFalse(subview.yoga.isDirty);
|
||||||
|
[subview.yoga markDirty];
|
||||||
|
XCTAssertTrue(subview.yoga.isDirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation {
|
||||||
|
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 *label = [[UILabel alloc] initWithFrame:CGRectZero];
|
UILabel* view = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||||
label.text = @"This is a short text.";
|
view.text = @"This is a short text.";
|
||||||
label.numberOfLines = 1;
|
view.numberOfLines = 1;
|
||||||
label.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
[container addSubview:label];
|
[container addSubview:view];
|
||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(146,21), label.bounds.size), @"Size is actually %@", NSStringFromCGSize(label.bounds.size));
|
CGSize const viewSizeAfterFirstPass = view.frame.size;
|
||||||
|
|
||||||
label.text = @"This is a slightly longer text.";
|
view.text = @"This is a slightly longer text.";
|
||||||
[label.yoga markDirty];
|
XCTAssertTrue(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
|
||||||
|
|
||||||
[container.yoga applyLayout];
|
[view.yoga markDirty];
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(213,21), label.bounds.size), @"Size is actually %@", NSStringFromCGSize(label.bounds.size));
|
|
||||||
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
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;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
|
||||||
subview.yoga.isEnabled = YES;
|
|
||||||
subview.yoga.flexGrow = 1;
|
|
||||||
|
|
||||||
[container addSubview:subview];
|
|
||||||
}
|
|
||||||
[container.yoga applyLayout];
|
|
||||||
|
|
||||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
|
|
||||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
|
|
||||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
|
|
||||||
|
|
||||||
CGFloat totalWidth = 0;
|
|
||||||
for (UIView *view in container.subviews) {
|
|
||||||
totalWidth += view.bounds.size.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
|
|
||||||
{
|
|
||||||
const CGSize containerSize = CGSizeMake(300, 50);
|
|
||||||
|
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
|
||||||
container.yoga.isEnabled = YES;
|
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
|
||||||
|
|
||||||
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 applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
|
XCTAssertEqualWithAccuracy(
|
||||||
|
subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
|
||||||
|
XCTAssertEqualWithAccuracy(
|
||||||
|
subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
|
||||||
|
|
||||||
|
CGFloat totalWidth = 0;
|
||||||
|
for (UIView* view in container.subviews) {
|
||||||
|
totalWidth += view.bounds.size.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(
|
||||||
|
containerSize.width,
|
||||||
|
totalWidth,
|
||||||
|
@"The container's width is %.6f, the subviews take up %.6f",
|
||||||
|
containerSize.width,
|
||||||
|
totalWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder {
|
||||||
|
const CGSize containerSize = CGSizeMake(300, 50);
|
||||||
|
|
||||||
|
UIView* container = [[UIView alloc]
|
||||||
|
initWithFrame:CGRectMake(
|
||||||
|
0, 0, containerSize.width, containerSize.height)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
|
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
subview1.yoga.isEnabled = YES;
|
||||||
|
subview1.yoga.flexGrow = 1;
|
||||||
|
[container addSubview:subview1];
|
||||||
|
|
||||||
|
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
subview2.yoga.isEnabled = YES;
|
||||||
|
subview2.yoga.flexGrow = 1;
|
||||||
|
[container addSubview:subview2];
|
||||||
|
|
||||||
|
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
subview3.yoga.isEnabled = YES;
|
||||||
|
subview3.yoga.flexGrow = 1;
|
||||||
|
[container addSubview:subview3];
|
||||||
|
|
||||||
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)), @"It's actually %@", NSStringFromCGRect(subview2.frame));
|
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
|
||||||
|
|
||||||
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
|
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
|
||||||
subview2.yoga.isIncludedInLayout = NO;
|
subview2.yoga.isIncludedInLayout = NO;
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50)));
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50)));
|
||||||
@@ -188,200 +336,414 @@
|
|||||||
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 applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
for (UIView *view in container.subviews) {
|
for (UIView* subview in container.subviews) {
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), view.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
XCTAssertEqual(subview.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
subview3.yoga.isIncludedInLayout = NO;
|
subview3.yoga.isIncludedInLayout = NO;
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 150);
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
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
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size));
|
// previously at.
|
||||||
|
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];
|
||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
XCTAssertEqual(1, container.yoga.numberOfChildren);
|
XCTAssertEqual(container.yoga.numberOfChildren, 1);
|
||||||
|
|
||||||
subview2.yoga.isIncludedInLayout = YES;
|
subview2.yoga.isIncludedInLayout = YES;
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
XCTAssertEqual(2, container.yoga.numberOfChildren);
|
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;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 150);
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size));
|
XCTAssertEqual(subview3.bounds.size.width, 0);
|
||||||
|
|
||||||
subview3.yoga.isIncludedInLayout = YES;
|
subview3.yoga.isIncludedInLayout = YES;
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
for (UIView *view in container.subviews) {
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), view.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 100);
|
||||||
}
|
XCTAssertEqual(subview2.bounds.size.width, 100);
|
||||||
|
XCTAssertEqual(subview3.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testyg_isLeafFlag
|
- (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);
|
||||||
|
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.width = 50.0;
|
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 = 50.0;
|
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 = 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 = 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 applyLayout];
|
[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 applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 25), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 100);
|
||||||
for (UIView *subview in subview1.subviews) {
|
XCTAssertEqual(subview1.bounds.size.height, 25);
|
||||||
|
for (UIView* subview in subview1.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subviewSize));
|
XCTAssertNotEqual(subviewSize.width, 0);
|
||||||
|
XCTAssertNotEqual(subviewSize.height, 0);
|
||||||
XCTAssertFalse(isnan(subviewSize.height));
|
XCTAssertFalse(isnan(subviewSize.height));
|
||||||
XCTAssertFalse(isnan(subviewSize.width));
|
XCTAssertFalse(isnan(subviewSize.width));
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 25), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
for (UIView *subview in subview2.subviews) {
|
XCTAssertEqual(subview2.bounds.size.height, 25);
|
||||||
|
for (UIView* subview in subview2.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subview.bounds.size));
|
XCTAssertNotEqual(subviewSize.width, 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 applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
[subview2 removeFromSuperview];
|
[subview2 removeFromSuperview];
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testPointPercent {
|
||||||
|
XCTAssertEqual(YGPointValue(1).value, 1);
|
||||||
|
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
|
||||||
|
XCTAssertEqual(YGPercentValue(2).value, 2);
|
||||||
|
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testPositionalPropertiesWork {
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
|
view.yoga.left = YGPointValue(1);
|
||||||
|
XCTAssertEqual(view.yoga.left.value, 1);
|
||||||
|
XCTAssertEqual(view.yoga.left.unit, YGUnitPoint);
|
||||||
|
view.yoga.left = YGPercentValue(2);
|
||||||
|
XCTAssertEqual(view.yoga.left.value, 2);
|
||||||
|
XCTAssertEqual(view.yoga.left.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.right = YGPointValue(3);
|
||||||
|
XCTAssertEqual(view.yoga.right.value, 3);
|
||||||
|
XCTAssertEqual(view.yoga.right.unit, YGUnitPoint);
|
||||||
|
view.yoga.right = YGPercentValue(4);
|
||||||
|
XCTAssertEqual(view.yoga.right.value, 4);
|
||||||
|
XCTAssertEqual(view.yoga.right.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.top = YGPointValue(5);
|
||||||
|
XCTAssertEqual(view.yoga.top.value, 5);
|
||||||
|
XCTAssertEqual(view.yoga.top.unit, YGUnitPoint);
|
||||||
|
view.yoga.top = YGPercentValue(6);
|
||||||
|
XCTAssertEqual(view.yoga.top.value, 6);
|
||||||
|
XCTAssertEqual(view.yoga.top.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.bottom = YGPointValue(7);
|
||||||
|
XCTAssertEqual(view.yoga.bottom.value, 7);
|
||||||
|
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPoint);
|
||||||
|
view.yoga.bottom = YGPercentValue(8);
|
||||||
|
XCTAssertEqual(view.yoga.bottom.value, 8);
|
||||||
|
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.start = YGPointValue(9);
|
||||||
|
XCTAssertEqual(view.yoga.start.value, 9);
|
||||||
|
XCTAssertEqual(view.yoga.start.unit, YGUnitPoint);
|
||||||
|
view.yoga.start = YGPercentValue(10);
|
||||||
|
XCTAssertEqual(view.yoga.start.value, 10);
|
||||||
|
XCTAssertEqual(view.yoga.start.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.end = YGPointValue(11);
|
||||||
|
XCTAssertEqual(view.yoga.end.value, 11);
|
||||||
|
XCTAssertEqual(view.yoga.end.unit, YGUnitPoint);
|
||||||
|
view.yoga.end = YGPercentValue(12);
|
||||||
|
XCTAssertEqual(view.yoga.end.value, 12);
|
||||||
|
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testMarginPropertiesWork {
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
|
view.yoga.margin = YGPointValue(1);
|
||||||
|
XCTAssertEqual(view.yoga.margin.value, 1);
|
||||||
|
XCTAssertEqual(view.yoga.margin.unit, YGUnitPoint);
|
||||||
|
view.yoga.margin = YGPercentValue(2);
|
||||||
|
XCTAssertEqual(view.yoga.margin.value, 2);
|
||||||
|
XCTAssertEqual(view.yoga.margin.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginHorizontal = YGPointValue(3);
|
||||||
|
XCTAssertEqual(view.yoga.marginHorizontal.value, 3);
|
||||||
|
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginHorizontal = YGPercentValue(4);
|
||||||
|
XCTAssertEqual(view.yoga.marginHorizontal.value, 4);
|
||||||
|
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginVertical = YGPointValue(5);
|
||||||
|
XCTAssertEqual(view.yoga.marginVertical.value, 5);
|
||||||
|
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginVertical = YGPercentValue(6);
|
||||||
|
XCTAssertEqual(view.yoga.marginVertical.value, 6);
|
||||||
|
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginLeft = YGPointValue(7);
|
||||||
|
XCTAssertEqual(view.yoga.marginLeft.value, 7);
|
||||||
|
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginLeft = YGPercentValue(8);
|
||||||
|
XCTAssertEqual(view.yoga.marginLeft.value, 8);
|
||||||
|
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginRight = YGPointValue(9);
|
||||||
|
XCTAssertEqual(view.yoga.marginRight.value, 9);
|
||||||
|
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginRight = YGPercentValue(10);
|
||||||
|
XCTAssertEqual(view.yoga.marginRight.value, 10);
|
||||||
|
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginTop = YGPointValue(11);
|
||||||
|
XCTAssertEqual(view.yoga.marginTop.value, 11);
|
||||||
|
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginTop = YGPercentValue(12);
|
||||||
|
XCTAssertEqual(view.yoga.marginTop.value, 12);
|
||||||
|
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginBottom = YGPointValue(13);
|
||||||
|
XCTAssertEqual(view.yoga.marginBottom.value, 13);
|
||||||
|
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginBottom = YGPercentValue(14);
|
||||||
|
XCTAssertEqual(view.yoga.marginBottom.value, 14);
|
||||||
|
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginStart = YGPointValue(15);
|
||||||
|
XCTAssertEqual(view.yoga.marginStart.value, 15);
|
||||||
|
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginStart = YGPercentValue(16);
|
||||||
|
XCTAssertEqual(view.yoga.marginStart.value, 16);
|
||||||
|
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.marginEnd = YGPointValue(17);
|
||||||
|
XCTAssertEqual(view.yoga.marginEnd.value, 17);
|
||||||
|
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPoint);
|
||||||
|
view.yoga.marginEnd = YGPercentValue(18);
|
||||||
|
XCTAssertEqual(view.yoga.marginEnd.value, 18);
|
||||||
|
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testPaddingPropertiesWork {
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
|
view.yoga.padding = YGPointValue(1);
|
||||||
|
XCTAssertEqual(view.yoga.padding.value, 1);
|
||||||
|
XCTAssertEqual(view.yoga.padding.unit, YGUnitPoint);
|
||||||
|
view.yoga.padding = YGPercentValue(2);
|
||||||
|
XCTAssertEqual(view.yoga.padding.value, 2);
|
||||||
|
XCTAssertEqual(view.yoga.padding.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingHorizontal = YGPointValue(3);
|
||||||
|
XCTAssertEqual(view.yoga.paddingHorizontal.value, 3);
|
||||||
|
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingHorizontal = YGPercentValue(4);
|
||||||
|
XCTAssertEqual(view.yoga.paddingHorizontal.value, 4);
|
||||||
|
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingVertical = YGPointValue(5);
|
||||||
|
XCTAssertEqual(view.yoga.paddingVertical.value, 5);
|
||||||
|
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingVertical = YGPercentValue(6);
|
||||||
|
XCTAssertEqual(view.yoga.paddingVertical.value, 6);
|
||||||
|
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingLeft = YGPointValue(7);
|
||||||
|
XCTAssertEqual(view.yoga.paddingLeft.value, 7);
|
||||||
|
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingLeft = YGPercentValue(8);
|
||||||
|
XCTAssertEqual(view.yoga.paddingLeft.value, 8);
|
||||||
|
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingRight = YGPointValue(9);
|
||||||
|
XCTAssertEqual(view.yoga.paddingRight.value, 9);
|
||||||
|
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingRight = YGPercentValue(10);
|
||||||
|
XCTAssertEqual(view.yoga.paddingRight.value, 10);
|
||||||
|
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingTop = YGPointValue(11);
|
||||||
|
XCTAssertEqual(view.yoga.paddingTop.value, 11);
|
||||||
|
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingTop = YGPercentValue(12);
|
||||||
|
XCTAssertEqual(view.yoga.paddingTop.value, 12);
|
||||||
|
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingBottom = YGPointValue(13);
|
||||||
|
XCTAssertEqual(view.yoga.paddingBottom.value, 13);
|
||||||
|
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingBottom = YGPercentValue(14);
|
||||||
|
XCTAssertEqual(view.yoga.paddingBottom.value, 14);
|
||||||
|
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingStart = YGPointValue(15);
|
||||||
|
XCTAssertEqual(view.yoga.paddingStart.value, 15);
|
||||||
|
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingStart = YGPercentValue(16);
|
||||||
|
XCTAssertEqual(view.yoga.paddingStart.value, 16);
|
||||||
|
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPercent);
|
||||||
|
|
||||||
|
view.yoga.paddingEnd = YGPointValue(17);
|
||||||
|
XCTAssertEqual(view.yoga.paddingEnd.value, 17);
|
||||||
|
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPoint);
|
||||||
|
view.yoga.paddingEnd = YGPercentValue(18);
|
||||||
|
XCTAssertEqual(view.yoga.paddingEnd.value, 18);
|
||||||
|
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testBorderWidthPropertiesWork {
|
||||||
|
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
|
view.yoga.borderWidth = 1;
|
||||||
|
XCTAssertEqual(view.yoga.borderWidth, 1);
|
||||||
|
|
||||||
|
view.yoga.borderLeftWidth = 2;
|
||||||
|
XCTAssertEqual(view.yoga.borderLeftWidth, 2);
|
||||||
|
|
||||||
|
view.yoga.borderRightWidth = 3;
|
||||||
|
XCTAssertEqual(view.yoga.borderRightWidth, 3);
|
||||||
|
|
||||||
|
view.yoga.borderTopWidth = 4;
|
||||||
|
XCTAssertEqual(view.yoga.borderTopWidth, 4);
|
||||||
|
|
||||||
|
view.yoga.borderBottomWidth = 5;
|
||||||
|
XCTAssertEqual(view.yoga.borderBottomWidth, 5);
|
||||||
|
|
||||||
|
view.yoga.borderStartWidth = 6;
|
||||||
|
XCTAssertEqual(view.yoga.borderStartWidth, 6);
|
||||||
|
|
||||||
|
view.yoga.borderEndWidth = 7;
|
||||||
|
XCTAssertEqual(view.yoga.borderEndWidth, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "YGLayout.h"
|
|
||||||
|
|
||||||
@interface UIView (Yoga)
|
|
||||||
|
|
||||||
@property (nonatomic, readonly, strong) YGLayout *yoga;
|
|
||||||
|
|
||||||
@end
|
|
@@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "UIView+Yoga.h"
|
|
||||||
#import "YGLayout+Private.h"
|
|
||||||
#import <objc/runtime.h>
|
|
||||||
|
|
||||||
static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
|
|
||||||
|
|
||||||
@implementation UIView (YogaKit)
|
|
||||||
|
|
||||||
- (YGLayout *)yoga
|
|
||||||
{
|
|
||||||
YGLayout *yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
|
|
||||||
if (!yoga) {
|
|
||||||
yoga = [[YGLayout alloc] initWithView:self];
|
|
||||||
objc_setAssociatedObject(self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
return yoga;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
@@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "YGLayout.h"
|
|
||||||
|
|
||||||
@interface YGLayout (Private)
|
|
||||||
|
|
||||||
- (instancetype)initWithView:(UIView *)view;
|
|
||||||
|
|
||||||
@end
|
|
@@ -1,114 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import <yoga/YGEnums.h>
|
|
||||||
|
|
||||||
@interface YGLayout : NSObject
|
|
||||||
|
|
||||||
/**
|
|
||||||
The property that decides if we should include this view when calculating layout. Defaults to YES.
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The property that decides during layout/sizing whether or not styling properties should be applied. Defaults to NO.
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) YGDirection direction;
|
|
||||||
@property (nonatomic, readwrite, assign) YGFlexDirection flexDirection;
|
|
||||||
@property (nonatomic, readwrite, assign) YGJustify justifyContent;
|
|
||||||
@property (nonatomic, readwrite, assign) YGAlign alignContent;
|
|
||||||
@property (nonatomic, readwrite, assign) YGAlign alignItems;
|
|
||||||
@property (nonatomic, readwrite, assign) YGAlign alignSelf;
|
|
||||||
@property (nonatomic, readwrite, assign) YGPositionType position;
|
|
||||||
@property (nonatomic, readwrite, assign) YGWrap flexWrap;
|
|
||||||
@property (nonatomic, readwrite, assign) YGOverflow overflow;
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat flexBasis;
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat left;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat top;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat right;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat bottom;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat start;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat end;
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginLeft;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginTop;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginRight;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginBottom;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginStart;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginEnd;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginHorizontal;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat marginVertical;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat margin;
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingLeft;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingTop;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingRight;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingBottom;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingStart;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingEnd;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingHorizontal;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat paddingVertical;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat padding;
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderRightWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderBottomWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderStartWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat width;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat height;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat minWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat minHeight;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat maxWidth;
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat maxHeight;
|
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
|
||||||
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the resolved direction of this node. This won't be YGDirectionInherit
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readonly, assign) YGDirection resolvedDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Perform a layout calculation and update the frames of the views in the hierarchy with the results
|
|
||||||
*/
|
|
||||||
- (void)applyLayout NS_SWIFT_NAME(applyLayout());
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readonly, assign) CGSize intrinsicSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the number of children that are using Flexbox.
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readonly, assign) NSUInteger numberOfChildren;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return a BOOL indiciating whether or not we this node contains any subviews that are included in Yoga's layout.
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readonly, assign) BOOL isLeaf;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Mark that a view's layout needs to be recalculated. Only works for leaf views.
|
|
||||||
*/
|
|
||||||
- (void)markDirty;
|
|
||||||
|
|
||||||
@end
|
|
@@ -1,380 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "YGLayout+Private.h"
|
|
||||||
#import "UIView+Yoga.h"
|
|
||||||
#import <yoga/Yoga.h>
|
|
||||||
|
|
||||||
#define YG_STYLE_PROPERTY_IMPL(type, lowercased_name, capitalized_name) \
|
|
||||||
- (type)lowercased_name \
|
|
||||||
{ \
|
|
||||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
- (void)set##capitalized_name:(type)lowercased_name \
|
|
||||||
{ \
|
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_STYLE_EDGE_PROPERTY_IMPL(lowercased_name, capitalized_name, property, edge) \
|
|
||||||
- (CGFloat)lowercased_name { \
|
|
||||||
return YGNodeStyleGet##property(self.node, edge); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
- (void)set##capitalized_name:(CGFloat)lowercased_name { \
|
|
||||||
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_STYLE_VALUE_PROPERTY_IMPL(lowercased_name, capitalized_name) \
|
|
||||||
- (CGFloat)lowercased_name \
|
|
||||||
{ \
|
|
||||||
YGValue value = YGNodeStyleGet##capitalized_name(self.node); \
|
|
||||||
if (value.unit == YGUnitPixel) { \
|
|
||||||
return value.value; \
|
|
||||||
} else { \
|
|
||||||
return YGUndefined; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
- (void)set##capitalized_name:(CGFloat)lowercased_name \
|
|
||||||
{ \
|
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, edge, edge_suffix) \
|
|
||||||
- (CGFloat)lowercased_name##edge_suffix \
|
|
||||||
{ \
|
|
||||||
YGValue value = YGNodeStyleGet##capitalized_name(self.node, edge); \
|
|
||||||
if (value.unit == YGUnitPixel) { \
|
|
||||||
return value.value; \
|
|
||||||
} else { \
|
|
||||||
return YGUndefined; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
- (void)set##capitalized_name##edge_suffix:(CGFloat)lowercased_name \
|
|
||||||
{ \
|
|
||||||
YGNodeStyleSet##capitalized_name(self.node, edge, lowercased_name); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeLeft, Left) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeTop, Top) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeRight, Right) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeBottom, Bottom) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeStart, Start) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeEnd, End) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeHorizontal, Horizontal) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeVertical, Vertical) \
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeAll, )
|
|
||||||
|
|
||||||
@interface YGLayout ()
|
|
||||||
|
|
||||||
@property (nonatomic, weak, readonly) UIView *view;
|
|
||||||
@property (nonatomic, assign, readonly) YGNodeRef node;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation YGLayout
|
|
||||||
|
|
||||||
@synthesize isEnabled=_isEnabled;
|
|
||||||
@synthesize isIncludedInLayout=_isIncludedInLayout;
|
|
||||||
|
|
||||||
+ (void)initialize
|
|
||||||
{
|
|
||||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (instancetype)initWithView:(UIView*)view
|
|
||||||
{
|
|
||||||
if (self = [super init]) {
|
|
||||||
_view = view;
|
|
||||||
_node = YGNodeNew();
|
|
||||||
YGNodeSetContext(_node, (__bridge void *) view);
|
|
||||||
_isEnabled = NO;
|
|
||||||
_isIncludedInLayout = YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dealloc
|
|
||||||
{
|
|
||||||
YGNodeFree(self.node);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)markDirty
|
|
||||||
{
|
|
||||||
if (self.isLeaf) {
|
|
||||||
YGNodeMarkDirty(self.node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSUInteger)numberOfChildren
|
|
||||||
{
|
|
||||||
return YGNodeGetChildCount(self.node);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isLeaf
|
|
||||||
{
|
|
||||||
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
|
|
||||||
if (self.isEnabled) {
|
|
||||||
for (UIView *subview in self.view.subviews) {
|
|
||||||
YGLayout *const yoga = subview.yoga;
|
|
||||||
if (yoga.isEnabled && yoga.isIncludedInLayout) {
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Style
|
|
||||||
|
|
||||||
- (YGPositionType)position
|
|
||||||
{
|
|
||||||
return YGNodeStyleGetPositionType(self.node);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setPosition:(YGPositionType)position
|
|
||||||
{
|
|
||||||
YGNodeStyleSetPositionType(self.node, position);
|
|
||||||
}
|
|
||||||
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGDirection, direction, Direction)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGFlexDirection, flexDirection, FlexDirection)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGJustify, justifyContent, JustifyContent)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGAlign, alignContent, AlignContent)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGAlign, alignItems, AlignItems)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGAlign, alignSelf, AlignSelf)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGWrap, flexWrap, FlexWrap)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(YGOverflow, overflow, Overflow)
|
|
||||||
|
|
||||||
YG_STYLE_PROPERTY_IMPL(CGFloat, flexGrow, FlexGrow)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(CGFloat, flexShrink, FlexShrink)
|
|
||||||
YG_STYLE_VALUE_PROPERTY_IMPL(flexBasis, FlexBasis)
|
|
||||||
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeLeft, Left)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeTop, Top)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeRight, Right)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeBottom, Bottom)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeStart, Start)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeEnd, End)
|
|
||||||
YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(margin, Margin)
|
|
||||||
YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(padding, Padding)
|
|
||||||
|
|
||||||
YG_STYLE_EDGE_PROPERTY_IMPL(borderLeftWidth, BorderLeftWidth, Border, YGEdgeLeft)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_IMPL(borderTopWidth, BorderTopWidth, Border, YGEdgeTop)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_IMPL(borderRightWidth, BorderRightWidth, Border, YGEdgeRight)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_IMPL(borderBottomWidth, BorderBottomWidth, Border, YGEdgeBottom)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_IMPL(borderStartWidth, BorderStartWidth, Border, YGEdgeStart)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_IMPL(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd)
|
|
||||||
YG_STYLE_EDGE_PROPERTY_IMPL(borderWidth, BorderWidth, Border, YGEdgeAll)
|
|
||||||
|
|
||||||
YG_STYLE_VALUE_PROPERTY_IMPL(width, Width)
|
|
||||||
YG_STYLE_VALUE_PROPERTY_IMPL(height, Height)
|
|
||||||
YG_STYLE_VALUE_PROPERTY_IMPL(minWidth, MinWidth)
|
|
||||||
YG_STYLE_VALUE_PROPERTY_IMPL(minHeight, MinHeight)
|
|
||||||
YG_STYLE_VALUE_PROPERTY_IMPL(maxWidth, MaxWidth)
|
|
||||||
YG_STYLE_VALUE_PROPERTY_IMPL(maxHeight, MaxHeight)
|
|
||||||
YG_STYLE_PROPERTY_IMPL(CGFloat, aspectRatio, AspectRatio)
|
|
||||||
|
|
||||||
#pragma mark - Layout and Sizing
|
|
||||||
|
|
||||||
- (YGDirection)resolvedDirection
|
|
||||||
{
|
|
||||||
return YGNodeLayoutGetDirection(self.node);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)applyLayout
|
|
||||||
{
|
|
||||||
[self calculateLayoutWithSize:self.view.bounds.size];
|
|
||||||
YGApplyLayoutToViewHierarchy(self.view);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (CGSize)intrinsicSize
|
|
||||||
{
|
|
||||||
const CGSize constrainedSize = {
|
|
||||||
.width = YGUndefined,
|
|
||||||
.height = YGUndefined,
|
|
||||||
};
|
|
||||||
return [self calculateLayoutWithSize:constrainedSize];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Private
|
|
||||||
|
|
||||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
|
||||||
{
|
|
||||||
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
|
|
||||||
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
|
|
||||||
|
|
||||||
YGAttachNodesFromViewHierachy(self.view);
|
|
||||||
|
|
||||||
const YGNodeRef node = self.node;
|
|
||||||
YGNodeCalculateLayout(
|
|
||||||
node,
|
|
||||||
size.width,
|
|
||||||
size.height,
|
|
||||||
YGNodeStyleGetDirection(node));
|
|
||||||
|
|
||||||
return (CGSize) {
|
|
||||||
.width = YGNodeLayoutGetWidth(node),
|
|
||||||
.height = YGNodeLayoutGetHeight(node),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static YGSize YGMeasureView(
|
|
||||||
YGNodeRef node,
|
|
||||||
float width,
|
|
||||||
YGMeasureMode widthMode,
|
|
||||||
float height,
|
|
||||||
YGMeasureMode heightMode)
|
|
||||||
{
|
|
||||||
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
|
||||||
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
|
|
||||||
|
|
||||||
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
|
|
||||||
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
|
|
||||||
.width = constrainedWidth,
|
|
||||||
.height = constrainedHeight,
|
|
||||||
}];
|
|
||||||
|
|
||||||
return (YGSize) {
|
|
||||||
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
|
||||||
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static CGFloat YGSanitizeMeasurement(
|
|
||||||
CGFloat constrainedSize,
|
|
||||||
CGFloat measuredSize,
|
|
||||||
YGMeasureMode measureMode)
|
|
||||||
{
|
|
||||||
CGFloat result;
|
|
||||||
if (measureMode == YGMeasureModeExactly) {
|
|
||||||
result = constrainedSize;
|
|
||||||
} else if (measureMode == YGMeasureModeAtMost) {
|
|
||||||
result = MIN(constrainedSize, measuredSize);
|
|
||||||
} else {
|
|
||||||
result = measuredSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
|
|
||||||
{
|
|
||||||
if (YGNodeGetChildCount(node) != subviews.count) {
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<subviews.count; i++) {
|
|
||||||
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void YGAttachNodesFromViewHierachy(UIView *const view)
|
|
||||||
{
|
|
||||||
YGLayout *const yoga = view.yoga;
|
|
||||||
const YGNodeRef node = yoga.node;
|
|
||||||
|
|
||||||
// Only leaf nodes should have a measure function
|
|
||||||
if (yoga.isLeaf) {
|
|
||||||
YGRemoveAllChildren(node);
|
|
||||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
|
||||||
} else {
|
|
||||||
YGNodeSetMeasureFunc(node, NULL);
|
|
||||||
|
|
||||||
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
|
||||||
for (UIView *subview in view.subviews) {
|
|
||||||
if (subview.yoga.isIncludedInLayout) {
|
|
||||||
[subviewsToInclude addObject:subview];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
|
|
||||||
YGRemoveAllChildren(node);
|
|
||||||
for (int i=0; i<subviewsToInclude.count; i++) {
|
|
||||||
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (UIView *const subview in subviewsToInclude) {
|
|
||||||
YGAttachNodesFromViewHierachy(subview);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void YGRemoveAllChildren(const YGNodeRef node)
|
|
||||||
{
|
|
||||||
if (node == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (YGNodeGetChildCount(node) > 0) {
|
|
||||||
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static CGFloat YGRoundPixelValue(CGFloat value)
|
|
||||||
{
|
|
||||||
static CGFloat scale;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^(){
|
|
||||||
scale = [UIScreen mainScreen].scale;
|
|
||||||
});
|
|
||||||
|
|
||||||
return round(value * scale) / scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void YGApplyLayoutToViewHierarchy(UIView *view)
|
|
||||||
{
|
|
||||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
|
||||||
|
|
||||||
const YGLayout *yoga = view.yoga;
|
|
||||||
|
|
||||||
if (!yoga.isIncludedInLayout) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeRef node = yoga.node;
|
|
||||||
const CGPoint topLeft = {
|
|
||||||
YGNodeLayoutGetLeft(node),
|
|
||||||
YGNodeLayoutGetTop(node),
|
|
||||||
};
|
|
||||||
|
|
||||||
const CGPoint bottomRight = {
|
|
||||||
topLeft.x + YGNodeLayoutGetWidth(node),
|
|
||||||
topLeft.y + YGNodeLayoutGetHeight(node),
|
|
||||||
};
|
|
||||||
|
|
||||||
view.frame = (CGRect) {
|
|
||||||
.origin = {
|
|
||||||
.x = YGRoundPixelValue(topLeft.x),
|
|
||||||
.y = YGRoundPixelValue(topLeft.y),
|
|
||||||
},
|
|
||||||
.size = {
|
|
||||||
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
|
||||||
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!yoga.isLeaf) {
|
|
||||||
for (NSUInteger i=0; i<view.subviews.count; i++) {
|
|
||||||
YGApplyLayoutToViewHierarchy(view.subviews[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
6
YogaKit/YogaKitSample/Podfile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
use_frameworks!
|
||||||
|
|
||||||
|
target 'YogaKitSample' do
|
||||||
|
pod 'YogaKit', :path => '../../YogaKit.podspec'
|
||||||
|
pod 'IGListKit', '~> 2.1.0'
|
||||||
|
end
|
26
YogaKit/YogaKitSample/Podfile.lock
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
PODS:
|
||||||
|
- IGListKit (2.1.0):
|
||||||
|
- IGListKit/Default (= 2.1.0)
|
||||||
|
- IGListKit/Default (2.1.0):
|
||||||
|
- IGListKit/Diffing
|
||||||
|
- IGListKit/Diffing (2.1.0)
|
||||||
|
- Yoga (1.7.0)
|
||||||
|
- YogaKit (1.7.0):
|
||||||
|
- Yoga (~> 1.7)
|
||||||
|
|
||||||
|
DEPENDENCIES:
|
||||||
|
- IGListKit (~> 2.1.0)
|
||||||
|
- YogaKit (from `../../YogaKit.podspec`)
|
||||||
|
|
||||||
|
EXTERNAL SOURCES:
|
||||||
|
YogaKit:
|
||||||
|
:path: ../../YogaKit.podspec
|
||||||
|
|
||||||
|
SPEC CHECKSUMS:
|
||||||
|
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
|
||||||
|
Yoga: 2ed1d7accfef3610a67f58c0cf101a0662137f2c
|
||||||
|
YogaKit: 31576530e8fcae3175469719ec3212397403330b
|
||||||
|
|
||||||
|
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404
|
||||||
|
|
||||||
|
COCOAPODS: 1.1.1
|
@@ -1,3 +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.
|
||||||
|
*/
|
||||||
|
|
||||||
// !$*UTF8*$!
|
// !$*UTF8*$!
|
||||||
{
|
{
|
||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
@@ -7,24 +14,27 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
13687D481DF8748400E7C260 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D471DF8748400E7C260 /* main.m */; };
|
|
||||||
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4A1DF8748400E7C260 /* AppDelegate.m */; };
|
|
||||||
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4D1DF8748400E7C260 /* ViewController.m */; };
|
|
||||||
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; };
|
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; };
|
||||||
13687D781DF878C600E7C260 /* YGEnums.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5E1DF8778F00E7C260 /* YGEnums.h */; };
|
|
||||||
13687D791DF878C600E7C260 /* YGMacros.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5F1DF8778F00E7C260 /* YGMacros.h */; };
|
|
||||||
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; };
|
|
||||||
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+Yoga.h */; };
|
|
||||||
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */; };
|
|
||||||
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D601DF8778F00E7C260 /* YGNodeList.c */; };
|
|
||||||
13687D821DF87CF200E7C260 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D621DF8778F00E7C260 /* Yoga.c */; };
|
|
||||||
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; };
|
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; };
|
||||||
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; };
|
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; };
|
||||||
638A94431E1EF5D000A726AD /* YGLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 638A94411E1EF5D000A726AD /* YGLayout.m */; };
|
15A7CB5995C9DAB1C8803834 /* Pods_YogaKitSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C80A931E90C7F3088CB86822 /* Pods_YogaKitSample.framework */; };
|
||||||
638A94451E1EF8A900A726AD /* YGValue.h in yoga */ = {isa = PBXBuildFile; fileRef = 638A94441E1EF89C00A726AD /* YGValue.h */; };
|
40BD9F461E477A09002790A9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F451E477A09002790A9 /* AppDelegate.swift */; };
|
||||||
638A94481E1F06D100A726AD /* SwiftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638A94471E1F06D100A726AD /* SwiftViewController.swift */; };
|
40BD9F4B1E47850C002790A9 /* BasicViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F4A1E47850C002790A9 /* BasicViewController.swift */; };
|
||||||
|
40BD9F501E479079002790A9 /* SingleLabelCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F4F1E479079002790A9 /* SingleLabelCollectionCell.swift */; };
|
||||||
|
40BD9F521E479173002790A9 /* LayoutInclusionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F511E479173002790A9 /* LayoutInclusionViewController.swift */; };
|
||||||
|
638A94481E1F06D100A726AD /* ExamplesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638A94471E1F06D100A726AD /* ExamplesViewController.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
638A94541E215CC800A726AD /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 13687D3B1DF8748300E7C260 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 13687D421DF8748300E7C260;
|
||||||
|
remoteInfo = YogaKitSample;
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
13687D771DF878A000E7C260 /* yoga */ = {
|
13687D771DF878A000E7C260 /* yoga */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
@@ -32,10 +42,6 @@
|
|||||||
dstPath = include/yoga;
|
dstPath = include/yoga;
|
||||||
dstSubfolderSpec = 16;
|
dstSubfolderSpec = 16;
|
||||||
files = (
|
files = (
|
||||||
638A94451E1EF8A900A726AD /* YGValue.h in yoga */,
|
|
||||||
13687D781DF878C600E7C260 /* YGEnums.h in yoga */,
|
|
||||||
13687D791DF878C600E7C260 /* YGMacros.h in yoga */,
|
|
||||||
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */,
|
|
||||||
);
|
);
|
||||||
name = yoga;
|
name = yoga;
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -46,7 +52,6 @@
|
|||||||
dstPath = include/YogaKit;
|
dstPath = include/YogaKit;
|
||||||
dstSubfolderSpec = 16;
|
dstSubfolderSpec = 16;
|
||||||
files = (
|
files = (
|
||||||
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */,
|
|
||||||
);
|
);
|
||||||
name = YogaKit;
|
name = YogaKit;
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -55,29 +60,19 @@
|
|||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
13687D431DF8748400E7C260 /* YogaKitSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YogaKitSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
13687D431DF8748400E7C260 /* YogaKitSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YogaKitSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
13687D471DF8748400E7C260 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
|
||||||
13687D491DF8748400E7C260 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
|
||||||
13687D4A1DF8748400E7C260 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
|
||||||
13687D4C1DF8748400E7C260 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
|
||||||
13687D4D1DF8748400E7C260 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
|
||||||
13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
13687D5E1DF8778F00E7C260 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = "<group>"; };
|
|
||||||
13687D5F1DF8778F00E7C260 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
|
|
||||||
13687D601DF8778F00E7C260 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = "<group>"; };
|
|
||||||
13687D611DF8778F00E7C260 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
|
|
||||||
13687D621DF8778F00E7C260 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = "<group>"; };
|
|
||||||
13687D631DF8778F00E7C260 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
|
|
||||||
13687D691DF8778F00E7C260 /* UIView+Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+Yoga.h"; sourceTree = "<group>"; };
|
|
||||||
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+Yoga.m"; sourceTree = "<group>"; };
|
|
||||||
13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||||
13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
638A94401E1EF5D000A726AD /* YGLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGLayout.h; sourceTree = "<group>"; };
|
1D2FF4D5FCA6A8C54A4074A3 /* Pods-YogaKitSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YogaKitSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
638A94411E1EF5D000A726AD /* YGLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YGLayout.m; sourceTree = "<group>"; };
|
40BD9F451E477A09002790A9 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
638A94421E1EF5D000A726AD /* YGLayout+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "YGLayout+Private.h"; sourceTree = "<group>"; };
|
40BD9F4A1E47850C002790A9 /* BasicViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BasicViewController.swift; path = ViewControllers/BasicViewController.swift; sourceTree = "<group>"; };
|
||||||
638A94441E1EF89C00A726AD /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGValue.h; sourceTree = "<group>"; };
|
40BD9F4F1E479079002790A9 /* SingleLabelCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SingleLabelCollectionCell.swift; path = Views/SingleLabelCollectionCell.swift; sourceTree = "<group>"; };
|
||||||
638A94461E1F06D100A726AD /* YogaKitSample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "YogaKitSample-Bridging-Header.h"; sourceTree = "<group>"; };
|
40BD9F511E479173002790A9 /* LayoutInclusionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LayoutInclusionViewController.swift; path = ViewControllers/LayoutInclusionViewController.swift; sourceTree = "<group>"; };
|
||||||
638A94471E1F06D100A726AD /* SwiftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftViewController.swift; sourceTree = "<group>"; };
|
638A94471E1F06D100A726AD /* ExamplesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExamplesViewController.swift; sourceTree = "<group>"; };
|
||||||
|
638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YogaKitSampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
82F0896A88112E957EF37C7F /* Pods-YogaKitSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YogaKitSample.release.xcconfig"; path = "Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
C80A931E90C7F3088CB86822 /* Pods_YogaKitSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_YogaKitSample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -87,6 +82,14 @@
|
|||||||
files = (
|
files = (
|
||||||
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */,
|
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */,
|
||||||
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */,
|
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */,
|
||||||
|
15A7CB5995C9DAB1C8803834 /* Pods_YogaKitSample.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
638A944C1E215CC800A726AD /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -96,11 +99,10 @@
|
|||||||
13687D3A1DF8748300E7C260 = {
|
13687D3A1DF8748300E7C260 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
13687D5D1DF8778F00E7C260 /* yoga */,
|
|
||||||
13687D641DF8778F00E7C260 /* YogaKit */,
|
|
||||||
13687D451DF8748400E7C260 /* YogaKitSample */,
|
13687D451DF8748400E7C260 /* YogaKitSample */,
|
||||||
13687D441DF8748400E7C260 /* Products */,
|
13687D441DF8748400E7C260 /* Products */,
|
||||||
13687D831DF87D1E00E7C260 /* Frameworks */,
|
13687D831DF87D1E00E7C260 /* Frameworks */,
|
||||||
|
E1C759E3C8E84821213ECE8D /* Pods */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@@ -108,6 +110,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
13687D431DF8748400E7C260 /* YogaKitSample.app */,
|
13687D431DF8748400E7C260 /* YogaKitSample.app */,
|
||||||
|
638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -115,64 +118,52 @@
|
|||||||
13687D451DF8748400E7C260 /* YogaKitSample */ = {
|
13687D451DF8748400E7C260 /* YogaKitSample */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
13687D491DF8748400E7C260 /* AppDelegate.h */,
|
40BD9F4E1E47902F002790A9 /* Views */,
|
||||||
13687D4A1DF8748400E7C260 /* AppDelegate.m */,
|
40BD9F481E4784B3002790A9 /* ViewControllers */,
|
||||||
13687D4C1DF8748400E7C260 /* ViewController.h */,
|
638A94471E1F06D100A726AD /* ExamplesViewController.swift */,
|
||||||
13687D4D1DF8748400E7C260 /* ViewController.m */,
|
|
||||||
638A94471E1F06D100A726AD /* SwiftViewController.swift */,
|
|
||||||
638A94461E1F06D100A726AD /* YogaKitSample-Bridging-Header.h */,
|
|
||||||
13687D521DF8748400E7C260 /* Assets.xcassets */,
|
13687D521DF8748400E7C260 /* Assets.xcassets */,
|
||||||
13687D571DF8748400E7C260 /* Info.plist */,
|
13687D571DF8748400E7C260 /* Info.plist */,
|
||||||
13687D461DF8748400E7C260 /* Supporting Files */,
|
40BD9F451E477A09002790A9 /* AppDelegate.swift */,
|
||||||
);
|
);
|
||||||
path = YogaKitSample;
|
path = YogaKitSample;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
13687D461DF8748400E7C260 /* Supporting Files */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
13687D471DF8748400E7C260 /* main.m */,
|
|
||||||
);
|
|
||||||
name = "Supporting Files";
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
13687D5D1DF8778F00E7C260 /* yoga */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
638A94441E1EF89C00A726AD /* YGValue.h */,
|
|
||||||
13687D5E1DF8778F00E7C260 /* YGEnums.h */,
|
|
||||||
13687D5F1DF8778F00E7C260 /* YGMacros.h */,
|
|
||||||
13687D601DF8778F00E7C260 /* YGNodeList.c */,
|
|
||||||
13687D611DF8778F00E7C260 /* YGNodeList.h */,
|
|
||||||
13687D621DF8778F00E7C260 /* Yoga.c */,
|
|
||||||
13687D631DF8778F00E7C260 /* Yoga.h */,
|
|
||||||
);
|
|
||||||
name = yoga;
|
|
||||||
path = ../../yoga;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
13687D641DF8778F00E7C260 /* YogaKit */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
13687D691DF8778F00E7C260 /* UIView+Yoga.h */,
|
|
||||||
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */,
|
|
||||||
638A94401E1EF5D000A726AD /* YGLayout.h */,
|
|
||||||
638A94421E1EF5D000A726AD /* YGLayout+Private.h */,
|
|
||||||
638A94411E1EF5D000A726AD /* YGLayout.m */,
|
|
||||||
);
|
|
||||||
name = YogaKit;
|
|
||||||
path = ..;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
13687D831DF87D1E00E7C260 /* Frameworks */ = {
|
13687D831DF87D1E00E7C260 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
13687D861DF87D2400E7C260 /* Foundation.framework */,
|
13687D861DF87D2400E7C260 /* Foundation.framework */,
|
||||||
13687D841DF87D1E00E7C260 /* UIKit.framework */,
|
13687D841DF87D1E00E7C260 /* UIKit.framework */,
|
||||||
|
C80A931E90C7F3088CB86822 /* Pods_YogaKitSample.framework */,
|
||||||
);
|
);
|
||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
40BD9F481E4784B3002790A9 /* ViewControllers */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
40BD9F4A1E47850C002790A9 /* BasicViewController.swift */,
|
||||||
|
40BD9F511E479173002790A9 /* LayoutInclusionViewController.swift */,
|
||||||
|
);
|
||||||
|
name = ViewControllers;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
40BD9F4E1E47902F002790A9 /* Views */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
40BD9F4F1E479079002790A9 /* SingleLabelCollectionCell.swift */,
|
||||||
|
);
|
||||||
|
name = Views;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E1C759E3C8E84821213ECE8D /* Pods */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
1D2FF4D5FCA6A8C54A4074A3 /* Pods-YogaKitSample.debug.xcconfig */,
|
||||||
|
82F0896A88112E957EF37C7F /* Pods-YogaKitSample.release.xcconfig */,
|
||||||
|
);
|
||||||
|
name = Pods;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@@ -180,11 +171,14 @@
|
|||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */;
|
buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
|
513B543F92B2E4F4D1EE1CE7 /* [CP] Check Pods Manifest.lock */,
|
||||||
13687D771DF878A000E7C260 /* yoga */,
|
13687D771DF878A000E7C260 /* yoga */,
|
||||||
13687D7B1DF878CE00E7C260 /* YogaKit */,
|
13687D7B1DF878CE00E7C260 /* YogaKit */,
|
||||||
13687D3F1DF8748300E7C260 /* Sources */,
|
13687D3F1DF8748300E7C260 /* Sources */,
|
||||||
13687D401DF8748300E7C260 /* Frameworks */,
|
13687D401DF8748300E7C260 /* Frameworks */,
|
||||||
13687D411DF8748300E7C260 /* Resources */,
|
13687D411DF8748300E7C260 /* Resources */,
|
||||||
|
FA2FB9DD6471BDD3FBCE503B /* [CP] Embed Pods Frameworks */,
|
||||||
|
6E01EB987F1564F3D71EBE5A /* [CP] Copy Pods Resources */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
@@ -195,6 +189,24 @@
|
|||||||
productReference = 13687D431DF8748400E7C260 /* YogaKitSample.app */;
|
productReference = 13687D431DF8748400E7C260 /* YogaKitSample.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
};
|
};
|
||||||
|
638A944E1E215CC800A726AD /* YogaKitSampleTests */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */;
|
||||||
|
buildPhases = (
|
||||||
|
638A944B1E215CC800A726AD /* Sources */,
|
||||||
|
638A944C1E215CC800A726AD /* Frameworks */,
|
||||||
|
638A944D1E215CC800A726AD /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
638A94551E215CC800A726AD /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = YogaKitSampleTests;
|
||||||
|
productName = YogaKitSampleTests;
|
||||||
|
productReference = 638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */;
|
||||||
|
productType = "com.apple.product-type.bundle.unit-test";
|
||||||
|
};
|
||||||
/* End PBXNativeTarget section */
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
/* Begin PBXProject section */
|
/* Begin PBXProject section */
|
||||||
@@ -209,6 +221,11 @@
|
|||||||
LastSwiftMigration = 0820;
|
LastSwiftMigration = 0820;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
|
638A944E1E215CC800A726AD = {
|
||||||
|
CreatedOnToolsVersion = 8.2.1;
|
||||||
|
ProvisioningStyle = Automatic;
|
||||||
|
TestTargetID = 13687D421DF8748300E7C260;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
buildConfigurationList = 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */;
|
buildConfigurationList = 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */;
|
||||||
@@ -225,6 +242,7 @@
|
|||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
targets = (
|
targets = (
|
||||||
13687D421DF8748300E7C260 /* YogaKitSample */,
|
13687D421DF8748300E7C260 /* YogaKitSample */,
|
||||||
|
638A944E1E215CC800A726AD /* YogaKitSampleTests */,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
@@ -238,26 +256,93 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
638A944D1E215CC800A726AD /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
/* End PBXResourcesBuildPhase section */
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
|
513B543F92B2E4F4D1EE1CE7 /* [CP] Check Pods Manifest.lock */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "[CP] Check Pods Manifest.lock";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
6E01EB987F1564F3D71EBE5A /* [CP] Copy Pods Resources */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "[CP] Copy Pods Resources";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample-resources.sh\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
FA2FB9DD6471BDD3FBCE503B /* [CP] Embed Pods Frameworks */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "[CP] Embed Pods Frameworks";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample-frameworks.sh\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
13687D3F1DF8748300E7C260 /* Sources */ = {
|
13687D3F1DF8748300E7C260 /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
638A94481E1F06D100A726AD /* SwiftViewController.swift in Sources */,
|
40BD9F501E479079002790A9 /* SingleLabelCollectionCell.swift in Sources */,
|
||||||
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */,
|
40BD9F521E479173002790A9 /* LayoutInclusionViewController.swift in Sources */,
|
||||||
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */,
|
638A94481E1F06D100A726AD /* ExamplesViewController.swift in Sources */,
|
||||||
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */,
|
40BD9F4B1E47850C002790A9 /* BasicViewController.swift in Sources */,
|
||||||
13687D821DF87CF200E7C260 /* Yoga.c in Sources */,
|
40BD9F461E477A09002790A9 /* AppDelegate.swift in Sources */,
|
||||||
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */,
|
);
|
||||||
13687D481DF8748400E7C260 /* main.m in Sources */,
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
638A94431E1EF5D000A726AD /* YGLayout.m in Sources */,
|
};
|
||||||
|
638A944B1E215CC800A726AD /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
/* End PBXSourcesBuildPhase section */
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
638A94551E215CC800A726AD /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = 13687D421DF8748300E7C260 /* YogaKitSample */;
|
||||||
|
targetProxy = 638A94541E215CC800A726AD /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
13687D581DF8748400E7C260 /* Debug */ = {
|
13687D581DF8748400E7C260 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
@@ -351,6 +436,7 @@
|
|||||||
};
|
};
|
||||||
13687D5B1DF8748400E7C260 /* Debug */ = {
|
13687D5B1DF8748400E7C260 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 1D2FF4D5FCA6A8C54A4074A3 /* Pods-YogaKitSample.debug.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
@@ -358,7 +444,7 @@
|
|||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
|
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "YogaKitSample/YogaKitSample-Bridging-Header.h";
|
SWIFT_INSTALL_OBJC_HEADER = NO;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_VERSION = 3.0;
|
||||||
};
|
};
|
||||||
@@ -366,6 +452,7 @@
|
|||||||
};
|
};
|
||||||
13687D5C1DF8748400E7C260 /* Release */ = {
|
13687D5C1DF8748400E7C260 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 82F0896A88112E957EF37C7F /* Pods-YogaKitSample.release.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
@@ -373,11 +460,39 @@
|
|||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
|
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "YogaKitSample/YogaKitSample-Bridging-Header.h";
|
SWIFT_INSTALL_OBJC_HEADER = NO;
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_VERSION = 3.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
638A94571E215CC800A726AD /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
INFOPLIST_FILE = YogaKitSampleTests/Info.plist;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
638A94581E215CC800A726AD /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
INFOPLIST_FILE = YogaKitSampleTests/Info.plist;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
/* End XCBuildConfiguration section */
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
/* Begin XCConfigurationList section */
|
||||||
@@ -399,6 +514,15 @@
|
|||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
|
638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
638A94571E215CC800A726AD /* Debug */,
|
||||||
|
638A94581E215CC800A726AD /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
};
|
};
|
||||||
rootObject = 13687D3B1DF8748300E7C260 /* Project object */;
|
rootObject = 13687D3B1DF8748300E7C260 /* Project object */;
|
||||||
|
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0820"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "638A944E1E215CC800A726AD"
|
||||||
|
BuildableName = "YogaKitSampleTests.xctest"
|
||||||
|
BlueprintName = "YogaKitSampleTests"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
10
YogaKit/YogaKitSample/YogaKitSample.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:YogaKitSample.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:Pods/Pods.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
@@ -1,16 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
|
||||||
|
|
||||||
@property (strong, nonatomic) UIWindow *window;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
@@ -1,27 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "AppDelegate.h"
|
|
||||||
#import "ViewController.h"
|
|
||||||
|
|
||||||
@interface AppDelegate ()
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AppDelegate
|
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
||||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
|
||||||
self.window.rootViewController = [ViewController new];
|
|
||||||
self.window.backgroundColor = [UIColor whiteColor];
|
|
||||||
[self.window makeKeyAndVisible];
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
26
YogaKit/YogaKitSample/YogaKitSample/AppDelegate.swift
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@UIApplicationMain
|
||||||
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
var window: UIWindow?
|
||||||
|
|
||||||
|
func applicationDidFinishLaunching(_ application: UIApplication) {
|
||||||
|
self.window = UIWindow(frame: UIScreen.main.bounds)
|
||||||
|
if let window = self.window {
|
||||||
|
let navigationController = UINavigationController(rootViewController: ExamplesViewController())
|
||||||
|
navigationController.navigationBar.isTranslucent = false
|
||||||
|
|
||||||
|
window.rootViewController = navigationController
|
||||||
|
window.backgroundColor = .white
|
||||||
|
window.makeKeyAndVisible()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,43 +1,69 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"idiom" : "iphone",
|
|
||||||
"size" : "20x20",
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-20x20@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "iphone",
|
|
||||||
"size" : "20x20",
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-20x20@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "iphone",
|
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"scale" : "2x"
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-29x29@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "iphone",
|
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"scale" : "3x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"size" : "40x40",
|
"filename" : "Yoga-29x29@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"size" : "29x29",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"size" : "40x40",
|
"filename" : "Yoga-29x29@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"size" : "40x40",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"size" : "60x60",
|
"filename" : "Yoga-40x40@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"size" : "40x40",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-40x40@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "57x57",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-57x57@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "57x57",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-57x57@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
"size" : "60x60",
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-60x60@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Yoga-60x60@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 868 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 7.4 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import IGListKit
|
||||||
|
|
||||||
|
private final class ExampleModel {
|
||||||
|
let title: String
|
||||||
|
let controllerClass: UIViewController.Type
|
||||||
|
|
||||||
|
init(title: String, controllerClass: UIViewController.Type) {
|
||||||
|
self.title = title
|
||||||
|
self.controllerClass = controllerClass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ExampleModel: IGListDiffable {
|
||||||
|
fileprivate func diffIdentifier() -> NSObjectProtocol {
|
||||||
|
return title as NSString
|
||||||
|
}
|
||||||
|
|
||||||
|
fileprivate func isEqual(toDiffableObject object: IGListDiffable?) -> Bool {
|
||||||
|
guard let otherObj = object as? ExampleModel else { return false }
|
||||||
|
|
||||||
|
return (title == otherObj.title) &&
|
||||||
|
(controllerClass == otherObj.controllerClass)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class ExamplesViewController: UIViewController, IGListAdapterDataSource, IGListSingleSectionControllerDelegate {
|
||||||
|
private lazy var adapter: IGListAdapter = {
|
||||||
|
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
|
||||||
|
}()
|
||||||
|
private let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
||||||
|
|
||||||
|
|
||||||
|
// Update this to array to create more examples.
|
||||||
|
private let models: [ExampleModel] = [ExampleModel(title: "Basic Layout", controllerClass: BasicViewController.self),
|
||||||
|
ExampleModel(title: "Exclude Views in Layout", controllerClass: LayoutInclusionViewController.self)]
|
||||||
|
|
||||||
|
//MARK: UIViewController
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
title = "Examples"
|
||||||
|
view.addSubview(collectionView)
|
||||||
|
adapter.collectionView = collectionView
|
||||||
|
adapter.dataSource = self
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLayoutSubviews() {
|
||||||
|
super.viewDidLayoutSubviews()
|
||||||
|
collectionView.frame = view.bounds
|
||||||
|
}
|
||||||
|
|
||||||
|
//MARK: IGListAdapterDataSource
|
||||||
|
|
||||||
|
func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] {
|
||||||
|
return models as [IGListDiffable]
|
||||||
|
}
|
||||||
|
|
||||||
|
func listAdapter(_ listAdapter: IGListAdapter, sectionControllerFor object: Any) -> IGListSectionController {
|
||||||
|
let sizeBlock: IGListSingleSectionCellSizeBlock = { (model, context) in
|
||||||
|
return CGSize(width: (context?.containerSize.width)!, height: 75.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
let configureBlock: IGListSingleSectionCellConfigureBlock = { (model, cell) in
|
||||||
|
guard let m = model as? ExampleModel, let c = cell as? SingleLabelCollectionCell else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.label.text = m.title
|
||||||
|
}
|
||||||
|
|
||||||
|
let sectionController = IGListSingleSectionController(cellClass: SingleLabelCollectionCell.self,
|
||||||
|
configureBlock: configureBlock,
|
||||||
|
sizeBlock: sizeBlock)
|
||||||
|
sectionController.selectionDelegate = self
|
||||||
|
return sectionController
|
||||||
|
}
|
||||||
|
|
||||||
|
func emptyView(for listAdapter: IGListAdapter) -> UIView? { return nil }
|
||||||
|
|
||||||
|
//MARK: IGListSingleSectionControllerDelegate
|
||||||
|
|
||||||
|
func didSelect(_ sectionController: IGListSingleSectionController) {
|
||||||
|
let section = adapter.section(for: sectionController)
|
||||||
|
let model = models[section]
|
||||||
|
|
||||||
|
let controller = model.controllerClass.init()
|
||||||
|
controller.title = model.title
|
||||||
|
|
||||||
|
self.navigationController?.pushViewController(controller, animated: true)
|
||||||
|
}
|
||||||
|
}
|
@@ -1,40 +1,70 @@
|
|||||||
/**
|
/*
|
||||||
* 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
|
||||||
|
import IGListKit
|
||||||
|
import YogaKit
|
||||||
|
|
||||||
class SwiftViewController: UIViewController {
|
struct DemoItem {
|
||||||
override func viewDidLoad() {
|
let name: String
|
||||||
let root = self.view!
|
|
||||||
root.backgroundColor = .red
|
root.backgroundColor = .red
|
||||||
root.yoga.isEnabled = true
|
root.yoga.isEnabled = true
|
||||||
root.yoga.width = self.view.bounds.size.width
|
root.yoga.width = YGValue(self.view.bounds.size.width)
|
||||||
root.yoga.height = self.view.bounds.size.height
|
root.yoga.height = YGValue(self.view.bounds.size.height)
|
||||||
root.yoga.alignItems = .center
|
root.yoga.alignItems = .center
|
||||||
root.yoga.justifyContent = .center
|
}
|
||||||
|
|
||||||
let child1 = UIView()
|
final class SwiftViewController: UIViewController, IGListAdapterDataSource {
|
||||||
child1.backgroundColor = .blue
|
|
||||||
child1.yoga.isEnabled = true
|
|
||||||
child1.yoga.width = 100
|
|
||||||
child1.yoga.height = 10
|
|
||||||
|
|
||||||
let child2 = UIView()
|
lazy var adapter: IGListAdapter = {
|
||||||
child2.backgroundColor = .green
|
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
|
||||||
child2.frame = CGRect(x: 0, y: 0, width: 200, height: 100)
|
}()
|
||||||
|
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
||||||
|
|
||||||
let child3 = UIView()
|
//MARK: UIViewController
|
||||||
child3.backgroundColor = .yellow
|
|
||||||
child3.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
|
|
||||||
|
|
||||||
child2.addSubview(child3)
|
override func viewDidLoad() {
|
||||||
root.addSubview(child1)
|
super.viewDidLoad()
|
||||||
root.addSubview(child2)
|
title = "YogaKit Examples"
|
||||||
root.yoga.applyLayout()
|
view.addSubview(collectionView)
|
||||||
|
adapter.collectionView = collectionView
|
||||||
|
adapter.dataSource = self
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLayoutSubviews() {
|
||||||
|
super.viewDidLayoutSubviews()
|
||||||
|
collectionView.frame = view.bounds
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//MARK: IGListAdapterDataSource
|
||||||
|
|
||||||
|
func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] {
|
||||||
|
return ["Dustin" as IGListDiffable, "Ryan" as IGListDiffable]
|
||||||
|
}
|
||||||
|
|
||||||
|
func listAdapter(_ listAdapter: IGListAdapter, sectionControllerFor object: Any) -> IGListSectionController {
|
||||||
|
let sizeBlock: IGListSingleSectionCellSizeBlock = { (model, context) in
|
||||||
|
return CGSize(width: (context?.containerSize.width)!, height: 100.0)
|
||||||
|
}
|
||||||
|
let configureBlock: IGListSingleSectionCellConfigureBlock = { (model, cell) in
|
||||||
|
guard let m = model as? String else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.backgroundColor = (m == "Dustin") ? .blue : .red
|
||||||
|
}
|
||||||
|
|
||||||
|
return IGListSingleSectionController(cellClass: UICollectionViewCell.self,
|
||||||
|
configureBlock: configureBlock,
|
||||||
|
sizeBlock: sizeBlock)
|
||||||
|
}
|
||||||
|
|
||||||
|
func emptyView(for listAdapter: IGListAdapter) -> UIView? {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@interface ViewController : UIViewController
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
@@ -1,60 +1,51 @@
|
|||||||
/**
|
/*
|
||||||
* 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"
|
||||||
|
|
||||||
#import <YogaKit/UIView+Yoga.h>
|
#import <YogaKit/UIView+Yoga.h>
|
||||||
|
|
||||||
@interface ViewController ()
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@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 = self.view.bounds.size.width;
|
root.yoga.width = YGPointValue(self.view.bounds.size.width);
|
||||||
root.yoga.height = 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 = 100;
|
child1.yoga.width = YGPointValue(100);
|
||||||
child1.yoga.height = 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 applyLayout];
|
[root.yoga applyLayoutPreservingOrigin:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import YogaKit
|
||||||
|
|
||||||
|
final class BasicViewController: UIViewController {
|
||||||
|
override func viewDidLoad() {
|
||||||
|
let containerSize = self.view.bounds.size
|
||||||
|
|
||||||
|
let root = self.view!
|
||||||
|
root.backgroundColor = .white
|
||||||
|
root.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.width = YGValue(containerSize.width)
|
||||||
|
layout.height = YGValue(containerSize.height)
|
||||||
|
layout.alignItems = .center
|
||||||
|
layout.justifyContent = .center
|
||||||
|
}
|
||||||
|
|
||||||
|
let child1 = UIView()
|
||||||
|
child1.backgroundColor = .blue
|
||||||
|
child1.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.width = 100
|
||||||
|
layout.height = 10
|
||||||
|
layout.marginBottom = 25
|
||||||
|
}
|
||||||
|
root.addSubview(child1)
|
||||||
|
|
||||||
|
let child2 = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
|
||||||
|
child2.backgroundColor = .green
|
||||||
|
child2.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.alignSelf = .flexEnd
|
||||||
|
}
|
||||||
|
root.addSubview(child2)
|
||||||
|
|
||||||
|
let child3 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
||||||
|
child3.backgroundColor = .yellow
|
||||||
|
child3.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.alignSelf = .flexStart
|
||||||
|
}
|
||||||
|
root.addSubview(child3)
|
||||||
|
|
||||||
|
root.yoga.applyLayout(preservingOrigin: true)
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import YogaKit
|
||||||
|
|
||||||
|
final class LayoutInclusionViewController: UIViewController {
|
||||||
|
private let button: UIButton = UIButton(type: .system)
|
||||||
|
private let disappearingView: UIView = UIView(frame: .zero)
|
||||||
|
private let contentView: UIView = UIView(frame: .zero)
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
let root = self.view!
|
||||||
|
root.backgroundColor = .white
|
||||||
|
root.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.flexDirection = .column
|
||||||
|
layout.justifyContent = .spaceAround
|
||||||
|
}
|
||||||
|
|
||||||
|
contentView.backgroundColor = .clear
|
||||||
|
contentView.layer.borderColor = UIColor.lightGray.cgColor
|
||||||
|
contentView.layer.borderWidth = 1.0
|
||||||
|
contentView.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.height = 300
|
||||||
|
layout.width = YGValue(self.view.bounds.size.width)
|
||||||
|
layout.flexDirection = .row
|
||||||
|
layout.justifyContent = .center
|
||||||
|
layout.paddingHorizontal = 25
|
||||||
|
}
|
||||||
|
self.view.addSubview(contentView)
|
||||||
|
|
||||||
|
let redView = UIView(frame: .zero)
|
||||||
|
redView.backgroundColor = .red
|
||||||
|
redView.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.flexGrow = 1
|
||||||
|
layout.flexShrink = 1
|
||||||
|
}
|
||||||
|
contentView.addSubview(redView)
|
||||||
|
|
||||||
|
disappearingView.backgroundColor = .blue
|
||||||
|
disappearingView.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.flexGrow = 1
|
||||||
|
}
|
||||||
|
contentView.addSubview(disappearingView)
|
||||||
|
|
||||||
|
button.setTitle("Add Blue View", for: UIControlState.selected)
|
||||||
|
button.setTitle("Remove Blue View", for: UIControlState.normal)
|
||||||
|
button.addTarget(self, action: #selector(buttonWasTapped), for: UIControlEvents.touchUpInside)
|
||||||
|
button.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.height = 300
|
||||||
|
layout.width = 300
|
||||||
|
layout.alignSelf = .center
|
||||||
|
}
|
||||||
|
root.addSubview(button)
|
||||||
|
|
||||||
|
root.yoga.applyLayout(preservingOrigin: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK - UIButton Action
|
||||||
|
func buttonWasTapped() {
|
||||||
|
button.isSelected = !button.isSelected
|
||||||
|
|
||||||
|
button.isUserInteractionEnabled = false
|
||||||
|
disappearingView.yoga.isIncludedInLayout = !disappearingView.yoga.isIncludedInLayout
|
||||||
|
disappearingView.isHidden = !disappearingView.isHidden
|
||||||
|
|
||||||
|
contentView.yoga.applyLayout(preservingOrigin: true)
|
||||||
|
button.isUserInteractionEnabled = true
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import YogaKit
|
||||||
|
|
||||||
|
final class SingleLabelCollectionCell: UICollectionViewCell {
|
||||||
|
let label: UILabel = UILabel(frame: .zero)
|
||||||
|
|
||||||
|
override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
|
||||||
|
contentView.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.flexDirection = .column
|
||||||
|
layout.justifyContent = .flexEnd
|
||||||
|
}
|
||||||
|
|
||||||
|
label.textAlignment = .center
|
||||||
|
label.numberOfLines = 1
|
||||||
|
label.yoga.isIncludedInLayout = false
|
||||||
|
contentView.addSubview(label)
|
||||||
|
|
||||||
|
let border = UIView(frame: .zero)
|
||||||
|
border.backgroundColor = .lightGray
|
||||||
|
border.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.height = 0.5
|
||||||
|
layout.marginHorizontal = 25
|
||||||
|
}
|
||||||
|
contentView.addSubview(border)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
contentView.yoga.applyLayout(preservingOrigin: false)
|
||||||
|
label.frame = contentView.bounds
|
||||||
|
}
|
||||||
|
}
|
@@ -1,10 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "UIView+Yoga.h"
|
|
||||||
#import <yoga/Yoga.h>
|
|
@@ -1,16 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "AppDelegate.h"
|
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
|
||||||
@autoreleasepool {
|
|
||||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
|
||||||
}
|
|
||||||
}
|
|
21
android/README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# YogaLayout [](https://facebook.github.io/yoga/docs/api/android/) [](https://facebook.github.io/yoga/docs/api/android/) [](https://bintray.com/facebook/maven/com.facebook.yoga.android%3Ayoga-layout/_latestVersion)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
YogaLayout is available via jcenter:
|
||||||
|
|
||||||
|
implementation 'com.facebook.yoga.android:yoga-layout:1.16.0'
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
buck install -r android/sample
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
See the CONTRIBUTING file for how to help out.
|
38
android/build.gradle
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace 'com.facebook.yoga.android'
|
||||||
|
|
||||||
|
compileSdkVersion rootProject.compileSdkVersion
|
||||||
|
buildToolsVersion rootProject.buildToolsVersion
|
||||||
|
ndkVersion rootProject.ndkVersion
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion rootProject.minSdkVersion
|
||||||
|
targetSdkVersion rootProject.targetSdkVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
targetCompatibility rootProject.targetCompatibilityVersion
|
||||||
|
sourceCompatibility rootProject.sourceCompatibilityVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api project(':yoga')
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't build Javadoc at this time as we can't disable "BUCK" files
|
||||||
|
// from mistakenly getting parsed as Java.
|
||||||
|
tasks.withType(Javadoc).all {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.vanniktech.maven.publish'
|
12
android/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
GROUP=com.facebook.yoga.android
|
||||||
|
POM_NAME=YogaLayout
|
||||||
|
POM_DESCRIPTION=YogaLayout
|
||||||
|
POM_ARTIFACT_ID=yoga-layout
|
||||||
|
POM_PACKAGING=aar
|
48
android/sample/AndroidManifest.xml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0"
|
||||||
|
>
|
||||||
|
|
||||||
|
<variable name="applicationId" value="com.facebook.yoga"/>
|
||||||
|
<variable name="app_label" value="Yoga Sample App"/>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:allowBackup="false"
|
||||||
|
android:theme="@style/NoTitleBarWhiteBG"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".BenchmarkActivity"
|
||||||
|
android:exported="false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
BIN
android/sample/debug.keystore
Normal file
3
android/sample/debug.keystore.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
key.alias=androiddebugkey
|
||||||
|
key.store.password=android
|
||||||
|
key.alias.password=android
|
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
|
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
import com.facebook.yoga.android.YogaViewLayoutFactory;
|
||||||
|
|
||||||
|
public class BenchmarkActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
LayoutInflater.from(this).setFactory(YogaViewLayoutFactory.getInstance());
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.benchmark_select_layout);
|
||||||
|
|
||||||
|
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||||
|
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
|
||||||
|
|
||||||
|
final ActionBar actionBar = getSupportActionBar();
|
||||||
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||||
|
|
||||||
|
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
|
||||||
|
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||||
|
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||||
|
viewPager.setCurrentItem(tab.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
actionBar.addTab(
|
||||||
|
actionBar.newTab()
|
||||||
|
.setText("Inflate")
|
||||||
|
.setTabListener(tabListener));
|
||||||
|
actionBar.addTab(
|
||||||
|
actionBar.newTab()
|
||||||
|
.setText("Measure")
|
||||||
|
.setTabListener(tabListener));
|
||||||
|
actionBar.addTab(
|
||||||
|
actionBar.newTab()
|
||||||
|
.setText("Layout")
|
||||||
|
.setTabListener(tabListener));
|
||||||
|
|
||||||
|
viewPager.setOnPageChangeListener(
|
||||||
|
new ViewPager.SimpleOnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
// When swiping between pages, select the
|
||||||
|
// corresponding tab.
|
||||||
|
actionBar.setSelectedNavigationItem(position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
viewPager.setOffscreenPageLimit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.action_bar_benchmark, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// There is only one option
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
this.finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PagerAdapter extends FragmentPagerAdapter {
|
||||||
|
public PagerAdapter(FragmentManager fm) {
|
||||||
|
super(fm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int i) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
return new BenchmarkInflate();
|
||||||
|
case 1:
|
||||||
|
return new BenchmarkMeasure();
|
||||||
|
default:
|
||||||
|
return new BenchmarkLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,198 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.Math;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.os.Environment;
|
||||||
|
|
||||||
|
import static java.util.Collections.sort;
|
||||||
|
|
||||||
|
public class BenchmarkAggregator {
|
||||||
|
|
||||||
|
private final int GRAPH_WIDTH = 30;
|
||||||
|
private final int GRAPH_HEIGHT = 6;
|
||||||
|
|
||||||
|
private List<Long> times;
|
||||||
|
private boolean tracing;
|
||||||
|
private long lastTraceStart;
|
||||||
|
|
||||||
|
private boolean statsFresh;
|
||||||
|
private long mean;
|
||||||
|
private long variance;
|
||||||
|
private long stddev;
|
||||||
|
private long min;
|
||||||
|
private long max;
|
||||||
|
private long p10;
|
||||||
|
private long p50;
|
||||||
|
private long p90;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public BenchmarkAggregator(String name) {
|
||||||
|
times = new ArrayList<>();
|
||||||
|
tracing = false;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startTrace() {
|
||||||
|
if (tracing) {
|
||||||
|
throw new RuntimeException("Cannot start trace while running previous one");
|
||||||
|
}
|
||||||
|
tracing = true;
|
||||||
|
lastTraceStart = System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endTrace() {
|
||||||
|
if (!tracing) {
|
||||||
|
throw new RuntimeException("Cannot stop trace if none are running!");
|
||||||
|
}
|
||||||
|
times.add(System.nanoTime() - lastTraceStart);
|
||||||
|
tracing = false;
|
||||||
|
statsFresh = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void computeStats() {
|
||||||
|
if (statsFresh) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sort(times);
|
||||||
|
|
||||||
|
min = Long.MAX_VALUE;
|
||||||
|
max = -1;
|
||||||
|
mean = 0;
|
||||||
|
for (long f: times) {
|
||||||
|
mean += f;
|
||||||
|
if (f < min) {
|
||||||
|
min = f;
|
||||||
|
}
|
||||||
|
if (f > max) {
|
||||||
|
max = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mean /= times.size();
|
||||||
|
|
||||||
|
variance = 0;
|
||||||
|
for (long f: times) {
|
||||||
|
variance += (f-mean)*(f-mean);
|
||||||
|
}
|
||||||
|
variance /= times.size();
|
||||||
|
stddev = (long) Math.sqrt((double) variance);
|
||||||
|
|
||||||
|
p10 = times.get(times.size()*10/100);
|
||||||
|
p50 = times.get(times.size()*50/100);
|
||||||
|
p90 = times.get(times.size()*90/100);
|
||||||
|
|
||||||
|
statsFresh = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
computeStats();
|
||||||
|
return String.format(
|
||||||
|
"%s:\n" +
|
||||||
|
"| %d samples\n" +
|
||||||
|
"| Mean %.3f\u00B1%.3fms\n" + // plusminus
|
||||||
|
"| Min %.3fms ; Max %.3fms\n" +
|
||||||
|
"| p10 %.3fms ; p50 %.3fms ; p90 %.3fms\n" +
|
||||||
|
"%s",
|
||||||
|
name,
|
||||||
|
times.size(),
|
||||||
|
mean/10e6,
|
||||||
|
stddev/10e6,
|
||||||
|
min/10e6,
|
||||||
|
max/10e6,
|
||||||
|
p10/10e6,
|
||||||
|
p50/10e6,
|
||||||
|
p90/10e6,
|
||||||
|
makeGraph());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String makeGraph() {
|
||||||
|
char canvas[][] = new char[GRAPH_HEIGHT][GRAPH_WIDTH];
|
||||||
|
for (int i = 0; i < GRAPH_HEIGHT; i++)
|
||||||
|
for (int j = 0; j < GRAPH_WIDTH; j++)
|
||||||
|
canvas[i][j] = ' ';
|
||||||
|
|
||||||
|
long bucketSize = (p90 - p10) / GRAPH_WIDTH+1;
|
||||||
|
int bucketCount[] = new int[GRAPH_WIDTH];
|
||||||
|
for (long time : times) {
|
||||||
|
if (time<p90 && time>p10) {
|
||||||
|
bucketCount[(int) ((time - p10) / bucketSize)]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxBucket = 0;
|
||||||
|
for (int i = 0; i < GRAPH_WIDTH; i++)
|
||||||
|
if (bucketCount[i] > maxBucket) {
|
||||||
|
maxBucket = bucketCount[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < GRAPH_HEIGHT; i++)
|
||||||
|
for (int j = 0; j < GRAPH_WIDTH; j++)
|
||||||
|
if (i < bucketCount[j] * GRAPH_HEIGHT / maxBucket) {
|
||||||
|
canvas[i][j] = 'Z';
|
||||||
|
}
|
||||||
|
|
||||||
|
String graph = new String();
|
||||||
|
for (int i = 0; i < GRAPH_HEIGHT; i++)
|
||||||
|
{
|
||||||
|
int percentage = 100 * (GRAPH_HEIGHT - i - 1) * maxBucket / (times.size() * GRAPH_HEIGHT);
|
||||||
|
graph += String.format("| %2d%% ", percentage);
|
||||||
|
for (int j = 0; j < GRAPH_WIDTH; j++)
|
||||||
|
graph += canvas[GRAPH_HEIGHT-1-i][j];
|
||||||
|
graph += '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
graph += "| p10";
|
||||||
|
for (int i = 0; i < GRAPH_WIDTH-6; i++)
|
||||||
|
graph += " ";
|
||||||
|
graph += "p90\n";
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the collected times to a file on the device. This allows us to grab the raw data
|
||||||
|
* and perform more in-depth analysis.
|
||||||
|
*/
|
||||||
|
public void dump(Context context) {
|
||||||
|
String state = Environment.getExternalStorageState();
|
||||||
|
if (!Environment.MEDIA_MOUNTED.equals(state)) {
|
||||||
|
Log.e("YogaLayoutBenchmark","No external file storage");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
|
String filename = format.format(new Date()) + "_" + name.replace(' ','_');
|
||||||
|
File file = new File(context.getExternalFilesDir(
|
||||||
|
Environment.DIRECTORY_DOCUMENTS), filename);
|
||||||
|
|
||||||
|
try {
|
||||||
|
PrintWriter printWriter = new PrintWriter(file);
|
||||||
|
for (long l : times) {
|
||||||
|
printWriter.println(l);
|
||||||
|
}
|
||||||
|
printWriter.close();
|
||||||
|
|
||||||
|
Log.i("YogaLayoutBenchmark","Benchmark data saved in "+file.getPath());
|
||||||
|
} catch (java.io.IOException e) {
|
||||||
|
Log.e("YogaLayoutBenchmark", "Could not save benchmark data", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
import com.facebook.yoga.android.YogaLayout;
|
||||||
|
|
||||||
|
public class BenchmarkFragment extends Fragment implements AdapterView.OnItemSelectedListener {
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
|
protected com.facebook.yoga.android.YogaLayout rootLayout;
|
||||||
|
protected int yogaLayout;
|
||||||
|
protected int linearLayout;
|
||||||
|
|
||||||
|
static final Random random = new Random();
|
||||||
|
|
||||||
|
static void randomizeText(View root) {
|
||||||
|
if (root instanceof TextView) {
|
||||||
|
((TextView) root).setText("" + random.nextInt(1000));
|
||||||
|
((TextView) root).setTextSize(10 + random.nextInt(20));
|
||||||
|
ViewParent parent = root.getParent();
|
||||||
|
if (parent instanceof YogaLayout) {
|
||||||
|
((YogaLayout) parent).invalidate(root);
|
||||||
|
}
|
||||||
|
} else if (root instanceof ViewGroup) {
|
||||||
|
for (int i = 0; i < ((ViewGroup) root).getChildCount(); i++) {
|
||||||
|
randomizeText(((ViewGroup) root).getChildAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BenchmarkFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
mInflater = inflater;
|
||||||
|
|
||||||
|
rootLayout = (YogaLayout) inflater.inflate(
|
||||||
|
R.layout.benchmark_fragment,
|
||||||
|
container,
|
||||||
|
false);
|
||||||
|
|
||||||
|
Spinner benchmarkSelect = (Spinner) rootLayout.findViewById(R.id.benchmarkSelect);
|
||||||
|
String[] items = new String[]{"Basic", "Typical", "Nested"};
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items);
|
||||||
|
benchmarkSelect.setAdapter(adapter);
|
||||||
|
benchmarkSelect.setOnItemSelectedListener(this);
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||||
|
switch (pos) {
|
||||||
|
case 0:
|
||||||
|
yogaLayout = R.layout.benchmark_layout_1;
|
||||||
|
linearLayout = R.layout.benchmark_layout_1_linear;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
yogaLayout = R.layout.benchmark_layout_2;
|
||||||
|
linearLayout = R.layout.benchmark_layout_2_linear;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
yogaLayout = R.layout.benchmark_layout_3;
|
||||||
|
linearLayout = R.layout.benchmark_layout_3_linear;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
yogaLayout = R.layout.benchmark_layout_1;
|
||||||
|
linearLayout = R.layout.benchmark_layout_1_linear;
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePreview() {
|
||||||
|
LinearLayout previewLayout = (LinearLayout) rootLayout.findViewById(R.id.preview);
|
||||||
|
View v = mInflater.inflate(yogaLayout, rootLayout, false);
|
||||||
|
v.setLayoutParams(new LinearLayout.LayoutParams(
|
||||||
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
LinearLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
previewLayout.removeAllViews();
|
||||||
|
previewLayout.addView(v);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
|
||||||
|
public class BenchmarkInflate extends BenchmarkFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
Button b = (Button) rootLayout.findViewById(R.id.btn);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startBenchmark() {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
|
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
|
||||||
|
|
||||||
|
final int ITERATIONS = 500;
|
||||||
|
|
||||||
|
inflater.inflate(yogaLayout, null);
|
||||||
|
inflater.inflate(linearLayout, null);
|
||||||
|
|
||||||
|
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Inflate");
|
||||||
|
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Inflate");
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
yogaInflationAggregator.startTrace();
|
||||||
|
inflater.inflate(yogaLayout, null);
|
||||||
|
yogaInflationAggregator.endTrace();
|
||||||
|
linearInflationAggregator.startTrace();
|
||||||
|
inflater.inflate(linearLayout, null);
|
||||||
|
linearInflationAggregator.endTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setText(
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
Log.i(
|
||||||
|
"YogaLayoutBenchmark",
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
rootLayout.invalidate();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class BenchmarkLayout extends BenchmarkFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
Button b = (Button) rootLayout.findViewById(R.id.btn);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startBenchmark() {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
|
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
final int ITERATIONS = 500;
|
||||||
|
|
||||||
|
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Layout");
|
||||||
|
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Layout");
|
||||||
|
View yogaView = inflater.inflate(yogaLayout, null);
|
||||||
|
View linearView = inflater.inflate(linearLayout, null);
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
randomizeText(yogaView);
|
||||||
|
randomizeText(linearView);
|
||||||
|
yogaView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
linearView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
yogaInflationAggregator.startTrace();
|
||||||
|
yogaView.layout(0, 0, yogaView.getMeasuredWidth(), yogaView.getMeasuredHeight());
|
||||||
|
yogaInflationAggregator.endTrace();
|
||||||
|
linearInflationAggregator.startTrace();
|
||||||
|
linearView.layout(0, 0, linearView.getMeasuredWidth(), linearView.getMeasuredHeight());
|
||||||
|
linearInflationAggregator.endTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setText(
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
Log.i(
|
||||||
|
"YogaLayoutBenchmark",
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class BenchmarkMeasure extends BenchmarkFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
Button b = (Button) rootLayout.findViewById(R.id.btn);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startBenchmark() {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
|
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
final int ITERATIONS = 500;
|
||||||
|
|
||||||
|
BenchmarkAggregator yogaMeasureAggregator = new BenchmarkAggregator("Yoga Measure");
|
||||||
|
BenchmarkAggregator linearMeasureAggregator = new BenchmarkAggregator("Linear Measure");
|
||||||
|
View yogaView = inflater.inflate(yogaLayout, null);
|
||||||
|
View linearView = inflater.inflate(linearLayout, null);
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
randomizeText(yogaView);
|
||||||
|
randomizeText(linearView);
|
||||||
|
yogaMeasureAggregator.startTrace();
|
||||||
|
yogaView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
yogaMeasureAggregator.endTrace();
|
||||||
|
linearMeasureAggregator.startTrace();
|
||||||
|
linearView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
linearMeasureAggregator.endTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setText(
|
||||||
|
yogaMeasureAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearMeasureAggregator.toString());
|
||||||
|
Log.i(
|
||||||
|
"YogaLayoutBenchmark",
|
||||||
|
yogaMeasureAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearMeasureAggregator.toString());
|
||||||
|
|
||||||
|
yogaMeasureAggregator.dump(getActivity());
|
||||||
|
linearMeasureAggregator.dump(getActivity());
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.Menu;
|
||||||
|
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
import com.facebook.soloader.SoLoader;
|
||||||
|
import com.facebook.yoga.android.YogaViewLayoutFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An activity to show off Yoga in Android. This activity shows a simple layout (defined in
|
||||||
|
* {@code main_layout.xml}) that shows off the awesome functionality of the Yoga layout engine
|
||||||
|
* as well as some optimisations on layout systems that it facilitates.
|
||||||
|
*/
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
LayoutInflater.from(this).setFactory(YogaViewLayoutFactory.getInstance());
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
SoLoader.init(this, false);
|
||||||
|
|
||||||
|
setContentView(R.layout.main_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.action_bar_home, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// There is only one option
|
||||||
|
Intent intent = new Intent(this, BenchmarkActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
this.finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
17
android/sample/res/drawable/action_bar_background.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle"
|
||||||
|
>
|
||||||
|
<solid
|
||||||
|
android:color="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
</shape>
|
BIN
android/sample/res/drawable/ic_launcher.png
Normal file
After Width: | Height: | Size: 28 KiB |
34
android/sample/res/drawable/sample_children_background.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle"
|
||||||
|
>
|
||||||
|
|
||||||
|
<corners
|
||||||
|
android:radius="4dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/children_stroke"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:top="6dp"
|
||||||
|
android:bottom="6dp"
|
||||||
|
android:left="8dp"
|
||||||
|
android:right="8dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<solid
|
||||||
|
android:color="@color/children_background"
|
||||||
|
/>
|
||||||
|
</shape>
|