20 Commits

Author SHA1 Message Date
Michael Schneider
6f2c7caac3 [Layout] Improve ASDimensionMake via NSString (#2351)
* Improve ASDimensionMake via NSString

- ASXCTAssertEqualDimensions
- Add support for "auto"
- Assert if given an empty or invalid string

* Address comments

* Add ASCGFloatFromString and ASCGFloatFromNumber

* Rename CGRect+ASConvenience to CoreGraphics+ASConvenience
2016-10-06 16:29:33 -07:00
Michael Schneider
8897614f0e [Layout] Layout API based on content area (#2110)
* Initial commit for adding a size constraint to ASLayoutable's

* Some more commits

* Fix sample projects in extra/

* Remove preferredFrameSize test of ASEditableTextNode

* Remove preferredFrameSize from examples_extra

* Add deprecation warning to -[ASDisplayNode preferredFrameSize]

* Add deprecation warning to -[ASDisplayNode measureWithSizeRange:]

* Commit

* Commit

* Remove ASRelativeSizeRange

* Make ASRelativeSize private

* Adjust examples

* Improve setting of -[ASLayoutable size] with points or fractions

* Add ASWrapperLayoutSpec

* Improve creation of ASRelativeDimension

* Add `preferredFrameSize` back and add deprecated logging

* Add `layoutSpecBlock` setter and getter and add locking for it

* Add better documentation and fix macros to create ASRelativeDimension

* Create new ASSizeRangeMake with just a CGSize as parameter

* Update Kitten and Social App Layout example

* Add layoutThatFits: and deprecate measure:

* Rename ASRelativeDimension to ASDimension

* Fix examples for ASDimension renaming

* Remove fancy height and width setter

* Fix ASDimension helper

* Rename -[ASLayout layoutableObject] to -[ASLayout layoutable]

* Update layout related methods and more clearer documentation around how to use it

* Deprecate old ASLayout class constructors

* Don't unnecessary recalculate layout if constrained or parent size did not change

* Use shared pointer for ASDisplayNodeLayout

* Fix rebase conflicts

* Add documentation and move implementation in mm file of ASDisplayNodeLayout

* Fix test errors

* Rename ASSize to ASLayoutableSize

* Address comments

* Rename setSizeFromCGSize to setSizeWithCGSize

* Improve inline functions in ASDimension

* Fix rebase conflicts
2016-09-07 08:44:48 -07:00
Adlai Holler
578ac4c48d [Unit Tests] Add Text Layout Performance Tests (#2161)
* Add single-threaded text node performance testing

* Relax test a bit
2016-08-28 16:47:03 -07:00
Michael Schneider
705cc763fd Fix failing ASTextNode tests 2016-07-14 19:30:44 -07:00
Scott Goodson
bf9c142765 Revert "[ASTextNode] Fix text node truncation (#1863)"
This reverts commit 6238e5edbde55fb82982ce4a19a0cbca7fe7eb9d.

We will re-apply this change, but there are some early signs of performance impacts that need to be investigated.
2016-07-09 23:54:43 -07:00
Michael Schneider
6238e5edbd [ASTextNode] Fix text node truncation (#1863)
* Before truncate a text storage in ASTextKitContext reset the text storage to original value

* Fix ASTextNode tests

We should pass in the constrained size in both cases and the sizes should be the same. We adjust the calculated size in ASTextNode to be a bit narrower in the second case if we truncate again with the calculated size as constrained size it will truncate more and the resulting size will shrink.
2016-07-09 15:40:31 -07:00
Hannah Troisi
c857e809f4 Clean up header comments (for consistent Facebook licensing info) (#1741)
[Licensing] Clean up header comments (for consistent Facebook licensing info)
2016-06-11 23:31:39 -07:00
Michael Schneider
19bb6519ed Fix crash truncating a string of a node with a zero size
The crash happens in the placeholderImage of ASTextNode. The node is not visible in the time it try to get the `placeholderImage` and so the `visibleRange` has count 0 and a crash happens while accessing the first object of an empty array.
2016-06-03 09:53:59 -07:00
Michael Schneider
29ab87a1e4 Fix API ASTextNode API inconsistencies
- Deprecate attributedString in ASTextNode in favor of attributedText to be aligned with UILabel
- Deprecate truncationAttributedString in ASTextNode in favor of truncationAttributedText to be aligned with attributedText
2016-05-04 21:03:31 -07:00
Maxim Bunkov
8a8843a32a Added additionalTruncationMessage Unit test 2016-01-28 10:27:58 +05:00
Samuel Hsiung
f9d476e170 Fix ASTextNode truncated size calculation ignoring attributes in the last line 2015-12-15 10:09:03 -08:00
Levi McCallum
9d327cd14f Remove fixme from test 2015-11-30 06:54:51 -08:00
Levi McCallum
52b6c47d23 Allow resizing TextKit tests to pass by taking into account imprecision 2015-11-30 06:46:53 -08:00
Levi McCallum
197a31f636 Fix mistakenly renamed method in unit test 2015-11-30 06:44:53 -08:00
Levi McCallum
a0c05ebffc Rename CK classes to AS classes 2015-11-30 06:44:53 -08:00
Tobias Klonk
2a29f81b3a ASTextNode expose exclusion paths
expose NSTextContainer's exclusionPaths property on ASTextNode to be able to exclude view areas from typesetting.

This implements #394
2015-04-20 10:21:01 +02:00
Ben Cunningham
32d005dc0b Add point parameter to ASTextNode delegate methods
Outfit ASTextNodeDelegate shouldHighlight and shouldLongPress methods
with a point parameter that describes the location of the relevant
touch.
2014-10-27 16:53:44 -07:00
Nadine Salter
17fcca19ce s/richTextNode/textNode/g.
ASTextNode's delegate methods are all prefixed with "richTextNode".
Rename these to "textNode" for consistency.
2014-10-01 15:54:03 -07:00
Nadine Salter
7dd94a6102 Merge in downstream changes.
Introduce `ASTableView`, a UITableView subclass that uses `ASCellNode`
instead of UITableViewCell.  Add working range support via
`ASRangeController`, which observes the visible range, maintains a
working range, and handles most ASDK machinery.  ASRangeController is
loosely-enough coupled that it should be easily adapted to
UICollectionView if that's desired in the future.

Notable considerations in the ASRangeController architecture:

* There's no sense rewriting UITableView -- the real win comes from
  using nodes instead of UITableViewCells (easily parallelisable
  computation, large number of cells vs. few table views, etc.).  So,
  use a UITableView with empty cells, using UITableViewCell's
  contentView as a host for arbitrary node hierarchies.

* Instead of lazy-loading cells the instant they're needed by
  UITableView, load them in advance.  Preload a substantial number of
  nodes in the direction of scroll, as well as a small buffer in the
  other direction.

* Maintain compatibility with UITableView's API, with one primary change
  -- consumer code yields configured ASCellNodes, not UITableViewCells.

* Don't use -tableView:heightForRowAtIndexPath:.  Nodes already compute
  their preferred sizes and cache results for use at layout-time, so
  ASTableView uses their calculatedSizes directly.

* Corollary:  ASTableView is only aware of nodes that have been sized.
  This means that, if a cell appears onscreen, it has layout data and
  can display a "realistic placeholder", e.g. by making its subnodes'
  background colour grey.

Other improvements:

* Remove dead references and update headers (fixes #7, #20).

* Rename `-[ASDisplayNode sizeToFit:]` to `-measure:` and fix
  `constrainedSizeForCalulatedSize` typo (fixes #15).

* Rename `-willAppear` and `-didDisappear` to `-willEnterHierarchy` and
  `-didExitHierarchy`.  Remove `-willDisappear` -- it was redundant, and
  there was no counterpart `-didAppear`.

* Rename `viewLoaded` to `nodeLoaded`.
2014-09-22 14:33:39 -07:00
Nadine Salter
15565873c9 Initial commit. 2014-06-26 22:32:55 -07:00