chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-06 21:10:18 -07:00
parent f6c7fdad0c
commit 49cd2f0df3
10 changed files with 113 additions and 55 deletions

View File

@@ -3,7 +3,7 @@
"main": "index",
"types": "index.d.ts",
"description": "NativeScript Core Modules",
"version": "6.5.10",
"version": "7.0.0-rc.0",
"homepage": "https://www.nativescript.org",
"repository": {
"type": "git",
@@ -23,13 +23,13 @@
"css-tree": "^1.0.0-alpha.39",
"reduce-css-calc": "^2.1.6",
"semver": "~7.3.2",
"tns-core-modules-widgets": "~6.5.2",
"@nativescript/core-widgets": "~7.0.0-rc.0",
"tslib": "~2.0.0"
},
"devDependencies": {
"@types/chai": "~4.2.11",
"@types/node": "~14.0.14",
"tns-platform-declarations": "~6.5.8"
"@nativescript/types": "~7.0.0-rc.0"
},
"scripts": {
"version": "conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md",

View File

@@ -0,0 +1,7 @@
import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view';
export declare class ContentView extends CustomLayoutView implements AddChildFromBuilder {
content: View;
layoutView(): View;
_addChildFromBuilder(name: string, value: any): void;
}

View File

@@ -1,13 +1,12 @@
import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view';
import { layout } from '../../utils';
import { isIOS } from '../../platform';
import { ContentView as ContentViewDefinition } from '.';
/**
* Represents a View that has a single child - content.
* The View itself does not have visual representation and serves as a placeholder for its content in the logical tree.
*/
export class ContentView extends CustomLayoutView implements ContentViewDefinition, AddChildFromBuilder {
export class ContentView extends CustomLayoutView implements AddChildFromBuilder {
private _content: View;
/**

View File

@@ -382,3 +382,14 @@ export function action(arg: any): Promise<string> {
}
});
}
/**
* Singular rollup for convenience of all dialog methods
*/
export const Dialogs = {
alert,
confirm,
prompt,
login,
action,
};

View File

@@ -293,3 +293,14 @@ export interface LoginResult {
*/
password: string;
}
/**
* Singular rollup for convenience of all dialog methods
*/
export declare const Dialogs: {
alert: typeof alert;
confirm: typeof confirm;
prompt: typeof prompt;
login: typeof login;
action: typeof action;
};

View File

@@ -44,6 +44,46 @@ function raiseCallback(callback, result) {
callback(result);
}
}
function showUIAlertController(alertController: UIAlertController) {
let viewController = ios.rootController;
while (viewController && viewController.presentedViewController) {
viewController = viewController.presentedViewController;
}
if (!viewController) {
Trace.write(`No root controller found to open dialog.`, Trace.categories.Error, Trace.messageType.warn);
return;
}
if (alertController.popoverPresentationController) {
alertController.popoverPresentationController.sourceView = viewController.view;
alertController.popoverPresentationController.sourceRect = CGRectMake(viewController.view.bounds.size.width / 2.0, viewController.view.bounds.size.height / 2.0, 1.0, 1.0);
alertController.popoverPresentationController.permittedArrowDirections = 0;
}
let color = getButtonColors().color;
if (color) {
alertController.view.tintColor = color.ios;
}
let lblColor = getLabelColor();
if (lblColor) {
if (alertController.title) {
let title = NSAttributedString.alloc().initWithStringAttributes(alertController.title, <any>{ [NSForegroundColorAttributeName]: lblColor.ios });
alertController.setValueForKey(title, 'attributedTitle');
}
if (alertController.message) {
let message = NSAttributedString.alloc().initWithStringAttributes(alertController.message, <any>{ [NSForegroundColorAttributeName]: lblColor.ios });
alertController.setValueForKey(message, 'attributedMessage');
}
}
viewController.presentModalViewControllerAnimated(alertController, true);
}
export function alert(arg: any): Promise<void> {
return new Promise<void>((resolve, reject) => {
try {
@@ -218,45 +258,6 @@ export function login(...args: any[]): Promise<LoginResult> {
});
}
function showUIAlertController(alertController: UIAlertController) {
let viewController = ios.rootController;
while (viewController && viewController.presentedViewController) {
viewController = viewController.presentedViewController;
}
if (!viewController) {
Trace.write(`No root controller found to open dialog.`, Trace.categories.Error, Trace.messageType.warn);
return;
}
if (alertController.popoverPresentationController) {
alertController.popoverPresentationController.sourceView = viewController.view;
alertController.popoverPresentationController.sourceRect = CGRectMake(viewController.view.bounds.size.width / 2.0, viewController.view.bounds.size.height / 2.0, 1.0, 1.0);
alertController.popoverPresentationController.permittedArrowDirections = 0;
}
let color = getButtonColors().color;
if (color) {
alertController.view.tintColor = color.ios;
}
let lblColor = getLabelColor();
if (lblColor) {
if (alertController.title) {
let title = NSAttributedString.alloc().initWithStringAttributes(alertController.title, <any>{ [NSForegroundColorAttributeName]: lblColor.ios });
alertController.setValueForKey(title, 'attributedTitle');
}
if (alertController.message) {
let message = NSAttributedString.alloc().initWithStringAttributes(alertController.message, <any>{ [NSForegroundColorAttributeName]: lblColor.ios });
alertController.setValueForKey(message, 'attributedMessage');
}
}
viewController.presentModalViewControllerAnimated(alertController, true);
}
export function action(): Promise<string> {
let options: ActionOptions;
@@ -319,3 +320,14 @@ export function action(): Promise<string> {
}
});
}
/**
* Singular rollup for convenience of all dialog methods
*/
export const Dialogs = {
alert,
confirm,
prompt,
login,
action,
};

View File

@@ -5,17 +5,26 @@ export { BottomNavigation, SelectedIndexChangedEventData } from './bottom-naviga
export { Builder, LoadOptions } from './builder';
export { Button } from './button';
export { ContentView } from './content-view';
export { ViewBase, ShowModalOptions } from './core/view-base';
export { ViewBase, ShowModalOptions, eachDescendant, getAncestor, getViewById } from './core/view-base';
export { View, Template, KeyedTemplate, ShownModallyData } from './core/view';
export { Property, CoercibleProperty, InheritedProperty, CssProperty, InheritedCssProperty, ShorthandProperty, CssAnimationProperty, unsetValue } from './core/properties';
export { DatePicker } from './date-picker';
export { EditableTextBase } from './editable-text-base';
// No need go export dialogs, they are already export exported globally
export { action, alert, confirm, login, prompt, getCurrentPage, Dialogs, DialogStrings, DialogOptions, CancelableOptions, AlertOptions, PromptResult, PromptOptions, ActionOptions, ConfirmOptions, LoginResult, LoginOptions, inputType, capitalizationType } from './dialogs';
export * from './editable-text-base';
export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry } from './frame';
export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData } from './gestures';
export { HtmlView } from './html-view';
export { Image } from './image';
export { Cache as ImageCache, DownloadError, DownloadRequest, DownloadedData } from './image-cache';
export { Label } from './label';
export * from './layouts';
export * from './layouts'; // barrel export
export { ListPicker } from './list-picker';
export { ListView, ItemEventData, TemplatedItemsView, ItemsSource } from './list-view';
export { Page, NavigatedData } from './page';
@@ -27,14 +36,19 @@ export { ScrollView, ScrollEventData } from './scroll-view';
export { SearchBar } from './search-bar';
export { SegmentedBar, SegmentedBarItem } from './segmented-bar';
export { Slider } from './slider';
// TODO: Consider adding APIs from style
// export { addTaggedAdditionalCSS, removeTaggedAdditionalCSS } from "./styling/style-scope";
export { Style, CommonLayoutParams } from './styling/style';
export * from './styling/style-properties';
export { Switch } from './switch';
export { TabContentItem } from './tab-navigation-base/tab-content-item';
export { TabNavigationBase } from './tab-navigation-base/tab-navigation-base';
export { TabStrip, TabStripItemEventData } from './tab-navigation-base/tab-strip';
export { TabStripItem } from './tab-navigation-base/tab-strip-item';
export { TabView, TabViewItem } from './tab-view';
export { Tabs, IOSTabBarItemsAlignment } from './tabs';
export { Tabs } from './tabs';
export { TextBase } from './text-base';
export { FormattedString } from './text-base/formatted-string';
export { Span } from './text-base/span';

View File

@@ -11,9 +11,7 @@ export { Property, CoercibleProperty, InheritedProperty, CssProperty, InheritedC
export { DatePicker } from './date-picker';
// No need go export dialogs, they are already export exported globally
export * from './dialogs/dialogs-common';
import { action, alert, confirm, login, prompt } from './dialogs';
export const Dialogs = { action, alert, confirm, login, prompt };
export { action, alert, confirm, login, prompt, getCurrentPage, Dialogs, DialogStrings, DialogOptions, CancelableOptions, AlertOptions, PromptResult, PromptOptions, ActionOptions, ConfirmOptions, LoginResult, LoginOptions, inputType, capitalizationType } from './dialogs';
export * from './editable-text-base';
export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry } from './frame';