<?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 Stuart Paul on Medium]]></title>
        <description><![CDATA[Stories by Stuart Paul on Medium]]></description>
        <link>https://medium.com/@stuartpaul007?source=rss-5145c4cf656b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cmkkXXwcNlZ2TVT-FLtz1A.jpeg</url>
            <title>Stories by Stuart Paul on Medium</title>
            <link>https://medium.com/@stuartpaul007?source=rss-5145c4cf656b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 06:39:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stuartpaul007/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[Build a bottom navigation bar with simple micro-interaction example]]></title>
            <link>https://stuartpaul007.medium.com/build-a-bottom-navigation-bar-with-simple-micro-interaction-example-1cf8a4c45e72?source=rss-5145c4cf656b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cf8a4c45e72</guid>
            <category><![CDATA[microinteractions]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Stuart Paul]]></dc:creator>
            <pubDate>Tue, 12 Jan 2021 08:40:40 GMT</pubDate>
            <atom:updated>2021-01-12T09:44:16.975Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build a bottom navigation bar with a simple micro-interaction example</h3><p>Including micro-interactions in your app always helps your user to be more engaged in the app process, so any app developer should learn a few tricks to keep the users busy while the app is running some heavy tasks, but always remember to keep it subtle.</p><p>So recently I saw <a href="https://www.linkedin.com/posts/kshitij-anand-happy_adobexd-uiuxdesign-uidesigner-ugcPost-6751611907700011008-5Mgw">one such micro-interaction design </a>for a bottom navigation bar in social media and thought of building it in Flutter.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fdeterminedbrokenherring&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fdeterminedbrokenherring&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FDeterminedBrokenHerring-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1416" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9ab71eb6a998b6d976466c688207f75/href">https://medium.com/media/f9ab71eb6a998b6d976466c688207f75/href</a></iframe><p>So let&#39;s start building!</p><p>As you can see, this design contains two main parts, one is the bottom navigation icon which shows a shadow while highlighted, and another is the tube-light-like container on top of the current icon, which when combined together gives a good experience. Also, the top container moves along the top smoothly so we have to play with animation a little.</p><p>Before going further, to specify the dimensions of each widget and also to make it fit in any screens, I have used a method in which I first get the screen width and height of the device, and divide it into blocks (let&#39;s say a hundred). So any dimensions are specified in terms of these blocks, rather than giving it a static value. This part is specified in <strong>SizeConfig</strong> class, and we call it whenever required.</p><p><strong>SizeConfig</strong> class:</p><pre>class SizeConfig{<br><br>  static MediaQueryData <em>_mediaQueryData</em><strong>;<br>  </strong>static double <em>screenWidth</em><strong>;<br>  </strong>static double <em>screenHeight</em><strong>;<br>  </strong>static double <em>blockSizeHorizontal</em><strong>;<br>  </strong>static double <em>blockSizeVertical</em><strong>;<br><br>  </strong>void init (BuildContext context){<br><br>    <em>_mediaQueryData</em>=MediaQuery.<em>of</em>(context)<strong>;<br>    </strong><em>screenWidth </em>=<em>_mediaQueryData</em>.size.width<strong>;<br>    </strong><em>screenHeight</em>=<em>_mediaQueryData</em>.size.height<strong>;<br>    </strong><em>blockSizeHorizontal</em>=<em>screenWidth</em>/<strong>100;<br>    </strong><em>blockSizeVertical</em>=<em>screenHeight</em>/<strong>100;<br><br>  </strong>}<br>}</pre><p>Now coming back, first build the base container for the navigation bar, give it the necessary padding to make it float. For icons, let&#39;s create a separate class <strong>BottomNavButton</strong>, where we specify how the icon should behave when clicked. Here we pass a function <strong>onPressed </strong>to specify on click changes, icon-data for each icon, and index of each container, and the index of the current container.</p><p>The icon is wrapped with <strong>AnimatedOpacity </strong>and the opacity is changed from 1 to 0.2</p><p>We need a shadow for the icon that is selected currently, so we use the <strong>Positioned </strong>widget to the left and bottom to align another icon behind and wrap it in the stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*mbebOOk4Nwfo8g8k41A-kw.jpeg" /></figure><p><strong>BottomNavButton </strong>class:</p><pre>class BottomNavButton extends StatelessWidget {<br><br>  final Function(int) onPressed<strong>;<br>  </strong>final IconData icon<strong>;<br>  </strong>final int index<strong>;<br>  </strong>final int currentIndex<strong>;<br><br>  </strong>BottomNavButton({this.icon<strong>,</strong>this.onPressed<strong>,</strong>this.index<strong>,</strong>this.currentIndex<strong>, </strong>Key key}) : super(key: key)<strong>;<br><br>  </strong>@override<br>  Widget build(BuildContext context) {<br>    SizeConfig().init(context)<strong>;<br>    </strong>return InkWell(<br>      onTap: (){<br>        onPressed(index)<strong>;<br>      </strong>}<strong>,<br>      </strong>child: Container(<br>        height: SizeConfig.<em>blockSizeHorizontal</em>*<strong>13,<br>        </strong>width: SizeConfig.<em>blockSizeHorizontal</em>*<strong>17,<br>        </strong>decoration: BoxDecoration(<br>          color: Colors.<em>transparent</em><strong>,<br>        </strong>)<strong>,<br>        </strong>child: Stack(<br>          alignment: Alignment.<em>center</em><strong>,<br>          </strong>children: [<br><br><br>            (currentIndex == index) ?<br>            Positioned(<br>              left: SizeConfig.<em>blockSizeHorizontal</em>*<strong>4,<br>              </strong>bottom:  SizeConfig.<em>blockSizeHorizontal</em>*<strong>1.5,<br>              </strong>child: Icon(<br>              icon<strong>,<br>              </strong>color: Colors.<em>black</em><strong>,<br>              </strong>size: SizeConfig.<em>blockSizeHorizontal</em>*<strong>8,<br>            </strong>)<strong>,</strong>):Container()<strong>,<br><br>            </strong>AnimatedOpacity(<br>              opacity: (currentIndex == index) ? <strong>1 </strong>: <strong>0.2,<br>              </strong>duration: Duration(milliseconds: <strong>300</strong>)<strong>,<br>              </strong>curve: Curves.<em>easeIn</em><strong>,<br>              </strong>child: Icon(<br>                icon<strong>,<br>                </strong>color: Colors.<em>yellow</em>[<strong>300</strong>]<strong>,<br>                </strong>size: SizeConfig.<em>blockSizeHorizontal</em>*<strong>8,<br>              </strong>)<strong>,<br>            </strong>)<strong>,<br>          </strong>]<strong>,<br>        </strong>)<strong>,<br>      </strong>)<strong>,<br>    </strong>)<strong>;<br>  </strong>}<br>}</pre><p>So we have successfully finished the first part, and now we have a bottom navigation bar with icons animated on click, but it&#39;s not completed until we create a tube-light container on top. As you can see from the first image the light should fade from top to bottom and should have a trapezium shape. So we use clipper <strong>MyCustomClipper, </strong>to specify the shape. This clipper is wrapped around the container in which we specify gradient values from top to bottom.</p><p><strong>MyCustomClipper </strong>class:</p><pre>class MyCustomClipper extends CustomClipper&lt;Path&gt; {<br>  @override<br>  Path getClip(Size size) {<br>    var path = Path()<strong>;<br>    </strong>path.lineTo(SizeConfig.<em>blockSizeHorizontal</em>*<strong>3, 0</strong>)<strong>;<br>    </strong>path.lineTo(<strong>0, </strong>size.height)<strong>;<br>    </strong>path.lineTo(size.width<strong>, </strong>size.height)<strong>;<br>    </strong>path.lineTo( size.width - SizeConfig.<em>blockSizeHorizontal</em>*<strong>3 , 0</strong>)<strong>;<br><br>    </strong>return path<strong>;<br>  </strong>}<br><br>  @override<br>  bool shouldReclip(CustomClipper&lt;Path&gt; oldClipper) {<br>    return true<strong>;<br>  </strong>}<br>}</pre><p>Now finally we wrap this entire widget with <strong>AnimatedPositioned </strong>and it is left alignment is changed as per the current index.</p><p>Inside <strong>HomeScreen </strong>class<strong>:</strong></p><pre>AnimatedPositioned(<br>  duration: Duration(milliseconds: <strong>300</strong>)<strong>,<br>  </strong>curve: Curves.<em>decelerate</em><strong>,<br>  </strong>top: <strong>0,<br>  </strong>left:<br>  (_currentIndex == <strong>0 </strong>) ? SizeConfig.<em>blockSizeHorizontal</em>*<strong>5.5 </strong>:<br>  (_currentIndex == <strong>1 </strong>) ? SizeConfig.<em>blockSizeHorizontal</em>*<strong>22.5 </strong>:<br>  (_currentIndex == <strong>2 </strong>) ? SizeConfig.<em>blockSizeHorizontal</em>*<strong>39.5 </strong>:<br>  (_currentIndex == <strong>3 </strong>) ? SizeConfig.<em>blockSizeHorizontal</em>*<strong>56.5  </strong>:<br>  (_currentIndex == <strong>4 </strong>) ? SizeConfig.<em>blockSizeHorizontal</em>*<strong>73.5 </strong>: <strong>0,<br><br>  </strong>child: Column(<br>    children: [<br>      Container(<br>        height: SizeConfig.<em>blockSizeHorizontal</em>*<strong>1.0,<br>        </strong>width: SizeConfig.<em>blockSizeHorizontal</em>*<strong>12,<br>        </strong>decoration: BoxDecoration(<br>            color: Colors.<em>yellow</em><strong>,<br>            </strong>borderRadius: BorderRadius.circular(<strong>10</strong>)<strong>,<br>        </strong>)<strong>,<br>      </strong>)<strong>,<br>      </strong>ClipPath(<br>        clipper: MyCustomClipper()<strong>,<br>        </strong>child: Container(<br>          height: SizeConfig.<em>blockSizeHorizontal</em>*<strong>15,<br>          </strong>width: SizeConfig.<em>blockSizeHorizontal</em>*<strong>12,<br>          </strong>decoration: BoxDecoration(<br>              gradient: LinearGradient(<br>                  begin: Alignment.<em>topCenter</em><strong>,<br>                  </strong>end: Alignment.<em>bottomCenter</em><strong>,<br>                  </strong>colors: [<br>                    Colors.<em>yellow</em>.withOpacity(<strong>0.8</strong>)<strong>,<br>                    </strong>Colors.<em>yellow</em>.withOpacity(<strong>0.5</strong>)<strong>,<br>                    </strong>Colors.<em>transparent<br>                  </em>]<br>              )<br>          )<strong>,<br>        </strong>)<strong>,<br>      </strong>)<strong>,<br>    </strong>]<strong>,<br>  </strong>)<br>)</pre><p>And that’s it !! We have successfully built our bottom navigation bar, and it will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*-whkJqAc3Ggun6JTgrPHAQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*pISKdIoYftuD1iNPTnPYxg.jpeg" /></figure><p>You can check the source code here:</p><p><a href="https://bitbucket.org/StuartPaul7/bottom-navigation-bar-custom/src/master/">Bitbucket</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cf8a4c45e72" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>