跨平臺移動開發平臺,NativeScript 1.5.0 發布
NativeScript 1.5.0 發布,此版本更新內容:
重大改進
-
修改驗證器 XSD 模式的 XML 命名空間 (xmlns),從
xmlns="http://www.nativescript.org/tns.xsd"
修改為xmlns="http://schemas.nativescript.org/tns.xsd"
###Bug 修復
-
(#1089) http toString will raise error if response cannot be converted to string
-
(#1082) Null reference exception in view.android.setOnTouchListener method
-
(#1081) file-system writeTextSync will now unlock the file when it is done writing
-
(#1038) WebView with HTML string source does not render on old Android
-
(#1028) [iOS] SelectedIndex property of the TabView widget does not work
-
(#1021) page.loaded and page.navigatedTo events are fired twice on iOS
-
(#1019) search-bar color not applied correctly
-
(#1012) TextField/TextView CSS color not applied to cursor
-
(#1010) Slider CSS color/background-color support
-
(#1007) When application.start() is called twice on iOS, a meaningful error should be thrown
-
(#1004) ActivityIndicator CSS color support
-
(#1000) Border radius is not working on Android API 17
-
(#998) web-view images now will be loaded correctly with base url
-
(#993) CSS does not support new lowercase element names
-
(#990) Android 6 Webview onReceivedError
-
(#986) [iOS] The switch widget does not show up on the page
-
(#973) iOS owner pattern changed to use WeakRef in order to prevent memory leaks
-
(#966) Observable emits two
propertyChange
events when created with JSON -
(#963) Always set base URL in WebView
-
(#955) Gestures event arguments for Android fixed
-
(#941) global.ios missing (consistency)
-
(#940) ListView: Inconsistency retrieving bindingContext in tap handler
-
(#936) Subsequent animation of transition and rotation or scale will appear jumpy in iOS
-
(#889) vertical-align css inconsistency
-
(#820) The x and y components of an Android translate or scale animation are not animated together when delay is specified
-
(#801) Chained animations lose state on iOS
-
(#789) Error in Page Navigating Events order
-
(#781) ios page.showModal platform inconsistancies & bugs
-
(#715) Frame crashes on app restore occasionally
-
(#642) Ability to style other native widgets
###新特性
-
(#1001) Embed utility fonts: Awesome, Icons, etc
-
(#1102) Ability to specify an animation easing, i.e. curve in a platform-independent manner
-
(#1086) This will now allow the dialog to call the resolve function when cancelled by clicking outside
-
(#1057) Expose scroll event on ScrollView
-
(#1048) Event for start/end of an event
-
(#1041) Support binding for
class
property of views -
(#1034) Support CSS white-space: nowrap and normal
-
(#1020) DatePicker and TimePicker stylers added
-
(#1014) Button wrapText property
-
(#977) Smarter LiveSync
-
(#954) added simple showModal() overload
-
(#926) Context as to whether a navigation was back or not
-
(#922) Feature request: Add loading wheel to Dialogs module
-
(#875) CSS feature request:
text-decoration
-
(#856) Android 6 support
-
(#849) Implement dismissSoftInput() for search-bar
-
(#841) Distribute TypeScript definitions
-
(#767) Change Android navigation and tabs title color
-
(#727) Provide a way to get a reference to the currently showing modal page instance
-
(#693) ListView - the position of the item after scroll down is not correct
-
(#597) Some Complex Properties are Inconsistent with rest of API - Discussion
-
(#551) Ship a verified image picker plugin
-
(#364) Ability to use built-in system icons on ActionBarItems
下載:
NativeScript 可以使用 Javascript,CSS, XML 創建真正的 Native 跨平臺應用,支持 iOS Android,NativeScript 將您的跨平臺代碼翻譯成目標平臺的代碼。
UI 使用 XML 描述,CSS 樣式,在編譯時將 UI 轉化成本地原生代碼,最終得到正在的 Native 原生應用。
Telerik 公開了用于創建安卓、iOS和Windows Universal跨平臺原生應用的框架,NativeScript 的公共訪問權限。
NativeScript既不是一種新型的JavaScript語言,也不是原生功能的封裝器,它包括一個JavaScript運行時環境和一種將 JavaScript調用轉化為原生調用的機制。用JavaScript(或TypeScript,CoffeeScript等)語言編寫應用,之后在安 卓平臺用V8,在iOS和Windows Phone上用WebKit JavaScriptCore解釋應用。然后,NativeScript運行時環境找到原生的目標API,將JS數據類型轉化為相應的原生類型,然后調用原生API,并將得到的結果值返回,具體流程如下圖所示:
舉例來說,在安卓平臺上創建文件對象var file = new java.io.File(path);的步驟如下:
-
用V8解釋代碼
-
根據原數據確定相應的原生方法調用。原數據是在各個平臺上預先構建的提供類型和方法簽名的全部可用API集合。
-
類型轉換模塊將JavaScript的String類型轉換為一個java.lang.String對象
-
運行時環境為java.io.File創建一個代理對象
-
通過該代理將對原有JS File對象的調用委托給相應的Java實例
據Telerik介紹,與純原生代碼相比NativeScript運行時環境會帶來大概10%的性能損失。
NativeScript可以將其所支持平臺上的任意原生API作為目標,包括傳感器接口API和用Objective C,Java或.NET編寫的第三方庫。UI組件是原生的,UI事件由在JavaScript代碼中聲明的原生處理程序處理,如View.OnClickListener,UIControl.addTarget。
為了避免開發者需要對三個支持的平臺有深入的理解,該框架包含了一個抽象與原生代碼連接的NativeScript模塊層(NativeScript Modules Layer,NML), 可以自動將JavaScript調用轉化為原生調用。NML包含如下模 塊:Application,Camera,Color,Console,Data,File System,HTTP,Imaging,Local Settings,Location,Timer,UI。開發者并未受限于只能使用NML,也可以訪問任意原生API。
NativeScript其它一些功能簡單列示如下:
-
當前支持平臺:iOS7+,安卓4.2+。預計將在4月實現Windows Phone的支持。對安卓早期版本的支持也將很快到來。
-
iOS平臺的編譯可以在遠程完成,無需Mac電腦或iOS工具
-
開發工作可以在任意IDE中完成。
-
支持任意跨瀏覽器的JavaScript庫。
-
支持CSS。
-
支持MVVM。
-
即時支持新的原生平臺。
部分介紹來自 InfoQ