44 <a href="https://android-arsenal.com/api?level=21">
55 <img src="https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat" alt="API">
66</a >
7- <img src =" https://img.shields.io/github/v/release/w2sv/Composed ?include_prereleases " alt =" GitHub release (latest by date including pre-releases) " >
8- <a href =" https://github.com/w2sv/Composed /actions/workflows/workflow.yaml " >
9- <img src="https://github.com/w2sv/Composed /actions/workflows/workflow.yaml/badge.svg" alt="Build">
7+ <img src =" https://img.shields.io/github/v/release/w2sv/Compose-Utils ?include_prereleases " alt =" GitHub release (latest by date including pre-releases) " >
8+ <a href =" https://github.com/w2sv/Compose-Utils /actions/workflows/workflow.yaml " >
9+ <img src="https://github.com/w2sv/Compose-Utils /actions/workflows/workflow.yaml/badge.svg" alt="Build">
1010</a >
11- <img src =" https://img.shields.io/github/license/w2sv/Composed " alt =" GitHub License " >
11+ <img src =" https://img.shields.io/github/license/w2sv/Compose-Utils " alt =" GitHub License " >
1212</p >
1313
1414------
3535
3636## State Savers
3737
38- ### ` colorSaver() `
39-
40- Returns a ` rememberSavable ` state saver for ` Color ` .
41-
4238``` kotlin
39+ /* *
40+ * Returns a rememberSavable state saver for Color.
41+ */
4342fun colorSaver (): Saver <Color , Int >
44- ```
45-
46- ### ` nullableColorSaver() `
47-
48- Returns a ` rememberSavable ` state saver for an optional ` Color ` .
4943
50- ``` kotlin
44+ /* *
45+ * Returns a rememberSavable state saver for an optional Color.
46+ */
5147fun nullableColorSaver (): Saver <Color ?, Float >
52- ```
53-
54- ### ` nullableListSaver() `
55-
56- ` listSaver ` for an optional object, enabling handling of non-null instances only.
5748
58- ``` kotlin
49+ /* *
50+ * listSaver for an optional object, enabling handling of non-null instances only.
51+ */
5952fun <Original , Saveable > nullableListSaver (
6053 saveNonNull : SaverScope .(value: Original ) -> List <Saveable >,
6154 restoreNonNull : (list: List <Saveable >) -> Original ?
6255): Saver <Original ?, Any >
63- ```
64-
65- ### ` nullableMapSaver() `
66-
67- ` mapSaver ` for an optional object, enabling handling of non-null instances only.
6856
69- ``` kotlin
57+ /* *
58+ * mapSaver for an optional object, enabling handling of non-null instances only.
59+ */
7060fun <T > nullableMapSaver (
7161 saveNonNull : SaverScope .(value: T ) -> Map <String , Any ?>,
7262 restoreNonNull : (Map <String , Any ?>) -> T
@@ -75,22 +65,20 @@ fun <T> nullableMapSaver(
7565
7666## Styled Text
7767
78- ### ` rememberStyledTextResource() `
79-
80- Convert a HTML-styled string resource text to an ` AnnotatedString ` and remember it.
81-
8268``` kotlin
69+ /* *
70+ * Converts a HTML-styled string resource text to a remembered AnnotatedString.
71+ */
8372@Composable
8473fun rememberStyledTextResource (@StringRes id : Int , vararg formatArgs : Any ): AnnotatedString
8574```
8675
8776## Modifiers
8877
89- ### ` Modifier.thenIf() `
90-
91- Applies modifiers depending on a condition.
92-
9378``` kotlin
79+ /* *
80+ * Applies modifiers depending on a condition.
81+ */
9482inline fun Modifier.thenIf (
9583 condition : Boolean ,
9684 onFalse : Modifier .() -> Modifier = { this },
@@ -100,25 +88,21 @@ inline fun Modifier.thenIf(
10088
10189## Flow Collectors
10290
103- ### ` CollectFromFlow() `
104-
105- Collects from a flow and emits values into a collector.
106-
10791``` kotlin
92+ /* *
93+ * Collects from a flow and emits values into a collector.
94+ */
10895@Composable
10996fun <T > CollectFromFlow (
11097 flow : Flow <T >,
11198 collector : FlowCollector <T >,
11299 key1 : Any? = null,
113100 key2 : Any? = null
114101)
115- ```
116102
117- ### ` CollectLatestFromFlow() `
118-
119- Collects latest from a flow with given action.
120-
121- ``` kotlin
103+ /* *
104+ * Collects latest from a flow with given action.
105+ */
122106@Composable
123107fun <T > CollectLatestFromFlow (
124108 flow : Flow <T >,
@@ -130,11 +114,10 @@ fun <T> CollectLatestFromFlow(
130114
131115## Lifecycle Observers
132116
133- ### ` OnLifecycleEvent() `
134-
135- Runs a callback whenever the lifecycleOwner reaches the given lifecycleEvent.
136-
137117``` kotlin
118+ /* *
119+ * Runs a callback whenever the lifecycleOwner reaches the given lifecycleEvent.
120+ */
138121@Composable
139122fun OnLifecycleEvent (
140123 callback : () -> Unit ,
@@ -143,142 +126,110 @@ fun OnLifecycleEvent(
143126 key1 : Any? = null,
144127 key2 : Any? = null
145128)
146- ```
147-
148- ### ` OnRemoveFromComposition() `
149-
150- Runs a callback when removed from composition.
151129
152- ``` kotlin
130+ /* *
131+ * Runs a callback when removed from composition.
132+ */
153133@Composable
154134fun OnRemoveFromComposition (callback : () -> Unit )
155135```
156136
157137## Orientation
158138
159- ### ` isLandscapeModeActive `
160-
161139``` kotlin
140+ /* *
141+ * Returns true if the landscape mode is active, false otherwise.
142+ */
162143val isLandscapeModeActive: Boolean
163- @Composable
164- @ReadOnlyComposable
165- get() = LocalConfiguration .current.orientation == Configuration .ORIENTATION_LANDSCAPE
166- ```
167144
168- ### ` isPortraitModeActive `
169-
170- ``` kotlin
145+ /* *
146+ * Returns true if the portrait mode is active, false otherwise.
147+ */
171148val isPortraitModeActive: Boolean
172- @Composable
173- @ReadOnlyComposable
174- get() = LocalConfiguration .current.orientation == Configuration .ORIENTATION_PORTRAIT
175149```
176150
177151## Dimension Conversion
178152
179- ### ` toPx() `
180-
181- Converts ` Dp ` to pixels.
182-
183153``` kotlin
154+ /* *
155+ * Converts Dp to pixels.
156+ */
184157@Composable
185158@ReadOnlyComposable
186159fun Dp.toPx (): Float
187- ```
188160
189- ### ` toDp() `
190-
191- Converts pixels to ` Dp ` .
192-
193- ``` kotlin
161+ /* *
162+ * Converts pixels to Dp.
163+ */
194164@Composable
195165@ReadOnlyComposable
196166fun Int.toDp (): Dp
197- ```
198167
199- ### ` toDp() `
200-
201- Converts pixels to ` Dp ` .
202-
203- ``` kotlin
168+ /* *
169+ * Converts pixels to Dp.
170+ */
204171@Composable
205172@ReadOnlyComposable
206173fun Float.toDp (): Dp
207174```
208175
209176## Color Conversion
210177
211- ### ` toComposeColor() `
212-
213- Converts a hex color string to ` Color ` .
214-
215178``` kotlin
179+ /* *
180+ * Converts a hex color string to Color.
181+ */
216182fun String.toComposeColor (): Color
217183```
218184
219185## Map Conversion
220186
221187``` kotlin
188+ /* *
189+ * Converts a regular Map to a SnapshotStateMap.
190+ */
222191fun <K , V > Map <K , V >.toMutableStateMap (): SnapshotStateMap <K , V >
223192```
224193
225194## Drawer State
226195
227- ### ` DrawerState.visibilityPercentage() `
228-
229- Returns a ` State<Float> ` whose value ranges from 0.0 (drawer closed) to 1.0 (drawer fully open).
230-
231196``` kotlin
197+ /* *
198+ * Returns a State<Float> whose value ranges from 0.0 (drawer closed) to 1.0 (drawer fully open).
199+ */
232200fun DrawerState.visibilityPercentage (@FloatRange(from = 0.0 ) maxWidthPx : Float ): State <Float >
233- ```
234-
235- ### ` DrawerState.rememberVisibilityPercentage() `
236201
237- ``` kotlin
202+ /* *
203+ * Remembers a visibility percentage for the drawer.
204+ */
238205@Composable
239- fun DrawerState.rememberVisibilityPercentage (@FloatRange(from = 0.0 ) maxWidthPx : Float = DrawerDefaults .MaximumDrawerWidth .toPx()): State <Float > =
206+ fun DrawerState.rememberVisibilityPercentage (@FloatRange(from = 0.0 ) maxWidthPx : Float = DrawerDefaults .MaximumDrawerWidth .toPx()): State <Float >
240207```
241208
242209## Permission States
243210
244- ### ` ExtendedPermissionState `
245-
246211``` kotlin
247212/* *
248213 * Permission state which, as opposed to the accompanist ones,
249214 * - exposes a [grantedFromRequest] shared flow to allow for distributed subscription and callback invocation, instead of only being able to pass a onPermissionResult callback upon instantiation, which needs to cover all granting reactions, possibly impacting various components
250215 * - allows for callbacks upon permission requesting being suppressed
251216 */
252-
253217@Stable
254218interface ExtendedPermissionState {
255219 val granted: Boolean
256-
257- /* *
258- * The result of a launched permission request.
259- */
260220 val grantedFromRequest: SharedFlow <Boolean >
261-
262- /* *
263- * Launches the permission request if launching is not suppressed, otherwise invokes [onSuppressed].
264- */
265221 fun launchRequest (onSuppressed : (() -> Unit )? = null)
266222}
267- ```
268-
269- with the implementations
270223
271- #### ` ExtendedSinglePermissionState `
224+ // With the implementations:
272225
273- ``` kotlin
274226@Stable
275227open class ExtendedSinglePermissionState (
276228 private val requestLaunchedBefore : StateFlow <Boolean >,
277229 permissionState : PermissionState ,
278230 override val grantedFromRequest : SharedFlow <Boolean >,
279231 private val defaultOnLaunchingSuppressed : () -> Unit = {}
280- ) : PermissionState by permissionState,
281- ExtendedPermissionState
232+ ) : PermissionState by permissionState, ExtendedPermissionState
282233
283234@Composable
284235fun rememberExtendedSinglePermissionState (
@@ -289,21 +240,16 @@ fun rememberExtendedSinglePermissionState(
289240 defaultOnLaunchingSuppressed : () -> Unit = {},
290241 scope : CoroutineScope = rememberCoroutineScope()
291242): ExtendedSinglePermissionState
292- ```
293-
294- and
295243
296- #### ` ExtendedMultiplePermissionsState `
244+ // And
297245
298- ``` kotlin
299246@Stable
300247open class ExtendedMultiplePermissionsState (
301248 private val requestLaunchedBefore : StateFlow <Boolean >,
302249 multiplePermissionsState : MultiplePermissionsState ,
303250 override val grantedFromRequest : SharedFlow <Boolean >,
304251 private val defaultOnLaunchingSuppressed : () -> Unit = {}
305- ) : MultiplePermissionsState by multiplePermissionsState,
306- ExtendedPermissionState
252+ ) : MultiplePermissionsState by multiplePermissionsState, ExtendedPermissionState
307253
308254@Composable
309255fun rememberExtendedMultiplePermissionsState (
0 commit comments