SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
Kobkrit Viriyayudhakorn, Ph.D.
CEO of iApp Technology Limited.
kobkrit@gmail.com
All source code
• https://github.com/kobkrit/react-native-class-2017
Download Exercise
• https://github.com/kobkrit/react-native-class-2017/
raw/master/exercise/L4.zip
Prepare ENV for making Android App by

React-Native on Windows
• See https://kobkrit.com/react-native-tutorial-react-
native-setup-on-windows-for-android-development-
walkthrough-a463e825159d#.joucl9xkg
Prepare ENV for making Android App by

React-Native on Mac
• https://kobkrit.com/react-native-tutorial-set-up-
react-native-on-mac-for-ios-and-android-
development-78a30a26aa3b#.cn29imr81
Setup Project (15 min)
• Enter to your coding directory (Maybe ~/code, or c:code, but not
c:windowssystem32)
• (Both) $ react-native init flexbox

(Both) $ cd flexbox
• Open index.ios.js current directory with your IDE

(Mac) $ atom index.ios.js

(Win) > notepad index.android.js
• (Win) Run your android emulator (e.g. Genymotion)
• (Mac) $ react-native run-ios

(Win) > react-native run-android
• Set up the Screen like this.
• Enable Hot Reloading
• Open Developer Menu by Command-D on Mac

or Menu Button in Android Simulator (for 

Windows)
• Tap Enable Hot Reloading
• Make Change the file, and hit Save.
• See the changes in Simulators.
Structure
JSX
• JSX is a JavaScript syntax extension that looks
similar to XML.
• We use a JSX to write User Interface (UI).
• JSX use camelCase.
• We use JSX at the render() function of a React
component.
index.ios.js

index.android.js
JSX Syntax
<Text>Hello World!</Text>
<Image
style={{height:100, width:100}}
source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
/>
Tag name: Text
Opening Tag Closing Tag
Tag body
Attribute Name Attribute ValueSelf Closing Tag
Attribute Value
• Using JavaScript Expression as Attribute Value,
Use { }
• Using String as Attribute Value, Use ''
Putting JS Logic in JSX
• Using JavaScript Statements, Put it between { }
Comment
• To comment in JSX, Put it between {/* */}, {// … n 

}
One Outmost Parent Tag Rules
OK! 

Only one outmost parent tags: View
BAD! 

