chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-07 15:57:02 -07:00
parent c6902538cf
commit 0ae8dba962
70 changed files with 585 additions and 520 deletions

View File

@@ -9,7 +9,7 @@ import { Color } from '../../color';
import { ImageSource } from '../../image-source';
import { Device } from '../../platform';
import { ios as iosUtils, isFontIconURI, layout } from '../../utils';
import { CSSType, ios as iosView, View } from '../core/view';
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';
@@ -44,7 +44,7 @@ class UITabBarControllerImpl extends UITabBarController {
// Unify translucent and opaque bars layout
this.extendedLayoutIncludesOpaqueBars = true;
iosView.updateAutoAdjustScrollInsets(this, owner);
IOSHelper.updateAutoAdjustScrollInsets(this, owner);
if (!owner.parent) {
owner.callLoaded();
@@ -86,7 +86,7 @@ class UITabBarControllerImpl extends UITabBarController {
const owner = this._owner.get();
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
owner.notify({
eventName: iosView.traitCollectionColorAppearanceChangedEvent,
eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent,
object: owner,
});
}
@@ -540,7 +540,7 @@ export class BottomNavigation extends TabNavigationBase {
newController = item.content.ios.controller;
(<any>item).setViewController(newController, newController.view);
} else {
newController = iosView.UILayoutViewController.initWithOwner(new WeakRef(item.content)) as UIViewController;
newController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(item.content)) as UIViewController;
newController.view.addSubview(item.content.nativeViewProtected);
item.content.viewController = newController;
(<any>item).setViewController(newController, item.content.nativeViewProtected);

View File

@@ -1,5 +1,4 @@
// Definitions.
import { ComponentModule } from '.';
import { View } from '../../core/view';
// Types.
@@ -11,6 +10,11 @@ import { Device } from '../../../platform';
import { sanitizeModuleName } from '../module-name-sanitizer';
import { resolveModuleName } from '../../../module-name-resolver';
export interface ComponentModule {
component: View;
exports: any;
}
const UI_PATH = 'ui/';
const MODULES = {
TabViewItem: 'ui/tab-view',
@@ -156,7 +160,7 @@ export function getComponentModule(elementName: string, namespace: string, attri
applyComponentCss(instance, moduleNamePath, attributes);
}
applyComponentAttributes(instance, instanceModule, moduleExports);
applyComponentAttributes(instance, instanceModule, moduleExports, attributes);
let componentModule;
if (instance && instanceModule) {

View File

@@ -1,5 +0,0 @@
{
"name": "component-builder",
"main": "component-builder",
"types": "component-builder.d.ts"
}

View File

@@ -7,6 +7,9 @@ import { HorizontalAlignment, VerticalAlignment, Visibility, Length, PercentLeng
import { GestureTypes, GestureEventData, GesturesObserver } from '../../gestures';
import { LinearGradient } from '../../styling/gradient';
// helpers (these are okay re-exported here)
export * from './view-helper';
export function PseudoClassHandler(...pseudoClasses: string[]): MethodDecorator;
/**
@@ -854,26 +857,3 @@ export const isEnabledProperty: Property<View, boolean>;
export const isUserInteractionEnabledProperty: Property<View, boolean>;
export const iosOverflowSafeAreaProperty: Property<View, boolean>;
export const iosOverflowSafeAreaEnabledProperty: InheritedProperty<View, boolean>;
export namespace ios {
/**
* String value used when hooking to traitCollectionColorAppearanceChangedEvent event.
*/
export const traitCollectionColorAppearanceChangedEvent: string;
/**
* Returns a view with viewController or undefined if no such found along the view's parent chain.
* @param view The view form which to start the search.
*/
export function getParentWithViewController(view: View): View;
export function updateAutoAdjustScrollInsets(controller: any /* UIViewController */, owner: View): void;
export function updateConstraints(controller: any /* UIViewController */, owner: View): void;
export function layoutView(controller: any /* UIViewController */, owner: View): void;
export function getPositionFromFrame(frame: any /* CGRect */): { left; top; right; bottom };
export function getFrameFromPosition(position: { left; top; right; bottom }, insets?: { left; top; right; bottom }): any; /* CGRect */
export function shrinkToSafeArea(view: View, frame: any /* CGRect */): any; /* CGRect */
export function expandBeyondSafeArea(view: View, frame: any /* CGRect */): any; /* CGRect */
export class UILayoutViewController {
public static initWithOwner(owner: WeakRef<View>): UILayoutViewController;
}
}

View File

@@ -24,6 +24,9 @@ import { TextTransform } from '../../text-base';
import * as am from '../../animation';
// helpers (these are okay re-exported here)
export * from './view-helper';
let animationModule: typeof am;
function ensureAnimationModule() {
if (!animationModule) {
@@ -166,7 +169,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
}
let handled = false;
this.eachChildView((child) => {
this.eachChildView((child: ViewCommon) => {
if (child._onLivesync(context)) {
handled = true;

View File

@@ -33,6 +33,9 @@ export class ViewHelper {
public static combineMeasuredStates(curState: number, newState): number;
}
/**
* Various iOS view helper methods
*/
export namespace IOSHelper {
/**
* String value used when hooking to traitCollectionColorAppearanceChangedEvent event.

View File

@@ -1,7 +1,6 @@
/**
* iOS specific dialogs functions implementation.
*/
import { ios as iosView } from '../core/view';
import { Trace } from '../../trace';
import { ConfirmOptions, PromptOptions, PromptResult, LoginOptions, LoginResult, ActionOptions, getCurrentPage, getLabelColor, getButtonColors, getTextFieldColor, isDialogOptions, inputType, capitalizationType, DialogStrings, parseLoginOptions } from './dialogs-common';
import { isString, isDefined, isFunction } from '../../utils/types';

View File

@@ -1,10 +1,11 @@
import { EditableTextBase as EditableTextBaseDefinition, KeyboardType, ReturnKeyType, UpdateTextTrigger, AutocapitalizationType } from '.';
import { EditableTextBase as EditableTextBaseDefinition, ReturnKeyType, UpdateTextTrigger, AutocapitalizationType } from '.';
import { TextBase } from '../text-base';
import { Property, CssProperty, makeValidator, makeParser } from '../core/properties';
import { PseudoClassHandler } from '../core/view';
import { booleanConverter } from '../core/view-base';
import { Style } from '../styling/style';
import { Color } from '../../color';
import { KeyboardType } from '../enums';
export abstract class EditableTextBase extends TextBase implements EditableTextBaseDefinition {
public static blurEvent = 'blur';

View File

@@ -3,6 +3,7 @@ import { Color } from '../../color';
import { FormattedString } from '../text-base/formatted-string';
import { Style } from '../styling/style';
import { Property, CssProperty } from '../core/properties';
import { KeyboardType } from '../enums';
/**
* Represents the base class for all editable text views.
@@ -65,7 +66,6 @@ export class EditableTextBase extends TextBase {
//@endprivate
}
export type KeyboardType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer';
export type ReturnKeyType = 'done' | 'next' | 'go' | 'search' | 'send';
export type UpdateTextTrigger = 'focusLost' | 'textChanged';
export type AutocapitalizationType = 'none' | 'words' | 'sentences' | 'allcharacters';
@@ -86,5 +86,3 @@ export const maxLengthProperty: Property<EditableTextBase, number>;
*/
export function _updateCharactersInRangeReplacementString(formattedText: FormattedString, rangeLocation: number, rangeLength: number, replacementString: string): void;
//@endprivate
export * from '../text-base';

View File

@@ -1,5 +1,5 @@
import { CubicBezierAnimationCurve } from '../animation';
import { KeyboardType as BaseKeyboardType, ReturnKeyType as BaseReturnKeyType, UpdateTextTrigger as BaseUpdateTrigger, AutocapitalizationType as BaseAutocapitalizationType } from '../editable-text-base';
import { ReturnKeyType as BaseReturnKeyType, UpdateTextTrigger as BaseUpdateTrigger, AutocapitalizationType as BaseAutocapitalizationType } from '../editable-text-base';
import { WhiteSpace as BaseWhiteSpace, TextAlignment as BaseTextAlignment, TextTransform as BaseTextTransform, TextDecoration as BaseTextDecoration } from '../text-base';
@@ -13,6 +13,7 @@ import { Stretch as BaseStretch } from '../image';
import { FontStyle as BaseFontStyle, FontWeight as BaseFontWeight } from '../styling/font-common';
export type KeyboardType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer';
/**
* Represents a soft keyboard flavor.
*/
@@ -21,36 +22,36 @@ export module KeyboardType {
* Android: [TYPE_CLASS_DATETIME](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_DATETIME) | [TYPE_DATETIME_VARIATION_NORMAL](http://developer.android.com/reference/android/text/InputType.html#TYPE_DATETIME_VARIATION_NORMAL)
* iOS: [UIKeyboardTypeNumbersAndPunctuation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
export const datetime: BaseKeyboardType;
export const datetime: KeyboardType;
/**
* Android: [TYPE_CLASS_PHONE](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_PHONE)
* iOS: [UIKeyboardTypePhonePad](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
export const phone: BaseKeyboardType;
export const phone: KeyboardType;
/**
* Android: [TYPE_CLASS_NUMBER](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_NUMBER) | [TYPE_NUMBER_VARIATION_NORMAL](http://developer.android.com/intl/es/reference/android/text/InputType.html#TYPE_NUMBER_VARIATION_NORMAL) | [TYPE_NUMBER_FLAG_SIGNED](http://developer.android.com/reference/android/text/InputType.html#TYPE_NUMBER_FLAG_SIGNED) | [TYPE_NUMBER_FLAG_DECIMAL](http://developer.android.com/reference/android/text/InputType.html#TYPE_NUMBER_FLAG_DECIMAL)
* iOS: [UIKeyboardTypeNumbersAndPunctuation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
export const number: BaseKeyboardType;
export const number: KeyboardType;
/**
* Android: [TYPE_CLASS_TEXT](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_TEXT) | [TYPE_TEXT_VARIATION_URI](http://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_VARIATION_URI)
* iOS: [UIKeyboardTypeURL](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
export const url: BaseKeyboardType;
export const url: KeyboardType;
/**
* Android: [TYPE_CLASS_TEXT](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_TEXT) | [TYPE_TEXT_VARIATION_EMAIL_ADDRESS](http://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_VARIATION_EMAIL_ADDRESS)
* iOS: [UIKeyboardTypeEmailAddress](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
export const email: BaseKeyboardType;
export const email: KeyboardType;
/**
* Android: [TYPE_CLASS_NUMBER](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_NUMBER | [TYPE_NUMBER_VARIATION_PASSWORD](android type_text_variation_password))
* iOS: [UIKeyboardTypeNumberPad](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
export const integer: BaseKeyboardType;
export const integer: KeyboardType;
}
/**

View File

@@ -1,6 +1,7 @@
// imported for definition purposes only
import * as animationModule from '../../ui/animation';
export type KeyboardType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer';
export module KeyboardType {
export const datetime = 'datetime';
export const phone = 'phone';

View File

@@ -14,6 +14,8 @@ export { DatePicker } from './date-picker';
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';
import * as enumsModule from './enums';
export const Enums = enumsModule;
export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry } from './frame';
export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData } from './gestures';

View File

@@ -14,6 +14,8 @@ export { DatePicker } from './date-picker';
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';
import * as enumsModule from './enums';
export const Enums = enumsModule;
export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry } from './frame';
export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData } from './gestures';
@@ -49,7 +51,7 @@ 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 } from './tabs';
export { TextBase } from './text-base';
export { TextBase, TextTransform } from './text-base';
export { FormattedString } from './text-base/formatted-string';
export { Span } from './text-base/span';
export { TextField } from './text-field';

View File

@@ -1,7 +1,7 @@
export { AbsoluteLayout } from './absolute-layout';
export { DockLayout } from './dock-layout';
export { FlexboxLayout } from './flexbox-layout';
export { GridLayout, GridUnitType } from './grid-layout';
export { GridLayout, GridUnitType, ItemSpec } from './grid-layout';
export { StackLayout } from './stack-layout';
export { WrapLayout } from './wrap-layout';
export { LayoutBase } from './layout-base';

View File

@@ -1,7 +1,7 @@
export { AbsoluteLayout } from './absolute-layout';
export { DockLayout } from './dock-layout';
export { FlexboxLayout } from './flexbox-layout';
export { GridLayout, GridUnitType } from './grid-layout';
export { GridLayout, GridUnitType, ItemSpec } from './grid-layout';
export { StackLayout } from './stack-layout';
export { WrapLayout } from './wrap-layout';
export { LayoutBase } from './layout-base';

View File

@@ -3,7 +3,7 @@ import { Frame, BackstackEntry } from '../frame';
import { NavigationType } from '../frame/frame-common';
// Types.
import { ios as iosView, View } from '../core/view';
import { View, IOSHelper } from '../core/view';
import { PageBase, actionBarHiddenProperty, statusBarStyleProperty } from './page-common';
import { profile } from '../../profiling';
@@ -118,7 +118,7 @@ class UIViewControllerImpl extends UIViewController {
}
// Set autoAdjustScrollInsets in will appear - as early as possible
iosView.updateAutoAdjustScrollInsets(this, owner);
IOSHelper.updateAutoAdjustScrollInsets(this, owner);
// Pages in backstack are unloaded so raise loaded here.
if (!owner.isLoaded) {
@@ -242,7 +242,7 @@ class UIViewControllerImpl extends UIViewController {
super.viewWillLayoutSubviews();
const owner = this._owner.get();
if (owner) {
iosView.updateConstraints(this, owner);
IOSHelper.updateConstraints(this, owner);
}
}
@@ -290,7 +290,7 @@ class UIViewControllerImpl extends UIViewController {
}
}
iosView.layoutView(this, owner);
IOSHelper.layoutView(this, owner);
}
}
@@ -302,7 +302,7 @@ class UIViewControllerImpl extends UIViewController {
const owner = this._owner.get();
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
owner.notify({
eventName: iosView.traitCollectionColorAppearanceChangedEvent,
eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent,
object: owner,
});
}

View File

@@ -111,4 +111,21 @@ export const fontInternalProperty: InheritedCssProperty<Style, Font>;
export type BackgroundRepeat = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
export type Visibility = 'visible' | 'hidden' | 'collapse';
export type HorizontalAlignment = 'left' | 'center' | 'right' | 'stretch';
export type VerticalAlignment = 'top' | 'middle' | 'bottom' | 'stretch';
export namespace HorizontalAlignment {
export const LEFT: 'left';
export const CENTER: 'center';
export const RIGHT: 'right';
export const STRETCH: 'stretch';
}
export type VerticalAlignment = 'top' | 'middle' | 'bottom' | 'stretch' | 'text-top' | 'text-bottom' | 'super' | 'sub' | 'baseline';
export namespace VerticalAlignment {
export const TOP: 'top';
export const MIDDLE: 'middle';
export const BOTTOM: 'bottom';
export const STRETCH: 'stretch';
export const TEXTTOP: 'text-top';
export const TEXTBOTTOM: 'text-bottom';
export const SUPER: 'super';
export const SUB: 'sub';
export const BASELINE: 'baseline';
}

View File

@@ -1,7 +1,7 @@
import { TabViewItem as TabViewItemDefinition } from '.';
import { Font } from '../styling/font';
import { ios as iosView, View } from '../core/view';
import { IOSHelper, View } from '../core/view';
import { ViewBase } from '../core/view-base';
import { TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, tabTextColorProperty, tabTextFontSizeProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, iosIconRenderingModeProperty, traceMissingIcon } from './tab-view-common';
import { Color } from '../../color';
@@ -44,7 +44,7 @@ class UITabBarControllerImpl extends UITabBarController {
return;
}
iosView.updateAutoAdjustScrollInsets(this, owner);
IOSHelper.updateAutoAdjustScrollInsets(this, owner);
if (!owner.parent) {
owner.callLoaded();
@@ -78,7 +78,7 @@ class UITabBarControllerImpl extends UITabBarController {
const owner = this._owner.get();
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
owner.notify({
eventName: iosView.traitCollectionColorAppearanceChangedEvent,
eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent,
object: owner,
});
}
@@ -432,7 +432,7 @@ export class TabView extends TabViewBase {
newController = item.view.ios.controller;
item.setViewController(newController, newController.view);
} else {
newController = iosView.UILayoutViewController.initWithOwner(new WeakRef(item.view)) as UIViewController;
newController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(item.view)) as UIViewController;
newController.view.addSubview(item.view.nativeViewProtected);
item.view.viewController = newController;
item.setViewController(newController, item.view.nativeViewProtected);

View File

@@ -9,7 +9,7 @@ import { Color } from '../../color';
import { ImageSource } from '../../image-source';
import { Device } from '../../platform';
import { ios as iosUtils, isFontIconURI, layout } from '../../utils';
import { ios as iosView, View } from '../core/view';
import { IOSHelper, View } from '../core/view';
import { ViewBase } from '../core/view-base';
import { Frame } from '../frame';
import { Font } from '../styling/font';
@@ -144,7 +144,7 @@ class UIPageViewControllerImpl extends UIPageViewController {
return;
}
iosView.updateAutoAdjustScrollInsets(this, owner);
IOSHelper.updateAutoAdjustScrollInsets(this, owner);
// Tabs can be reset as a root view. Call loaded here in this scenario.
if (!owner.isLoaded) {
@@ -234,7 +234,7 @@ class UIPageViewControllerImpl extends UIPageViewController {
const owner = this._owner.get();
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
owner.notify({
eventName: iosView.traitCollectionColorAppearanceChangedEvent,
eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent,
object: owner,
});
}
@@ -665,7 +665,7 @@ export class Tabs extends TabsBase {
newController = item.content.ios.controller;
(<any>item).setViewController(newController, newController.view);
} else {
newController = iosView.UILayoutViewController.initWithOwner(new WeakRef(item.content)) as UIViewController;
newController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(item.content)) as UIViewController;
newController.view.addSubview(item.content.nativeViewProtected);
item.content.viewController = newController;
(<any>item).setViewController(newController, item.content.nativeViewProtected);

View File

@@ -1,6 +1,7 @@
import { ScrollEventData } from '../scroll-view';
import { textProperty } from '../text-base';
import { TextViewBase as TextViewBaseCommon, maxLinesProperty } from './text-view-common';
import { editableProperty, hintProperty, textProperty, placeholderColorProperty, _updateCharactersInRangeReplacementString } from '../editable-text-base';
import { editableProperty, hintProperty, placeholderColorProperty, _updateCharactersInRangeReplacementString } from '../editable-text-base';
import { CSSType } from '../core/view';
import { Color } from '../../color';
import { colorProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, Length } from '../styling/style-properties';