1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! # Layout
//!
//! A composable takes its modifier first, its spec second, and its content
//! last. `Text` is the exception: its value comes first.
//!
//! ```no_run
//! #![allow(non_snake_case)]
//! use cranpose::prelude::*;
//! # use cranpose::{
//! # __branch_group_scope_deferred, branch_location_key,
//! # cached_branch_location_key, cached_composable_definition_key,
//! # caller_location_key,
//! # composable_definition_key, composable_identity_key, debug_label_current_scope,
//! # location_key,
//! # with_current_composer, CallbackHolder, Composer, Key, ParamState, ReturnSlot,
//! # };
//!
//! #[composable]
//! fn Card() {
//! Column(
//! Modifier::empty()
//! .fill_max_width()
//! .padding(16.0)
//! .background(Color(0.1, 0.12, 0.18, 1.0))
//! .rounded_corners(12.0),
//! ColumnSpec::default().vertical_arrangement(LinearArrangement::spaced_by(8.0)),
//! move || {
//! Text("Title", Modifier::empty(), TextStyle::default());
//! Text("Body", Modifier::empty(), TextStyle::default());
//! },
//! );
//! }
//!
//! fn main() {}
//! ```
//!
//! A `Modifier` is an ordered chain and the order is the meaning:
//! `.padding(8.0).background(c)` paints the background inside the padding,
//! `.background(c).padding(8.0)` paints it outside.
//!
//! ## Lists
//!
//! A `for` loop composes every item. Anything long belongs in `LazyColumn`,
//! which composes only what is on screen and takes its state positionally:
//!
//! ```no_run
//! #![allow(non_snake_case)]
//! use cranpose::prelude::*;
//! # use cranpose::{
//! # __branch_group_scope_deferred, branch_location_key,
//! # cached_branch_location_key, cached_composable_definition_key,
//! # caller_location_key,
//! # composable_definition_key, composable_identity_key, debug_label_current_scope,
//! # location_key,
//! # with_current_composer, CallbackHolder, Composer, Key, ParamState, ReturnSlot,
//! # };
//!
//! #[composable]
//! fn Rows(count: usize) {
//! let state = rememberLazyListState();
//!
//! LazyColumn(
//! Modifier::empty().fill_max_size(),
//! state,
//! LazyColumnSpec::new().vertical_arrangement(LinearArrangement::SpacedBy(4.0)),
//! move |scope| {
//! scope.items(LazyItems::new(count), move |index| {
//! Text(
//! format!("Row {index}"),
//! Modifier::empty(),
//! TextStyle::default(),
//! );
//! });
//! },
//! );
//! }
//!
//! fn main() {}
//! ```
//!
//! Give `LazyItems::content_type` a real grouping when items differ
//! structurally: it is what lets the runtime reuse a subtree between items of
//! the same shape instead of building a new one.