<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SAQ</title>
    <description>The latest articles on DEV Community by SAQ (@swair_aq).</description>
    <link>https://dev.to/swair_aq</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F351797%2Faaf8e6f8-99bc-4641-b54d-8c1269255d3e.jpg</url>
      <title>DEV Community: SAQ</title>
      <link>https://dev.to/swair_aq</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swair_aq"/>
    <language>en</language>
    <item>
      <title>Custom colors in React-Native</title>
      <dc:creator>SAQ</dc:creator>
      <pubDate>Wed, 26 May 2021 17:54:40 +0000</pubDate>
      <link>https://dev.to/swair_aq/custom-colors-in-react-native-19b5</link>
      <guid>https://dev.to/swair_aq/custom-colors-in-react-native-19b5</guid>
      <description>&lt;h1&gt;
  
  
  Pop-up your app’s brand.
&lt;/h1&gt;

&lt;p&gt;Obviously, you’ll be using multiple colors in your app but the question is how to make color usage effective and optimized.&lt;/p&gt;

&lt;p&gt;We’ll be quickly adding colors to our react-native application.&lt;br&gt;
First thing first define hierarchy of your app and know where you want your color file to be, I like to keep in utilities/config folder and name it as Color.js&lt;/p&gt;

&lt;p&gt;Now open your newly made file and start defining your colors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Colors =
{}
export default Colors;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We made a simple “Colors” object and exported it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Colors =
{
AQUA_GREEN: '#1A5276',
RED: '#B03A2E',
ORANGE: '#DC7633',
PURPLE: '#8E44AD',
GRAY: '#566573',
}
export default Colors;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can put Hex, rgba, rgb whatever sails your boat, I like to work mostly with hex unless need to control opacity.&lt;/p&gt;

&lt;p&gt;Now save it and go back to your App.js or wherever:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Colors from './src/utilites/Color'
after importing Colors you can use as you please..
&amp;lt;Text style={{
backgroundColor: Colors.AQUA_GREEN,
color: Colors.ORANGE
}}&amp;gt;
{HELLO_WORLD}
&amp;lt;/Text&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&amp;amp; that’s practically it.&lt;br&gt;
The main advantage of using colors in separate files that it is: &lt;/p&gt;

&lt;ol&gt;
1- Maintainable.
2- Reusable.
3- Changeable.
&lt;/ol&gt;

&lt;p&gt;Like say, if you want to change the shade of red a tone you won’t have to go in each file changing it, you can easily change it in your file &amp;amp; it’ll be applied to whole app.&lt;br&gt;
&lt;/p&gt;
&lt;center&gt; ** Automated ** &lt;/center&gt;
&lt;br&gt;
Kidding lol, anyway, I have this series of easy customization things for your react-native app. If you want me to cover anything in this series do let me know in comments below.&lt;br&gt;
Until next time!

&lt;p&gt;P.S: Drop a heart, I just like that notification. 👇&lt;/p&gt;

&lt;p&gt;Here's a link to github repo:&lt;br&gt;
&lt;a href="https://github.com/swairAQ/CustomizationReactNative"&gt;https://github.com/swairAQ/CustomizationReactNative&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Youtube tutorial:&lt;br&gt;
&lt;a href="https://youtu.be/NEX_eQR-mEY"&gt;https://youtu.be/NEX_eQR-mEY&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>customization</category>
      <category>javascript</category>
      <category>colors</category>
    </item>
    <item>
      <title>React-Native dropdown search-bar</title>
      <dc:creator>SAQ</dc:creator>
      <pubDate>Fri, 02 Apr 2021 07:03:10 +0000</pubDate>
      <link>https://dev.to/swair_aq/react-native-dropdown-search-bar-2kjh</link>
      <guid>https://dev.to/swair_aq/react-native-dropdown-search-bar-2kjh</guid>
      <description>&lt;p&gt;If you are like me who wanted an absolute dropdown view of searchbar results and didn’t have any luck and google directed you to this deserted article then cheers&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F500%2F0%2A6qBLLkbRWCH110Co.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F500%2F0%2A6qBLLkbRWCH110Co.gif" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had a hard time finding a library or component which gave such results, there are dropdown but they will push the previous view below, surely don’t want that (or maybe I’m failing at being a programmer and don’t know how to query google right).&lt;br&gt;
