* Reuse updater lambdas and eliminate backing field for efficiency
Use the same lambda instances for all nodes to update their modifier, measure policy, or debug policy. Also eliminate the Modifier backing field and instead just recompute the layers.
* Update Node.kt
- Move `Fill` and `Stroke` inside the `DrawStyle`
- Remove `toString` from `DrawStyle.Stroke` because `@Poko` is already doing it
- In the robot sample, the use of the `offset` modifier in the robot (`Text`)
- Remove `TODO https://github.com/JakeWharton/mosaic/issues/11` in the robot sample, it seems that it is no longer relevant
- In the robot sample, add `isActive` check in the loop for keyboard input
- Fix in the `README.md` `mutableStateOf` to `mutableIntStateOf`, as is correct in newer versions
- Change the `drawRect` method in `DrawScope` like the method from the Compose UI
- Add support for `DrawStyle`: `Fill` and `Stroke` in `DrawScope#drawRect`
- Add support for drawing a rectangle from text characters
- Add `Filler` with code point
- Change the robot sample to show `drawRect` with `Stroke`
- Add `Color.Unspecified` for replace nullable `Color`
- Add some extension functions for `Color` to check on `Color.Unspecified`
- Use `TextStyle.Unspecified` instead null for `TextStyle`
- Add some extension functions for `TextStyle` to check on `TextStyle.Unspecified` and `TextStyle.Empty`
- Make `TextStyle` an inline class
- Using `Int` as codepoint (`TextPixel#codePoint`) instead of `String` in `TextPixel` (`TextPixel#value`)
- Rename `style: TextStyle` to `textStyle: TextStyle` for clearer and less confusing naming, as there are several other styles
- Add emoji to demo sample and use of 2 styles for part of the text
* Use CRLF line endings to support rendering when terminal runs in raw mode
* Update tests to expect CRLF line endings
* Update CHANGELOG.md
* Update CHANGELOG.md
* Apply changes from spotlessKotlin
---------
Co-authored-by: Jake Wharton <github@jakewharton.com>
* Unit tests for modifiers and some fixes
Added unit tests for `AspectRatio`, `Offset`, `Padding`, `Size` modifiers.
Added unit tests for `Arrangement`.
Added some auxiliary tools for unit tests.
Added `equals` and `hashCode` implementations for `SizeModifier`, `FillModifier`, `WrapContentModifier`, `UnspecifiedConstraintsModifier`.
Added a new `Composable` - `Filler`. Draws the same symbol over its entire size. Similar to `Spacer`, where such a symbol is a space without additional styles.
Added a `Composable` `Box` without content.
Fixed formatting in the `toString` implementation for `Alignment`, taking into account possible non-integers.
Fixed a problem in `OffsetModifier` with incorrect transmission of `x` and `y` due to shadowing fields.
Fixed some bugs and typos in `Node.kt` related to the `minIntrinsicWidth`, `maxIntrinsicWidth`, `minIntrinsicHeight`, `maxIntrinsicHeight` methods.
* Code review fixes
Added Arrangement to Row and Column.
Changed the implementation of Row and Column to one common with Constraints support.
Modifier.weight has been added to RowScope and ColumnScope.
* Add AnnotatedString with SpanStyle for text customization
This is a simplified version of AnnotatedString and SpanStyle from Jetpack Compose. There is no ParagraphStyle support. SpanStyle contains fewer properties.
The tests are also taken from Jetpack Compose, but simplified.
The API has been saved for using AnnotatedString and creating and styling it, for quick understanding if you know Jetpack Compose.
The code has two Compose Text functions, two DrawScope.DrawText methods, two TextLayout inheritors, in which the difference is only in the accepted value - either String or AnnotatedString. This is done for optimization, but in theory it may be unnecessary.
Update the jest example using AnnotatedString.
* Add MosaicComposable to Text function with AnnotatedString parameter
* Change TextLayout access modifier to internal
* Add Constraints and intrinsics to layout system
Added the `Constraints` parameter for all required methods.
Extended `MeasurePolicy` with methods of intrinsics.
`Constraints` are fully supported in `Box` and `Modifier.padding`.
* Add Spacer and size modifiers
`Spacer` and size modifiers use new `Constraints`.
* Fix unit tests
* CompositionLocal for terminal size by Mordant
The Mordant KMP library has been added to the mosaic-runtime module in commonMain, which allows you to interact with the cli.
This makes it possible to get the size of the terminal via `CompositionLocal` - `Terminal.current.size`.
* Use local variable for terminalInfo in loop with terminal size update
Co-authored-by: Jake Wharton <github@jakewharton.com>
---------
Co-authored-by: Jake Wharton <github@jakewharton.com>
The 'layout' package is now a standalone widget tree. The 'ui' package is now only composables. The root package contains all the code for integration and Compose.