mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-20 07:26:11 +08:00
Merge branch 'master' of github.com:NativeScript/NativeScript
# Conflicts: # packages/core/package.json # packages/core/ui/tabs/index.android.ts
This commit is contained in:
30
CHANGELOG.md
30
CHANGELOG.md
@ -1,3 +1,33 @@
|
||||
## [7.0.8](https://github.com/NativeScript/NativeScript/compare/7.0.7-core...7.0.8) (2020-09-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **core:** global index typing fix for unit testing framework ([#8915](https://github.com/NativeScript/NativeScript/issues/8915)) ([806fc88](https://github.com/NativeScript/NativeScript/commit/806fc880dd944a8808a0f407ae5d0c0d4be55d5d))
|
||||
* **core:** Observable splice index > length ([#8900](https://github.com/NativeScript/NativeScript/issues/8900)) ([65b1cdb](https://github.com/NativeScript/NativeScript/commit/65b1cdbae0a9e873a3d2bc4636038423351b794e))
|
||||
* **ios:** Utils.openFile ([#8914](https://github.com/NativeScript/NativeScript/issues/8914)) ([647926e](https://github.com/NativeScript/NativeScript/commit/647926ee281712a82238d5153522d9a07be5870c))
|
||||
|
||||
|
||||
|
||||
## [7.0.7](https://github.com/NativeScript/NativeScript/compare/7.0.6-core...7.0.7) (2020-09-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ios:** preferredDatePickerStyle property ([#8899](https://github.com/NativeScript/NativeScript/issues/8899)) ([dbefc43](https://github.com/NativeScript/NativeScript/commit/dbefc43b9bb9b907883990f8d40c178fc7ecea9c))
|
||||
|
||||
|
||||
|
||||
## [7.0.6](https://github.com/NativeScript/NativeScript/compare/7.0.5-core...7.0.6) (2020-09-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **core:** delegate should be set on nativeTextViewProtected ([#8881](https://github.com/NativeScript/NativeScript/issues/8881)) ([021c0bb](https://github.com/NativeScript/NativeScript/commit/021c0bb9a24f15a9adf9d5e25a981ea53901e600))
|
||||
* **core:** global handling with env.production flag ([#8903](https://github.com/NativeScript/NativeScript/issues/8903)) ([3437ed7](https://github.com/NativeScript/NativeScript/commit/3437ed7e1483cddf75aeca9bd8ff475e449f110f))
|
||||
|
||||
|
||||
|
||||
## [7.0.5](https://github.com/NativeScript/NativeScript/compare/7.0.4-core...7.0.5) (2020-09-23)
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<p align="center">
|
||||
<a href="http://www.nativescript.org">
|
||||
<img alt="NativeScript" src="https://i.imgur.com/YmNIMqS.png" />
|
||||
<img alt="NativeScript" src="https://d1lfyz5kwt8vu9.cloudfront.net/nativescript-logo.png" width="100"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@ -11,7 +11,7 @@ NativeScript
|
||||
[](https://travis-ci.org/NativeScript/NativeScript)
|
||||
|
||||
|
||||
[NativeScript](http://www.nativescript.org) empowers you to access native api's from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile development and can be utilized in a number of diverse use cases.
|
||||
[NativeScript](http://www.nativescript.org) empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile development and can be utilized in a number of diverse use cases.
|
||||
|
||||
## Getting Started and Installation
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nativescript",
|
||||
"version": "7.0.5",
|
||||
"version": "7.0.8",
|
||||
"license": "MIT",
|
||||
"config": {
|
||||
"npm_alias": "npm"
|
||||
|
@ -30,6 +30,7 @@
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"../global-types.d.ts",
|
||||
"./**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
|
@ -476,24 +476,23 @@ function ensureBroadCastReceiverClass() {
|
||||
return;
|
||||
}
|
||||
|
||||
@NativeClass
|
||||
class BroadcastReceiver extends android.content.BroadcastReceiver {
|
||||
private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void;
|
||||
@NativeClass
|
||||
class BroadcastReceiver extends android.content.BroadcastReceiver {
|
||||
private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void;
|
||||
|
||||
constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) {
|
||||
super();
|
||||
this._onReceiveCallback = onReceiveCallback;
|
||||
constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) {
|
||||
super();
|
||||
this._onReceiveCallback = onReceiveCallback;
|
||||
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
public onReceive(context: android.content.Context, intent: android.content.Intent) {
|
||||
if (this._onReceiveCallback) {
|
||||
this._onReceiveCallback(context, intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
public onReceive(context: android.content.Context, intent: android.content.Intent) {
|
||||
if (this._onReceiveCallback) {
|
||||
this._onReceiveCallback(context, intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BroadcastReceiverClass = BroadcastReceiver;
|
||||
}
|
||||
|
2
packages/core/application/index.d.ts
vendored
2
packages/core/application/index.d.ts
vendored
@ -62,7 +62,7 @@ export let autoSystemAppearanceChanged: boolean;
|
||||
/**
|
||||
* enable/disable systemAppearanceChanged
|
||||
*/
|
||||
export function setAutoSystemAppearanceChanged (value: boolean);
|
||||
export function setAutoSystemAppearanceChanged(value: boolean);
|
||||
|
||||
/**
|
||||
* Updates root view classes including those of modals
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type {InstrumentationMode} from '../profiling'
|
||||
import type { InstrumentationMode } from '../profiling';
|
||||
|
||||
interface IConfigPlatform {
|
||||
/**
|
||||
@ -144,4 +144,3 @@ export interface NativeScriptConfig {
|
||||
*/
|
||||
cssParser?: 'rework' | 'nativescript' | 'css-tree';
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
export * from './config.interface';
|
||||
export * from './config.interface';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {android as androidApp, getNativeApplication} from '../application';
|
||||
import { android as androidApp, getNativeApplication } from '../application';
|
||||
|
||||
export enum connectionType {
|
||||
none = 0,
|
||||
|
@ -246,7 +246,7 @@ export class ObservableArray<T> extends Observable {
|
||||
eventName: CHANGE,
|
||||
object: this,
|
||||
action: ChangeType.Splice,
|
||||
index: start,
|
||||
index: Math.min(start, this._array.length-1),
|
||||
removed: result,
|
||||
addedCount: this._array.length + result.length - length,
|
||||
});
|
||||
|
2
packages/core/globals/index.d.ts
vendored
2
packages/core/globals/index.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import { Observable } from '../data/observable';
|
||||
export declare class NativeScriptGlobalState {
|
||||
events: Observable<any>;
|
||||
events: Observable;
|
||||
launched: boolean;
|
||||
}
|
||||
export function installPolyfills(moduleName: string, exportNames: string[]): void;
|
||||
|
@ -359,5 +359,5 @@ export function initGlobal() {
|
||||
}
|
||||
}
|
||||
if (!global.NativeScriptHasInitGlobal) {
|
||||
initGlobal();
|
||||
}
|
||||
initGlobal();
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ export const Application = {
|
||||
loadAppCss,
|
||||
addCss,
|
||||
on,
|
||||
off,
|
||||
notify,
|
||||
hasListeners,
|
||||
off,
|
||||
notify,
|
||||
hasListeners,
|
||||
run,
|
||||
orientation,
|
||||
getNativeApplication,
|
||||
@ -135,11 +135,11 @@ export const Utils = {
|
||||
android: androidUtils,
|
||||
// legacy (a lot of plugins use the shorthand "ad" Utils.ad instead of Utils.android)
|
||||
ad: androidUtils,
|
||||
ios: iosUtils,
|
||||
setTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
clearTimeout,
|
||||
ios: iosUtils,
|
||||
setTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
clearTimeout,
|
||||
Source,
|
||||
ClassInfo,
|
||||
getClass,
|
||||
|
@ -1,5 +1,5 @@
|
||||
console.log('Loading inspector modules...');
|
||||
import './globals';
|
||||
import './globals';
|
||||
require('./debugger/webinspector-network');
|
||||
require('./debugger/webinspector-dom');
|
||||
require('./debugger/webinspector-css');
|
||||
|
@ -3,7 +3,7 @@
|
||||
"main": "index",
|
||||
"types": "index.d.ts",
|
||||
"description": "NativeScript Core Modules",
|
||||
"version": "7.0.6-alpha.2",
|
||||
"version": "7.0.8",
|
||||
"homepage": "https://nativescript.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -456,7 +456,7 @@ export class BottomNavigation extends TabNavigationBase {
|
||||
const fragmentManager = this._getFragmentManager();
|
||||
const transaction = fragmentManager.beginTransaction();
|
||||
const fragments = fragmentManager.getFragments().toArray();
|
||||
for (let i=0;i<fragments.length;i++) {
|
||||
for (let i = 0; i < fragments.length; i++) {
|
||||
transaction.remove(fragments[i]);
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,18 @@
|
||||
// Types
|
||||
import {TabContentItem} from '../tab-navigation-base/tab-content-item';
|
||||
import {TabStrip} from '../tab-navigation-base/tab-strip';
|
||||
import {TabStripItem} from '../tab-navigation-base/tab-strip-item';
|
||||
import {getTransformedText, TextTransform} from '../text-base';
|
||||
import { TabContentItem } from '../tab-navigation-base/tab-content-item';
|
||||
import { TabStrip } from '../tab-navigation-base/tab-strip';
|
||||
import { TabStripItem } from '../tab-navigation-base/tab-strip-item';
|
||||
import { getTransformedText, TextTransform } from '../text-base';
|
||||
|
||||
// Requires
|
||||
import {Color} from '../../color';
|
||||
import {ImageSource} from '../../image-source';
|
||||
import {Device} from '../../platform';
|
||||
import {iOSNativeHelper, isFontIconURI, layout} from '../../utils';
|
||||
import {CSSType, IOSHelper, View} from '../core/view';
|
||||
import {Frame} from '../frame';
|
||||
import {Font} from '../styling/font';
|
||||
import {
|
||||
getIconSpecSize,
|
||||
itemsProperty,
|
||||
selectedIndexProperty,
|
||||
TabNavigationBase,
|
||||
tabStripProperty
|
||||
} from '../tab-navigation-base/tab-navigation-base';
|
||||
import { Color } from '../../color';
|
||||
import { ImageSource } from '../../image-source';
|
||||
import { Device } from '../../platform';
|
||||
import { iOSNativeHelper, isFontIconURI, layout } from '../../utils';
|
||||
import { CSSType, IOSHelper, View } from '../core/view';
|
||||
import { Frame } from '../frame';
|
||||
import { Font } from '../styling/font';
|
||||
import { getIconSpecSize, itemsProperty, selectedIndexProperty, TabNavigationBase, tabStripProperty } from '../tab-navigation-base/tab-navigation-base';
|
||||
|
||||
// TODO:
|
||||
// import { profile } from "../../profiling";
|
||||
|
@ -95,7 +95,7 @@ const createComponentInstance = profile('createComponentInstance', (elementName:
|
||||
}
|
||||
|
||||
// Get the component type from module.
|
||||
const instanceType = instanceModule[elementName];
|
||||
const instanceType = instanceModule[elementName];
|
||||
|
||||
// Create instance of the component.
|
||||
instance = new instanceType();
|
||||
|
@ -305,7 +305,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
||||
super();
|
||||
this._domId = viewIdCounter++;
|
||||
this._style = new Style(new WeakRef(this));
|
||||
this.notify({eventName: ViewBase.createdEvent, type: this.constructor.name, object: this});
|
||||
this.notify({ eventName: ViewBase.createdEvent, type: this.constructor.name, object: this });
|
||||
}
|
||||
|
||||
// Used in Angular.
|
||||
|
@ -13,6 +13,7 @@ export class DatePickerBase extends View implements DatePickerDefinition {
|
||||
public maxDate: Date;
|
||||
public minDate: Date;
|
||||
public date: Date;
|
||||
public iosPreferredDatePickerStyle: number;
|
||||
}
|
||||
|
||||
DatePickerBase.prototype.recycleNativeView = 'auto';
|
||||
@ -60,3 +61,10 @@ export const dateProperty = new Property<DatePickerBase, Date>({
|
||||
valueConverter: (v) => new Date(v),
|
||||
});
|
||||
dateProperty.register(DatePickerBase);
|
||||
|
||||
export const iosPreferredDatePickerStyleProperty = new Property<DatePickerBase, number>({
|
||||
name: 'iosPreferredDatePickerStyle',
|
||||
defaultValue: 0,
|
||||
valueConverter: (v) => parseInt(v),
|
||||
});
|
||||
iosPreferredDatePickerStyleProperty.register(DatePickerBase);
|
11
packages/core/ui/date-picker/index.d.ts
vendored
11
packages/core/ui/date-picker/index.d.ts
vendored
@ -7,6 +7,7 @@ export const dayProperty: Property<DatePicker, number>;
|
||||
export const dateProperty: Property<DatePicker, Date>;
|
||||
export const maxDate: Property<DatePicker, Date>;
|
||||
export const minDate: Property<DatePicker, Date>;
|
||||
export const iosPreferredDatePickerStyleProperty: Property<DatePicker, number>;
|
||||
|
||||
/**
|
||||
* Represents an date picker.
|
||||
@ -51,4 +52,14 @@ export class DatePicker extends View {
|
||||
* Gets or sets the min date.
|
||||
*/
|
||||
minDate: Date;
|
||||
|
||||
/**
|
||||
* Gets or set the UIDatePickerStyle of the date picker in iOS 13.4+. Defaults to 0.
|
||||
* Valid values are numbers:
|
||||
* - 0: automatic (system picks the concrete style based on the current platform and date picker mode)
|
||||
* - 1: wheels (the date picker displays as a wheel picker)
|
||||
* - 2: compact (the date picker displays as a label that when tapped displays a calendar-style editor)
|
||||
* - 3: inline (the date pickers displays as an inline, editable field)
|
||||
*/
|
||||
iosPreferredDatePickerStyle: number;
|
||||
}
|
||||
|
@ -5,9 +5,8 @@ import { Device } from '../../platform';
|
||||
|
||||
export * from './date-picker-common';
|
||||
|
||||
const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.os) >= 14.0;
|
||||
const SUPPORT_TEXT_COLOR = parseFloat(Device.os) < 14.0;
|
||||
const DEFAULT_DATE_PICKER_STYLE = 1;
|
||||
const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.osVersion) >= 13.4;
|
||||
const SUPPORT_TEXT_COLOR = parseFloat(Device.osVersion) < 14.0;
|
||||
|
||||
export class DatePicker extends DatePickerBase {
|
||||
private _changeHandler: NSObject;
|
||||
@ -17,7 +16,7 @@ export class DatePicker extends DatePickerBase {
|
||||
const picker = UIDatePicker.new();
|
||||
picker.datePickerMode = UIDatePickerMode.Date;
|
||||
if (SUPPORT_DATE_PICKER_STYLE) {
|
||||
picker.preferredDatePickerStyle = DEFAULT_DATE_PICKER_STYLE;
|
||||
picker.preferredDatePickerStyle = this.iosPreferredDatePickerStyle;
|
||||
}
|
||||
return picker;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ const FragmentClass = (<any>org.nativescript.widgets.FragmentBase).extend('com.t
|
||||
},
|
||||
|
||||
onPause(): void {
|
||||
this._callbacks.onPause(this, superProto.onStop);
|
||||
this._callbacks.onPause(this, superProto.onPause);
|
||||
},
|
||||
|
||||
onCreate(savedInstanceState: android.os.Bundle) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import '../../../globals';
|
||||
import { isNullOrUndefined } from '../../../utils/types';
|
||||
|
||||
import * as cssParser from '../../../css';
|
||||
|
@ -54,7 +54,7 @@ export class TabContentItem extends TabContentItemBase {
|
||||
}
|
||||
|
||||
const fragments = fragmentManager.getFragments().toArray();
|
||||
for (let i=0;i<fragments.length;i++) {
|
||||
for (let i = 0; i < fragments.length; i++) {
|
||||
if (fragments[i].index === this.index) {
|
||||
tabFragment = fragments[i];
|
||||
break;
|
||||
|
@ -366,7 +366,7 @@ export class TabViewItem extends TabViewItemBase {
|
||||
let tabFragment = null;
|
||||
const fragmentManager = tabView._getFragmentManager();
|
||||
const fragments = fragmentManager.getFragments().toArray();
|
||||
for (let i=0;i<fragments.length;i++) {
|
||||
for (let i = 0; i < fragments.length; i++) {
|
||||
if (fragments[i].index === this.index) {
|
||||
tabFragment = fragments[i];
|
||||
break;
|
||||
@ -624,7 +624,7 @@ export class TabView extends TabViewBase {
|
||||
const fragmentManager = this._getFragmentManager();
|
||||
const transaction = fragmentManager.beginTransaction();
|
||||
let fragments = <Array<any>>fragmentManager.getFragments().toArray();
|
||||
for (let i=0;i<fragments.length;i++) {
|
||||
for (let i = 0; i < fragments.length; i++) {
|
||||
transaction.remove(fragments[i]);
|
||||
}
|
||||
transaction.commitNowAllowingStateLoss();
|
||||
|
@ -27,25 +27,25 @@ export abstract class TextBaseCommon extends View implements TextBaseDefinition
|
||||
public formattedText: FormattedString;
|
||||
|
||||
/***
|
||||
* In the NativeScript Core; by default the nativeTextViewProtected points to the same value as nativeViewProtected.
|
||||
* At this point no internal NS components need this indirection functionality.
|
||||
* This indirection is used to allow support usage by third party components so they don't have to duplicate functionality.
|
||||
*
|
||||
* A third party component can just override the `nativeTextViewProtected` getter and return a different internal view and that view would be
|
||||
* what all TextView/TextInput class features would be applied to.
|
||||
*
|
||||
* A example is the Android MaterialDesign TextInput class, it has a wrapper view of a TextInputLayout
|
||||
* https://developer.android.com/reference/com/google/android/material/textfield/TextInputLayout
|
||||
* which wraps the actual TextInput. This wrapper layout (TextInputLayout) must be assigned to the nativeViewProtected as the entire
|
||||
* NS Core uses nativeViewProtected for everything related to layout, so that it can be measured, added to the parent view as a child, ect.
|
||||
*
|
||||
* However, its internal view would be the actual TextView/TextInput and to allow that sub-view to have the normal TextView/TextInput
|
||||
* class features, which we expose and to allow them to work on it, the internal TextView/TextInput is what the needs to have the class values applied to it.
|
||||
*
|
||||
* So all code that works on what is expected to be a TextView/TextInput should use `nativeTextViewProtected` so that any third party
|
||||
* components that need to have two separate components can work properly without them having to duplicate all the TextBase (and decendants) functionality
|
||||
* by just overriding the nativeTextViewProtected getter.
|
||||
**/
|
||||
* In the NativeScript Core; by default the nativeTextViewProtected points to the same value as nativeViewProtected.
|
||||
* At this point no internal NS components need this indirection functionality.
|
||||
* This indirection is used to allow support usage by third party components so they don't have to duplicate functionality.
|
||||
*
|
||||
* A third party component can just override the `nativeTextViewProtected` getter and return a different internal view and that view would be
|
||||
* what all TextView/TextInput class features would be applied to.
|
||||
*
|
||||
* A example is the Android MaterialDesign TextInput class, it has a wrapper view of a TextInputLayout
|
||||
* https://developer.android.com/reference/com/google/android/material/textfield/TextInputLayout
|
||||
* which wraps the actual TextInput. This wrapper layout (TextInputLayout) must be assigned to the nativeViewProtected as the entire
|
||||
* NS Core uses nativeViewProtected for everything related to layout, so that it can be measured, added to the parent view as a child, ect.
|
||||
*
|
||||
* However, its internal view would be the actual TextView/TextInput and to allow that sub-view to have the normal TextView/TextInput
|
||||
* class features, which we expose and to allow them to work on it, the internal TextView/TextInput is what the needs to have the class values applied to it.
|
||||
*
|
||||
* So all code that works on what is expected to be a TextView/TextInput should use `nativeTextViewProtected` so that any third party
|
||||
* components that need to have two separate components can work properly without them having to duplicate all the TextBase (and decendants) functionality
|
||||
* by just overriding the nativeTextViewProtected getter.
|
||||
**/
|
||||
get nativeTextViewProtected() {
|
||||
return this.nativeViewProtected;
|
||||
}
|
||||
|
12
packages/core/ui/time-picker/index.d.ts
vendored
12
packages/core/ui/time-picker/index.d.ts
vendored
@ -54,6 +54,16 @@ export class TimePicker extends View {
|
||||
* Gets or sets the minute interval.
|
||||
*/
|
||||
minuteInterval: number;
|
||||
|
||||
/**
|
||||
* Gets or set the UIDatePickerStyle of the date picker in iOS 13.4+. Defaults to 0.
|
||||
* Valid values are numbers:
|
||||
* - 0: automatic (system picks the concrete style based on the current platform and date picker mode)
|
||||
* - 1: wheels (the date picker displays as a wheel picker)
|
||||
* - 2: compact (the date picker displays as a label that when tapped displays a calendar-style editor)
|
||||
* - 3: inline (the date pickers displays as an inline, editable field)
|
||||
*/
|
||||
iosPreferredDatePickerStyle: number;
|
||||
}
|
||||
|
||||
export const hourProperty: Property<TimePicker, number>;
|
||||
@ -66,3 +76,5 @@ export const minMinuteProperty: Property<TimePicker, number>;
|
||||
|
||||
export const timeProperty: Property<TimePicker, Date>;
|
||||
export const minuteIntervalProperty: Property<TimePicker, number>;
|
||||
|
||||
export const iosPreferredDatePickerStyleProperty: Property<TimePicker, number>;
|
@ -5,9 +5,8 @@ import { Device } from '../../platform';
|
||||
|
||||
export * from './time-picker-common';
|
||||
|
||||
const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.os) >= 14.0;
|
||||
const SUPPORT_TEXT_COLOR = parseFloat(Device.os) < 14.0;
|
||||
const DEFAULT_DATE_PICKER_STYLE = 1;
|
||||
const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.osVersion) >= 13.4;
|
||||
const SUPPORT_TEXT_COLOR = parseFloat(Device.osVersion) < 14.0;
|
||||
|
||||
function getDate(hour: number, minute: number): Date {
|
||||
let components = NSDateComponents.alloc().init();
|
||||
@ -36,7 +35,7 @@ export class TimePicker extends TimePickerBase {
|
||||
const picker = UIDatePicker.new();
|
||||
picker.datePickerMode = UIDatePickerMode.Time;
|
||||
if (SUPPORT_DATE_PICKER_STYLE) {
|
||||
picker.preferredDatePickerStyle = DEFAULT_DATE_PICKER_STYLE;
|
||||
picker.preferredDatePickerStyle = this.iosPreferredDatePickerStyle;
|
||||
}
|
||||
return picker;
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ export abstract class TimePickerBase extends View implements TimePickerDefinitio
|
||||
public maxHour: number;
|
||||
public minMinute: number;
|
||||
public maxMinute: number;
|
||||
public iosPreferredDatePickerStyle: number;
|
||||
}
|
||||
|
||||
TimePickerBase.prototype.recycleNativeView = 'auto';
|
||||
@ -204,3 +205,10 @@ export const timeProperty = new Property<TimePickerBase, Date>({
|
||||
},
|
||||
});
|
||||
timeProperty.register(TimePickerBase);
|
||||
|
||||
export const iosPreferredDatePickerStyleProperty = new Property<TimePickerBase, number>({
|
||||
name: 'iosPreferredDatePickerStyle',
|
||||
defaultValue: 0,
|
||||
valueConverter: (v) => parseInt(v),
|
||||
});
|
||||
iosPreferredDatePickerStyleProperty.register(TimePickerBase);
|
||||
|
@ -11,7 +11,7 @@ export function openFile(filePath: string): boolean {
|
||||
let path = iOSNativeHelper.isRealDevice() ? filePath.replace('~', appPath) : filePath;
|
||||
|
||||
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
||||
controller.delegate = <UIDocumentInteractionControllerDelegate>new iOSNativeHelper.UIDocumentInteractionControllerDelegateImpl();
|
||||
controller.delegate = iOSNativeHelper.createUIDocumentInteractionControllerDelegate();
|
||||
|
||||
return controller.presentPreviewAnimated(true);
|
||||
} catch (e) {
|
||||
|
5
packages/core/utils/native-helper.d.ts
vendored
5
packages/core/utils/native-helper.d.ts
vendored
@ -168,7 +168,10 @@ export namespace iOSNativeHelper {
|
||||
*/
|
||||
export function applyRotateTransform(transform: any /* CATransform3D*/, x: number, y: number, z: number): any; /* CATransform3D*/
|
||||
|
||||
export class UIDocumentInteractionControllerDelegateImpl {}
|
||||
/**
|
||||
* Create a UIDocumentInteractionControllerDelegate implementation for use with UIDocumentInteractionController
|
||||
*/
|
||||
export function createUIDocumentInteractionControllerDelegate(): any;
|
||||
|
||||
/**
|
||||
* Checks whether the application is running on real device and not on simulator.
|
||||
|
@ -14,7 +14,7 @@ function openFileAtRootModule(filePath: string): boolean {
|
||||
let path = iOSNativeHelper.isRealDevice() ? filePath.replace('~', appPath) : filePath;
|
||||
|
||||
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
||||
controller.delegate = new iOSNativeHelper.UIDocumentInteractionControllerDelegateImpl();
|
||||
controller.delegate = iOSNativeHelper.createUIDocumentInteractionControllerDelegate();
|
||||
|
||||
return controller.presentPreviewAnimated(true);
|
||||
} catch (e) {
|
||||
@ -125,30 +125,33 @@ export namespace iOSNativeHelper {
|
||||
}
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
@NativeClass
|
||||
export class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UIDocumentInteractionControllerDelegate {
|
||||
public static ObjCProtocols = [UIDocumentInteractionControllerDelegate];
|
||||
|
||||
public getViewController(): UIViewController {
|
||||
const app = UIApplication.sharedApplication;
|
||||
|
||||
return app.keyWindow.rootViewController;
|
||||
}
|
||||
|
||||
public documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController();
|
||||
}
|
||||
|
||||
public documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController().view;
|
||||
}
|
||||
|
||||
public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect {
|
||||
return this.getViewController().view.frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createUIDocumentInteractionControllerDelegate(): NSObject {
|
||||
@NativeClass
|
||||
class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UIDocumentInteractionControllerDelegate {
|
||||
public static ObjCProtocols = [UIDocumentInteractionControllerDelegate];
|
||||
|
||||
public getViewController(): UIViewController {
|
||||
const app = UIApplication.sharedApplication;
|
||||
|
||||
return app.keyWindow.rootViewController;
|
||||
}
|
||||
|
||||
public documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController();
|
||||
}
|
||||
|
||||
public documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController().view;
|
||||
}
|
||||
|
||||
public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect {
|
||||
return this.getViewController().view.frame;
|
||||
}
|
||||
}
|
||||
return new UIDocumentInteractionControllerDelegateImpl();
|
||||
}
|
||||
|
||||
export function isRealDevice() {
|
||||
try {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nativescript/webpack",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"main": "index",
|
||||
"description": "Webpack plugin for NativeScript",
|
||||
"homepage": "https://nativescript.org",
|
||||
|
Reference in New Issue
Block a user