Multiple outmost parent tags: Text,Text
Basic Elements
<Text>Hello World!</Text>
iOS Android
<Image
style={{height:100, width:100}}
source={{uri: 'https://facebook.

github.io/react/img/logo_og.png'}}
/>
<Switch />
<View></View> (Container) (Container)
Basic Elements
<TextInput
style={{height:40, borderColor:

'gray', borderWidth: 1}}
value='Useless TextInput’
/>
iOS
Android<TextInput

multiLine={true}
numberOfLine={4}
style={{height:100, borderColor:

'gray', borderWidth: 1}}
value='Useless MultiLine TextInput’
/>
Basic Elements
<TouchableOpacity onPress={()=>{}}
style={{borderColor:'#f00',
backgroundColor:'#faa', borderWidth:
1, padding:10}}>
<Text>Touch me for Opacity!</Text>
</TouchableOpacity>
iOS & Android: Default
iOS & Android: Tapping
<TouchableHighlight onPress={()=>{}}
underlayColor='#f00a'
style={{borderColor:'#f00',
backgroundColor:'#faa', borderWidth:1,
padding:10}}>
<Text>Touch me for Highlight!</Text>
</TouchableHighlight>
JSX’s Example
Style
Basic CSS
View: Blue Box
80
80
80
8040
40
40
40
Margin
Padding
BorderRadius
20
Width: 200
Height: 200
View: Red Box+ Text
Flex:1
40
Exercise I (5 min)
More CSS for View
More CSS for Text
Flexbox Layout
• Flexbox => CSS Flexible Box Layout (in W3C Last Call
Working Draft)
• Providing efficient way to layout, align and distribute space
among items in a container, even when their size is
unknown and/or dynamic (flex)
• Containers can alter its items width/height and order to
best fill the available space.
• Flexbox is a direction-agnostic, which support complex
applications (especially when it comes to orientation
changing, resizing, stretching, shrinking, etc.)
• main axis - Primary axis of a flex container, 

defined by flexDirection.
• main-start | main-end — Flex items placed within container
starting from main-start and going to main-end.

• main-size - Flex item’s width or height, whichever is in the
primary dimension.
Above is flexDirection = row (horizontal)
Above is flexDirection = row (horizontal)
• cross axis - Secondary axis that perpendicular to the 

primary axis (opposed with the flexDirection)
• cross-start | cross-end - Flex lines are filled with items and

placed into the container starting on the cross-start side or

on the cross-end side.

• cross-size - the flex item’s width or height, whichever is in

the cross dimension.
Two types of Flex properties
Containers
• flexDirection
• justifyContent
• alignItems
• flexWrap
Items
• flex
• alignSelf
Containers
• flexDirection
• justifyContent
• alignItems
• flexWrap
FlexDirection
Horizontally

flexDirection: row;
Vertically

flexDirection: column;
(Container)
Default flexDirection in React Native is column
Justify Content
• Adding justifyContent to a
component's style determines
the distribution of children
along the primary axis.
• Should children be distributed
at the start, the center, the end,
or spaced evenly?
• Available options are flex-
start, center, flex-
end, space-around, and
space-between.
• Default is flex-start
(Container)
flexDirection: ‘column’, 

justifyContent: ‘space-between’
Align Items
• Adding alignItems to a
component's style determines
the alignment of children along
the secondary axis (if the
primary axis is row, then the
secondary is column, and vice
versa).
• Should children be aligned at
the start, the center, the end, or
stretched to fill?
• Available options are flex-
start, center, flex-
end, and stretch.
• Default is flex-start
(Container)
flexDirection: ‘column’, 

justifyContent: ‘center’, alignItems: ‘center’
FlexWrap
• By default, flex items will all try
to fit onto one line.
• Adding FlexWrap, You can
change that and allow the
items to wrap as needed with
this property.
• Direction also plays a role
here, determining the direction
new lines are stacked in.
• Available options are nowrap,
wrap
• Default is nowrap
(Container)
nowrap vs wrap
Items
• flex
• alignSelf
Flex
• “Flex” CSS syntax applied to item elements to tell how much they can
stretches inside their container by compares with its siblings.
• {flex: (positive integer number)}, e.g., {flex : 1}
• They equally divide all container’s space by the sum of flex values of
their children, then allocate space according to each child’s flex score.
(Item)
Align Self
• Adding alignSelf to a component's style determines the alignment of itself
along the secondary axis (overwrite the alignItems from its container).
• Available options are auto, flex-start, center, flex-end, and
stretch.
• Default is auto (Follow the alignItems from its container)
(Item)
Colors
• '#f0f' (#rgb)
• '#f0fc' (#rgba)
• '#ff00ff' (#rrggbb)
• '#ff00ff00' (#rrggbbaa)
• 'rgb(255, 255, 255)'
• 'rgba(255, 255, 255,
1.0)'
• 'hsl(360, 100%, 100%)'
• 'hsla(360, 100%, 100%,
1.0)'
• 'transparent'
• 'red'
• 0xff00ff00 (0xrrggbbaa)
More Colors…
https://facebook.github.io/react-native/docs/colors.html
Exercise II (10 min)
Exercise III (15 min)
Exercise IV (15 min)

Contenu connexe

Tendances

Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy stepsprince Loffar
 
Responsive web designing ppt(1)
Responsive web designing ppt(1)Responsive web designing ppt(1)
Responsive web designing ppt(1)admecindia1
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - OperatorsWebStackAcademy
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced JavascriptAdieu
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Basic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJS
Basic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJSBasic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJS
Basic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJSDeepak Upadhyay
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions Reem Alattas
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.pptsentayehu
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntaxDhani Ahmad
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react formYao Nien Chung
 

Tendances (20)

Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
 
Bootstrap ppt
Bootstrap pptBootstrap ppt
Bootstrap ppt
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Java script
Java scriptJava script
Java script
 
Responsive web designing ppt(1)
Responsive web designing ppt(1)Responsive web designing ppt(1)
Responsive web designing ppt(1)
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Basic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJS
Basic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJSBasic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJS
Basic of HTML, CSS(StyleSheet), JavaScript(js), Bootstrap, JSON & AngularJS
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
 
Css3
Css3Css3
Css3
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 

Similaire à [React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox

Basics of expression blend4
Basics of expression blend4Basics of expression blend4
Basics of expression blend4Samson Tennela
 
Building Layouts with CSS
Building Layouts with CSSBuilding Layouts with CSS
Building Layouts with CSSBoris Paillard
 
Web development basics (Part-2)
Web development basics (Part-2)Web development basics (Part-2)
Web development basics (Part-2)Rajat Pratap Singh
 
JavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy FowlerJavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy FowlerStephen Chin
 
CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)Woodridge Software
 
Designing Windows apps with Xaml
Designing Windows apps with XamlDesigning Windows apps with Xaml
Designing Windows apps with XamlJiri Danihelka
 
Flexbox Will Shock You!
Flexbox Will Shock You!Flexbox Will Shock You!
Flexbox Will Shock You!Scott Vandehey
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfKaty Slemon
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform AppsFITC
 
Intro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS PropertyIntro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS PropertyAdam Soucie
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans Fabrizio Giudici
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJSFestUA
 
Electronic Grading of Paper Assessments
Electronic Grading of Paper AssessmentsElectronic Grading of Paper Assessments
Electronic Grading of Paper AssessmentsMatthew Leingang
 
Show & tell - Flex in flux
Show & tell - Flex in fluxShow & tell - Flex in flux
Show & tell - Flex in fluxDan Dineen
 
Flexbox, Grid and Sass
Flexbox, Grid and SassFlexbox, Grid and Sass
Flexbox, Grid and SassSeble Nigussie
 
React Native: Introduction
React Native: IntroductionReact Native: Introduction
React Native: IntroductionInnerFood
 

Similaire à [React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox (20)

Basics of expression blend4
Basics of expression blend4Basics of expression blend4
Basics of expression blend4
 
React native
React nativeReact native
React native
 
Building Layouts with CSS
Building Layouts with CSSBuilding Layouts with CSS
Building Layouts with CSS
 
Web development basics (Part-2)
Web development basics (Part-2)Web development basics (Part-2)
Web development basics (Part-2)
 
JavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy FowlerJavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy Fowler
 
CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)
 
Designing Windows apps with Xaml
Designing Windows apps with XamlDesigning Windows apps with Xaml
Designing Windows apps with Xaml
 
Flexbox Will Shock You!
Flexbox Will Shock You!Flexbox Will Shock You!
Flexbox Will Shock You!
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
 
slides-students-C04.pdf
slides-students-C04.pdfslides-students-C04.pdf
slides-students-C04.pdf
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform Apps
 
Intro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS PropertyIntro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS Property
 
2. react - native: basic
2. react - native: basic2. react - native: basic
2. react - native: basic
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-Native
 
Electronic Grading of Paper Assessments
Electronic Grading of Paper AssessmentsElectronic Grading of Paper Assessments
Electronic Grading of Paper Assessments
 
Show & tell - Flex in flux
Show & tell - Flex in fluxShow & tell - Flex in flux
Show & tell - Flex in flux
 
A complete guide to flexbox
A complete guide to flexboxA complete guide to flexbox
A complete guide to flexbox
 
Flexbox, Grid and Sass
Flexbox, Grid and SassFlexbox, Grid and Sass
Flexbox, Grid and Sass
 
React Native: Introduction
React Native: IntroductionReact Native: Introduction
React Native: Introduction
 

Plus de Kobkrit Viriyayudhakorn

Chochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotChochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotKobkrit Viriyayudhakorn
 
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...Kobkrit Viriyayudhakorn
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Kobkrit Viriyayudhakorn
 
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)Kobkrit Viriyayudhakorn
 
Check Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationCheck Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationKobkrit Viriyayudhakorn
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)Kobkrit Viriyayudhakorn
 
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)Kobkrit Viriyayudhakorn
 
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)Kobkrit Viriyayudhakorn
 
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.Kobkrit Viriyayudhakorn
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationKobkrit Viriyayudhakorn
 
