Skip to content

0.0.6

Latest

Choose a tag to compare

@honghaoz honghaoz released this 18 Nov 22:21
· 6 commits to master since this release

Breaking Changes

  • With the default animation behavior, bounds changes no longer animate the updates of reused renderables, except with the view's own resize animation when the resize animates, such as a rotation or a layoutIfNeeded() in a UIKit animation block, so the content keeps up with the view. Insert and remove transitions also run on resizes and the first layout. (#24, #323)
  • Replaced ComposeView.RenderType.scroll with .boundsChange(previousBounds:bounds:), and merged RenderableUpdateType.scroll into .boundsChange. A scroll is a bounds change that keeps the size. (#24)
  • Removed RenderableUpdateType.requiresFullUpdate. Handle each update type as the renderable needs. (#14)
  • Drop and inner shadow paths follow the renderable's size instead of the viewport's, and DropShadowLayer.update(...) and InnerShadowLayer.update(...) take paths or path, like the nodes. Request a refresh when a path's other inputs change. (#24, #49)
  • Resizing a ComposeView lays out its content without evaluating the content builder again. Call refresh() or setNeedsRefresh() to apply changed configuration. (#14)
  • SwiftUIViewNode evaluates its dynamic content when it's first needed, and keeps it until the next refresh. (#14)
  • Removed LayoutCacheNode. (#14)
  • Delayed animations are scheduled with Core Animation's beginTime instead of a timer. (#5, #10)
  • A zero-duration transition calls its completion, as does a transition whose animation ends early. (#10)
  • RenderableTransition.opacity's to is optional. Without it, the fade ends at the opacity that the content sets. (#74)
  • Removed ScrollViewType, and ScrollView has UIKit's scroll view API on macOS too: contentOffset replaces contentOffset() and setContentOffset(_:), contentSize replaces contentSize() and setContentSize(_:), adjustedContentInset replaces contentInsets(), contentInset replaces setContentInsets(_:), contentOffset with visibleSize replace bounds(), and isScrollEnabled replaces BaseScrollView.isScrollable, also in the renderDidUpdateScrollableBehavior debug event. On macOS, setting contentOffset doesn't clamp the offset into the scrollable range. Replace setBounds(_:) with setting frame.size, then contentOffset. contentView() and documentView() are no longer public: use documentView on macOS, and the scroll view itself elsewhere. (#105, #106, #114)
  • On macOS, ComposeView lays out its content beside legacy scroll bars instead of under them, onWillLayout can run more than once in a render pass, and tile() is final. (#113)
  • On macOS, ComposeView no longer supports automatic content insets, magnification, borders, rulers, the find bar or auto-hiding scroll bars. Changing them asserts and keeps the default, and they're final. (#109, #113, #118)
  • ComposeView lays out, centers and scrolls its content within its content insets, and sizeThatFits(_:) includes them. (#116)
  • A VStack or HStack laid out again at the same size with the same ComposeNodeLayoutContext returns its earlier layout, so lay out changed content with a new context, made on the main thread. (#128)
  • ComposeView keeps its content's layout through a resize that changes only lengths the layout doesn't read, which each node reports in its sizing's dependence. A custom node that returns its child's sizing and also reads the container size itself adds those lengths to the child's dependence. (#244, #246)
  • On macOS, setting BaseTextView's text to an equal text leaves it in place, as on iOS. To change an attribute object, such as an attachment's image, set a text with a new object. (#129)
  • Replaced ComposeContent.asNodes() with the nodes property, and removed ComposeContentBuilder.Item: the builder's methods take and return _Node, _Content and _Component. A type that implemented asNodes() becomes a node, or a property or function marked @ComposeContentBuilder. An app's own builder method returns the _Content of one of the builder's methods, such as buildExpression(_:), or its type becomes a node. (#136, #225)
  • ComposeNode requires render(visibleBounds:into:) instead of renderableItems(in:). Rename a node's implementation, append its items to the given array instead of returning them, and remove the old method. (#188)
  • ComposeView.theme stays the same during a render pass, and overrideTheme is final and asserts when set during the view's own render pass. (#144)
  • A text node that's neither editable nor selectable, as a label is by default, shows its text in a new TextLabelView instead of a BaseTextView. To keep a text view, make the text selectable. (#183, #185, #236)
  • A render pass reuses the label and text views of TextNode and LabelNode in place for new nodes of the same kind, so their superview and window callbacks don't run, and an app's view can opt in with reuseId(_:inPlace: true). A custom RenderablePoolType doesn't see the views reused in place. (#203, #212, #233)
  • Methods that return a changed node, such as LabelNode.font(_:), consume the node, so a call on a borrowing parameter needs a copy: (copy node).font(font). (#219)
  • TextNode defaults to a label's font and text color on macOS and tvOS. To keep the old look, pass font: .systemFont(ofSize: 17) and foregroundColor: ThemedColor(light: .black, dark: .white). (#223)
  • Building ComposeUI requires Swift 6.0, which Xcode 16 has, and the package still builds in the Swift 5 language mode. (#225)
  • Renamed ComposeNode.renderableItemsBoundingRect to renderableItemsBounds. Rename a node's implementation, since one under the old name still builds but isn't read. (#251)
  • The render pass no longer resets a renderable's transform to identity on each pass, so a node that sets a transform only while a condition holds sets the identity transform when it doesn't. (#270)
  • An update block, such as onUpdate, must keep the renderable's frame, and debug builds assert when one changes it. Change a renderable's frame through the node's layout. (#283)
  • A renderable must take the frame that the render pass gives it, and debug builds assert when one doesn't. A view that keeps its own size needs a fixed-size node, such as ViewNode<UISwitch>().fixedSize(). (#286)
  • A fixed-size ViewNode needs intrinsicSize when make is custom or update changes the view's size, and debug builds assert without it. (#286)

Changes

  • Made TextLabelView public, so it can be used as a performant label in place of UILabel or NSTextField. (#326)
  • A label or text node sized to its text wraps narrowly when its inset leaves no width, instead of measuring as one line. (#326)
  • Added previousRenderBounds and renderBounds to RenderableUpdateContext, which tell a scroll from a resize. (#24)
  • Added a scale transition, .scale(from:anchor:timing:options:), and UnitPoint, which moved from ChouTiUI. (#10, #255)
  • Added InsertTransition.prepareForTakeover(renderable:), and revivalPosition and revivalTransform in the insert transition context, for transitions that take over a removal. (#6, #10, #74)
  • Added CALayer.retarget(keyPath:to:), which sets a property and continues its in-flight animations toward the new value. (#48)
  • Added a transform(_:anchor:) modifier, which transforms a node's renderables, each around its anchor, without changing their layout. (#271, #273, #277)
  • Added dependence to ComposeNodeSizing, the lengths of the container size that a node's layout reads, which lets ComposeView keep a layout when only another length changes. (#244)
  • DropShadowLayer and InnerShadowLayer can be created and subclassed outside the framework. (#44)
  • A nested compose view updates and lays out within its parent's render pass. Set its properties in willInsert or willUpdate, since onInsert and onUpdate run after its first render. (#14, #29, #30)
  • A render pass requested during another view's render pass, and a bounds change made during the view's own render pass, render after that pass. (#30)
  • AnimationBehavior.dynamic is called once per render pass instead of once per renderable. (#24)
  • ComposeView renders again when the display scale changes on iOS and tvOS, as on macOS. (#10)
  • ComposeView renders again when the text size or Bold Text changes, SwiftUIViewNode measures its content with them, and ComposeNodeLayoutContext gives them to custom nodes. (#312, #314)
  • Coalesced setNeedsRefresh(animated:) requests refresh without animation when any of them asked for none. (#8, #10)
  • Animations are smoother: a non-animated update continues in-flight animations instead of jumping, updates animate only the properties that changed, and stacked modifiers of one property apply only the outermost. (#39, #42, #49, #68, #72, #74, #76, #121)
  • Animations run at up to 120 Hz on ProMotion displays, and Animations.preferredFrameRateRange changes the frame rate range they ask for. An iPhone app needs CADisableMinimumFrameDurationOnPhone: YES in its Info.plist to go above 60 Hz. (#310)
  • Animations begin at a time read once per turn of the main run loop. A test that compares animations with the media time should turn the run loop first. (#87)
  • Debug builds assert on invalid AnimationTiming values, which fall back to defaults. (#62)
  • oldFrame in the update and remove contexts is the newFrame of the renderable's previous update, so the two are equal when the frame didn't change. (#269)
  • On macOS, a scroll view, such as a ComposeView or ButtonView, clips its content as clipsToBounds says. (#306)
  • On macOS, a trackpad scroll stays with its scroll view until its glide ends, and a mouse wheel scrolls the innermost scroll view that can scroll in its direction. (#114, #119)
  • On macOS, the arrow and page keys scroll a ScrollView, such as a ComposeView, while the keyboard focus is in it, an arrow key by a page with Option and to the edge with Command. (#297, #299, #302)
  • On macOS, view frame changes no longer slow down as text views come and go. A BaseTextView subclass that observes NSView.frameDidChangeNotification does so with another object. (#160)
  • On macOS, labels draw ahead of time on background threads, so a color made with NSColor(name:dynamicProvider:) must be safe to call off the main thread. (#196)
  • Text views lay out their text with TextKit 1, so measured sizes match what they draw. Right-to-left text without a writing direction aligns to the right on all systems, a paragraph in an editable text node aligns by the user's language, and Writing Tools shows its results for an editable text node in a panel. (#160)
  • On iOS, tvOS and visionOS, the text view of a text node that isn't editable doesn't scroll, as on macOS. (#172)
  • Fixed a text node sized to its text, such as with fixedSize(), wrapping its text when it has a horizontal inset. On macOS, BaseTextView's intrinsic content size includes its inset. (#184)
  • .byCharWrapping in a TextNode, a LabelNode or a BaseTextView on TextKit 1 breaks every line between characters and keeps the line limit, as in UILabel and NSTextField. While its line break mode is .byCharWrapping, a BaseTextView uses its layout manager's delegate. (#296)
  • Fixed a render pass without an onWillRender handler dropping items after a change of the content size. (#24)
  • Fixed a stack that never finished its layout in release builds when a child has an infinite fixed size. Use .flexible to fill the space. (#150)
  • Changing the view or layer type of an item under the same id replaces its renderable instead of crashing. (#179)
  • A ComposeView released while its items animate out deallocates right away, without calling their onRemove blocks. (#182)
  • Fixed CALayer.animate crashing, losing the change or dropping the layer's transform for a geometry key path, such as position.x, on a view-backed layer on macOS. (#63)
  • On visionOS, views whose layers UIKit moves into a wrapper layer, such as labels and buttons, take frame changes without animating them, instead of drawing away from their frames after an animated refresh. (#290)

Performance