slide-out removed

This commit is contained in:
Vladimir Enchev
2015-09-14 15:26:18 +03:00
parent 26d10e5387
commit 4354c16a78
6 changed files with 1 additions and 489 deletions

View File

@ -779,16 +779,6 @@
<TypeScriptCompile Include="ui\search-bar\search-bar-common.ts">
<DependentUpon>search-bar.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\slide-out\slide-out-common.ts">
<DependentUpon>slide-out.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\slide-out\slide-out.android.ts">
<DependentUpon>slide-out.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\slide-out\slide-out.d.ts" />
<TypeScriptCompile Include="ui\slide-out\slide-out.ios.ts">
<DependentUpon>slide-out.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\slider\slider-common.ts">
<DependentUpon>slider.d.ts</DependentUpon>
</TypeScriptCompile>
@ -1741,9 +1731,6 @@
<Content Include="trace\Readme.md" />
</ItemGroup>
<ItemGroup>
<Content Include="ui\slide-out\package.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="apps\perf-tests\LargeObjectArrayMemoryLeakTest\package.json" />
</ItemGroup>
<ItemGroup>
@ -1984,7 +1971,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@ -1,2 +0,0 @@
{ "name" : "ui/slide-out",
"main" : "slide-out.js" }

View File

@ -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 = <SlideOutControl>data.object;
slideOut._onSlideWidthChanged();
}
function onOptionsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var slideOut = <SlideOutControl>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));
// }
//}
}

View File

@ -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 = <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 = <android.app.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 = <frame.Frame>view.getAncestor(this, "Frame");
if (owningFrame) {
owningFrame.android.addEventListener(frame.Frame.androidOptionSelectedEvent, this._optionSelectedCallback);
this._optionsCallbackAdded = true;
}
}
}

View File

@ -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;
}
}

View File

@ -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 = <gestures.SwipeGestureEventData>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 = <UIView>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 = <gestures.SwipeGestureEventData>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 = <UIView>child.ios;
iOSView.removeFromSuperview();
}
}
}