SlideShare a Scribd company logo
WHO AM I ?
OTSIMO
OTSIMO CHILD
OTSIMO FAMILY
REACT NATIVE ON OTSIMO
V
What is Swift ?
Apple’s new programming language
Created by Chris Lattner, who wrote LLVM
First appeared in June 2, 2014
Easy
Android
Why Swift ?
iOS
Safe
SCADE
A Framework for building native apps using React
Started as Facebook’s internal hackathon project, in the
summer of 2013
The first public preview was in January of 2015 at React.js
Conference
What is React Native ?
Web Developer friendly
Multi-Platform Support
Live reload (vs Compile&Wait)
Why React Native ?
Some Keywords
Component
Props
State
What is component ?
render() {
return (
<View style={styles.container}>
<Background
color={this.state.bgColor} />
<Header
user={this.state.firstName}
/>
<CategoryScroller
categories={this.state.categories}
/>
</View>
);
Everything
is
component
Props is data passed to child
component
<Header
user={this.state.firstName}
/>
<Text>
{this.getWelcomeText(this.props.user)}
</Text>
in header.jsin dashboard.js
State is internal data
of a component
state = {
email: '',
password: '',
valid: false,
};
To Start React Native
brew install node
brew install watchman
npm install -g react-native-cli
react-native init firstApp
cd firstApp
react-native run-ios
Hello World
import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';
class HelloWorld extends Component {
render() {
return (
<Text>Hello world!</Text>
);
}
}
AppRegistry.registerComponent('HelloWorld', () =>
HelloWorld);
Hello World
import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';
class HelloWorld extends Component {
render() {
return (
<Text>Hello world!</Text>
);
}
}
AppRegistry.registerComponent('HelloWorld', () =>
HelloWorld);
Hello world!
Let's use Swift and React
Native together
{
"name": “ios-rn“,
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/
cli.js start"
},
"dependencies": {
"react": "16.0.0-alpha.6",
"react-native": "^0.44.0"
}
}
package.json
npm install or yarn
What our
application is
doing ?
export class RegisterView extends Component {
constructor(props) {
super(props);
this.state = {
value: '',
}
}
render() {
return (
<View style={styles.container}>
<TextInput placeholder={'Adınızı giriniz'} style={styles.textInput}
onChangeText={(v) => this.setState({ value: v })} />
<Button onPress={() => { this.printHello() }} title='OK' />
<Button onPress={() => { this.goBack() }} title='GO BACK' />
</View>
);
}
}
register.js
import React from 'react';
import {
AppRegistry
} from 'react-native';
import { RegisterView } from './src/register';
AppRegistry.registerComponent('RegisterView', () =>
RegisterView);
index.ios.js
SecondVC.swift
@IBOutlet var rnView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
let jsCodeLocation = URL(string: "http://localhost:8081/
index.ios.bundle?platform=ios")
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "RegisterView",
initialProperties: nil,
launchOptions: nil
)
rootView!.frame = CGRect(x: 0, y: 0, width: rnView.frame.width,
height: rnView.frame.height)
rnView.addSubview(rootView!);
}
DEMO
Let's run the Swift function
in React Native
@IBOutlet var lbl: UILabel!
func goBack(){
navigationController?.popViewController(animated: true)
}
func printUserName(_ value : String){
lbl.text = "Hello " + value
}
SecondVC.swift
#import "React/RCTBridgeModule.h"
@interface RCT_EXTERN_MODULE(SecondVCModule, NSObject)
RCT_EXTERN_METHOD(back: (nonnull NSNumber *)reactTag)
RCT_EXTERN_METHOD(printName: (nonnull NSNumber *)reactTag
value: (nonnull NSString *)value)
@end
NativeBridge.m
@objc(SecondVCModule)
class SecondVCModule: RCTEventEmitter{
@objc func back(_ reactTag: NSNumber) {
DispatchQueue.main.async {
if let view = self.bridge.uiManager.view(forReactTag: reactTag) {
let cur: UIViewController! = view.reactViewController()
if let c = cur as? SecondVC{
c.goBack();
}
}
}
}
@objc func printName(_ reactTag: NSNumber,value value: NSString) {
DispatchQueue.main.async {
if let view = self.bridge.uiManager.view(forReactTag: reactTag) {
let cur: UIViewController! = view.reactViewController()
if let c = cur as? SecondVC{
c.printUserName(value as String)
}
}
}
}
}
SecondVCModule.swift
DEMO
Send data from Swift to
React Native
contact.js
export class ContactView extends React.Component {
renderContactItem(contact) {
return (
<View key={contact.name} style={styles.item} >
<Text style={styles.name} >{contact.name} </Text>
<Text style={styles.phone}>{contact.phone} </Text>
</View>
);
}
render() {
return (
<View style={styles.container} >
<Text style={styles.title} > Your Friends </Text>
{// render Contact items}
</View>);
}
}
ContactVC.swift
let mockData:NSDictionary = ["contacts":
[
["name":"Alex", "phone":"+90 648 274 26 19"],
["name":"Joel", "phone":"+90 342 452 45 64"]
]
]
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "ContactView",
initialProperties: mockData as [NSObject : AnyObject],
launchOptions: nil
)
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "RegisterView",
initialProperties: nil,
launchOptions: nil
)
before
contact.js
export class ContactView extends React.Component {
renderContactItem(contact) {
return (
<View key={contact.name} style={styles.item} >
<Text style={styles.name} >{contact.name} </Text>
<Text style={styles.phone}>{contact.phone} </Text>
</View>
);
}
render() {
return (
<View style={styles.container} >
<Text style={styles.title} > Your Friends </Text>
{this.props["contacts"].map(contact => this.renderContactItem(contact))}
</View>);
}
}
SecondVCModule.swift
export class ContactView extends React.Component {
renderContactItem(contact) {
return (
<View key={contact.name} style={{
height: 50,
flexDirection: 'row', margin: 8, padding: 8,
justifyContent: 'space-between', alignItems: 'center'
}} >
<Text style={{ fontSize: 30 }} >{contact.name} </Text>
<Text style={{ fontSize: 20 }}>{contact.phone} </Text>
</View>
);
}
render() {
return (<View style={{ flex: 1, justifyContent: 'center' }} >
<Text style={{ fontSize: 50,fontWeight:'bold' }} > Your Friends</Text>
{
this.props["contacts"].map(contact => this.renderContactItem(contact))
}
</View>);
}
}
Hello world!
DEMO
Who are using React Native ?
THANK YOU
ANY QUESTION ?
@muhammetdemirci
muhammed@otsimo.com

