From 4354c16a78b4d07d522052c7f4a8181ce502418c Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Mon, 14 Sep 2015 15:26:18 +0300 Subject: [PATCH] slide-out removed --- CrossPlatformModules.csproj | 15 +-- ui/slide-out/package.json | 2 - ui/slide-out/slide-out-common.ts | 156 ------------------------- ui/slide-out/slide-out.android.ts | 183 ------------------------------ ui/slide-out/slide-out.d.ts | 42 ------- ui/slide-out/slide-out.ios.ts | 92 --------------- 6 files changed, 1 insertion(+), 489 deletions(-) delete mode 100644 ui/slide-out/package.json delete mode 100644 ui/slide-out/slide-out-common.ts delete mode 100644 ui/slide-out/slide-out.android.ts delete mode 100644 ui/slide-out/slide-out.d.ts delete mode 100644 ui/slide-out/slide-out.ios.ts diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj index 507e2c7a3..ed69cbede 100644 --- a/CrossPlatformModules.csproj +++ b/CrossPlatformModules.csproj @@ -779,16 +779,6 @@ search-bar.d.ts - - slide-out.d.ts - - - slide-out.d.ts - - - - slide-out.d.ts - slider.d.ts @@ -1741,9 +1731,6 @@ - - PreserveNewest - @@ -1984,7 +1971,7 @@ False - + \ No newline at end of file diff --git a/ui/slide-out/package.json b/ui/slide-out/package.json deleted file mode 100644 index 242b0a84a..000000000 --- a/ui/slide-out/package.json +++ /dev/null @@ -1,2 +0,0 @@ -{ "name" : "ui/slide-out", - "main" : "slide-out.js" } \ No newline at end of file diff --git a/ui/slide-out/slide-out-common.ts b/ui/slide-out/slide-out-common.ts deleted file mode 100644 index 33d709da1..000000000 --- a/ui/slide-out/slide-out-common.ts +++ /dev/null @@ -1,156 +0,0 @@ -import definition = require("ui/slide-out"); -import view = require("ui/core/view"); -import dependencyObservable = require("ui/core/dependency-observable"); -import proxy = require("ui/core/proxy"); - -function onSlideContentWidthPropertyChanged(data: dependencyObservable.PropertyChangeData) { - var slideOut = data.object; - slideOut._onSlideWidthChanged(); -} - -function onOptionsPropertyChanged(data: dependencyObservable.PropertyChangeData) { - var slideOut = data.object; - slideOut._onOptionsChanged(); -} - -export var slideContentWidthProperty = new dependencyObservable.Property( - "slideContentWidth", - "SlideOutControl", - new proxy.PropertyMetadata( - 240, - dependencyObservable.PropertyMetadataSettings.None, - onSlideContentWidthPropertyChanged - ) - ); - -export var optionsProperty = new dependencyObservable.Property( - "options", - "SlideOutControl", - new proxy.PropertyMetadata( - undefined, - dependencyObservable.PropertyMetadataSettings.None, - onOptionsPropertyChanged - ) - ); - -export class SlideOutControl extends view.View implements definition.SlideOutControl { - private _slideContent: view.View; - private _mainContent: view.View; - - get options(): definition.Options { - return this._getValue(optionsProperty); - } - set options(value: definition.Options) { - this._setValue(optionsProperty, value); - } - - get slideContentWidth(): number { - return this._getValue(slideContentWidthProperty); - } - set slideContentWidth(value: number) { - this._setValue(slideContentWidthProperty, value); - } - - get slideContent(): view.View { - return this._slideContent; - } - set slideContent(value: view.View) { - if (this._slideContent === value) { - return; - } - - if (this._slideContent) { - this._detachSlideContent(); - } - - this._slideContent = value; - - if (this._slideContent) { - this._attachSlideContent(); - } - } - - get mainContent(): view.View { - return this._mainContent; - } - set mainContent(value: view.View) { - if (this._mainContent === value) { - return; - } - - if (this._mainContent) { - this._detachMainContent(); - } - - this._mainContent = value; - - if (this._mainContent) { - this._attachMainContent(); - } - } - - public openSlideContent(): void { - // - } - - public closeSlideContent(): void { - // - } - - get _childrenCount(): number { - var count = 0; - if (this._slideContent) { - count++; - } - if (this._mainContent) { - count++; - } - - return count; - } - - public _eachChildView(callback: (child: view.View) => boolean) { - var res: boolean; - if (this._slideContent) { - res = callback(this._slideContent); - } - if (res && this._mainContent) { - callback(this._mainContent); - } - } - - public _attachSlideContent() { - this._slideContent.width = this.slideContentWidth; - this._addView(this._slideContent); - } - - public _detachSlideContent() { - this._removeView(this._slideContent); - } - - public _attachMainContent() { - this._addView(this._mainContent); - } - - public _detachMainContent() { - this._removeView(this._mainContent); - } - - public _onSlideWidthChanged() { - // - } - - public _onOptionsChanged() { - // - } - - //public _arrangeOverride(finalSize: geometry.Size): void { - // if (this.slideContent) { - // this.slideContent.arrange(new geometry.Rect(0, 0, this.slideContentWidth, finalSize.height)); - // } - - // if (this.mainContent) { - // this.mainContent.arrange(new geometry.Rect(0, 0, finalSize.width, finalSize.height)); - // } - //} -} \ No newline at end of file diff --git a/ui/slide-out/slide-out.android.ts b/ui/slide-out/slide-out.android.ts deleted file mode 100644 index e4155c8a2..000000000 --- a/ui/slide-out/slide-out.android.ts +++ /dev/null @@ -1,183 +0,0 @@ -import common = require("ui/slide-out/slide-out-common"); -import view = require("ui/core/view"); -import utils = require("utils/utils"); -import frame = require("ui/frame"); - -export class SlideOutControl extends common.SlideOutControl { - // private _android: android.support.v4.widget.DrawerLayout; - // TODO: Update with actual types once the definitions are available - private _android: any; - private _toggle: any; - private _optionSelectedCallback: (data: frame.AndroidOptionEventData) => void; - private _optionsCallbackAdded = false; - - constructor() { - super(); - - var that = this; - this._optionSelectedCallback = function (data: frame.AndroidOptionEventData) { - if (that._android) { - data.handled = that._toggle.onOptionsItemSelected(data.item); - } - } - } - - public _createUI() { - this._android = new android.support.v4.widget.DrawerLayout(this._context); - this._createToggle(); - } - - get android(): android.support.v4.widget.DrawerLayout { - return this._android; - } - - public _addViewToNativeVisualTree(child: view.View): boolean { - super._addViewToNativeVisualTree(child); - - if (!this._android) { - return false; - } - - this._android.addView(child.android); - - var layoutParams: android.support.v4.widget.DrawerLayout.LayoutParams; - if (child === this.slideContent) { - var density = utils.layout.getDisplayDensity(); - layoutParams = new android.support.v4.widget.DrawerLayout.LayoutParams( - this.slideContentWidth * density, - android.view.ViewGroup.LayoutParams.MATCH_PARENT, - android.view.Gravity.START - ); - } else { - layoutParams = new android.support.v4.widget.DrawerLayout.LayoutParams( - android.view.ViewGroup.LayoutParams.MATCH_PARENT, - android.view.ViewGroup.LayoutParams.MATCH_PARENT - ); - } - - child.android.setLayoutParams(layoutParams); - - // Z-order is important, bring slide content to front - if (this.slideContent && this.slideContent._isAddedToNativeVisualTree) { - this._android.bringChildToFront(this.slideContent.android); - } - - return true; - } - - public _removeViewFromNativeVisualTree(child: view.View) { - super._removeViewFromNativeVisualTree(child); - - if (this._android) { - this._android.removeView(child.android); - } - } - - public _getMeasureSpec(length: number, horizontal: boolean): number { - return utils.layout.makeMeasureSpec(length, utils.layout.EXACTLY); - } - - public _onDetached(force?: boolean) { - super._onDetached(force); - - if (!this._optionsCallbackAdded) { - return; - } - - var owningFrame: frame.Frame = view.getAncestor(this, "Frame"); - if (owningFrame) { - owningFrame.android.removeEventListener(frame.Frame.androidOptionSelectedEvent, this._optionSelectedCallback); - this._optionsCallbackAdded = false; - } - } - - //public _measureOverride(availableSize: geometry.Size): geometry.Size { - // var baseSize = super._measureOverride(availableSize); - - // if (this.slideContent) { - // this.slideContent.measure(new geometry.Size(this.slideContentWidth, availableSize.height), utils.layout.EXACTLY); - // } - - // //TODO: Here we probably need to measure with size returned from measuring native element (baseSize is 0). - // if (this.mainContent) { - // this.mainContent.measure(baseSize, utils.layout.EXACTLY); - // } - - // return baseSize; - //} - - //private _createSlideLayout() { - // // TODO: Implement our own FrameLayout layout - // this._slideLayout = new android.widget.FrameLayout(this._context); - - // var layoutParams: android.support.v4.widget.DrawerLayout.LayoutParams; - // var width = this.slideContentWidth; - // if (!width) { - // width = DEFAULT_SLIDE_WIDTH; - // } - - // layoutParams = new android.support.v4.widget.DrawerLayout.LayoutParams( - // utils.layout.getDevicePixels(width, this._context), - // android.view.ViewGroup.LayoutParams.MATCH_PARENT, - // android.view.Gravity.START - // ); - - // this._slideLayout.setLayoutParams(layoutParams); - //} - - //private _createMainLayout() { - // // TODO: Implement our own FrameLayout layout - // this._mainLayout = new android.widget.FrameLayout(this._context); - - // var layoutParams: android.support.v4.widget.DrawerLayout.LayoutParams; - // layoutParams = new android.support.v4.widget.DrawerLayout.LayoutParams( - // android.view.ViewGroup.LayoutParams.MATCH_PARENT, - // android.view.ViewGroup.LayoutParams.MATCH_PARENT - // ); - - // this._mainLayout.setLayoutParams(layoutParams); - //} - - private _createToggle() { - // To create a valid ActionBarDrawerToggle we need all of the android options specified - var opts = this.options; - if (!opts || !opts.android) { - return; - } - - if (!opts.android.closeDescriptionResourceId || - !opts.android.openDescriptionResourceId || - !opts.android.toggleImageResourceId) { - return; - } - - var activity = this._context; - if (!activity) { - return; - } - - var bar = activity.getActionBar(); - if (!bar) { - return; - } - - bar.setHomeButtonEnabled(true); - bar.setDisplayHomeAsUpEnabled(true); - - this._toggle = new android.support.v4.app.ActionBarDrawerToggle( - activity, - this._android, opts.android.toggleImageResourceId, - opts.android.openDescriptionResourceId, - opts.android.closeDescriptionResourceId - ); - - this._android.setDrawerListener(this._toggle); - this._toggle.syncState(); - - var owningFrame: frame.Frame = view.getAncestor(this, "Frame"); - if (owningFrame) { - owningFrame.android.addEventListener(frame.Frame.androidOptionSelectedEvent, this._optionSelectedCallback); - this._optionsCallbackAdded = true; - } - } -} \ No newline at end of file diff --git a/ui/slide-out/slide-out.d.ts b/ui/slide-out/slide-out.d.ts deleted file mode 100644 index 5ed9dc799..000000000 --- a/ui/slide-out/slide-out.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -//@private -/** - * - */ -declare module "ui/slide-out" { - import view = require("ui/core/view"); - import dependencyObservable = require("ui/core/dependency-observable"); - - export var slideContentWidthProperty: dependencyObservable.Property; - export var optionsProperty: dependencyObservable.Property; - - export class SlideOutControl extends view.View { - android: android.support.v4.widget.DrawerLayout; - ios: UIViewController; - - slideContent: view.View; - mainContent: view.View; - - slideContentWidth: number; - options: Options; - - openSlideContent(): void; - closeSlideContent(): void; - - //@private - _attachSlideContent(): void; - _attachMainContent(): void; - _detachSlideContent(): void; - _detachMainContent(): void; - //@endprivate - } - - export interface Options { - android: AndroidOptions; - } - - export interface AndroidOptions { - toggleImageResourceId: number; - openDescriptionResourceId: number; - closeDescriptionResourceId: number; - } -} \ No newline at end of file diff --git a/ui/slide-out/slide-out.ios.ts b/ui/slide-out/slide-out.ios.ts deleted file mode 100644 index e824c9232..000000000 --- a/ui/slide-out/slide-out.ios.ts +++ /dev/null @@ -1,92 +0,0 @@ -import common = require("ui/slide-out/slide-out-common"); -import view = require("ui/core/view"); -import application = require("application"); -import gestures = require("ui/gestures"); - -export class SlideOutControl extends common.SlideOutControl { - constructor() { - super(); - - this._ios = new UIView(); - - this.observe(gestures.GestureTypes.swipe, (args) => { - var swipeArgs = args; - if (swipeArgs.direction === gestures.SwipeDirection.left) { - this._toggleSlideContentVisibility(false); - } else if (swipeArgs.direction === gestures.SwipeDirection.right) { - this._toggleSlideContentVisibility(true); - } - }); - } - - private _ios: any; - get ios(): any { - return this._ios; - } - - private _toggleSlideContentVisibility(value: boolean): void { - if (this.slideContent && this.slideContent.ios) { - this.slideContent.ios.hidden = !value; - } - } - - public openSlideContent(): void { - this._toggleSlideContentVisibility(true); - } - - public closeSlideContent(): void { - this._toggleSlideContentVisibility(false); - } - - //public _measureOverride(availableSize: geometry.Size): geometry.Size { - // if (this.slideContent) { - // this.slideContent.measure(new geometry.Size(this.slideContentWidth, availableSize.height)); - // } - - // if (this.mainContent) { - // return this.mainContent.measure(availableSize); - // } - - // return geometry.Size.zero; - //} - - public _addViewToNativeVisualTree(view: view.View): boolean { - super._addViewToNativeVisualTree(view); - - if (this.ios && view.ios) { - var iOSView = this.ios; - - if (view === this.slideContent) { - view.ios.hidden = true; - - view.observe(gestures.GestureTypes.tap | gestures.GestureTypes.swipe, (args) => { - if (args.type & gestures.GestureTypes.tap) { - this._toggleSlideContentVisibility(false); - } - - if (args.type & gestures.GestureTypes.swipe) { - var swipeArgs = args; - if (swipeArgs.direction === gestures.SwipeDirection.left) { - this._toggleSlideContentVisibility(false); - } - } - }); - } - - iOSView.addSubview(view.ios); - return true; - } - - return false; - } - - public _removeViewFromNativeVisualTree(child: view.View) { - super._removeViewFromNativeVisualTree(child); - - // TODO: Probably remove gesture. - if (application.ios && this.ios && child.ios) { - var iOSView = child.ios; - iOSView.removeFromSuperview(); - } - } -} \ No newline at end of file