Unity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidUnity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidKobkrit Viriyayudhakorn
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2Kobkrit Viriyayudhakorn
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Kobkrit Viriyayudhakorn
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityKobkrit Viriyayudhakorn
 
Lecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingLecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingKobkrit Viriyayudhakorn
 
Lecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeLecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeKobkrit Viriyayudhakorn
 

Plus de Kobkrit Viriyayudhakorn (20)

Thai E-Voting System
Thai E-Voting System Thai E-Voting System
Thai E-Voting System
 
Thai National ID Card OCR
Thai National ID Card OCRThai National ID Card OCR
Thai National ID Card OCR
 
Chochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotChochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service Robot
 
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)
 
How Emoticon Affects Chatbot Users
How Emoticon Affects Chatbot UsersHow Emoticon Affects Chatbot Users
How Emoticon Affects Chatbot Users
 
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
 
Check Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationCheck Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching Presentation
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
 
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
 
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
 
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase Authentication
 
Unity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidUnity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and Android
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in Unity
 
Lecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingLecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR Programming
 
Thai Word Embedding with Tensorflow
Thai Word Embedding with Tensorflow Thai Word Embedding with Tensorflow
Thai Word Embedding with Tensorflow
 
Lecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeLecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-Native
 

Dernier

Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 

