Sitemap
Bhurisub Dejpipatpracha

Bhurisub Dejpipatpracha

NativeBase

2 min readJan 18, 2017

--

ช่วงนี้กำลังลองศึกษา React Native ซึ่งเป็น Framework สำหรับพัฒนา Mobile Applications ที่สามารถทำงานได้ทั้ง Android และ iOS

หลังจากลองไปซักระยะก็พยายามค้นดูว่า น่าจะมี Framework อะไรบ้างที่ช่วยทำให้หน้าตา App ของเราสวยงามและน่าใช้งานมากขึ้น ซึ่งหากเปรียบเทียบกับการพัฒนา Web Application คงจะเป็นกลุ่ม CSS Framework เช่น Bootstrap Foundation GUMBY เป็นต้น

Get Bhurisub Dejpipatpracha’s stories in your inbox

Join Medium for free to get updates from this writer.

ค้นไปค้นมาก็ไปเจอกับ NativeBase ซึ่งเป็น Framework ที่ช่วยสร้าง Components ต่างๆ มากมายสำหรับพัฒนา App โดยสามารถใช้ React Native เป็นฐานหลักสำหรับพัฒนา App ได้

icon

ข้อดีอย่างหนึ่งที่เห็นได้ชัดสำหรับ NatvieBase นั้นก็คือ หากจะต้องสร้างอะไรซักอย่าง ซึ่งหากเขียนสคริปต์ด้วย React Native แบบเพียวๆไม่มีของผสม ก็คงต้องเขียนกันหลายบรรทัด แต่สำหรับ NativeBase เขียนสคริปต์ไม่กี่บรรทัดก็สามารถสร้างได้เหมือนกัน ดังภาพตัวอย่างการปุ่ม

Press enter or click to view image in full size
NativeBase.io

สำหรับ NativeBase ที่เป็นปุ่ม เมนู icon เรียกว่า Component โดย Components ของ NativeBase มีเลือกใช้งานมากมายได้ เช่น

import { Container, Header, Title, Content, Badge , Button ,Card ,Check Box , DeckSwiper, Fab, FooterTab, Icon, Picker, InputGroup, Layout, List, ListItem, Text, Radio, Spinner, Tabs, Thumbnail, } from ‘native-base’;

ซึ่งจะขอยกตัวอย่าง Component บางส่วนของ NativeBase ดังนี้

Card (Card Showcase)

Press enter or click to view image in full size
http://nativebase.io/docs/v0.5.13/components#cardShowcase

Icon

Press enter or click to view image in full size
http://nativebase.io/docs/v0.5.13/components#icon

List Avatar

Press enter or click to view image in full size

ตัวอย่างหน้าตา NativeBase ที่สามารถแสดงบน iOS และ Android

Press enter or click to view image in full size
http://nativebase.io/kitchen-sink-app

วิธีการติดตั้ง NativeBase

$ react-native init nativebaseapp
$ cd nativebaseapp
$ npm install native-base --save

สำหรับ Android

$ react-native link react-native-vector-icons

และปรับปรุง android/app/build.gradle เพื่อให้ App สามารถแสดง icons ต่างๆ และ fonts ได้

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
Press enter or click to view image in full size
ทดลองใช้ NativeBase

สุดท้าย…เขียนเก็บไว้เผื่อลืมและเผื่อใครสนใจจะลองใช้งาน สามารถดูข้อมูลเพิ่มเติมได้ที่ http://nativebase.io/ ครับ

--

--