More Related Content

What's hot

Angular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code levelAngular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code level
Anuradha Bandara
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operations
Mateusz Grzechociński
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
FITC
 
React on es6+
React on es6+React on es6+
React on es6+
Nikolaus Graf
 
ReactJS (1)
ReactJS (1)ReactJS (1)
ReactJS (1)
George Tony
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
Stephan Schmidt
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
Jo Cranford
 
7 Redux challenges
7 Redux challenges7 Redux challenges
7 Redux challenges
reactima
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
Visual Engineering
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
Mathieu Savy
 
React and redux
React and reduxReact and redux
React and redux
Mystic Coders, LLC
 
Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular
Jalpesh Vadgama
 
Actor Model pattern for concurrency
Actor Model pattern for concurrencyActor Model pattern for concurrency
Actor Model pattern for concurrency
ggarber
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
Vincent Pradeilles
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
React.js+Redux Workshops
React.js+Redux WorkshopsReact.js+Redux Workshops
React.js+Redux Workshops
Marcin Grzywaczewski
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
Mitch Chen
 
Railsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and webRailsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and web
talkingquickly
 
20190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.120190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.1
Hui Seo
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone
 

What's hot (20)

Angular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code levelAngular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code level
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operations
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 
React on es6+
React on es6+React on es6+
React on es6+
 
ReactJS (1)
ReactJS (1)ReactJS (1)
ReactJS (1)
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
 
7 Redux challenges
7 Redux challenges7 Redux challenges
7 Redux challenges
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
 
React and redux
React and reduxReact and redux
React and redux
 
Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular
 
Actor Model pattern for concurrency
Actor Model pattern for concurrencyActor Model pattern for concurrency
Actor Model pattern for concurrency
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
React.js+Redux Workshops
React.js+Redux WorkshopsReact.js+Redux Workshops
React.js+Redux Workshops
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
 
Railsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and webRailsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and web
 
20190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.120190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.1
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 

Similar to JSAnkara Swift v React Native

Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
Visual Engineering
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
Matteo Manchi
 
Android development
Android developmentAndroid development
Android development
Gregoire BARRET
 
React native
React nativeReact native
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
DayNightGaMiNg
 
Android development with Scala and SBT
Android development with Scala and SBTAndroid development with Scala and SBT
Android development with Scala and SBT
Anton Yalyshev
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)
Jens Ravens
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
DayNightGaMiNg
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
janet736113
 
React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
Lohika_Odessa_TechTalks
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
C.T.Co
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
Alexey Buzdin
 
Vývojařská Plzeň - React
Vývojařská Plzeň - ReactVývojařská Plzeň - React
Vývojařská Plzeň - React
Viliam Elischer
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
joshcjensen
 
Making React Native UI Components with Swift
Making React Native UI Components with SwiftMaking React Native UI Components with Swift
Making React Native UI Components with Swift
Ray Deck
 
React native
React nativeReact native
React native
Vishal Dubey
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
Hassan Abid
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
John Stevenson
 

Similar to JSAnkara Swift v React Native (20)

Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
Android development
Android developmentAndroid development
Android development
 
React native
React nativeReact native
React native
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
Android development with Scala and SBT
Android development with Scala and SBTAndroid development with Scala and SBT
Android development with Scala and SBT
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Vývojařská Plzeň - React
Vývojařská Plzeň - ReactVývojařská Plzeň - React
Vývojařská Plzeň - React
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
 
Making React Native UI Components with Swift
Making React Native UI Components with SwiftMaking React Native UI Components with Swift
Making React Native UI Components with Swift
 
React native
React nativeReact native
React native
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 

Recently uploaded

E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
Envertis Software Solutions
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 

Recently uploaded (20)

E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 

