<?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 Suha Baobaid on Medium]]></title>
        <description><![CDATA[Stories by Suha Baobaid on Medium]]></description>
        <link>https://medium.com/@suha.baobaid?source=rss-7e3f0484f4d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Bc6SUl6i7-UWyEfsiLNnnA@2x.jpeg</url>
            <title>Stories by Suha Baobaid on Medium</title>
            <link>https://medium.com/@suha.baobaid?source=rss-7e3f0484f4d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:35:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suha.baobaid/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[CustomTabNavigation — CodingChallenge #1]]></title>
            <link>https://medium.com/@suha.baobaid/customtabnavigation-codingchallenge-1-b2db1d978801?source=rss-7e3f0484f4d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2db1d978801</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ui-animation]]></category>
            <category><![CDATA[codingcallenges]]></category>
            <dc:creator><![CDATA[Suha Baobaid]]></dc:creator>
            <pubDate>Sun, 01 Jul 2018 13:27:47 GMT</pubDate>
            <atom:updated>2019-06-09T14:02:12.544Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Edit: Updated Version with latest RN (0.59.9) </strong><a href="https://github.com/suhabaobaid/ReactNativeChallenges"><strong>here</strong></a></p><blockquote><strong>“Unless you try to do something beyond what you have already mastered, you will never grow.” — Ronald W. Emerson</strong></blockquote><p>Everyone knows that in order to achieve greater things, one has to go beyond their comfort zone. This is why I am writing this, a start for some interesting and fun coding challenges. These challenges will be taken from weekly inspirations and my own implementation would be provided by the end of the week here as a post. I post the challenges in IG, so make sure you follow me there :) Everyone is welcome to join and implement the challenge with any programming language, framework, techniques they are most comfortable with and share it with me here or IG.</p><p>This week’s challenge is taken from <a href="https://tubikstudio.com/">Tubik Studio</a> with their design of the tap bar concept.</p><p>TL;DR here’s the code in <a href="https://github.com/suhabaobaid/ReactNativeChallenges/tree/custom-tab-navigation">github</a>.</p><h3>The design</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*6PssEjz0kNsEwsIAjXqHWA.gif" /><figcaption>GIF of the Tap Bar Concept</figcaption></figure><h3>The implementation — React Native</h3><p>I have decided to give React Native a go for this design’s implementation. Although React Native had many limitation regarding its support for animations previously, I found its animated API helpful to provide an approximate for this design. * (this implementation assumes prior knowledge in React Native)</p><ol><li>Creating the tab navigation</li></ol><p>First of all we need to create a tab navigation. There is no need to creating one from scratch, we can use <a href="https://reactnavigation.org/">react navigation</a> library. React navigation has an extensive API for creating different types of navigations and to customize it.</p><p>So, we will start by <a href="https://reactnavigation.org/docs/en/bottom-tab-navigator.html">creating a bottom tab navigator</a>.</p><pre>// imports <br>import FAwesomeIcon from &#39;react-native-vector-icons/FontAwesome&#39;;<br>import { createBottomTabNavigator } from &#39;react-navigation&#39;;</pre><pre>// Configs<br>const RouteConfig = {<br>  Saved: {<br>    screen: SavedScreen,<br>    navigationOptions: () =&gt; ({<br>      tabBarIcon: ({ tintColor }) =&gt; (<br>        &lt;FAwesomeIcon<br>          name=&quot;heart&quot;<br>          color={tintColor}<br>          size={size}<br>        /&gt;<br>      ),<br>    }),<br>  },<br>  ...</pre><pre>const BottomNavigatorConfig = {<br>  tabBarOptions: {<br>    activeTintColor: &#39;rgb(255,255,255)&#39;, //color when tab is active<br>    inactiveTintColor: &#39;rgb(89, 102, 139)&#39;,<br>    style: {<br>      backgroundColor: &#39;rgb(21, 31, 53)&#39;,<br>    },<br>  showLabel: false, // turn off tab labels<br>  },<br>};</pre><pre>export default createBottomTabNavigator(RouteConfig, BottomNavigatorConfig);</pre><ul><li>In the <strong>RouteConfig</strong>, we configure the screens to be directed to when the tab is pressed and each tab icon/label etc. We provide the icon element using <strong>tabBarIcon</strong> key in the <strong>navigationOptions</strong> method. <a href="https://github.com/oblador/react-native-vector-icons">React Native Vector Icons</a> is used to supply with the icons needed. The<strong> tintColor </strong>is a prop passed into the function from the <strong>BottomNavigatorConfig.</strong></li><li><strong>BottomNavigatorConfig </strong>provides the configuration for the tab navigator. labels are hidden using <em>showLabel: false </em>and the <strong>tintColor</strong> is taken from the <strong>activeTintColor / inactiveTintColor.</strong></li></ul><p>Then we have to add it to our main page or index.</p><pre>import React, { Component } from &#39;react&#39;;<br>import TabNavigator from &#39;./BottomTabNavigator&#39;;</pre><pre>class MainPage extends Component {<br>  render() {<br>    return(&lt;TabNavigator/&gt;);<br>  }<br>}</pre><pre>export default MainPage;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*H63l92jJXG_VZ9J8ZSfAHw.png" /><figcaption>BottomTabNavigator added</figcaption></figure><p>2. Adding a custom tab button</p><p>To create the add Button in the middle we need to create a custom component and add it to our BottomTabNavigator.</p><p>First let’s add the custom component <strong>AddButton </strong>to our list of screens in the <strong>RouteConfig.</strong></p><pre><em>// Import components<br></em>import AddButton from &#39;./components/AddButton&#39;;</pre><pre>const RouteConfig = {<br>  ...<br>  add: {<br>    screen: ChatScreen,<br>    navigationOptions: () =&gt; ({<br>      tabBarButtonComponent: () =&gt; (<br>        &lt;AddButton/&gt;<br>      ),<br>    }),<br>  },<br>  ...<br>};</pre><ul><li>Custom tab bar components can be provided by using the <strong>tabBarButtonComponent</strong>.</li></ul><p>Now, we can create our AddButton component</p><pre><em>// native<br></em>import React, { Component } from &#39;react&#39;;<br>import { TouchableOpacity, View, StyleSheet } from &#39;react-native&#39;;<br>import FAwesomeIcon from &#39;react-native-vector-icons/FontAwesome&#39;;</pre><pre>class AddButton extends Component {<br>  render() {<br>    return(<br>      &lt;View&gt;<br>        &lt;TouchableOpacity<br>          style={style.bigBubble}          <br>          hitSlop={{<br>            top: 20,<br>            bottom: 20,<br>            left: 20,<br>            right: 20,<br>          }}<br>          onPress={this.handleAdduButtonPress}&gt;<br>          &lt;FAwesomeIcon<br>            name=&quot;plus&quot;<br>            size={35}<br>            color=&quot;#FFF&quot;<br>          /&gt;<br>        &lt;/TouchableOpacity&gt;<br>      &lt;/View&gt;<br>    );<br>  }<br>}</pre><pre>const style = StyleSheet.create({<br>  bigBubble: {<br>    justifyContent: &#39;center&#39;,<br>    alignItems: &#39;center&#39;,<br>    backgroundColor: bubbleColor,<br>    height: bigBubbleSize,  <br>    width: bigBubbleSize,<br>    borderRadius: bigBubbleSize / 2, <br>    top: -30,<br>    position: &#39;absolute&#39;<br>  },<br>});</pre><pre>export default AddButton;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*SINM7GafVyimLHvH-oK7vg.png" /><figcaption>AddButton added</figcaption></figure><ul><li><strong>TouchableOpacity </strong>is used to wrap around the component with an implementation of onPress.</li><li>Position of the element is ‘absolute’ to have it a bit sliding downwards to give the same figure as the design.</li><li><strong>hitSlop</strong> is added to make the add button be easily pressed.</li><li><strong>bigBubbleSize </strong>is a constant to be changed according to preferences.</li></ul><p>3. Adding smaller buttons with the animation</p><p>This is where Animated API comes in hand. We need to animate 3 main transformations, which are the transition of the smaller buttons when the addButton is pressed outwards, the add button rotation and the elastic (gooey) effect as the smaller button leaves/enters the addButton.</p><ul><li>Create smaller buttons and animate the outward movement + the rotation of the add button</li></ul><pre>import { Animated } from &#39;react-native&#39;; // additional import</pre><pre>class AddButton extends Component {<br>  ...<br>  constructor(props){<br>    super(props);    <br>    this.topLeftValue = new Animated.Value(0); // for the small button        <br>    this.topCenterValue = new Animated.Value(0);<br>    this.topRightValue = new Animated.Value(0);<br>    this.animatedValue = new Animated.Value(0); // for the add button<br>  }</pre><pre>  handleAddButtonPress = () =&gt; {<br>    this.animate(1);<br>  }</pre><pre>animate = (toValue) =&gt; {<br>    Animated.stagger(delay,[<br>      Animated.parallel([<br>        Animated.timing(<br>          this.animatedValue,<br>          {<br>            toValue,<br>            duration: animateTime, <br>            easing: Easing.exp,<br>          }<br>       ),<br>       Animated.timing(<br>         this.topLeftValue,<br>         { <br>           toValue,<br>           duration: animateTime,<br>           easing: easingType,<br>         }<br>       ),<br>     ]),<br>     Animated.timing(<br>       this.topLeftValue,<br>       { <br>         toValue,<br>         duration: animateTime,<br>         easing: easingType,<br>       }<br>     ),<br>     Animated.timing(<br>       this.topLeftValue,<br>       { <br>         toValue,<br>         duration: animateTime,<br>         easing: easingType,<br>       }<br>     ),<br>    ]).start();<br>  }</pre><pre>render(){<br>    return(<br>      ...<br>      &lt;View&gt;<br>        &lt;Animated.View<br>          style={[ <br>            style.bigBubble,<br>            {<br>              transform: [<br>                {rotateZ: springValue.interpolate({<br>                   inputRange: [0, 1, 2, 3],<br>                   outputRange: [&#39;-45deg&#39;, &#39;-45deg&#39;, &#39;0deg&#39;, &#39;45deg&#39;],<br>                 }),<br>                },<br>               {scaleY: springValue.interpolate({<br>                  inputRange: [0, 0.65, 1, 1.65, 2, 2.65, 3],<br>                  outputRange: [1, 1.1, 1, 1.1, 1, 1.1, 1],<br>                }),<br>               },<br>             ],<br>           },<br>        ]}<br>       &gt;<br>       &lt;TouchableOpacity<br>         hitSlop={{<br>            top: 20,<br>            bottom: 20,<br>            left: 20,<br>            right: 20,<br>          }}<br>        &gt;<br>          &lt;Animated.View<br>            style={{<br>              transform: [<br>                {rotateZ: springValue.interpolate({<br>                   inputRange: [0, 1, 2, 3],<br>                   outputRange: [&#39;45deg&#39;, &#39;45deg&#39;, &#39;45deg&#39;, &#39;0deg&#39;],<br>                  }),<br>                }, <br>              ],<br>            }}<br>          &gt;<br>            &lt;FAwesomeIcon <br>              name=&quot;plus&quot;<br>              size={35}<br>              color=&quot;#FFF&quot;<br>            /&gt;</pre><pre>         &lt;/Animated.View&gt;</pre><pre>         &lt;/TouchableOpacity&gt;<br>      &lt;/Animated.View&gt;<br>      ...</pre><pre>    );<br>  }<br>}</pre><ul><li><strong>animate() </strong>function called when the addButton is pressed. <strong>Animated.stagger</strong> is used to have each of the Animated value created in the constructor to starting a thread to a value 1 sequentially with a delay between each (note: You could use Animated.sequence if you want the values to start after each has finished). The <strong>Animated.parallel</strong> is used the leftmost button (small top left button) and the rotation of the addButton icon.</li><li><strong>springValue</strong> is created by adding all the small buttons Animated values to create the scaling effect for the <strong>addButton </strong>when each smaller button leaves/enter the <strong>addButton. </strong>This effect to be replacing the goeey effect in the design as React Native doesn’t support svg filters yet. I have implemented the gooey effect in similar manner in css using svg filters <a href="https://codepen.io/suhabaobaid/pen/ERrWNe">here</a>. (note: for some reason safari doesn’t support the colormatrix for the filters to work. Please try the codepen code in chrome or firefox. If you were able to make it work in safari, let me know ;) )</li><li>the small buttons have transformations of <strong>translateX</strong> and <strong>translateY</strong> for the movement. <strong>Opacity</strong> is also animated. <strong>zIndex</strong> as the small buttons are initially residing in the middle of the addButton, so to enable the press of the addButton. You can also change the initial positioning of the small buttons and get rid of the <strong>zIndex</strong>.</li><li><strong>animateReverse </strong>method is added to the code to have the reverse animation of the button transitions and the rotation of the icons.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*jSQatodyYdMfECksrLTyOA.gif" /><figcaption>Result</figcaption></figure><h3>Conclusion</h3><p>We managed to make an approximate of the design with React Native. Hope it was an interesting challenge and an enjoyable one. (Note: there is an issue with Android as the animated buttons don&#39;t appear beyond the bottomTabNavigator. An update is in progress)</p><p>Note: this is my first post in medium, so I would appreciate feedback to improve future posts. And if you have any questions/improvements don’t hesistate to drop a response.</p><p>Have an awesome week ahead and stay tuned for the next challenge …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2db1d978801" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>