<?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 Beny Liantriana on Medium]]></title>
        <description><![CDATA[Stories by Beny Liantriana on Medium]]></description>
        <link>https://medium.com/@benyliantriana?source=rss-a23ecc9c8b16------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-gdWhJyl0i5kovg07LV1fw.jpeg</url>
            <title>Stories by Beny Liantriana on Medium</title>
            <link>https://medium.com/@benyliantriana?source=rss-a23ecc9c8b16------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:47:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@benyliantriana/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[Unidirectional Data Flow]]></title>
            <link>https://medium.com/@benyliantriana/unidirectional-data-flow-a0e619697413?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0e619697413</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[unidirectional-data-flow]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Mon, 09 Dec 2024 03:48:00 GMT</pubDate>
            <atom:updated>2024-12-09T03:48:00.435Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kevxZVW0jWB_1rXGtnda4A.png" /><figcaption>Unidirectional Data Flow</figcaption></figure><h3>Basic Knowledge of UDF</h3><p>Unidirectional data flow (known as UDF) is a technique that mainly found in functional reactive programming. It known also as one-way data flow, which mean the data has one and only one way to be transferred to other parts of the application.</p><p>The unidirectional means we don’t get our data by request it directly. The only way we get our data is we trigger an action from our view to our data layer then the side effect of this action is updating our data state.</p><p>The view is a result of the application state. State can only change by triggering actions. When actions happen, the state is updated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VmwLotj3gWg2dgjBAj9lsA.png" /><figcaption>View-State-Action</figcaption></figure><h3>UDF in MVVM</h3><p>From the basic knowledge of UDF, we should declare the Action Class for actions and UIState Class for states that bound to the view layer. Generally, the Action Class and UIState Class are created from sealed class.</p><p>In my opinion, there are two approach to implement UDF in MVVM. First, we fully use sealed class Action to define our actions. Every action that used to change the UIState is grouped by the feature or the variable that responsible to the UIState change (ex: Assessment, Curriculum, User, etc). Then in the view model layer we mapping the action to the specific function that responsible to triggered action.</p><p>The example of this approach:</p><p>UserAction.kt</p><pre>sealed class UserAction {<br>    object UserGetData : UserAction()<br>    data class UserUpdateData(<br>        val user: User<br>    ) : UserAction()<br>}</pre><p>UserUIState.kt</p><pre>sealed class UserUIState {<br>    object Loading : UserUIState()<br>    data class Error(val error: String) : UserUIState()<br>    data class SuccessFetchData(val user: User) : UserUIState()<br>    data class SuccessUpdateData(val user: User) : UserUIState()<br>}</pre><p>In the view model class we define a function that map the UserAction</p><pre>fun onUserAction(action: UserAction) {<br>    when (action) {<br>        is UserAction.UserGetData -&gt; {<br>            // call fun getDataUser()<br>        }<br>        is UserAction.UserUpdateData -&gt; {<br>            // call fun getDataUser(action.user)<br>        }<br>    }<br>}</pre><p>Then in the view layer we call this function</p><pre>fun foo() {<br>    viewModel.onUserAction(UserAction.UserGetData) // or other action<br>}</pre><p>In the view layer are observe the LiveData variable that bound to the UserUIState</p><pre>private fun onUserLoadedData(state: UserUIState) {<br>    when (state) {<br>        is UserUIState.SuccessFetchData -&gt; {<br>            // call fun setDataUser<br>        }<br>        is UserUIState.Error -&gt; {<br>            // call fun showError<br>        }<br>        ...<br>    }<br>}</pre><p>The second approach of implement UDF in MVVM pattern is we not define our actions in sealed class, instead we call the each function that responsible for every actions in the view model layer and the rest are quite same.</p><p>The example of this approach:</p><p>UserViewModel.kt</p><pre>fun userGetData() {<br>  ..<br>}</pre><pre>fun userUpdateData(user: User) {<br>  ..<br>}</pre><p>Then in the view layer we call the functions</p><pre>private fun foo() {<br>    viewModel.userGetData()<br>}</pre><pre>private fun foo2(user: User) {<br>    viewModel.userUpdateData(user: User)<br>}</pre><p>Then we use the LiveData UIState variable and observe it on the view layer</p><p>UserUIState.kt</p><pre>sealed class UserUIState {<br>    object Loading : UserUIState()<br>    data class Error(val error: String) : UserUIState()<br>    data class SuccessFetchData(val user: User) : UserUIState()<br>    data class SuccessUpdateData(val user: User) : UserUIState()<br>}</pre><pre>private fun onUserLoadedData(state: UserUIState) {<br>    when (state) {<br>        is UserUIState.SuccessFetchData -&gt; {<br>            // call fun setDataUser<br>        }<br>        is UserUIState.Error -&gt; {<br>            // call fun showError<br>        }<br>        ...<br>    }<br>}</pre><h3>UDF in Jetpack Compose</h3><p>If we look from the documentation, the concept of UDF that implemented on the Jetpack Compose is quite same. On the Jetpack Compose the Action is called Event. The view trigger the event, then the view model change the state. The composable function will automatically recompose itself when a state is change. This process will shown on this image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UMJSGcj7A6E-ebZDjoH48A.png" /><figcaption>Jetpack Compose Cycle</figcaption></figure><h3>UDF in Clean Architecture</h3><p>In our android app project, we already implemented clean architecture. Our each module is consist of View — View Model — Use Case — Repository — Data Source. Clean architecture basically make our data flow is unidirectional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QhLuplTGb4OGs13DVzxNTg.png" /><figcaption>Clean Architecture</figcaption></figure><p>The only thing we should adjust to implement UDF is on connection between View and View Model. Then we should check our View Layer and View Model Layer. On the View Model Layer, some variables are accessed directly from View Layer and we need to adjust these variable. To implement fully UDF to our android app we should refactor these variables and functions to MutableLiveData — LiveData or MutableStateFlow — StateFlow and observe it from the View Layer. Use SingleLiveEvent to variable that only consume once. Use function to update these observe-able variable.</p><h3>Discussion</h3><p>Unidirectional data flow is really flexible. So we need to discuss about our limit of using this approach. These are things that we could move using UDF-approach:</p><ul><li>SnackBar, Toast -&gt; Use SingleLiveEvent</li><li>Index item view pager -&gt; Use LiveData / Flow</li><li>Navigation -&gt; Use LiveData / Flow</li><li>Permission -&gt; Use SingleLiveEvent</li><li>Dialog -&gt; Use LiveData / Flow</li><li>Loading -&gt; Use LiveData / Flow</li><li>Error (SnackBar, Toast, Page, Dialog) -&gt; Use LiveData / Flow</li><li>Validation (Text Field, Form) -&gt; Use LiveData / Flow</li><li>Calculation [Any form of logics] -&gt; Move to ViewModel</li></ul><p>The mindset of UDF is make View Layer is know nothing about logic, calculation, and business. The View Layer only trigger events to get any form of logic or data to View Model Layer and show any response or feedback state from View Model Layer. The View Model Layer is responsible to any form of logic, calculation, and business.</p><h3>Conclusion</h3><p>The Unidirectional Data Flow is really interesting concept where our View Layer know nothing about logic and business. View Layer can only trigger event and passively show any data or state from View Model Layer. Even we have to write more codes, implementing UDF make us know how our data flows so debugging process are more easy and we have a better control how our data flows so we can make our logic more efficient.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0e619697413" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Makes You a Great Programmer?]]></title>
            <link>https://medium.com/@benyliantriana/what-makes-you-a-great-programmer-d0f3cbc17016?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0f3cbc17016</guid>
            <category><![CDATA[progamming]]></category>
            <category><![CDATA[technology-trends]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Wed, 18 Mar 2020 03:59:11 GMT</pubDate>
            <atom:updated>2020-03-18T08:17:18.721Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*DaMyPAHxlqLKcgAB-TVEuQ.jpeg" /><figcaption>Image from: <a href="https://badoystudio.com/wp-content/uploads/2018/11/apa-itu-programmer-750x410.jpeg">https://badoystudio.com</a></figcaption></figure><p>Anyone can become a programmer. An experienced programmer can become a good programmer. But what makes you a great programmer?</p><p>But before we talk about how become a great programmer, let’s talk about become a programmer and a good programmer.</p><p>To become a programmer you need to learn about a programming language and if your code works, you are a programmer! As simple as that. And to become a good programmer you need some experience about how to code better. Maybe in your first app / program you made it from a spaghetti code. Then you learn to code better, faster, simpler, and cleaner. After that, if your code is improved you can called yourself a good programmer (at least in your mind, lol).</p><p>And now, what makes you a great programmer? What is the differences of a good programmer and a great programmer? And these are what make the programmer great.</p><h3><strong>Positive Attitude</strong></h3><p>A great programmer is not only know how to program best but also know about their product. They are very dedicated about the product and has a positive mindset. They also patient about the problems that happened in the development process or the product itself. And they make their code easy to read and easy to understand. They also have ability to accept the critics if something goes wrong or needs to be improved.</p><h3>Communication Skills</h3><p>A great communication skills are required by a programmer to make their products success. They can breakdown about how to make their product works as intended, know what problems that may occurred in the future and provide a solution for that.</p><p>In a meeting, they can understand what the product team talking and can asking the right question about the topic. They also can explain and teach the team how to make this product works as intended or maybe how to code better.</p><h3>Time and Task Management</h3><p>A great programmer can manage all their tasks, and completed it in the deadlines. Before they work, they always calculate the time they needed to complete the tasks. If they think it’s not possible then they talk dirrectly to the scrum master or product team that the tasks are not possible to complete in a sprint and tell them why it’s not possible.</p><h3>Good Team Player</h3><p>Becoming the good team player is really required in a software development team. A great programmer always make decision what best for the user and the team in the development process. They always do what make their team at their best and always improving the team to become better. So, a good team player makes a good team and a good team makes the product better.</p><h3>User-oriented</h3><p>They are not only make their team at their best but also make the best for their user. Every decisions are make based-on their user even it’s hard for the team. They always think what make their product better, easier to use, and works as intended for user.</p><h3>Quick Learning Ability</h3><p>The technology is growing rapidly, so the programmers need to keep it up with the update. They need to learn about what’s new as fast as possible. Then they know what’s good and what’s bad about new techology so they can decide what best for their product.</p><h3>Deep and Broad Technical Experience</h3><p>Experience makes the programmer become an expert. So with the experience, a programmer can notice what’s wrong with their problem by looking from the pattern and know how to solve it. Broad technical experience can bring something new to discuss to team like new language, new architecture, etc.</p><h3>Ability to Plan</h3><p>When the team discuss about how to make their product. A great programmer will analize and make the plan about how to split the work for the team so the development process can be run as expected. And they know what’s required by the team to make the product.</p><h3>Willingness to Research</h3><p>Research is very important to make the product better. Research is not only about the new tech but also the older generation of tech. Maybe we can find something that we needed from the past generation instead of new generation of tech. Research is not only about tech but also about the product itself.</p><h3>Laziness</h3><p>Maybe some will not agree with this, but the lazy people tend to find the quickest and most efficient way to solve the problem.</p><p>Thanks for reading and stay healthy :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0f3cbc17016" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I am Moving to Kotlin from React Native]]></title>
            <link>https://medium.com/@benyliantriana/why-i-am-moving-to-kotlin-from-react-native-696124b882e3?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/696124b882e3</guid>
            <category><![CDATA[storytelling]]></category>
            <category><![CDATA[experience]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Sat, 29 Dec 2018 05:10:46 GMT</pubDate>
            <atom:updated>2018-12-29T05:10:46.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*YK5PLgDKciZ0J66Ilvb9wQ.png" /><figcaption>image by http://kotlinlang.org</figcaption></figure><p>First of all, React Native is very unique framework to develop an app in multiple platform. In one project code we can generate app in iOS and Android (why I write this? everybody knows about it). The community of react native is very large and almost everybody contributes to this framework’s development. And very popular!</p><p>Kotlin also has it’s own community. But I don’t think that the Kotlin community is larger than React Native in Indonesia. I join the both community channel in telegram and the React Native community is more people, more active, and more ideas about how to code best on the platform. Maybe because React Native is not very stable yet. I don’t know for sure.</p><p>Now back to the topic, why I am moving to Kotlin. Yes, because i move to another company! Haha. Join to the one of the unicorns company is something! Yes I move to Bukalapak. We use kotlin here.</p><p>Before I decide to join Bukalapak, I apply to the both marketplace unicorn, Tokopedia and Bukalapak. I am write Tokopedia first because I apply to Tokopedia before Bukalapak. Both of them is very large company with more than 1000 employees. I am really confused which company should I join. Kotlin is very unknown to me but I am familliar with java. React Native is more than OK to me but sometimes we need to hacky or tricky to make it works. But after some thoughts I decide to join Bukalapak because I think it’s more challenging to do something unknown.</p><p>After I join the company, I started to learn Kotlin. It’s like java but easier. Need time to get used to it. After a while, I understand little by little to code in this language and started to contribute to the company.</p><p>I still have a lot of things to learn about Kotlin and I hope, I can mastered it as fast as I can.</p><p>Last thing, being part of something big is very mixing feeling. The joy, the thrilling, the fear, and the fun become one. But overall it’s very fun to become part of it. I hope I can contribute in this company for a long time!!</p><p>Happy New Year Everybody!! :D :D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=696124b882e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pengenalan Flutter.io Bagi Developer React]]></title>
            <link>https://medium.com/skyshidigital/flutter-io-416c63020732?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/416c63020732</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Wed, 16 May 2018 07:34:48 GMT</pubDate>
            <atom:updated>2018-05-23T01:35:34.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*BMzIIlft5Sk_nQrxUyoaWw.jpeg" /><figcaption>Image by: <a href="https://codefluegel.com/">https://codefluegel.com/</a></figcaption></figure><p>Flutter adalah SDK untuk pengembangan aplikasi mobile yang dikembangkan oleh Google. Sama seperti <em>react native</em>, <em>framework</em> ini dapat digunakan untuk membuat atau mengembangkan aplikasi <em>mobile</em> yang dapat berjalan pada device iOS dan Android. Dibuat menggunakan bahasa C, C++, Dart and Skia membuat Flutter ini menjadi salah satu <em>framework</em> yang sangat menarik dan <em>worth</em> untuk kita pelajari. Hal yang menarik pada <em>framework</em> ini adalah semua kodenya di <em>compile </em>dalam kode native nya (Android NDK, LLVM, AOT-compiled) tanpa ada <em>intrepeter</em> pada prosesnya sehingga proses <em>compile</em>-nya menjadi lebih cepat. Dari segi penulisan kodenya, Flutter ini sangat berbeda dari <em>react native</em> dan lebih cenderung mendekati Java Android jadi untuk developer <em>react native</em> agak sedikit kesulitan untuk memahami kode pada Flutter ini.</p><h3>Instalasi</h3><p>Untuk instalasi pada artikel kali ini saya menggunakan device Mac jadi untuk windows dan Linux dapat mengikuti pada docs Flutter <a href="https://flutter.io/get-started/install/">disini</a>.</p><ul><li>Download SDK Flutter (pilih yang beta) <a href="https://flutter.io/sdk-archive/">disini</a></li><li>Kemudian extract SDK yang sudah di download tadi. SDK yang saya download versi 0.3.2-beta</li><li>Tambahkan pathflutter di terminal dengan command ini<br>export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH</li><li>Jalankan flutter doctor pada terminal untuk mengecek dependency. flutter doctor akan menampilkan depencency yang diperlukan dan langkah-langkah untuk menambahkan depencency tersebut.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*QjSfyyFntL2SmtK5REoxvA.png" /></figure><p>Apabila semua dependency yang diperlukan sudah ada maka sudah dapat membuat project Flutter ini.</p><h3>Create New Project</h3><p>Pada artikel kali ini saya menggunakan VS Code untuk membuat aplikasi sederhana menggunakan Flutter. Tambahkan plugin dart pada VS Code terlebih dahulu.</p><p>Untuk membuat project baru pada VS Code klik View &gt; Command Pallete dan ketik Flutter pilih new project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eaUyowoF2-xvNRsKF1e66Q.png" /></figure><p>Tuliskan nama project dan tunggu sampai proses nya selesai.</p><p>Pada project yang sudah kita buat akan ada folder libuntuk menuliskan kode program kita dalam ekstensi .dartdan file pubspec.yaml untuk menambahkan library. Klik Debug &gt; Start Debugging pada menu VS Code untuk menjalankan kode program kita. Pastikan ada emulator yang sudah berjalan atau device yang sudah pada mode debug yang terhubung. Setelah prosesnya selesai maka akan terlihat tampilan seperti ini pada emulator / device kita.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*aMID89Eam0Fdb9TNxTeRgQ.png" /></figure><p>Pada Flutter ini tersedia fungsi Hot Reload jadi apabila ada kode yang berubah pada emulator / device akan langsung otomatis memuat ulang kode yang baru. Namun apabila tidak otomatis memuat ulang kita dapat mengklik tombol refresh pada VS Code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*Fd-wRY1_RTXzl7LinFE4YQ.png" /></figure><p>Hapus dan gunakan kode ini untuk memulai dari awal dengan hello world agar menjadi lebih mudah untuk membaca kode nya.</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() =&gt; runApp(new MyApp());<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return new MaterialApp(<br>      title: &#39;Welcome to Flutter&#39;,<br>      home: new Scaffold(<br>        appBar: new AppBar(<br>          title: new Text(&#39;Welcome to Flutter&#39;),<br>        ),<br>        body: new Center(<br>          child: new Text(&#39;Hello World&#39;),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Aplikasi yang berjalan pada emulator/device menjalankan fungsi main() =&gt; runApp dan dapat kita lihat pada kode di atas bahwa kita menggunakan kelas MyApp dengan StatelessWidget yang berarti semua properti yang ada pada kelas ini bersifat <em>immutable </em>dan semua nilai value nya bersifat final. Apabila kelas kita digunakan di kelas lain maka kita menggunakan StatefulWidget. Widget build digunakan untuk membuat halaman pada aplikasi dengan MaterialApp untuk style UI nya. Scaffold merupakan code untuk membuat detail / konten rancangan UI nya.</p><h3>External Package</h3><p>Seperti yang sudah dijelaskan di atas bahwa untuk menggunakan <em>library</em> / <em>package </em>kita dapat menambahkan nama dan versi <em>library</em> pada file pubspec.yaml . Pada contoh kali ini kita akan mencoba menggunakan paket english_word versi 3.1.0 ke atas untuk meng-<em>generate</em> kata bahasa inggris secara acak.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  cupertino_icons: ^0.1.0<br>  english_words: ^3.1.0</pre><p>Tunggu sampai proses impor nya selesai dan dapat kita gunakan dengan cara import &#39;package:english_words/english_words.dart&#39;; untuk impor nya dan untuk meng-<em>generate</em> kata secara acak kita gunakan kode berikut:</p><pre>final wordPair = new WordPair.random();</pre><p>Ganti ‘Hello World’ dengan wordPair.asPascalCase sehingga code nya menjadi</p><pre>body: new Center(<br>          child: new Text(wordPair.asPascalCase),<br>        ),</pre><p>Kemudian pada aplikasi kita kata Hello World akan berubah menjadi kata yang acak. Apabila berubah maka penggunakan library eksternal berhasil!</p><h3>Stateful Widget</h3><p>Stateful Widget mengatur state yang mungkin terjadi selama widget digunakan (kalau di react mungkin component). Implementasi StatefulWidget memerlukan dua hal yaitu kelas StatefulWidget sendiri dan StateClass. Untuk lebih jelasnya kita langsung coba saja. Tambahkan kode berikut pada file main.dart dibawah kelas MyApp</p><pre>class RandomWords extends StatefulWidget {<br>  @override<br>  createState() =&gt; new RandomWordsState();<br>}</pre><p>Dan tambahkan kode ini</p><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    final wordPair = new WordPair.random();<br>    return new Text(wordPair.asPascalCase);<br>  }<br>}</pre><p>Hapus variable wordPair dan ubah kode pada body kelas MyApp menjadi berikut:</p><pre>body: new Center(<br>          child: new RandomWords(),<br>        ),</pre><p>Kalau kode yang dituliskan berhasil maka random word akan dibuat dari Stateful Widget yang kita buat tadi.</p><h3>ListView</h3><p>Langkah selanjutnya yaitu membuat ListView dari kelas Stateful Widget yang kita buat tadi.</p><ul><li>Tambahkan kode variable berikut untuk membuat array dari Wordpair (kata random) dan variabel untuk membuat teks menjadi lebih besar di bagian atas kelas RandomWordsState</li></ul><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  final _suggestions = &lt;WordPair&gt;[];<br><br>  final _biggerFont = const TextStyle(fontSize: 18.0);<br>  ... // kode yang sebelum nya<br>}</pre><ul><li>Tambahkan fungsi untuk ListView builder di bagian bawah kelas RandomWordsState</li></ul><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  ... // kode sebelumnya<br>  Widget _buildSuggestions() {<br>    return new ListView.builder(<br>      padding: const EdgeInsets.all(16.0),<br>      itemBuilder: (context, i) {<br>        if (i.isOdd) return new Divider();<br>        final index = i ~/ 2; <br>          // untuk mengecek kata yang masih tersedia</pre><pre>        if (index &gt;= _suggestions.length) {<br>          // kalau masih ada tambahkan ke list</pre><pre>          _suggestions.addAll(generateWordPairs().take(10));<br>        }<br>        return _buildRow(_suggestions[index]);<br>      }<br>    );<br>  }<br>}</pre><ul><li>Tambahkan kode ini di bawah kode diatas</li></ul><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  ... // kode sebelumnya<br><br>  Widget _buildRow(WordPair pair) {<br>    return new ListTile(<br>      title: new Text(<br>        pair.asPascalCase,<br>        style: _biggerFont,<br>      ),<br>    );<br>  }<br>}</pre><ul><li>Ubah kode Widget build pada kelas RandomWordsState</li></ul><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  ... // kode sebelumnya<br>  @override<br>  Widget build(BuildContext context) {<br>    return new Scaffold (<br>      appBar: new AppBar(<br>        title: new Text(&#39;Startup Name Generator&#39;),<br>      ),<br>      body: _buildSuggestions(),<br>    );<br>  }<br>  ... // kode setelahnya<br>}</pre><ul><li>Terakhir ubah kode Widget build pada kelas MyApp</li></ul><pre>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return new MaterialApp(<br>      title: &#39;Startup Name Generator&#39;,<br>      home: new RandomWords(),<br>    );<br>  }<br>}</pre><p>Jika kode dituliskan secara benar maka akan tampil list kata seperti dibawah ini:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*dddkOz3ui7jKj_bwRgw8Tg.png" /></figure><h3>onClick ListView</h3><p>Pada artikel kali ini akan diimplementasikan fungsi onClick untuk menyimpan kata. Untuk membuat fungsi ini ikuti langkah berikut</p><ul><li>Tambahkan variabel _saved di awal kelas RandomWordsState</li></ul><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  final _suggestions = &lt;WordPair&gt;[];<br><br>  final _saved = new Set&lt;WordPair&gt;(); // tambahkan ini<br><br>  final _biggerFont = const TextStyle(fontSize: 18.0);<br>  ... // kode selanjutnya<br>}</pre><ul><li>Pada fungsi _buildRow() tambahkan variable alreadySaved di awal fungsi dan Icon pada akhir fungsi</li></ul><pre>Widget _buildRow(WordPair pair) {<br>  final alreadySaved = _saved.contains(pair);<br>  return new ListTile(<br>    title: new Text(<br>      pair.asPascalCase,<br>      style: _biggerFont,<br>    ),<br>    trailing: new Icon(<br>      alreadySaved ? Icons.favorite : Icons.favorite_border,<br>      color: alreadySaved ? Colors.red : null,<br>    ),<br>  );<br>}</pre><ul><li>Selanjutnya tambahkan onTap (untuk onClick) dibawah trailing dan kodenya menjadi seperti ini:</li></ul><pre>Widget _buildRow(WordPair pair) {<br>  final alreadySaved = _saved.contains(pair);<br>  return new ListTile(<br>    title: new Text(<br>      pair.asPascalCase,<br>      style: _biggerFont,<br>    ),<br>    trailing: new Icon(<br>      alreadySaved ? Icons.favorite : Icons.favorite_border,<br>      color: alreadySaved ? Colors.red : null,<br>    ),<br>    onTap: () {<br>      setState(() {<br>        if (alreadySaved) {<br>          _saved.remove(pair);<br>        } else {<br>          _saved.add(pair);<br>        }<br>      });<br>    },<br>  );<br>}</pre><p>Jika berhasil maka tampilan app akan seperti ini:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*z09kReor8_VsLSTxWc6KqQ.png" /><figcaption>Setelah ada yang di klik / tap</figcaption></figure><h3>Navigation</h3><p>Yang terakhir adalah menambahkan navigasi sederhana pada aplikasi yang sudah kita buat tadi. Pada Flutter navigasi ini disebut dengan route dan pada artikel kali ini kita akan membuat routeuntuk halaman kata favorit yang kita klik tadi. Untuk implementasinya bisa ikuti langkah-langkah berikut</p><ul><li>Tambahkan tombol icon di appBar dibawah title pada kelas RandomWordsState</li></ul><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  ... // kode sebelumnya<br>  @override<br>  Widget build(BuildContext context) {<br>    return new Scaffold(<br>      appBar: new AppBar(<br>        title: new Text(&#39;Startup Name Generator&#39;),<br>        actions: &lt;Widget&gt;[<br>          new IconButton(icon: new Icon(Icons.list), onPressed: _pushSaved), // tambahkan ini<br>        ],<br>      ),<br>      body: _buildSuggestions(),<br>    );<br>  }<br>  ... // kode setelahnya<br>}</pre><ul><li>Tambahkan fungsi _pushSaved() pada kelas RandomWordsState</li></ul><pre>class RandomWordsState extends State&lt;RandomWords&gt; {<br>  ...<br>  void _pushSaved() {<br>  Navigator.of(context).push(<br>    new MaterialPageRoute(<br>      builder: (context) {<br>        final tiles = _saved.map(<br>          (pair) {<br>            return new ListTile(<br>              title: new Text(<br>                pair.asPascalCase,<br>                style: _biggerFont,<br>              ),<br>            );<br>          },<br>        );<br>        final divided = ListTile<br>          .divideTiles(<br>            context: context,<br>            tiles: tiles,<br>          )<br>          .toList();<br><br>        return new Scaffold(<br>          appBar: new AppBar(<br>            title: new Text(&#39;Saved Suggestions&#39;),<br>          ),<br>          body: new ListView(children: divided),<br>        );<br>      },<br>    ),<br>  );<br> }<br>}</pre><p>Jika berhasil maka halaman baru aplikasi kita akan terlihat seperti ini</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*1fkGno9r_1VkZHmUoI8qlA.png" /><figcaption>Halaman setelah icon di kana atas di klik</figcaption></figure><p>Untuk nama variabel dan fungsi harus memakai underscore (garis bawah) semisal _saved atau _pushSaved()</p><p>Sekian pengenalan framework Flutter ini semoga membantu :D</p><p>ref: <a href="https://flutter.io/get-started/codelab/">https://flutter.io/get-started/codelab/</a><br>git: <a href="https://github.com/benyliantriana/simpleflutter">https://github.com/benyliantriana/simpleflutter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=416c63020732" width="1" height="1" alt=""><hr><p><a href="https://medium.com/skyshidigital/flutter-io-416c63020732">Pengenalan Flutter.io Bagi Developer React</a> was originally published in <a href="https://medium.com/skyshidigital">SkyshiDigital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native vs Expo]]></title>
            <link>https://medium.com/skyshidigital/react-native-vs-expo-1859103861a0?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/1859103861a0</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Tue, 10 Apr 2018 07:57:43 GMT</pubDate>
            <atom:updated>2018-04-11T02:44:59.745Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N5eryViNa4Mz3H6PpBUUFw.png" /><figcaption>image by: Bhavis Hak’s Presentation</figcaption></figure><p>Pada artikel kali ini, saya tidak akan membahas secara detail tentang react native ataupun Expo. Artikel kali ini hanya membahas mengenai perbedaan ataupun pro dan kontra mengenai react native dengan Expo menurut pengalaman saya, kapan kita lebih baik menggunakan react native, kapan kita sebaiknya menggunakan Expo. Artikel ini dapat bersifat sangat subjektif.</p><h3>Introduction</h3><p>Secara singkat, react native merupakan framework javascript yang digunakan untuk mengembangkan aplikasi pada <em>smartphone</em>. Aplikasi yang dikembangkan dengan react native ini pada dasarnya dapat berjalan di ponsel berbasis Android dan IOS, hanya saja perlu sedikit penyesuaian untuk masing-masing OS nya. Sedangkan Expo adalah adalah framework berbasis react native yang digunakan juga untuk mengembangkan aplikasi dengan tujuan yang sama yaitu dapat berjalan pada Android dan IOS.</p><p>Expo merupakan satu set <em>tools</em>, <em>library</em>, dan <em>services </em>yang digunakan dalam pengembangan aplikasi. Pada dasarnya Expo dan react native ini sama dalam hal menuliskan kode program namun pengembangan aplikasi pada Expo dapat lebih cepat karna beberapa <em>tools, library, dan services</em> sudah disediakan oleh Expo. Untuk pro dan kontra pada Expo dapat dilihat pada list dibawah.</p><h3>My Experience</h3><p>Sebagai pengembang aplikasi dengan react native saya tertarik untuk mencoba menggunakan Expo (lebih tepatnya ada project yang harus menggunakan Expo ini). Meskipun saya agak gak <em>sreg</em> sama Expo ini jadi ya tetap memakai Expo. Yang bikin saya kurang yakin dengan Expo ini akan saya jelaskan nanti meskipun dalam pengembangan dan pengecekan apps nya menurut saya lebih mudah.</p><p>Singkat cerita, memang lebih cepat dalam project yang sudah saya kerjakan ini. Saya lebih menghemat waktu dalam pengembangannya. Fitur font, kamera, dan galeri sudah disediakan oleh Expo. Pengaturan AndroidManifest dan Info.plist juga sudah disediakan oleh Expo tinggal menambahkan pada file app.json dan tinggal direstart pada ExpoKit.</p><h3>Why use Expo?</h3><ul><li>Expo menggunakan Expo SDK jadi tidak memerlukan Android Studio dan Xcode</li><li>pengaturan aplikasi lebih mudah, bisa langsung ditambahkan pada file app.json, untuk lebih detail nya bisa dilihat <a href="https://docs.expo.io/versions/latest/workflow/configuration">disini</a></li><li>mode debug aplikasi dapat langsung di jalankan pada device dengan aplikasi Expo pada Android dan IOS (dengan membagikan link / qr code project)</li><li>beberapa fitur seperti Push Notification dan Facebook login sudah disediakan oleh Expo</li><li>beberapa library seperti maps, camera, dan gallery sudah di sediakan Expo sehingga tidak perlu menambahkan library dan dapat berjalan pada Android dan IOS</li><li>membuat versi rilis aplikasi lebih mudah karena dilakukan oleh server Expo (Expo akan memberikan link untuk mendownload versi rilis aplikasi kita)</li></ul><p>Menarik sekali ya kelebihan yang dimiliki Expo. Sampai pada akhirnya saya memerlukan library I18n untuk kamus <em>String</em> untuk aplikasi yang saya kerjakan. Untungnya, ada yang membuat library I18n ini untuk Expo, jadi saya terselamatkan dari keribetan. Namun saat sampai FCM saya baru merasakan Expo ini menyusahkan karena saya belum bisa mengimplementasikan fitur push notifikasinya.</p><h3>Why we should not use Expo?</h3><ul><li>Expo tidak mendukung native module sehingga beberapa library yang memerlukan react-native link tidak dapat berjalan pada aplikasi</li><li>aplikasi yang dibuat dengan Expo memiliki ukuran (size) yang besar sekitar 25 mb (pada react native sekitar 10mb)</li><li>Expo tidak mendukung background process sehingga fitur seperti tracking tidak dapat berjalan pada aplikasi</li><li>fitur push notification menggunakan server Expo sehingga dalam implementasi nya menjadi lebih rumit [?] (mungkin)</li></ul><p>Kemudian saya coba detach Expo sehingga saya dapat menggunakan native module react-native-fcm karena push notification ini memerlukan settingan khusus di level AndroidManifest dan react native link. Proses detach yang lumayan lama akhirnya sukses. Kemudian fitur-fitur yang dari Expo tidak dapat digunakan.</p><h3>Detaching Expo</h3><p>Expo memberikan kita fitur untuk melepaskan Expo dari project yang sudah kita buat. Expo akan mengunduh file-file project yang diperlukan dalam Android dan IOS sehingga setelah proses detach selesai akan terdapat folder android dan ios pada project kita yang kemudian kita dapat meneruskan project kita sebagai project react native biasa.</p><p>Setelah project kita detach maka kita harus mengatur file project kita sendiri seperti file credential dan SDK. Namun faktanya kita masih bergantung pada Expo SDK itu sendiri hanya saja kita perlu mengatur secara manual hal-hal yang diperlukan project kita.</p><blockquote>“We call this “detaching” because you still depend on the Expo SDK, but your project no longer lives inside the standard Expo client. You control the native projects, including configuring and building them yourself.”</blockquote><p>Setelah melakukan detach kita dapat menggunakan library-library yang menggunakan native module. Namun perlu diperhatikan, beberapa fungsi bawaan Expo tidak dapat berjalan pada file project yang sudah kita detach.</p><p>Saya kemudian mengganti kode untuk font, kamera, dan galeri. Tidak apalah, gak lama juga. Kemudian saya install react-native-fcm untuk push notifikasi dari firebase. Install nya sukses namun pada saat dipasang pada device tidak berhasil. Error depency google gms. Kemudian saya cek pada level android. Ternyata, masih terdapat file-file dari Expo yang lumayan banyak. Saya cek pada file gradle untuk mengecek duplikasi versi dependency google gms. Ternyata banyak dependency-dependency bawaan Expo yang masih ada pada file gradle tersebut. Hal inilah yang membuat aplikasi dari Expo memiliki <em>size</em> besar. Saya samakan versi gms pada react-native-fcm agar sama dengan bawaan Expo. Aplikasi sukses diinstal pada device.</p><p>Setelah aplikasi sukses diinstal pada device dilakukan testing pada semua fiturnya. Semua fiturnya dapat berjalan kecuali saat menerima notifikasi dari firebase. Saya cek berulang-ulang dan hasilnya tidak berhasil. React native fcm akan memanggil react activity pada saat menerima notifikasi sedangkan pada level android aplikasi tidak menggunakan react activity namun menggunakan activity dari Expo sehingga aplikasi akan langsung <em>crash</em> saat menerima notifikasi. Saya coba otak-atik native module react native fcm namun hasilnya sama, tetap <em>crash</em>.</p><h3>React Native vs Expo</h3><p>Expo merupakan pengembangan dari react native sehingga dari segi fungsional aplikasi kurang lebih sama. Expo lebih mudah dan lebih cepat dalam pengembangan aplikasi namun tidak semua fitur yang didukung oleh react native dapat dijalankan dalam expo. Native module merupakan salah satu hal yang sangat penting dalam pengembangan aplikasi meskipun tidak semua aplikasi memerlukan fitur tersebut.</p><p>Expo lebih cocok digunakan dalam pengembangan aplikasi sederhana yang tidak memerlukan kode pada level native module atau fitur-fitur dasar yang sudah didukung oleh Expo. Untuk fitur yang sudah didukung oleh Expo dapat dilihat <a href="https://docs.expo.io/versions/latest/">disini</a>.</p><p>React native lebih cocok digunakan untuk mengembangkan aplikasi yang tingkat kerumitannya diatas dari yang sudah didukung oleh Expo. React native mendukung kode berbasis native module sehingga kita dapat menambahkan fitur yang tidak didukung oleh react native namun masih di dukung oleh bahasa pemrograman dasar aplikasi (java untuk Android, swift untuk IOS) meskipun dalam implementasinya tidak mudah. Salah satu fitur yang tidak didukung Expo dan didukung react native adalah <em>bluetooth</em>.</p><p>Aplikasi dari react native memiliki <em>size </em>yang lebih kecil dibanding Expo. Hal ini juga menjadi pertimbangan dalam pengembangan aplikasi yang memiliki banyak fitur namun tetap dalam <em>size</em> yang wajar. <em>Size</em> aplikasi juga sangat mempengaruhi kinerja dari aplikasi yang telah kita buat.</p><p>Akhirnya saya memutuskan untuk membuat project baru dari react native dan mengkopi paste file js dari project yang dari Expo tadi. Kemudian aplikasi baru berjalan lancar tanpa <em>crash</em> :D</p><h3><strong>Conclusion</strong></h3><p>Expo menjadi rekomendasi dalam pengembangan aplikasi yang sederhana dan aplikasi dengan fitur yang sudah didukung oleh Expo. Untuk aplikasi yang lebih rumit tidak disarankan menggunakan Expo dan menggunakan react native saja. Detach bukan solusi untuk menambahkan fungsi native module pada aplikasi. Faktanya masih terdapat file-file bawaan Expo yang menurut saya tidak terlalu digunakan hanya memberatkan dan membuat beberapa library tidak <em>compatible.</em></p><p>Solusi terakhir untuk yang sudah terlanjur menggunakan Expo dan melakukan detach project dan masih terjadi crash, lebih baik membuat project baru dan memindahkan file js project Expo ke project react native.</p><p>Sekian dan terima kasih :D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1859103861a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/skyshidigital/react-native-vs-expo-1859103861a0">React Native vs Expo</a> was originally published in <a href="https://medium.com/skyshidigital">SkyshiDigital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy Way to Make Poligon Maps on React Native]]></title>
            <link>https://medium.com/skyshidigital/easy-way-to-make-poligon-maps-on-react-native-21d1d7ada2fb?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/21d1d7ada2fb</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Thu, 01 Feb 2018 04:02:53 GMT</pubDate>
            <atom:updated>2018-02-01T06:43:58.602Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*elCDr9SwksjoXvfpXFRpSw.png" /></figure><p>Pada postingan saya yang sebelumnya sudah kita bahas mengenai <a href="https://medium.com/skyshidigital/membuat-aplikasi-maps-menggunakan-react-native-maps-dan-react-native-google-places-autocomplete-aa1e060d29f6">implementasi google maps</a> dan <a href="https://medium.com/skyshidigital/maps-dan-google-places-autocomplete-pada-react-native-android-part-2-de54453a14a3">google places auto complete</a> pada react native. Dan pada postingan kali ini akan kita bahas cara mudah untuk membuat poligon dan mendapatkan jarak dan waktu dari dua titik area yang kita inginkan.</p><p>Pada percobaan ini saya menggunakan :</p><pre>&quot;@mapbox/polyline&quot;: &quot;^0.2.0&quot;,<br>&quot;react-native&quot;: &quot;0.50.4&quot;,<br>&quot;react-native-maps&quot;: &quot;0.16.4&quot;,</pre><p>Setelah depencencies di atas sudah dipasang pada project react native maka kita bisa langsung membuat component maps agar nantinya mudah untuk kita implementasi pada container kita.</p><p>Pada component maps ini saya gunakan koordinat kota Yogyakarta pada state myLocation dan kota Magelang pada state destination dalam contoh kali ini.</p><pre>constructor (props) {<br>  super(props)<br>  const region = {<br>     latitude: -7.7956,<br>     longitude: 110.3695,<br>     latitudeDelta: 0.02,<br>     longitudeDelta: 0.02<br>  }<br>  this.state = {<br>    region, // default region maps<br>    myLocation: {<br>       title: &#39;My Location&#39;,<br>       latitude: -7.7956,<br>       longitude: 110.3695<br>    },<br>    destination: {<br>       title: &#39;Destination&#39;,<br>       latitude: -7.4797,<br>       longitude: 110.2177<br>    },<br>    coords: [] // menampung array koordinat poligon<br>  }<br>}</pre><p>Setelah kita deklarasikan state kemudian kita bisa implementasi react native maps pada komponen maps ini.</p><pre>&lt;MapView<br>  ref=&#39;map&#39;<br>  style={{ flex: 1 }}<br>  initialRegion={this.state.region}<br>&gt;<br>  {this.renderMapMarkers(this.state.myLocation)}<br>  {this.renderMapMarkers(this.state.destination)}<br>  &lt;MapView.Polyline<br>    coordinates={this.state.coords} // array koordinat poligon<br>    strokeWidth={2} // ketebalan poligon<br>    strokeColor=&#39;red&#39; // warna poligon<br>  /&gt;<br>&lt;/MapView&gt;</pre><p>Untuk fungsi renderMapMarkers ini digunakan untuk membuat penanda pada koordinat yang diinputkan.</p><pre>renderMapMarkers (location) {<br>  return (<br>     &lt;MapView.Marker<br>        key={location.title}<br>        coordinate={{<br>          latitude: location.latitude,<br>          longitude: location.longitude}}<br>     &gt;<br>     &lt;/MapView.Marker&gt;<br>  )<br>}</pre><p>Kemudian kita buat fungsi untuk mendapatkan array poligon dari state myLocation dan destination.</p><pre>async getDirections (startLoc, destinationLoc) {<br>  try {<br>    const resp = await fetch(`https://maps.googleapis.com/maps/api/directions/json?origin=${ startLoc }&amp;destination=${ destinationLoc }`)<br> // mencoba mengambil data koordinat</pre><pre>const respJson = await resp.json() // mendapatkan response</pre><pre>const points = Polyline.decode(respJson.routes[0].overview_polyline.points);</pre><pre>const coords = points.map((point, index) =&gt; {<br>  return {<br>    latitude: point[0],<br>    longitude: point[1]<br>  }<br>})</pre><pre>const time = await fetch(`https://maps.googleapis.com/maps/api/distancematrix/json?origins=${ startLoc }&amp;destinations=${ destinationLoc }&amp;key=API_KEY_GOOGLE`) // mendapatkan waktu dan jarak</pre><pre>const timeJson = await time.json()</pre><pre>const timeLabel = timeJson.rows[0].elements[0].duration.text</pre><pre>const distance = timeJson.rows[0].elements[0].distance.text</pre><pre>this.setState({<br>  coords: coords // set koordinat dari respon yang tadi kita dapat<br>})</pre><pre>  this.props.setTime(timeLabel, distance) // set label dan waktu pada container</pre><pre>  return coords</pre><pre>  } catch (error) {<br>      return error<br>  }<br>}</pre><p>Setelah semua yang diperlukan sudah di siapkan maka kita bisa membuat poligon tersebut dengan memanggil fungsi</p><pre>this.refs.map.fitToElements(true) // untuk menampilkan semua marker</pre><pre>this.getDirections(<br>  String(myLocation.latitude + &#39;,&#39; + myLocation.longitude),<br>  String(destination.latitude + &#39;,&#39; + destination.longitude)<br>) // mendapatkan koordinat poligon</pre><p>Oh iya jangan lupa untuk mengimport library yang diperlukan</p><pre>import MapView from &#39;react-native-maps&#39;<br>import Polyline from &#39;@mapbox/polyline&#39;</pre><p>Kemudian pada container View kita bisa gunakan kelas component ini dengan</p><pre>render () {<br>  const { distance, time } = this.state<br>  return (<br>    &lt;View style={{ flex: 1 }}&gt;<br>      &lt;View style={{ flexDirection: &#39;row&#39;, padding: 5 }}<br>        &lt;Text style={{ marginRight: 20 }}&gt;<br>          Distance : {distance}<br>        &lt;/Text&gt;<br>        &lt;Text&gt;<br>          Time : {time}<br>        &lt;/Text&gt;<br>      &lt;/View&gt;<br>      &lt;Maps<br>         setTime={(time, distance) =&gt; this.setTime(time, distance)}<br>      /&gt;<br>    &lt;/View&gt;<br>  )<br>}</pre><p>Dengan fungsi setTime untuk mengganti value state distance dan time</p><pre>setTime (time, distance) {<br>  this.setState({<br>    distance: distance,<br>    time: time<br>  })<br>}</pre><p>Dan hasilnya adalah…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*elCDr9SwksjoXvfpXFRpSw.png" /></figure><p>Mantab gan!</p><p>Selamat mencobaa.. :)</p><p>source: <a href="https://github.com/benyliantriana/PoligonReactNativeExample">github.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21d1d7ada2fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/skyshidigital/easy-way-to-make-poligon-maps-on-react-native-21d1d7ada2fb">Easy Way to Make Poligon Maps on React Native</a> was originally published in <a href="https://medium.com/skyshidigital">SkyshiDigital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maps dan Google Places Autocomplete pada React Native(Android) part 2]]></title>
            <link>https://medium.com/skyshidigital/maps-dan-google-places-autocomplete-pada-react-native-android-part-2-de54453a14a3?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/de54453a14a3</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native-maps]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Mon, 10 Jul 2017 10:31:08 GMT</pubDate>
            <atom:updated>2017-07-11T01:33:01.900Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*TS4aiUYj4AeUmEuauUbB0g.jpeg" /></figure><p>Pada bagian <a href="https://medium.com/skyshidigital/membuat-aplikasi-maps-menggunakan-react-native-maps-dan-react-native-google-places-autocomplete-aa1e060d29f6">pertama</a> telah kita bahas mengenai membuat maps menggunakan react native maps dan react native google places auto complete. Namun pada bagian <a href="https://medium.com/skyshidigital/membuat-aplikasi-maps-menggunakan-react-native-maps-dan-react-native-google-places-autocomplete-aa1e060d29f6">pertama</a> kita hanya membahas bagaimana menggunakan library tersebut secara terpisah. Pada bagian ini tidak akan dibahas bagaimana memasang (install) dan menggunakan library tersebut karena sudah dibahas pada bagian <a href="https://medium.com/skyshidigital/membuat-aplikasi-maps-menggunakan-react-native-maps-dan-react-native-google-places-autocomplete-aa1e060d29f6">pertama</a> dan hanya akan membahas bagaimana menggunakan kedua library tersebut secara bersama-sama sehingga maps pada aplikasi kita dapat berjalan dengan lebih baik dan lebih interaktif kepada pengguna.</p><p>Untuk menggunakan kedua library ini secara bersama-sama kita perlu suatu state (variabel) yang nantinya akan digunakan pada library ini. State yang perlu kita gunakan yaitu state untuk region yang digunakan oleh library react-native maps untuk menampilkan koordinat lokasi yang diinputkan. Inisialisasi state region dapat dibuat kurang lebih seperti ini</p><pre>constructor(props) {<br>    super(props);<br>    this.state = {<br>      mapRegion: null,<br>      latitude: null,<br>      longitude: null<br>  };<br>}</pre><p>Kemudian kita perlu suatu fungsi untuk mengubah state region untuk input yang telah dimasukkan.</p><pre>onRegionChange(region, latitude, longitude) {<br>    this.setState({<br>      mapRegion: region,<br>      // If there are no new values set the current ones<br>      latitude: latitude || this.state.latitude,<br>      longitude: longitude || this.state.longitude<br>   });<br> }</pre><p>Setelah itu kita atur onClick pada library google places auto complete untuk memanggil fungsi onRegionChange yang telah kita buat tadi</p><pre>&lt;GooglePlacesAutocomplete<br>    placeholder=&#39;Enter Location&#39;<br>    minLength={2}<br>    autoFocus={false}<br>    fetchDetails<br>    listViewDisplayed=&#39;auto&#39;<br>    query={{<br>         key: &#39;TAMBAHKAN API DISINI&#39;,<br>         language: &#39;en&#39;,<br>         types: &#39;geocode&#39;,<br>    }}<br>    currentLocation={false}<br>    onPress={(data, details = null) =&gt; {<br>      const region = {<br>        latitude: details.geometry.location.lat,<br>        longitude: details.geometry.location.lng,<br>        latitudeDelta: 0.00922 * 1.5,<br>        longitudeDelta: 0.00421 * 1.5<br>      };<br>      this.onRegionChange(region, region.latitude, region.longitude);<br>    }}<br> /&gt;</pre><p>Pada MapView kita harus mengatur bahwa region yang ditampilkan merupakan state region yang dapat diubah oleh MapView maupun google places auto complete.</p><pre>&lt;MapView<br> style={{ flex: 1, width: window.width }<br> region={this.state.mapRegion}<br> onRegionChange={(regions) =&gt; {<br>   this.setState({<br>     mapRegion: regions<br>   });<br> }}<br> onPress={(e) =&gt; {<br>   const region = {<br>        latitude: e.nativeEvent.coordinate.latitude,<br>        longitude: e.nativeEvent.coordinate.longitude,<br>        latitudeDelta: 0.00922 * 1.5,<br>        longitudeDelta: 0.00421 * 1.5<br>      }<br>   this.onRegionChange(region, region.latitude, region.longitude);<br> }}<br>&gt;<br> &lt;MapView.Marker<br>   coordinate={{<br>     latitude: (this.state.latitude),<br>     longitude: (this.state.longitude),<br>   }}<br>   title=&quot;Lokasi&quot;<br>   description=&quot;Hello&quot;<br> /&gt;<br>&lt;/MapView&gt;</pre><p>Apabila kita menuliskan semua kode kita dengan benar maka tampilan nya dapat dilihat pada gambar berikut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*nK8mq6MuI-EQYUzb6mHPEA.png" /></figure><p>Kemudian apabila kita memasukkan input teks pada map akan muncul suggestion tempat yang didukung oleh google places auto complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*hPTcyZjeZf6lkcgTKut1VA.png" /></figure><p>Kemudian set region akan terpanggil apabila kita memilih suggestion yang ditampilkan oleh google places auto complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*-6IIJPvpMPZJxbcyM7Jaow.png" /></figure><p>Demikian cara menggunakan dua library ini secara bersama-sama. Pada hal ini yang perlu diperhatikan adalah state region dan latitude, longitude agar kedua library ini dapat saling berkomunikasi.</p><p>Selamat mencoba!! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de54453a14a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/skyshidigital/maps-dan-google-places-autocomplete-pada-react-native-android-part-2-de54453a14a3">Maps dan Google Places Autocomplete pada React Native(Android) part 2</a> was originally published in <a href="https://medium.com/skyshidigital">SkyshiDigital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maps dan Google Places Autocomplete pada React Native(Android)]]></title>
            <link>https://medium.com/skyshidigital/membuat-aplikasi-maps-menggunakan-react-native-maps-dan-react-native-google-places-autocomplete-aa1e060d29f6?source=rss-a23ecc9c8b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa1e060d29f6</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-maps]]></category>
            <dc:creator><![CDATA[Beny Liantriana]]></dc:creator>
            <pubDate>Sun, 07 May 2017 00:50:27 GMT</pubDate>
            <atom:updated>2017-05-17T02:38:56.367Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*SluXAlSPIxxWjwUsiqD2Kw.png" /></figure><p>React native maps merupakan library paling populer yang digunakan untuk membuat atau menambahkan fitur google maps pada aplikasi berbasis react native sedangkan react native google places autocomplete adalah suatu library yang digunakan untuk memberikan sugesti tempat atau daerah atas input yang dimasukkan oleh pengguna. Kedua library ini dapat digunakan untuk membuat aplikasi peta sederhana dengan react native maps untuk menampilkan peta dan react native google places auto complete untuk menerima input daerah atau wilayah pada peta..</p><p>Pertama, untuk menggunakan react native maps dan react native google places auto complete kita harus menambahkan library ini pada project kita dengan :</p><pre>npm install react-native-maps --save</pre><pre>npm install react-native-google-places-autocomplete --save</pre><p>Tunggu sampai unduhan library selesai…</p><p>Kedua, buka build.gradle pada folder app</p><pre>android/app/build.gradle</pre><p>Dan tambahkan kode berikut:</p><pre>dependencies {<br>  ...<br>  compile project(&#39;:react-native-maps&#39;) //tambahkan ini<br>}</pre><p>Atau dapat juga menentukan google play module yang digunakan untuk menjalankan library ini dengan mengganti depencency diatas menjadi:</p><pre>dependencies {<br>    ...<br>    compile(project(&#39;:react-native-maps&#39;)){<br>        exclude group: &#39;com.google.android.gms&#39;, module: &#39;play-services-base&#39;<br>        exclude group: &#39;com.google.android.gms&#39;, module: &#39;play-services-maps&#39;<br>    }<br>    compile &#39;com.google.android.gms:play-services-base:10.0.1&#39;<br>    compile &#39;com.google.android.gms:play-services-maps:10.0.1&#39;<br>}</pre><p>Langkah ketiga yaitu dengan menambahkan library yang sudah diunduh tadi pada project Android kita dengan menambahkan kode ini pada file setting.gradle pada folder android (yourproject/android/setting.gradle)</p><pre>android/settings.gradle</pre><p>Tambahkan kode ini:</p><pre>include &#39;:react-native-maps&#39;<br>project(&#39;:react-native-maps&#39;).projectDir = new File(rootProject.projectDir, &#39;../node_modules/react-native-maps/lib/android&#39;)</pre><p>Setelah ketiga langkah diatas dilakukan maka library maps kita sudah siap digunakan.</p><p>Untuk menggunakan google maps dan google places pada aplikasi, kita harus memerlukan API-KEY yang bisa kita dapatkan pada link berikut</p><p><a href="https://console.developers.google.com/apis/credentials">Google Cloud Platform</a></p><p>Pastikan sudah menghidupkan API google maps dan google places atas API-KEY yang kita buat tadi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*R47UggvhPMcgh3A62OuC7g.jpeg" /></figure><p>Setelah itu tambahkan API-KEY yang telah dibuat tadi pada Android.Manifest</p><pre>android\app\src\main\AndroidManifest.xml</pre><p>Tambahkan kode ini untuk menambah API-KEY google</p><pre>&lt;application<br>      android:name=&quot;.MainApplication&quot;<br>      ...<br>      &lt;meta-data<br>        android:name=&quot;com.google.android.geo.API_KEY&quot;<br>        android:value=&quot;TAMBAHKAN API DISINI&quot;/&gt;<br>      &lt;activity<br>        android:name=&quot;.MainActivity&quot;<br>        android:label=&quot;<a href="http://twitter.com/string/app_name">@string/app_name</a>&quot;<br>        ...</pre><p>Api key diatas digunakan untuk react native maps pada aplikasi kita sedangkan untuk menambahkan api key pada google places auto complete bisa kita tambahkan pada saat kita menggunakan library itu pada project kita.</p><p>Setelah semua persiapan selesai maka langsung saja kita membuat aplikasi peta sederhana.</p><p>Untuk menggunakan react native maps kita dapat mengimpor library dengan kode ini:</p><pre>import MapView from &#39;react-native-maps&#39;;</pre><p>Untuk menampilkan peta pakai kode ini</p><pre>&lt;MapView<br>    initialRegion={{<br>      latitude: 37.78825,<br>      longitude: -122.4324,<br>      latitudeDelta: 0.0922,<br>      longitudeDelta: 0.0421,<br>    }}<br>  /&gt;</pre><p>Pada react native maps ini digunakan latitude, longitude, latitudeDelta, dan longitudeDelta untuk dapat menampilkan wilayah (region) yang ingin kita fokuskan pada peta. Untuk membuat marker dapat kita gunakan kode ini:</p><pre>&lt;MapView.Marker<br>      coordinate={{<br>          latitude: 37.78825,<br>          longitude: -122.4324,<br>        }}<br>      title=&quot;Lokasi&quot;<br>      description=&quot;Hello&quot;<br>    /&gt;</pre><p>Jadi kode yang kita gunakan untuk membuat peta + marker menjadi</p><pre>&lt;MapView<br>   style={{ flex: 1, width: window.width }} //window pake Dimensions<br>   region={{<br>      latitude: 37.78825,<br>      longitude: -122.4324,<br>      latitudeDelta: 0.0922,<br>      longitudeDelta: 0.0421 <br>   }} &gt;<br>&lt;MapView.Marker<br>   coordinate={{<br>      latitude: 37.78825,<br>      longitude: -122.4324,<br>   }}<br>   title=&quot;Lokasi&quot;<br>   description=&quot;Hello&quot; /&gt;<br>&lt;/MapView&gt;</pre><p>Tampilkan untuk kode kurang lebih seperti ini</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*-ov59Jm3q0aLLwrT_RHUkg.png" /></figure><p>Nah setelah kita berhasil membuat peta pada aplikasi android react-native, sekarang kita membuat input untuk react native google places autocomplete. Untuk menggunakan library ini gunakan impor kode dibawah ini</p><pre>import { GooglePlacesAutocomplete } from &#39;react-native-google-places-autocomplete&#39;;</pre><p>Nah setelah diimport kita bisa langsung menggunakan library ini namun jangan lupa untuk memasukkan API-KEY yang sudah kita buat tadi.</p><pre>&lt;GooglePlacesAutocomplete<br>    placeholder=&#39;Enter Location&#39;<br>    minLength={2}<br>    autoFocus={false}<br>    fetchDetails<br>    listViewDisplayed=&#39;auto&#39;<br>    query={{<br>         key: &#39;TAMBAHKAN API DISINI&#39;,<br>         language: &#39;en&#39;,<br>         types: &#39;geocode&#39;,<br>    }}<br>    currentLocation={false} /&gt;</pre><p>Nah dengan ditambahkannya kode diatas maka kita sudah dapat menggunakan react native google places autocomplete. Namun apabila kita menggabungkan dengan peta yang sudah kita buat tadi, tampilan masih kurang rapi karena pada dasarnya si “react native google places autocomplete” ini di set flex: 1 dan perlu kita set sesuai dengan kebutuhan kita dengan menambahkan style pada library ini.</p><p>Untuk styling dan menggabungkan dua library ini akan kita bahas pada part 2..</p><p>:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa1e060d29f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/skyshidigital/membuat-aplikasi-maps-menggunakan-react-native-maps-dan-react-native-google-places-autocomplete-aa1e060d29f6">Maps dan Google Places Autocomplete pada React Native(Android)</a> was originally published in <a href="https://medium.com/skyshidigital">SkyshiDigital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>