Dernier (20)

Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 

[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox

  • 1. Kobkrit Viriyayudhakorn, Ph.D. CEO of iApp Technology Limited. kobkrit@gmail.com
  • 2. All source code • https://github.com/kobkrit/react-native-class-2017
  • 4. Prepare ENV for making Android App by
 React-Native on Windows • See https://kobkrit.com/react-native-tutorial-react- native-setup-on-windows-for-android-development- walkthrough-a463e825159d#.joucl9xkg
  • 5. Prepare ENV for making Android App by
 React-Native on Mac • https://kobkrit.com/react-native-tutorial-set-up- react-native-on-mac-for-ios-and-android- development-78a30a26aa3b#.cn29imr81
  • 6. Setup Project (15 min) • Enter to your coding directory (Maybe ~/code, or c:code, but not c:windowssystem32) • (Both) $ react-native init flexbox
 (Both) $ cd flexbox • Open index.ios.js current directory with your IDE
 (Mac) $ atom index.ios.js
 (Win) > notepad index.android.js • (Win) Run your android emulator (e.g. Genymotion) • (Mac) $ react-native run-ios
 (Win) > react-native run-android
  • 7. • Set up the Screen like this. • Enable Hot Reloading • Open Developer Menu by Command-D on Mac
 or Menu Button in Android Simulator (for 
 Windows) • Tap Enable Hot Reloading • Make Change the file, and hit Save. • See the changes in Simulators.
  • 9. JSX • JSX is a JavaScript syntax extension that looks similar to XML. • We use a JSX to write User Interface (UI). • JSX use camelCase. • We use JSX at the render() function of a React component.
  • 11. JSX Syntax <Text>Hello World!</Text> <Image style={{height:100, width:100}} source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}} /> Tag name: Text Opening Tag Closing Tag Tag body Attribute Name Attribute ValueSelf Closing Tag
  • 12. Attribute Value • Using JavaScript Expression as Attribute Value, Use { } • Using String as Attribute Value, Use ''
  • 13. Putting JS Logic in JSX • Using JavaScript Statements, Put it between { }
  • 14.
  • 15. Comment • To comment in JSX, Put it between {/* */}, {// … n 
 }
  • 16. One Outmost Parent Tag Rules OK! 
 Only one outmost parent tags: View BAD! 
 Multiple outmost parent tags: Text,Text
  • 17. Basic Elements <Text>Hello World!</Text> iOS Android <Image style={{height:100, width:100}} source={{uri: 'https://facebook.
 github.io/react/img/logo_og.png'}} /> <Switch /> <View></View> (Container) (Container)
  • 18. Basic Elements <TextInput style={{height:40, borderColor:
 'gray', borderWidth: 1}} value='Useless TextInput’ /> iOS Android<TextInput
 multiLine={true} numberOfLine={4} style={{height:100, borderColor:
 'gray', borderWidth: 1}} value='Useless MultiLine TextInput’ />
  • 19. Basic Elements <TouchableOpacity onPress={()=>{}} style={{borderColor:'#f00', backgroundColor:'#faa', borderWidth: 1, padding:10}}> <Text>Touch me for Opacity!</Text> </TouchableOpacity> iOS & Android: Default iOS & Android: Tapping <TouchableHighlight onPress={()=>{}} underlayColor='#f00a' style={{borderColor:'#f00', backgroundColor:'#faa', borderWidth:1, padding:10}}> <Text>Touch me for Highlight!</Text> </TouchableHighlight>
  • 21. Style
  • 24. View: Red Box+ Text Flex:1 40
  • 26. More CSS for View
  • 27.
  • 28.
  • 29. More CSS for Text
  • 30.
  • 31. Flexbox Layout • Flexbox => CSS Flexible Box Layout (in W3C Last Call Working Draft) • Providing efficient way to layout, align and distribute space among items in a container, even when their size is unknown and/or dynamic (flex) • Containers can alter its items width/height and order to best fill the available space. • Flexbox is a direction-agnostic, which support complex applications (especially when it comes to orientation changing, resizing, stretching, shrinking, etc.)
  • 32. • main axis - Primary axis of a flex container, 
 defined by flexDirection. • main-start | main-end — Flex items placed within container starting from main-start and going to main-end.
 • main-size - Flex item’s width or height, whichever is in the primary dimension. Above is flexDirection = row (horizontal)
  • 33. Above is flexDirection = row (horizontal) • cross axis - Secondary axis that perpendicular to the 
 primary axis (opposed with the flexDirection) • cross-start | cross-end - Flex lines are filled with items and
 placed into the container starting on the cross-start side or
 on the cross-end side.
 • cross-size - the flex item’s width or height, whichever is in
 the cross dimension.
  • 34. Two types of Flex properties Containers • flexDirection • justifyContent • alignItems • flexWrap Items • flex • alignSelf
  • 37. Default flexDirection in React Native is column
  • 38. Justify Content • Adding justifyContent to a component's style determines the distribution of children along the primary axis. • Should children be distributed at the start, the center, the end, or spaced evenly? • Available options are flex- start, center, flex- end, space-around, and space-between. • Default is flex-start (Container) flexDirection: ‘column’, 
 justifyContent: ‘space-between’
  • 39.
  • 40. Align Items • Adding alignItems to a component's style determines the alignment of children along the secondary axis (if the primary axis is row, then the secondary is column, and vice versa). • Should children be aligned at the start, the center, the end, or stretched to fill? • Available options are flex- start, center, flex- end, and stretch. • Default is flex-start (Container) flexDirection: ‘column’, 
 justifyContent: ‘center’, alignItems: ‘center’
  • 41.
  • 42. FlexWrap • By default, flex items will all try to fit onto one line. • Adding FlexWrap, You can change that and allow the items to wrap as needed with this property. • Direction also plays a role here, determining the direction new lines are stacked in. • Available options are nowrap, wrap • Default is nowrap (Container) nowrap vs wrap
  • 43.
  • 45. Flex • “Flex” CSS syntax applied to item elements to tell how much they can stretches inside their container by compares with its siblings. • {flex: (positive integer number)}, e.g., {flex : 1} • They equally divide all container’s space by the sum of flex values of their children, then allocate space according to each child’s flex score. (Item)
  • 46.
  • 47. Align Self • Adding alignSelf to a component's style determines the alignment of itself along the secondary axis (overwrite the alignItems from its container). • Available options are auto, flex-start, center, flex-end, and stretch. • Default is auto (Follow the alignItems from its container) (Item)
  • 48.
  • 49. Colors • '#f0f' (#rgb) • '#f0fc' (#rgba) • '#ff00ff' (#rrggbb) • '#ff00ff00' (#rrggbbaa) • 'rgb(255, 255, 255)' • 'rgba(255, 255, 255, 1.0)' • 'hsl(360, 100%, 100%)' • 'hsla(360, 100%, 100%, 1.0)' • 'transparent' • 'red' • 0xff00ff00 (0xrrggbbaa)