JSAnkara Swift v React Native

  • 6. V
  • 7. What is Swift ? Apple’s new programming language Created by Chris Lattner, who wrote LLVM First appeared in June 2, 2014
  • 10.
  • 11. A Framework for building native apps using React Started as Facebook’s internal hackathon project, in the summer of 2013 The first public preview was in January of 2015 at React.js Conference What is React Native ?
  • 12. Web Developer friendly Multi-Platform Support Live reload (vs Compile&Wait) Why React Native ?
  • 15. render() { return ( <View style={styles.container}> <Background color={this.state.bgColor} /> <Header user={this.state.firstName} /> <CategoryScroller categories={this.state.categories} /> </View> ); Everything is component
  • 16. Props is data passed to child component <Header user={this.state.firstName} /> <Text> {this.getWelcomeText(this.props.user)} </Text> in header.jsin dashboard.js
  • 17. State is internal data of a component state = { email: '', password: '', valid: false, };
  • 18. To Start React Native brew install node brew install watchman npm install -g react-native-cli react-native init firstApp cd firstApp react-native run-ios
  • 19. Hello World import React, { Component } from 'react'; import { AppRegistry, Text } from 'react-native'; class HelloWorld extends Component { render() { return ( <Text>Hello world!</Text> ); } } AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
  • 20. Hello World import React, { Component } from 'react'; import { AppRegistry, Text } from 'react-native'; class HelloWorld extends Component { render() { return ( <Text>Hello world!</Text> ); } } AppRegistry.registerComponent('HelloWorld', () => HelloWorld); Hello world!
  • 21. Let's use Swift and React Native together
  • 22. { "name": “ios-rn“, "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/ cli.js start" }, "dependencies": { "react": "16.0.0-alpha.6", "react-native": "^0.44.0" } } package.json npm install or yarn
  • 24.
  • 25. export class RegisterView extends Component { constructor(props) { super(props); this.state = { value: '', } } render() { return ( <View style={styles.container}> <TextInput placeholder={'Adınızı giriniz'} style={styles.textInput} onChangeText={(v) => this.setState({ value: v })} /> <Button onPress={() => { this.printHello() }} title='OK' /> <Button onPress={() => { this.goBack() }} title='GO BACK' /> </View> ); } } register.js
  • 26. import React from 'react'; import { AppRegistry } from 'react-native'; import { RegisterView } from './src/register'; AppRegistry.registerComponent('RegisterView', () => RegisterView); index.ios.js
  • 27. SecondVC.swift @IBOutlet var rnView: UIView! override func viewDidLoad() { super.viewDidLoad() let jsCodeLocation = URL(string: "http://localhost:8081/ index.ios.bundle?platform=ios") let rootView = RCTRootView( bundleURL: jsCodeLocation, moduleName: "RegisterView", initialProperties: nil, launchOptions: nil ) rootView!.frame = CGRect(x: 0, y: 0, width: rnView.frame.width, height: rnView.frame.height) rnView.addSubview(rootView!); }
  • 28. DEMO
  • 29. Let's run the Swift function in React Native
  • 30. @IBOutlet var lbl: UILabel! func goBack(){ navigationController?.popViewController(animated: true) } func printUserName(_ value : String){ lbl.text = "Hello " + value } SecondVC.swift
  • 31. #import "React/RCTBridgeModule.h" @interface RCT_EXTERN_MODULE(SecondVCModule, NSObject) RCT_EXTERN_METHOD(back: (nonnull NSNumber *)reactTag) RCT_EXTERN_METHOD(printName: (nonnull NSNumber *)reactTag value: (nonnull NSString *)value) @end NativeBridge.m
  • 32. @objc(SecondVCModule) class SecondVCModule: RCTEventEmitter{ @objc func back(_ reactTag: NSNumber) { DispatchQueue.main.async { if let view = self.bridge.uiManager.view(forReactTag: reactTag) { let cur: UIViewController! = view.reactViewController() if let c = cur as? SecondVC{ c.goBack(); } } } } @objc func printName(_ reactTag: NSNumber,value value: NSString) { DispatchQueue.main.async { if let view = self.bridge.uiManager.view(forReactTag: reactTag) { let cur: UIViewController! = view.reactViewController() if let c = cur as? SecondVC{ c.printUserName(value as String) } } } } } SecondVCModule.swift
  • 33. DEMO
  • 34. Send data from Swift to React Native
  • 35. contact.js export class ContactView extends React.Component { renderContactItem(contact) { return ( <View key={contact.name} style={styles.item} > <Text style={styles.name} >{contact.name} </Text> <Text style={styles.phone}>{contact.phone} </Text> </View> ); } render() { return ( <View style={styles.container} > <Text style={styles.title} > Your Friends </Text> {// render Contact items} </View>); } }
  • 36. ContactVC.swift let mockData:NSDictionary = ["contacts": [ ["name":"Alex", "phone":"+90 648 274 26 19"], ["name":"Joel", "phone":"+90 342 452 45 64"] ] ] let rootView = RCTRootView( bundleURL: jsCodeLocation, moduleName: "ContactView", initialProperties: mockData as [NSObject : AnyObject], launchOptions: nil ) let rootView = RCTRootView( bundleURL: jsCodeLocation, moduleName: "RegisterView", initialProperties: nil, launchOptions: nil ) before
  • 37. contact.js export class ContactView extends React.Component { renderContactItem(contact) { return ( <View key={contact.name} style={styles.item} > <Text style={styles.name} >{contact.name} </Text> <Text style={styles.phone}>{contact.phone} </Text> </View> ); } render() { return ( <View style={styles.container} > <Text style={styles.title} > Your Friends </Text> {this.props["contacts"].map(contact => this.renderContactItem(contact))} </View>); } }
  • 38. SecondVCModule.swift export class ContactView extends React.Component { renderContactItem(contact) { return ( <View key={contact.name} style={{ height: 50, flexDirection: 'row', margin: 8, padding: 8, justifyContent: 'space-between', alignItems: 'center' }} > <Text style={{ fontSize: 30 }} >{contact.name} </Text> <Text style={{ fontSize: 20 }}>{contact.phone} </Text> </View> ); } render() { return (<View style={{ flex: 1, justifyContent: 'center' }} > <Text style={{ fontSize: 50,fontWeight:'bold' }} > Your Friends</Text> { this.props["contacts"].map(contact => this.renderContactItem(contact)) } </View>); } } Hello world!
  • 39. DEMO
  • 40. Who are using React Native ?
  • 41. THANK YOU ANY QUESTION ? @muhammetdemirci muhammed@otsimo.com