I didn’t use any third party libraries just to make it plain and simple but you can use BlurView to make the background faded a bit for a classy look, here’s a simple tutorial to add &lt;a href="https://swairaq.medium.com/react-native-blur-overlay-1ca75d39baae" rel="noopener noreferrer"&gt;Blurview&lt;/a&gt;, promoting my other articles like an Arab should. 😁&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xlysl707yiz000biko2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xlysl707yiz000biko2.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;center&gt;This fanky thing is what you’ll get at the end&lt;/center&gt;
&lt;br&gt;
Okay, Im not really a design and great UI person but you can personalize it how you want and your designer has already handed over a design to you or you won’t be showing results in a dropdown.&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkzx9sw7m247gb44tyhg2.gif" alt="gotcha 2"&gt; &lt;br&gt;
Okay, let’s get coding…&lt;br&gt;
&lt;em&gt;App.js:&lt;/em&gt;&lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function App() {
return (
&amp;lt;View style={styles.container}&amp;gt;
&amp;lt;TextInput
style={styles.textInput}
placeholder="Search"
placeholderTextColor='white'
onChangeText={onSearch}
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here let’s declare some variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [dataSource] = useState(['apple', 'banana', 'cow', 'dex', 'zee', 'orange', 'air', 'bottle'])
const [filtered, setFiltered] = useState(dataSource)
const [searching, setSearching] = useState(false)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;dataSource&lt;/em&gt;&lt;/strong&gt; is to hold main data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;filtered&lt;/em&gt;&lt;/strong&gt; array is to hold searched data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;searching&lt;/em&gt;&lt;/strong&gt; flag is to define if user is searching or not(need it to show dropdown)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First initialize your component make it class or function whatever you want, I prefer functional components for God knows what reason, and we’re gonna mimic functionality of searchbar with a textinput, it’s great to use TextInput for search because you can customize it to endless posibilites whereas searchbar libraries limit you one way or another and then there’s no need to add a heavy library with this that components and increase your app size.&lt;br&gt;
Here we simply provided a search placeholder and onChangeText event to our component.&lt;/p&gt;
&lt;center&gt;…&lt;/center&gt;
&lt;br&gt;
Okay I'm not attaching my random UI components code snippet, obvi you don’t need this but if you need something to try it on here’s the link to repo copy the whole code from there: &lt;a href="https://github.com/swairAQ/DropdownSearch" rel="noopener noreferrer"&gt;Code Snippet&lt;/a&gt;&lt;br&gt;
Okay, we’ll pause our screen here and go on to make a separate file for dropdown, I named it “SearchDropDown” but whatever, simply make a function there and return a plain view for now we’ll get to it later.&lt;br&gt;
Now import this component to your main file &lt;em&gt;App.js&lt;/em&gt;:&lt;br&gt;
&lt;code&gt;import SearchDropDown from './app/component/SearchDropDown'&lt;/code&gt;

&lt;p&gt;Alright, here’s the deal now at the end of your whole view, I MEAN IT, the whole thing at the very bottom of your return statement go ahead and call your dropdown component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{/* Add all your components here or replace all this code to your components. */}
{/* and at the end of view */}
{
searching &amp;amp;&amp;amp;
&amp;lt;SearchDropDown
onPress={() =&amp;gt; setSearching(false)}
dataSource={filtered} /&amp;gt;
}
&amp;lt;/View&amp;gt;
)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we used our flag searching to show our component when user will be searching it’ll be displayed and not otherwise.&lt;br&gt;
In our component we’re pausing an array to dataSource prop, it’s the filtered search result that we want to display in our dropdown list.&lt;br&gt;
Now let’s head to functionality of search:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const onSearch = (text) =&amp;gt; {
if (text) {
setSearching(true) //to show dropdown make it true
const temp = text.toLowerCase() //making text lowercase to search
//filter main dataSource and put result in temp array
const tempList = dataSource.filter(item =&amp;gt; {
if (item.match(temp))
return item
})
//at the end of search setFiltered array to searched temp array.
setFiltered(tempList)
}
//if nothing was searched
else {
setSearching(false) //set searching to false
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flddz6mir8w9tf7c9wbqb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flddz6mir8w9tf7c9wbqb.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, our basically functionality is complete, now we need to design our UI to display our dropdownlist, heading over to&lt;br&gt;
&lt;em&gt;SearchDropDown.js&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function SearchDropDown(props) {
const { dataSource } = props //take data from parent
return (
//main container to position list over parent.
&amp;lt;TouchableOpacity onPress={props.onPress} style={styles.container}&amp;gt;
&amp;lt;View style={styles.subContainer}&amp;gt;
{
//if search results matched it'll have some length.
dataSource.length ?
//then show results
dataSource.map(item =&amp;gt; {
return (
&amp;lt;View style={styles.itemView}&amp;gt;
&amp;lt;Text style={styles.itemText}&amp;gt;{item}&amp;lt;/Text&amp;gt;
&amp;lt;/View&amp;gt;
)
})
//if there were no results show no result text instead of empty view
:
&amp;lt;View
style={styles.noResultView}&amp;gt;
&amp;lt;Text style={styles.noResultText}&amp;gt;No search items matched&amp;lt;/Text&amp;gt;
&amp;lt;/View&amp;gt;
}
&amp;lt;/View&amp;gt;
&amp;lt;/View&amp;gt;
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make it further smooth we replaced parent view with Touchableopacity and used a callback method from parent it’ll close the search view on clicking anywhere empty on screen.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fixaeexhd6gtdo2ra799d.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fixaeexhd6gtdo2ra799d.gif" alt="1_v1SMqJAGkZbOY2lmt2tadg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;center&gt; Here are final results&lt;/center&gt; 

&lt;p&gt;&lt;em&gt;That's all folks!&lt;/em&gt;&lt;br&gt;
Here’s a link to Github repo &lt;a href="https://github.com/swairAQ/DropdownSearch" rel="noopener noreferrer"&gt;https://github.com/swairAQ/DropdownSearch&lt;/a&gt;, running source code.&lt;br&gt;
There are many things that can go right but it’s upto you to sync this basic snippet to your app design and flow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Happy codi….. Drop your heart first!!!&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Happy coding!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>searchbar</category>
      <category>customization</category>
      <category>javascript</category>
    </item>
    <item>
      <title>COVID-19 and WORK FROM HOME?</title>
      <dc:creator>SAQ</dc:creator>
      <pubDate>Wed, 15 Apr 2020 14:35:12 +0000</pubDate>
      <link>https://dev.to/swair_aq/covid-19-and-work-from-home-28ci</link>
      <guid>https://dev.to/swair_aq/covid-19-and-work-from-home-28ci</guid>
      <description>&lt;p&gt;WFH is nothing new for IT people and especially for developers, we've been doing this as long as we can recall and to some point it's our dream way of working. As exciting as WFH sounds, it can overwhelm you and in this quarantine it can tire you up.&lt;/p&gt;

&lt;p&gt;If you want to make the best of your time, there are some rules to that, I know you are pro of isolation but believe me on this one.. :D&lt;/p&gt;

&lt;p&gt;1- Keep your WFH studio designated.&lt;br&gt;
2- Complete your WFH setup, have your system, screens, accessories, test devices and any other thing you may need.&lt;br&gt;
3- Keep some plant near you. (Please do that) It makes sure of fresh oxygen and help your strained eyes from all those dark-modes.&lt;br&gt;
4- Keep a bottle of water near you, it's important to stay hydrated.&lt;br&gt;
5- Now that your setup is complete, take pictures of your setup and don't forget to post it on social media cause I know everyone's gonna laaave it.&lt;br&gt;
6- Take breaks. Short and more.&lt;br&gt;
7- Take your dog out for a walk.&lt;br&gt;
8- Don't apologize if your pet jumps into your video conference, everyone needs that.&lt;br&gt;
9- Keep your working hours limited, I know your gonna get the lead to that error you've been stuck on whole day at time of leaving but you gotta drop it till tomorrow, leave the work at designated time. If you're gonna work long hours in start you're gonna be so sick of this WFH shortly.&lt;br&gt;
10- Give time to your family.&lt;br&gt;
11- On the topic of family, as important as it is to spend time with them it's also important you keep them away during working hours to keep your concentration. &lt;br&gt;
12- If you want to spice up your daily video calls, add snap camera and apply some cool filters. &lt;/p&gt;

&lt;p&gt;And that's a wrap. If I missed any points that you find helpful in your WFH please comment below.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Gradient Effect in React-Native</title>
      <dc:creator>SAQ</dc:creator>
      <pubDate>Wed, 15 Apr 2020 14:21:33 +0000</pubDate>
      <link>https://dev.to/swair_aq/gradient-effect-in-react-native-4hob</link>
      <guid>https://dev.to/swair_aq/gradient-effect-in-react-native-4hob</guid>
      <description>&lt;p&gt;Gradients add a very modern touch to your mobile apps, specially to button backgrounds.&lt;/p&gt;

&lt;p&gt;To add this we'll use react-native-linear-gradient cause it's totally designed for gradients, lightweight and allows both top-bottom and left-right gradient effects.&lt;/p&gt;

&lt;p&gt;To install library run&lt;br&gt;
    npm install react-native-linear-gradient --save&lt;br&gt;
and for iOS:&lt;br&gt;
    $ cd ios &amp;amp;&amp;amp; pod install &amp;amp;&amp;amp; cd ..&lt;br&gt;
as it installs all the pod dependencies to your project, make sure to restart your packager after making any changes on native side.&lt;br&gt;
Now let's go code… &lt;/p&gt;

&lt;p&gt;import the library to your file:&lt;br&gt;
import LinearGradient from 'react-native-linear-gradient';&lt;br&gt;
// Within your render function&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
    My Gradient Button&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
...&lt;/p&gt;

&lt;p&gt;// Later on in your styles..&lt;br&gt;
var styles = StyleSheet.create({&lt;br&gt;
linearGradient: {&lt;br&gt;
flex: 1,&lt;br&gt;
paddingLeft: 15,&lt;br&gt;
paddingRight: 15,&lt;br&gt;
borderRadius: 5&lt;br&gt;
},&lt;br&gt;
buttonText: {&lt;br&gt;
fontSize: 18,&lt;br&gt;
fontFamily: 'Gill Sans',&lt;br&gt;
textAlign: 'center',&lt;br&gt;
margin: 10,&lt;br&gt;
color: '#ffffff',&lt;br&gt;
backgroundColor: 'transparent',&lt;br&gt;
},&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;Above code will add a top-bottom gradient of shades of blue to your button styled text. Simple as that, you have to just pass array of colors you want your gradient as.&lt;/p&gt;

&lt;p&gt;That was easy, now see what can we do if we need a left-right or vice versa. For that LinearGradient give us start and end property where you can define axis.&lt;/p&gt;

&lt;p&gt;//in return statement&lt;br&gt;

style={height: '100%'}&lt;br&gt;
activeOpacity={0.9}&lt;br&gt;
onPress={() =&amp;gt; console.log('Beep Beep')}&lt;br&gt;
style={ width: 312,&lt;br&gt;
height: '17.5%',&lt;br&gt;
marginBottom: '3%'&lt;br&gt;
}&amp;gt;&lt;br&gt;

start={x: 1, y: 0} //here we are defined x as start position&lt;br&gt;
end={x: 0, y: 0} //here we can define axis but as end position&lt;br&gt;
colors={['#3393E4', '#715886']}&lt;br&gt;
style={&lt;br&gt;
height: '100%',&lt;br&gt;
justifyContent: 'center',&lt;br&gt;
alignItems: 'center',&lt;br&gt;
borderRadius: 5,&lt;br&gt;
}&amp;gt;&lt;br&gt;
 Log in &lt;br&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Here we developed a react-native button with gradient effect. You can play around with axis to meet your desires. Here's output of above code:&lt;/p&gt;

&lt;p&gt;Yeyyy!!!&lt;br&gt;
And that's a wrap. If you find any difficulties ping me. If you like the article high-five.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>reactnative</category>
      <category>gradient</category>
    </item>
  </channel>
</rss>
