<?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 Heba Mekawi on Medium]]></title>
        <description><![CDATA[Stories by Heba Mekawi on Medium]]></description>
        <link>https://medium.com/@hebamekawi?source=rss-9b4aee4fcb40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BYivuMUqDlwcpJ8Qhsg1GQ.jpeg</url>
            <title>Stories by Heba Mekawi on Medium</title>
            <link>https://medium.com/@hebamekawi?source=rss-9b4aee4fcb40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 15:19:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hebamekawi/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[Nested Auto Scroll For Section Based Lists With Jetpack Compose]]></title>
            <link>https://proandroiddev.com/nested-auto-scroll-for-multiple-section-based-lists-with-jetpack-compose-c193a9814b09?source=rss-9b4aee4fcb40------2</link>
            <guid isPermaLink="false">https://medium.com/p/c193a9814b09</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Heba Mekawi]]></dc:creator>
            <pubDate>Wed, 13 Jul 2022 06:27:40 GMT</pubDate>
            <atom:updated>2022-07-13T14:58:40.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oXSpCRAlzKXZNkXh" /><figcaption>Photo by <a href="https://unsplash.com/@nathanareboucas?utm_source=medium&amp;utm_medium=referral">Nathana Rebouças</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Showing menu items in multiple food &amp; drinks apps is one of the best use cases for multiple lists interaction, Let’s create a simple implementation with Jetpack Compose 🚀</p><p>We’ll cover all of the following points :</p><ul><li><strong>Show menu items list labeled by sections</strong></li><li><strong>Show sections list and highlight the selected one</strong></li><li><strong>On menu items list scroll, highlight the sections list with the displayed section</strong></li><li><strong>On click on section name, jump to the menu items list section position</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*BNJrOJhMB4ED6-cqP2kZSQ.gif" /></figure><h4><strong>Show menu items list labeled by sections</strong></h4><p>This is a simple list for all menu items labeled &amp; indexed by sections title</p><ul><li><strong>itemsListState</strong> is a <strong>LazyListState</strong> which will be used to handle auto scroll which will be discussed later</li><li><strong>onPostScroll</strong> used to detect a scroll action on the menu items list, called from <strong>nestedScroll</strong> modifier</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59412f39c89a7f8f0f6df89a751af7bd/href">https://medium.com/media/59412f39c89a7f8f0f6df89a751af7bd/href</a></iframe><p>And this is the MenuItemView, just a simple view to show section items:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12cbc9a2f1379224006888d7b1dd25c5/href">https://medium.com/media/12cbc9a2f1379224006888d7b1dd25c5/href</a></iframe><h4><strong>Show sections list and highlight the selected one</strong></h4><p>This is a simple list to show sections titles in a row and used SectionTextView to show and highlight the selected section:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3147861af4987282d78aab598d1b91b/href">https://medium.com/media/b3147861af4987282d78aab598d1b91b/href</a></iframe><p>SectionTextView will also show an underline to the selected section item, the underline width <strong>textWidth </strong>should always match the text size so it is measured on <strong>onGloballyPositioned</strong> modifier:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49fb22da3f584b0e44307d7950b2c3a1/href">https://medium.com/media/49fb22da3f584b0e44307d7950b2c3a1/href</a></iframe><h4><strong>On menu items list scroll, highlight the sections list with the displayed section</strong></h4><p>The main parent view which will handle both lists interactions is MenuView</p><p>It will hold the current selection and handle onPostScroll event from the menu items list view</p><ul><li>Update the selected section index</li><li>Scroll through the sections list to the selected section title position</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2436090731b241e2c278146d5ac43bdb/href">https://medium.com/media/2436090731b241e2c278146d5ac43bdb/href</a></iframe><h4><strong>On click on section name, jump to the section menu items list position</strong></h4><p>MenuView<strong> </strong>will also handle section title click event</p><ul><li>Update the selected section index</li><li>Scroll through the items list to the selected section position</li><li>Scroll through the sections list to the selected section title position</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f5e9d9740a8f936f6c86ebfc9886ea5/href">https://medium.com/media/8f5e9d9740a8f936f6c86ebfc9886ea5/href</a></iframe><p>Finally the MenuView<strong> </strong>will be like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/801e1d558c114873540602f930a6f7f4/href">https://medium.com/media/801e1d558c114873540602f930a6f7f4/href</a></iframe><p>That’s it! You made it! 💪</p><p>Do you see anything missing? please comment!</p><p>Thanks for reading, see you in the next article 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c193a9814b09" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/nested-auto-scroll-for-multiple-section-based-lists-with-jetpack-compose-c193a9814b09">Nested Auto Scroll For Section Based Lists With Jetpack Compose</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Big Form with Jetpack Compose]]></title>
            <link>https://proandroiddev.com/the-big-form-with-jetpack-compose-7bec9cde157e?source=rss-9b4aee4fcb40------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bec9cde157e</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Heba Mekawi]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 02:28:56 GMT</pubDate>
            <atom:updated>2022-03-04T20:35:29.677Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6L3DNpJTJy-dHjLOlhLPyQ.jpeg" /></figure><p>As always any app will always need a form screen like login, signup, edit profile, request form and many more …</p><p>This article aim to be a simple reference for the common form fields components</p><p>Let’s see how to make a form with Jetpack Compose 🚀</p><p>We’ll cover all of the following points :</p><ul><li><strong>IME Action</strong></li><li><strong>Password with Visibility Toggle</strong></li><li><strong>Mobile number with Country Code Picker</strong></li><li><strong>Date picker</strong></li><li><strong>Image Picker from Gallery or from Camera</strong></li><li><strong>Prevent keyboard from hiding textfields</strong></li></ul><h4>Styling Text Field</h4><p>Before starting you need to have a composable view of the text field component according to your app design, it can be something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*5M0Herau4D2UPjNMXWOang.png" /></figure><pre><em>fun </em>AppTextField(<br>    modifier: <em>Modifier </em>= Modifier,<br>    text: String,<br>    placeholder: String,<br>    leadingIcon: @Composable (() -&gt; Unit)? = <em>null</em>,<br>    onChange: (String) -&gt; Unit = {},<br>    imeAction: ImeAction = ImeAction.Next,<br>    keyboardType: KeyboardType = KeyboardType.Text,<br>    keyBoardActions: KeyboardActions = KeyboardActions(),<br>    isEnabled: Boolean = <em>true<br></em>) {<br>    OutlinedTextField(<br>        modifier = modifier.<em>fillMaxWidth</em>(),<br>        value = text,<br>        onValueChange = onChange,<br>        leadingIcon = leadingIcon,<br>        textStyle = TextStyle(fontSize = 18.<em>sp</em>),<br>        keyboardOptions = KeyboardOptions(imeAction = imeAction, keyboardType = keyboardType),<br>        keyboardActions = keyBoardActions,<br>        enabled = isEnabled,<br>        colors = TextFieldDefaults.outlinedTextFieldColors(<br>            focusedBorderColor = Color.Black,<br>            unfocusedBorderColor = Color.Gray,<br>            disabledBorderColor = Color.Gray,<br>            disabledTextColor = Color.Black<br>        ),<br>        placeholder = {<br>            Text(text = placeholder, style = TextStyle(fontSize = 18.<em>sp</em>, color = Color.LightGray))<br>        }<br>    )<br>}</pre><p>Also this example follow MVVM so the view model will hold all states, all can be empty or prefilled with previous value (like edit screen case)</p><pre><em>class </em>FormViewModel : ViewModel() {</pre><pre><em>var </em>firstName <em>by mutableStateOf</em>(&quot;&quot;)<br>    <em>var </em>lastName <em>by mutableStateOf</em>(&quot;&quot;)<br>    <em>var </em>password <em>by mutableStateOf</em>(&quot;&quot;)<br>    <em>var </em>mobileNumber <em>by mutableStateOf</em>(&quot;&quot;)<br>    <em>var </em>mobileCountryCode <em>by mutableStateOf</em>(&quot;&quot;)<em><br>    var </em>dateOfBirth <em>by mutableStateOf</em>(&quot;&quot;)<em><br>    ...<br>}</em></pre><h4>Add IME Actions</h4><p>In the parent composable form view, we can add multiple textfield components, all attached with keyboard IME actions</p><pre>//User name text field</pre><pre>Column{</pre><pre><strong><em>    val </em>focusManager = <em>LocalFocusManager</em>.current<br></strong><br>    <em>AppTextField</em>(<br>        text = viewModel.firstName,<br>        placeholder = &quot;First Name&quot;,<br>        onChange = {<br>            viewModel.firstName = it<br>        },<br>       <strong> imeAction = ImeAction.Next,</strong>//Show next as IME button<strong><br>        keyboardType = KeyboardType.Text, </strong>//Plain text keyboard<strong><br>        keyBoardActions = KeyboardActions(<br>            onNext = {<br>                focusManager.moveFocus(FocusDirection.Down)<br>            }<br>        )</strong><br>    )<br>    ...<br>}</pre><p>Also if the design have two text field views in a horizontal row, we can use <strong>FocusDirection.Left or FocusDirection.Right</strong></p><h4>Password Field</h4><p>Simple like plain text field but with <strong>PasswordVisualTransformation</strong></p><pre>AppTextField(<br>    text = viewModel.password,<br>    placeholder = &quot;Password&quot;,<br>    onChange = {<br>        viewModel.password = it<br>    },<br>    imeAction = ...<br>    <strong>visualTransformation = PasswordVisualTransformation(),</strong><br>   <strong> keyboardType = KeyboardType.Password,</strong><br>    keyBoardActions = ...<br>)</pre><p>Let’s also add the <strong>Visibility Toggle</strong> icon button to show/hide password like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*s34Dr0YbMCAI6Z-fep-vNg.gif" /></figure><pre><strong><em>var </em>isPasswordVisible <em>by remember { mutableStateOf</em>(<em>false</em>) }</strong></pre><pre>AppTextField(<br>    ....,<br>    <strong>leadingIcon = {<br>        IconButton(onClick = {<br>            isPasswordVisible = !isPasswordVisible<br>        }) {<br>            Icon(<br>             imageVector = <em>if </em>(isPasswordVisible) <br>               Icons.Filled.Visibility <br>             <em>else <br>               </em>Icons.Filled.VisibilityOff,<br>            contentDescription = &quot;Password Visibility&quot;<br>            )<br>        }<br>    },</strong></pre><pre><strong>   visualTransformation = <em>if </em>(isPasswordVisible)           <br>                            VisualTransformation.None <br>                         <em>else  <br>                            </em>PasswordVisualTransformation(),</strong><br>    ...<br>)</pre><p>Please note that in order to use these icons you will need the following dependency</p><pre>implementation &quot;androidx.compose.material:material-icons-extended:$compose_version&quot;</pre><h4>Mobile Number Field</h4><p>Same like plain text field but with phone keyboard type</p><pre>keyboardType = KeyboardType.Phone,</pre><p>Let’s add the <strong>Country Code Picker </strong>to the text field as following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*fzCTPehcG0-Zs9-s9x2BEw.gif" /></figure><p>And let’s add the selected country code label to the text field as a leading label</p><pre>leadingIcon = {<br>    viewModel.mobileCountry?.<em>let </em>{<br>        <strong>CountryPickerView(            <br>            countries = viewModel.countriesList<br>            selectedCountry = it,<br>            onSelection = { selectedCountry -&gt;<br>                viewModel.mobileCountry = selectedCountry<br>            },<br>        )</strong><br>    }<br>},</pre><p>Using <a href="https://gist.github.com/hkawii/453f905474acade1bcc1993b92ca914e">CountryPickerUtils.kt</a> , the viewmodel will hold the needed states as usual</p><pre><em>val </em>countriesList = <em>getCountriesList</em>()<br><em>var </em>mobileCountry <em>by mutableStateOf</em>&lt;Country?&gt;(<em>null</em>)</pre><p>And the CountryPickerView composable can be like this</p><pre>@Composable<br><em>fun </em>CountryPickerView(<br>    selectedCountry: Country,<br>    onSelection: (Country) -&gt; Unit,<br>    countries: <em>List</em>&lt;Country&gt;<br>) {<br>    <em>var </em>showDialog <em>by </em>remember { <em>mutableStateOf</em>(<em>false</em>) }<br>    <em>Text</em>(<br>        modifier = Modifier<br>            .<em>clickable </em>{<br>                showDialog = <em>true<br>            </em>}<br>            .<em>padding</em>(start = 20.<em>dp</em>, end = 5.<em>dp</em>),<br>        text = &quot;${<em>getFlagEmojiFor</em>(selectedCountry.nameCode)} +${selectedCountry.code}&quot;<br>    )<br><br>    <em>if </em>(showDialog)<br>        <em>CountryCodePickerDialog</em>(countries, onSelection) {<br>            showDialog = <em>false<br>        </em>}<br>}</pre><p>And this is a very simple implementation of CountryCodePickerDialog, absolutely enhance the design as needed according to your app design</p><pre>@Composable<br><em>fun </em>CountryCodePickerDialog(<br>    countries: <em>List</em>&lt;Country&gt;,<br>    onSelection: (Country) -&gt; Unit,<br>    dismiss: () -&gt; Unit,<br>) {<br>    <em>Dialog</em>(onDismissRequest = dismiss) {<br>        <em>Box </em>{<br>            <em>LazyColumn</em>(<br>                Modifier<br>                    .<em>fillMaxWidth</em>()<br>                    .<em>padding</em>(horizontal = 30.<em>dp</em>, vertical = 40.<em>dp</em>)<br>                    .<em>background</em>(shape = <em>RoundedCornerShape</em>(20.<em>dp</em>), color = Color.White)<br>            ) {<br>                <em>for </em>(country <em>in </em>countries) {<br>                    item {<br>                        Text(<br>                            modifier = Modifier<br>                                .<em>clickable </em>{<br>                                    onSelection(country)<br>                                    dismiss()<br>                                }<br>                                .<em>fillMaxWidth</em>()<br>                                .<em>padding</em>(10.<em>dp</em>),<br>                            text = &quot;${<em>getFlagEmojiFor</em>(country.nameCode)} ${country.fullName}&quot;<br>                        )<br>                    }<br>                }<br>            }<br>        }<br>    }<br>}</pre><h4><strong>Date Picker Field</strong></h4><p>It will show a date picker dialog like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*KZae2ksfc344PEIBfx9tpg.gif" /></figure><pre><em>val </em>context = <em>LocalContext</em>.current<br>AppTextField(<br>    modifier = Modifier.<em>clickable </em>{<br><strong>        viewModel.showDatePickerDialog(context)<br></strong>    },<br>    text = viewModel.dateOfBirth,<br>    placeholder = &quot;Birthdate&quot;,<br>    onChange = {<br>        viewModel.dateOfBirth = it<br>    },<br><strong>    isEnabled = <em>false</em></strong><em><br></em>)</pre><p>The date dialog will either show today’s date or the last selected date in the dateOfBirth state variable</p><pre><em>private var </em>dateFormat = &quot;yyyy-MM-dd&quot;</pre><pre><em>fun </em>showDatePickerDialog(context: Context) {<br>    <em>val </em>calendar = getCalendar()<br>    DatePickerDialog(<br>        context, { _, year, month, day -&gt;<br>            dateOfBirth = getPickedDateAsString(year, month, day)<br>        },<br>        calendar.get(Calendar.<em>YEAR</em>),<br>        calendar.get(Calendar.<em>MONTH</em>),<br>        calendar.get(Calendar.<em>DAY_OF_MONTH</em>)<br>    )<br>        .show()<br>}</pre><pre><em>private fun </em>getCalendar(): Calendar {<br>    <em>return if </em>(dateOfBirth.<em>isEmpty</em>())<br>        Calendar.getInstance()<br>    <em>else<br>        </em>getLastPickedDateCalendar()<br>}<br><br><br><em>private fun </em>getLastPickedDateCalendar(): Calendar {<br>    <em>val </em>dateFormat = SimpleDateFormat(dateFormat)<br>    <em>val </em>calendar = Calendar.getInstance()<br>    calendar.<em>time </em>= dateFormat.parse(dateOfBirth)<br>    <em>return </em>calendar<br>}<br><br><em>private fun </em>getPickedDateAsString(year: Int, month: Int, day: Int): String {<br>    <em>val </em>calendar = Calendar.getInstance()<br>    calendar.set(year, month, day)<br>    <em>val </em>dateFormat = SimpleDateFormat(dateFormat)<br>    <em>return </em>dateFormat.format(calendar.<em>time</em>)<br>}</pre><h4>Image Picker</h4><ul><li>Pick Image From Gallery</li><li>Capture Image From Camera</li></ul><p>First we will enable user to <strong>pick image from gallery</strong> as following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*I_mrLYLpFQ5z3t4v6515vw.gif" /></figure><p>First import coil compose library</p><pre>implementation &quot;io.coil-kt:coil-compose:1.4.0&quot;</pre><p>and keep the picked image uri in the view model</p><pre><em>val </em>pickedImage = <em>mutableStateOf</em>&lt;Uri?&gt;(<em>null</em>)</pre><p>Add the image picker view to the form view</p><pre><em>ImagePickerView</em>(<br>    modifier = Modifier.<em>align</em>(Alignment.CenterHorizontally),<br>    lastSelectedImage = viewModel.pickedImage.value,<br>    onSelection = {<br>        viewModel.pickedImage.value = it<br>    }<br>)</pre><p>To pick image from gallery the ImagePickerView composable will use the gallery launcher like this</p><pre>@Composable<br><em>fun </em>ImagePickerView(<br>    modifier: <em>Modifier </em>= Modifier,<br>    lastSelectedImage: Uri?,<br>    onSelection: (Uri?) -&gt; Unit<br>) {<br><strong>    <em>val </em>galleryLauncher = rememberLauncherForActivityResult(<br>       ActivityResultContracts.GetContent()) {<br>           onSelection(it)<br>    }</strong><br>    Image(<br>        modifier = modifier<br>            .<em>size</em>(100.<em>dp</em>)<br>            .<em>clip</em>(<em>CircleShape</em>)<br>            .<em>background</em>(Color.LightGray)<br>            .<em>clickable </em>{<br><strong>                galleryLauncher.launch(&quot;image/*&quot;)<br></strong>            },<br><strong>        painter = rememberImagePainter(lastSelectedImage),<br></strong>        contentDescription = &quot;Profile Picture&quot;,<br>        contentScale = ContentScale.Crop<br>    )<br>}</pre><p>Now to <strong>capture image from camera </strong>as following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*65Q_beTYZZ0NMYQ_CR1-Fg.gif" /></figure><p>First let’s handle camera permission using <a href="https://github.com/google/accompanist">Accompanist</a> library and import it</p><pre>implementation &quot;com.google.accompanist:accompanist-permissions:0.24.1-alpha&quot;</pre><p>And add the camera permission to the app manifest file</p><pre>&lt;uses-permission <em>android:name</em>=&quot;android.permission.CAMERA&quot; /&gt;</pre><p>Now let’s update the ImagePickerView composable to</p><ul><li>Request permission</li><li>Open camera launcher ( If permission is just granted or on click)</li></ul><pre>@OptIn(ExperimentalPermissionsApi::<em>class</em>)<br>@Composable<br><em>fun </em>ImagePickerView(<br>    modifier: <em>Modifier </em>= Modifier,<br>    lastSelectedImage: Uri?,<br>    onSelection: (Uri?) -&gt; Unit<br>) {<br>    <em>val </em>context = <em>LocalContext</em>.current<br><strong>    <em>val </em>cameraPermission = <em>rememberPermissionState</em>(Manifest.permission.<em>CAMERA</em>)</strong><br>    <em>var </em>isPermissionRequested <em>by </em>rememberSaveable { <em>mutableStateOf</em>(<em>false</em>) }<br><br><strong>    <em>val </em>cameraLauncher: ManagedActivityResultLauncher&lt;Void?, Bitmap?&gt; =<br>rememberLauncherForActivityResult(ActivityResultContracts.TakePicturePreview()) {<br>            onSelection(it?.<em>toUri</em>(context))<br>        }</strong><br><br>    <em>if </em>(isPermissionRequested &amp;&amp; cameraPermission.hasPermission) {<br><strong>        cameraLauncher.<em>launch</em>()<br></strong>        isPermissionRequested = <em>false<br>    </em>}<br><br>    Image(<br>        modifier = modifier<br>            .<em>size</em>(100.<em>dp</em>)<br>            .<em>clip</em>(<em>CircleShape</em>)<br>            .<em>background</em>(Color.LightGray)<br>            .<em>clickable </em>{<br>              <strong>  <em>if </em>(!cameraPermission.hasPermission) {<br>                    cameraPermission.launchPermissionRequest()<br>                    isPermissionRequested = <em>true<br>                </em>} <em>else<br>                    </em>cameraLauncher.<em>launch</em>()</strong><br>            },<br>        painter = rememberImagePainter(lastSelectedImage),<br>        contentDescription = &quot;Profile Picture&quot;,<br>        contentScale = ContentScale.Crop<br>    )<br>}</pre><p>Also please note that the accompanist permission state have <strong>shouldShowRationale </strong>which you can use to inform user why you need this permission before requesting it, Find more about this <a href="https://developer.android.com/training/permissions/requesting">here</a></p><h4>How to prevent keyboard from hiding textfield?</h4><p>With large form view with many text fields, probably the keyboard may cover the textfield, we can fix this as following</p><ul><li>In the manifest update the activity <em>windowSoftInputMode</em></li></ul><pre>&lt;activity<br>    <em>android:name</em>=&quot;.MainActivity&quot;<br><strong>    <em>android:windowSoftInputMode</em>=&quot;adjustResize&quot;<br></strong>    ... /&gt;</pre><ul><li>Include <a href="https://github.com/google/accompanist/tree/main/insets">Accompanist Insets</a> library to setup insets in your composables</li></ul><pre>implementation &quot;com.google.accompanist:accompanist-insets:0.24.1-alpha&quot;</pre><ul><li>Update your form composable to handle insets using <strong>ProvideWindowInsets &amp; navigationBarsWithImePadding </strong>as needed and make sure that the form parent composable is scrollable in this case</li></ul><pre>@Composable<br><em>fun </em>FormView() {<br>   <strong>ProvideWindowInsets {<br></strong>     Column(<br>         modifier = Modifier<br>             <strong>.<em>verticalScroll</em>(<em>rememberScrollState</em>())</strong><br>             <strong>.<em>navigationBarsWithImePadding</em>()</strong><br>     ) {<br>        ...<br>       }<br>   <strong>}</strong><br>}</pre><p>That’s it! You made it! 💪</p><p>Do you see anything missing? please comment!</p><p>Thanks for reading, see you in the next article 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bec9cde157e" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/the-big-form-with-jetpack-compose-7bec9cde157e">The Big Form with Jetpack Compose</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Map Address Picker With Jetpack Compose]]></title>
            <link>https://hebamekawi.medium.com/map-address-picker-with-jetpack-compose-9a6b852d4728?source=rss-9b4aee4fcb40------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a6b852d4728</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[google-maps]]></category>
            <dc:creator><![CDATA[Heba Mekawi]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 13:04:59 GMT</pubDate>
            <atom:updated>2022-02-26T02:38:24.371Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1guoTJA3wSW_alyXEqL8Ig.jpeg" /></figure><p>Today we’re going to make a simple address map screen with Jetpack Compose &amp; MVVM</p><p>The screen will enable user to enter his address with dragging the map OR enter the address text in a textfield which will be translated to a location on the map too, ie :</p><ul><li>From map to textfield</li><li>From textfield to map</li></ul><p>User can choose how to enter his address using the upper corner button, it’ll enable/disable address entry / map dragging</p><p>The final completed project github repository is shared below 👇</p><h4><strong>Let’s do it..</strong></h4><p>But first I’d like thank <a href="https://github.com/joreilly">John O’Reilly</a> for sharing his project <a href="https://github.com/joreilly/GalwayBus">GalwayBus</a>, it really helped a lot to create this example, thank you :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Yz_4yZnMl_IbHS8KeANIBw.gif" /></figure><h4>MapViewContainer</h4><p>It is a simple container for the MapView &amp; responsible for</p><ul><li>Set initial location</li><li>On map drag, trigger the view model with the new location</li><li>Disable map dragging when needed</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b36616aca52ba6a24c5c95c260d7f05/href">https://medium.com/media/0b36616aca52ba6a24c5c95c260d7f05/href</a></iframe><h4>Display address in the textfield</h4><p>On location change</p><ul><li>Viewmodel will use the Geocoder to extract the address line from the captured location latitude &amp; langitude</li><li>Set it to be the text of the textfield</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c76ad0690bc0bcc0d39a0e7395a91c62/href">https://medium.com/media/c76ad0690bc0bcc0d39a0e7395a91c62/href</a></iframe><p>Please note that this button is responsible for enable/disable edittext/map entry, and this is handled by a viewmodel boolean flag called <strong>isMapEditable</strong></p><h4>Display the entered address as a map location on the map</h4><p>On text change,</p><ul><li>Viewmodel will use the Geocoder to extract a location from the entered address text</li><li>Notify the view to update the map view according to it</li></ul><h4>MapView Update</h4><p>On location change the view will update the MapViewContainer according to it as following</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b7e8fc791425e076c639b0c35413966/href">https://medium.com/media/9b7e8fc791425e076c639b0c35413966/href</a></iframe><h4>MapPinOverlay</h4><p>In order to represent a simple map pin at the center of the view</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2dc6bfb40b59262e63254ec51b64d53/href">https://medium.com/media/c2dc6bfb40b59262e63254ec51b64d53/href</a></iframe><h4>The final complete project</h4><p>Here you can find the full example with view model implementation</p><p><a href="https://github.com/hkawii/Compose-Map-Address-Picker">GitHub - hkawii/Compose-Map-Address-Picker</a></p><p>That’s it for now, thanks for reading 😊</p><p>Don’t forget to subscribe to receive future articles 😎 Keep composing 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a6b852d4728" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>