巨头们已经着手从上自下展开技术融合,Web App开发者们与Native App开发者们长年相互鄙视斗争的过程将要告一段落
Poker
PC WEB页面
Mobile WEB页面
Hybird WEB页面
Native UI页面
....
Broswer/Webview
Native UI Components
?
切图工程师/移动前端开发工程师/...
前端开发工程师
全端UI开发工程师
HTML + CSS + Javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{background: #fff;}
</style>
</head>
<body>
<div id="container">
<div class="aside">Text</div>
</div>
</body>
</html>
HTML + CSS + 模块化Javascript + Node.js构建工具
{
"name": "grunt-zbj",
"description": "The grunt command line interface.",
"version": "0.1.0",
"author": {
"name": "laotan"
},
"devDependencies": {
"grunt": "*",
"grunt-cachebuster": "~0.1.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "~0.1.1",
"grunt-contrib-copy": "^0.8.1",
"grunt-contrib-less": "~0.7.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-contrib-yuidoc": "~0.4.0"
}
}
Virtual Dom + 原生接口封装调用 + CSS
<ion-header-bar align-title="left" class="bar-positive">
<div class="buttons">
<button class="button" ng-click="doSomething()">左侧按钮</button>
</div>
<h1 class="title">Title!</h1>
<div class="buttons">
<button class="button">右侧按钮</button>
</div>
</ion-header-bar>
<ion-content>
一些内容!
</ion-content>
http://clouda.baidu.com/blend/introduction/introduction
http://clouda.baidu.com/blendui/introduction/introduction
都是通过封装调用原生接口进行移动特性开发,JS桥接类一般更适合提供非界面的原生能力,对于绘制界面则显得有些力不从心
在Hybird这个阶段,jscore的雏形已经形成,但是类DOM的core还没有完善,我们还在使用html+css套在原生native的webview中去实现页面前端UI
“为什么不直接使用webview套页面,保持100%的web开发模式?”
第一次尝试
WebView上面盖一个native层(透明),native组件替换WebView组件,替换(问题,滚动问题,js告诉na计算,不灵活)
第二次尝试
分为多个WebView,js控制WebView的切换,摈弃掉不灵活的地方
原理是,从视图组件树创建对应的css node树,渲染的时候,
css node树计算出布局信息,然后设置回来到视图组件树
原生view控件
性能 定制性强 学习成本低(因为他们将Zepto.js修改版移植到blendUI)
native渲染细节
基础封装web UI,动画基础封装
队列
...
类似Facebook的CssLayout,实现了自己ViewTree下面的CSSCore支持最基础的css属性
问题
view —— node
view view — — node node(css对应设置,通过cssNode中转)
view过多会造成堆栈溢出,层级多了之后,优化,移除透明层的view,merge相应节点坐标为绝对坐标)
在Hybird这个阶段,jscore的雏形已经形成,但是类DOM的core还没有完善,我们还在使用html+css套在原生native的webview中去实现页面前端UI
https://github.com/hackers-painters/samurai-native
<RefreshCollectionView id="list" name="list" class="list" columns="1" is-vertical
onswipe-left="@selector(nextTab:)"
onswipe-right="@selector(prevTab:)">
<UICollectionViewCell name="section-shots" class="list-item">
<div class="shot-wrapper"></div>
</UICollectionViewCell>
</RefreshCollectionView>
Samurai-Native的终极目标是想做成一个标准的Web浏览器内核,来为开发者们提供一款W3C标准WebCore的跨平台UI解决方案,既能渲染Web页面,又能生成原生View树。通过私有浏览器内核技术(Objective-C编写)将HTML+CSS解析渲染成为Native View树,从而既有Web开发体验,又有不错的用户体验。
构建基于私有浏览器内核的原生应用
通过实现自有浏览器解析,实现声明调用原生UI渲染
But 没有JavascriptCore
“兴奋的同时,一个无法回避的事实,对Web前端来说这是一个全新的领域,就是一个大坑,需要我们去填平,
填平这些坑的就是我们配套的基础设施。
当这些基础设施相对完善时,就是React Native爆发的时候,而我们现在做的事将是未来的肩膀。”
元彦
未来Web前端开发与Native移动应用开发工程师的工作职责很可能会相互重叠,平台之间的边界不会太明显,还会产生更专注于跨平台App UI及交互构建的“全终端开发工程师”。
欢迎来到全端“IE”时代!
React Native
一切语言我们都从Hello World开始
brew install node
brew install watchman
npm install -g react-native-cli
react-native init PropertyFinder
'use strict'
var React = require('react-native');
var styles = React.StyleSheet.create({
text:{
color: 'black',
backgroundColor: 'white',
fontSize: 30,
margin: 110
}
});
var renderText = <React.Text style={styles.text}>
Hello Poker
</React.Text>;
class PropertyFinderApp extends React.Component{
render(){
return renderText;
}
}
React.AppRegistry.registerComponent('PropertyFinder', function() {
return PropertyFinderApp
});
Run it
React提出重新思考UI开发过程,其实不是面向浏览器,而是所有的前端,因为对前端开发而言我们需要涉及的领域已经开始包括了Web与Native。”
元彦
Web是未来,Native是当下,而我们在未来与当下之间。