From 49cd2f0df3c53b3d6d45032a05486ffff7c22f17 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 6 Jul 2020 21:10:18 -0700 Subject: [PATCH] chore: cleanup --- nativescript-core/package.json | 6 +- nativescript-core/ui/content-view/index.d.ts | 7 ++ nativescript-core/ui/content-view/index.ts | 3 +- nativescript-core/ui/dialogs/index.android.ts | 11 +++ nativescript-core/ui/dialogs/index.d.ts | 11 +++ nativescript-core/ui/dialogs/index.ios.ts | 90 +++++++++++-------- nativescript-core/ui/index.d.ts | 22 ++++- nativescript-core/ui/index.ts | 4 +- tns-core-modules-widgets/package.json | 6 +- tns-platform-declarations/package.json | 8 +- 10 files changed, 113 insertions(+), 55 deletions(-) create mode 100644 nativescript-core/ui/content-view/index.d.ts diff --git a/nativescript-core/package.json b/nativescript-core/package.json index 556f98a6d..7466799f5 100644 --- a/nativescript-core/package.json +++ b/nativescript-core/package.json @@ -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", diff --git a/nativescript-core/ui/content-view/index.d.ts b/nativescript-core/ui/content-view/index.d.ts new file mode 100644 index 000000000..392fe2395 --- /dev/null +++ b/nativescript-core/ui/content-view/index.d.ts @@ -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; +} diff --git a/nativescript-core/ui/content-view/index.ts b/nativescript-core/ui/content-view/index.ts index 13b7e8587..41e35d055 100644 --- a/nativescript-core/ui/content-view/index.ts +++ b/nativescript-core/ui/content-view/index.ts @@ -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; /** diff --git a/nativescript-core/ui/dialogs/index.android.ts b/nativescript-core/ui/dialogs/index.android.ts index 4add87789..f94b34466 100644 --- a/nativescript-core/ui/dialogs/index.android.ts +++ b/nativescript-core/ui/dialogs/index.android.ts @@ -382,3 +382,14 @@ export function action(arg: any): Promise { } }); } + +/** + * Singular rollup for convenience of all dialog methods + */ +export const Dialogs = { + alert, + confirm, + prompt, + login, + action, +}; diff --git a/nativescript-core/ui/dialogs/index.d.ts b/nativescript-core/ui/dialogs/index.d.ts index cc9bdbe6c..7536bdcb9 100644 --- a/nativescript-core/ui/dialogs/index.d.ts +++ b/nativescript-core/ui/dialogs/index.d.ts @@ -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; +}; diff --git a/nativescript-core/ui/dialogs/index.ios.ts b/nativescript-core/ui/dialogs/index.ios.ts index a29614707..459c9bf8c 100644 --- a/nativescript-core/ui/dialogs/index.ios.ts +++ b/nativescript-core/ui/dialogs/index.ios.ts @@ -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, { [NSForegroundColorAttributeName]: lblColor.ios }); + alertController.setValueForKey(title, 'attributedTitle'); + } + if (alertController.message) { + let message = NSAttributedString.alloc().initWithStringAttributes(alertController.message, { [NSForegroundColorAttributeName]: lblColor.ios }); + alertController.setValueForKey(message, 'attributedMessage'); + } + } + + viewController.presentModalViewControllerAnimated(alertController, true); +} + export function alert(arg: any): Promise { return new Promise((resolve, reject) => { try { @@ -218,45 +258,6 @@ export function login(...args: any[]): Promise { }); } -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, { [NSForegroundColorAttributeName]: lblColor.ios }); - alertController.setValueForKey(title, 'attributedTitle'); - } - if (alertController.message) { - let message = NSAttributedString.alloc().initWithStringAttributes(alertController.message, { [NSForegroundColorAttributeName]: lblColor.ios }); - alertController.setValueForKey(message, 'attributedMessage'); - } - } - - viewController.presentModalViewControllerAnimated(alertController, true); -} - export function action(): Promise { let options: ActionOptions; @@ -319,3 +320,14 @@ export function action(): Promise { } }); } + +/** + * Singular rollup for convenience of all dialog methods + */ +export const Dialogs = { + alert, + confirm, + prompt, + login, + action, +}; diff --git a/nativescript-core/ui/index.d.ts b/nativescript-core/ui/index.d.ts index adc552173..2dc8ce776 100644 --- a/nativescript-core/ui/index.d.ts +++ b/nativescript-core/ui/index.d.ts @@ -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'; diff --git a/nativescript-core/ui/index.ts b/nativescript-core/ui/index.ts index de0c5614f..2dc8ce776 100644 --- a/nativescript-core/ui/index.ts +++ b/nativescript-core/ui/index.ts @@ -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'; diff --git a/tns-core-modules-widgets/package.json b/tns-core-modules-widgets/package.json index 8b8b55201..7fb3d3f5f 100644 --- a/tns-core-modules-widgets/package.json +++ b/tns-core-modules-widgets/package.json @@ -1,7 +1,7 @@ { - "name": "tns-core-modules-widgets", - "version": "6.5.10", - "description": "Native widgets used in the NativeScript framework.", + "name": "@nativescript/core-widgets", + "version": "7.0.0-rc.0", + "description": "Native widgets used in @nativescript/core.", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/tns-platform-declarations/package.json b/tns-platform-declarations/package.json index e697af646..3d1e6eb70 100644 --- a/tns-platform-declarations/package.json +++ b/tns-platform-declarations/package.json @@ -1,7 +1,13 @@ { +<<<<<<< HEAD "name": "tns-platform-declarations", "version": "6.5.10", "description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects", +======= + "name": "@nativescript/types", + "version": "7.0.0-rc.0", + "description": "Platform-specific TypeScript declarations for NativeScript", +>>>>>>> chore: cleanup "main": "", "scripts": { "test": "tsc", @@ -22,7 +28,7 @@ "ns" ], "author": { - "name": "NativeScript Team", + "name": "NativeScript team", "email": "oss@nativescript.org", "url": "https://nativescript.org" },