<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vijay sonawane on Medium]]></title>
        <description><![CDATA[Stories by Vijay sonawane on Medium]]></description>
        <link>https://medium.com/@siyasonawane30sept?source=rss-242bafebf21f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2OAdGBEfy-oYYQau</url>
            <title>Stories by Vijay sonawane on Medium</title>
            <link>https://medium.com/@siyasonawane30sept?source=rss-242bafebf21f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:34:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@siyasonawane30sept/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Jetpack Compose Custom Slider with Range Labels]]></title>
            <link>https://medium.com/@siyasonawane30sept/jetpack-compose-custom-slider-with-range-labels-94980995213a?source=rss-242bafebf21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/94980995213a</guid>
            <category><![CDATA[slider]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[custom-view-android]]></category>
            <dc:creator><![CDATA[Vijay sonawane]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 18:36:55 GMT</pubDate>
            <atom:updated>2022-02-08T18:36:55.162Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I am going to develop the Jetpack Slider with range label values.</p><p>Here are screenshots of the final outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*NlnL1hpz7DWwXNu8nkOSGA.png" /></figure><p>Slider initial state</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*mRl279YtJfiQsdRVXuSRtQ.png" /><figcaption>Slider first step</figcaption></figure><p>Here is the final Composable.</p><pre>@Composable<br>fun RangeSlider(rangeLabel: List&lt;String&gt;, initialSliderValue: Float, onValueChange: (Int) -&gt; Unit) {<br>    val (initialSliderValue, setInitialSliderValue) = <em>remember </em><strong>{ </strong><em>mutableStateOf</em>(initialSliderValue) <strong>}<br>    </strong>val drawPadding = <em>with</em>(<em>LocalDensity</em>.current) <strong>{ </strong>10.<em>dp</em>.<em>toPx</em>() <strong>}<br>    </strong>val textSize = <em>with</em>(<em>LocalDensity</em>.current) <strong>{ </strong>10.<em>dp</em>.<em>toPx</em>() <strong>}<br>    </strong>val lineHeightDp = 10.<em>dp<br>    </em>val canvasHeight = 39.<em>dp<br>    </em>val textPaint = android.graphics.Paint().<em>apply </em><strong>{<br>        </strong><em>color </em>= 0xffffffff.toInt()<br>        <em>textAlign </em>= android.graphics.Paint.Align.<em>CENTER<br>        </em>this.<em>textSize </em>= textSize<br>    <strong>}<br>    </strong>Box(Modifier.<em>padding</em>(5.<em>dp</em>), contentAlignment = Alignment.Center) <strong>{<br>        </strong>Canvas(<br>            modifier = Modifier<br>                .<em>background</em>(Color.Gray)<br>                .<em>height</em>(canvasHeight)<br>                .<em>fillMaxWidth</em>()<br>                .<em>padding</em>(<br>                    top = canvasHeight<br>                        .div(2)<br>                        .minus(lineHeightDp.div(2))<br>                )<br>        ) <strong>{<br>            </strong>val yStart = 0f<br>            val distance = (size.width.minus(2 * drawPadding)).div(rangeLabel.size.minus(1))<br>            rangeLabel.<em>forEachIndexed </em><strong>{ </strong>index, step <strong>-&gt;<br>                </strong>this.drawContext.canvas.<em>nativeCanvas</em>.drawText(<br>                    step,<br>                    drawPadding + index.times(distance),<br>                    size.height,<br>                    textPaint<br>                )<br>            <strong>}<br>        }<br>        </strong>Slider(<br>            modifier = Modifier<br>                .<em>requiredHeight</em>(29.<em>dp</em>)<br>                .<em>fillMaxWidth</em>(),<br>            value = initialSliderValue,<br>            valueRange = 0f..rangeLabel.size.minus(1).toFloat(),<br>            steps = rangeLabel.size.minus(2),<br>            colors = rangeSliderColors(),<br>            onValueChange = <strong>{<br>                </strong>setInitialSliderValue(<strong>it</strong>)<br>                onValueChange(<strong>it</strong>.toInt())<br>            <strong>}</strong>)<br>    <strong>}<br></strong>}<br><br>@Composable<br>private fun rangeSliderColors(): SliderColors = SliderDefaults.colors(<br>    activeTickColor = Color.Transparent,<br>    inactiveTickColor = Color.Transparent,<br>    thumbColor = Color.Yellow,<br>    inactiveTrackColor = Color.Cyan<br>)</pre><p>How to use inactivity or fragment</p><pre>class MySliderActivity : ComponentActivity() {<br><br>    private val rangeLables =<br>        <em>mutableStateListOf</em>(&quot;5&quot;, &quot;10&quot;, &quot;15&quot;, &quot;25&quot;, &quot;50&quot;, &quot;100&quot;)<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        <em>setContent </em><strong>{<br>            </strong><em>WeatherCardTheme </em><strong>{<br>                </strong><em>// A surface container using the &#39;background&#39; color from the theme<br>                </em>RangeSlider(rangeLables, 0f, onValueChange =<br>                <strong>{<br>                    </strong>Toast.makeText(<em>applicationContext</em>, &quot;&quot; + <strong>it</strong>, Toast.<em>LENGTH_SHORT</em>).show()<br>                <strong>}</strong>)<br>            <strong>}<br>        }<br>    </strong>}<br>}</pre><p>Done…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94980995213a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Minimum lines support Flow layout in Jetpack compose]]></title>
            <link>https://medium.com/@siyasonawane30sept/design-minimum-lines-support-flow-layout-in-jetpack-compose-56d073d5d590?source=rss-242bafebf21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/56d073d5d590</guid>
            <category><![CDATA[chips]]></category>
            <category><![CDATA[flowlayout]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[wrap]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vijay sonawane]]></dc:creator>
            <pubDate>Sat, 05 Feb 2022 16:17:56 GMT</pubDate>
            <atom:updated>2022-02-05T16:48:59.233Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Design Minimum lines support Flow layout in Jetpack compose</strong></p><p>We have a requirement to develop the flow layout with minimum line support to “…see more” expanded collapse functionality.</p><p>Today we will try to develop the same custom flow layout using the Jetpack compose in android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*n96EAH81ITMp4n5p0Wl34Q.png" /><figcaption>Collapse state with 2 lines support</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*ZrdDzD3aSrwZfmBMu7tlpA.png" /><figcaption>Expand state with max line support</figcaption></figure><p>First, we will create a WarpFlowRow custom wrap child layout in jetpack compose as below</p><pre>@Composable<br>fun WarpFlowRow(<br>    lineSupport: MutableState&lt;Int&gt;,<br>    seeMoreShowState: MutableState&lt;Boolean&gt;,<br>    modifier: Modifier = Modifier,<br>    alignment: Alignment.Horizontal = Alignment.Start,<br>    verticalGap: Dp = 0.<em>dp</em>,<br>    horizontalGap: Dp = 0.<em>dp</em>,<br>    content: @Composable () -&gt; Unit,<br>) = Layout(content, modifier) <strong>{ </strong>measurables, constraints <strong>-&gt;<br>    </strong>val hGapPx = horizontalGap.<em>roundToPx</em>()<br>    val vGapPx = verticalGap.<em>roundToPx</em>()<br>    val rows = <em>mutableListOf</em>&lt;MeasuredRow&gt;()<br>    val itemConstraints = constraints.copy(minWidth = 0)<br>    var mCurrentLine = 0<br>    for (measurable in measurables) {<br>        val lastRow = rows.<em>lastOrNull</em>()<br>        val placeable = measurable.measure(itemConstraints)<br><br>        if (lastRow != null &amp;&amp; lastRow.width + hGapPx + placeable.width &lt;= constraints.maxWidth) {<br>            lastRow.items.add(placeable)<br>            lastRow.width += hGapPx + placeable.width<br>            lastRow.height = <em>max</em>(lastRow.height, placeable.height)<br>        } else {<br>            mCurrentLine++<br>            val nextRow = MeasuredRow(<br>                items = <em>mutableListOf</em>(placeable),<br>                width = placeable.width,<br>                height = placeable.height<br>            )<br>            if (mCurrentLine &lt;= lineSupport.value) {<br>                rows.add(nextRow)<br>            }<br>        }<br>    }<br>    if (mCurrentLine &gt; lineSupport.value) {<br>        seeMoreShowState.value = true<br>    }<br><br>    val width = rows.<em>maxOfOrNull </em><strong>{ </strong>row <strong>-&gt; </strong>row.width <strong>} </strong>?: 0<br>    val height = rows.<em>sumBy </em><strong>{ </strong>row <strong>-&gt; </strong>row.height <strong>} </strong>+ <em>max</em>(vGapPx.times(rows.size - 1), 0)<br><br>    val coercedWidth = width.<em>coerceIn</em>(constraints.minWidth, constraints.maxWidth)<br>    val coercedHeight = height.<em>coerceIn</em>(constraints.minHeight, constraints.maxHeight)<br><br>    layout(coercedWidth, coercedHeight) <strong>{<br>        </strong>var y = 0<br><br>        for (row in rows) {<br>            var x = when (alignment) {<br>                Alignment.Start -&gt; 0<br>                Alignment.CenterHorizontally -&gt; (coercedWidth - row.width) / 2<br>                Alignment.End -&gt; coercedWidth - row.width<br>                else -&gt; throw Exception(&quot;unsupported alignment&quot;)<br>            }<br>            for (item in row.items) {<br>                item.<em>place</em>(x, y)<br>                x += item.width + hGapPx<br>            }<br>            y += row.height + vGapPx<br>        }<br>    <strong>}<br>}<br><br></strong>private data class MeasuredRow(<br>    val items: MutableList&lt;Placeable&gt;,<br>    var width: Int,<br>    var height: Int,<br>)</pre><p>Next, we will create a “SeeMoreBottomRow” composable bottom row with a text view to show see more links to expand the layout vertically.</p><pre>@Composable<br>fun SeeMoreBottomRow(<br>    seeMoreText: MutableState&lt;String&gt;,<br>    onClick: () -&gt; Unit,<br>) {<br>    Row(Modifier.<em>fillMaxWidth</em>(), horizontalArrangement = Arrangement.End) <strong>{<br>        </strong>Text(<br>            modifier = Modifier<br>                .<em>padding</em>(0.<em>dp</em>, 0.<em>dp</em>, 0.<em>dp</em>, 20.<em>dp</em>)<br>                .<em>clickable </em><strong>{<br>                    </strong>onClick()<br>                <strong>}</strong>,<br>            textAlign = TextAlign.Right,<br>            text = if (seeMoreText.value.<em>isNotBlank</em>()) seeMoreText.value else &quot;&quot;,<br>            style = TextStyle(<br>                fontWeight = if (Build.VERSION.<em>SDK_INT </em>&gt;= Build.VERSION_CODES.<em>P</em>) {<br>                    FontWeight.Bold<br>                } else {<br>                    FontWeight.Normal<br>                },<br>                fontSize = 14.<em>sp</em>,<br>                letterSpacing = 0.<em>sp</em>,<br>                lineHeight = 18.<em>sp</em>,                <em><br>            </em>),<br>            color = <em>Color</em>(&quot;#70758B&quot;.<em>toColorInt</em>()),<br>        )<br>    <strong>}<br></strong>}</pre><p>Now, we will align these two “WarpFlowRow” and “SeeMoreBottomRow” composable in column with vertical orientation as below.</p><pre>@Composable<br>fun ChipFlowLayout(tags: Collection&lt;String&gt;, seeMoreText: String) {<br>    val seeMoreShowState = remember <strong>{<br>        </strong><em>mutableStateOf</em>(false)<br>    <strong>}<br>    </strong>val seeMoreText = remember <strong>{<br>        </strong><em>mutableStateOf</em>(seeMoreText)<br>    <strong>}<br>    </strong>var linesSupport = remember <strong>{<br>        </strong><em>mutableStateOf</em>(2)<br>    <strong>}<br>    </strong>Column(modifier = Modifier.<em>fillMaxWidth</em>().<em>background</em>(Color.Red)) <strong>{<br>        </strong>WarpFlowRow(<br>            linesSupport,<br>            seeMoreShowState,<br>            verticalGap = 8.<em>dp</em>,<br>            horizontalGap = 8.<em>dp</em>,<br>            alignment = Alignment.Start,<br>            modifier = Modifier.<em>padding</em>(16.<em>dp</em>)<br>        ) <strong>{<br>            </strong>for (tag in tags) {<br>                Text(<br>                    text = &quot;$tag&quot;,<br>                    maxLines = 1,<br>                    overflow = TextOverflow.Ellipsis,<br>                    modifier = Modifier<br>                        .<em>background</em>(Color.LightGray, <em>RoundedCornerShape</em>(4.<em>dp</em>))<br>                        .<em>padding</em>(4.<em>dp</em>)<br>                )<br>            }<br>        <strong>}<br>        </strong>if (seeMoreShowState.value) {<br>            SeeMoreBottomRow(seeMoreText, onClick =<br>            <strong>{<br>                </strong>seeMoreShowState.value = false<br>                linesSupport.value = Int.MAX_VALUE<br>            <strong>}</strong>)<br>        }<br>    <strong>}<br></strong>}</pre><p>finally, we can use “ChipFlowLayout” in the activity or fragment as below.</p><pre>val <em>chips</em>= <em>listOf</em>(    <br>&quot;HLSL&quot;,<br>&quot;.NET&quot;,<br>&quot;Sql&quot;,<br>&quot;React&quot;,<br>&quot;C++&quot;,<br>&quot;Tea&quot;,<br>&quot;Javascript&quot;,<br>&quot;Kotlin&quot;,<br>&quot;Groovy&quot;,<br>&quot;Processing&quot;,<br>&quot;Java&quot;,<br>&quot;ICI&quot;,<br>&quot;HLSL&quot;,<br>&quot;.NET&quot;,<br>&quot;Sql&quot;,<br>&quot;React&quot;,<br>&quot;C++&quot;,<br>&quot;Tea&quot;,<br>&quot;Javascript&quot;,<br>&quot;Kotlin&quot;,<br>&quot;Groovy&quot;,<br>&quot;Processing&quot;,<br>&quot;Java&quot;,<br>&quot;ICI&quot;)</pre><pre>class MainActivity : ComponentActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        <em>setContent </em><strong>{<br>            </strong><em>setContent </em><strong>{<br>                </strong>ChipFlowLayout(<em>sampleTags</em>, &quot;...See more&quot;)<br>            <strong>}<br>        }<br>    </strong>}<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uxuKcDZSZTnIY5CERh0STA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*laXyq3WeRd2MuFWhsReNIg.png" /></figure><p>Done…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56d073d5d590" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>