Skip to content

Commit 6f62fbc

Browse files
committed
Revert "feat(android): edge to edge (NativeScript#10774)"
This reverts commit 248ff4b. # Conflicts: # packages/core/platforms/android/widgets-release.aar # packages/core/ui/core/view/index.android.ts # packages/core/ui/core/view/index.d.ts # packages/core/ui/core/view/view-common.ts
1 parent d36698b commit 6f62fbc

File tree

50 files changed

+255
-1736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+255
-1736
lines changed

apps/toolbox/src/main-page.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page" androidOverflowEdge="bottom" statusBarStyle="dark">
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page" statusBarStyle="dark">
22
<Page.actionBar>
33
<ActionBar title="Dev Toolbox" icon="" class="action-bar">
44
</ActionBar>
@@ -36,4 +36,3 @@
3636
</ScrollView>
3737
</StackLayout>
3838
</Page>
39-
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Observable, Frame, StackLayout, AndroidOverflowInsetData } from '@nativescript/core';
1+
import { Observable, Frame, StackLayout } from '@nativescript/core';
22

33
export class HelloWorldModel extends Observable {
44
viewDemo(args) {
@@ -7,16 +7,4 @@ export class HelloWorldModel extends Observable {
77
moduleName: `pages/${args.object.text}`,
88
});
99
}
10-
11-
onInset(args: AndroidOverflowInsetData) {
12-
args.inset.top += 10; // add 10px to the top inset
13-
args.inset.bottom += 10; // add 10px to the bottom inset
14-
args.inset.left += 10; // add 10px to the left inset
15-
args.inset.right += 10; // add 10px to the right inset
16-
17-
args.inset.topConsumed = true; // consume the top inset
18-
args.inset.bottomConsumed = true; // consume the bottom inset
19-
args.inset.leftConsumed = true; // consume the left inset
20-
args.inset.rightConsumed = true; // consume the right inset
21-
}
2210
}

apps/toolbox/src/pages/list-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" actionBarHidden="false" androidOverflowEdge="bottom">
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" actionBarHidden="false">
22
<Page.actionBar>
33
<ActionBar>
44
<Label text="Components" class="header"/>

packages/core/core-types/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import { makeValidator, makeParser } from './validators';
77
import { CubicBezierAnimationCurve } from './animation-types';
88

99
export namespace CoreTypes {
10-
type AndroidOverflowSingle = 'ignore' | 'none' | 'dont-apply';
11-
type AndroidOverflowMultiple = 'left' | 'right' | 'top' | 'bottom' | 'left-dont-consume' | 'top-dont-consume' | 'right-dont-consume' | 'bottom-dont-consume' | 'all-but-left' | 'all-but-top' | 'all-but-right' | 'all-but-bottom';
12-
type AndroidOverflowStacked = AndroidOverflowSingle | `${AndroidOverflowSingle},${AndroidOverflowMultiple}`;
13-
export type AndroidOverflow = AndroidOverflowSingle | AndroidOverflowStacked;
1410
export type CSSWideKeywords = 'initial' | 'inherit' | 'unset' | 'revert';
1511

1612
/**

packages/core/ui/animation/index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import type { AnimationDefinition, AnimationPromise } from './animation-types';
66
* Defines a animation set.
77
*/
88
export class Animation {
9-
constructor(animationDefinitions: Array<AnimationDefinition>, playSequentially?: boolean);
10-
public play: (resetOnFinish?: boolean) => AnimationPromise;
11-
public cancel: () => void;
12-
public isPlaying: boolean;
13-
public _resolveAnimationCurve(curve: any): any;
9+
constructor(animationDefinitions: Array<AnimationDefinition>, playSequentially?: boolean);
10+
public play: (resetOnFinish?: boolean) => AnimationPromise;
11+
public cancel: () => void;
12+
public isPlaying: boolean;
13+
public _resolveAnimationCurve(curve: any): any;
1414
}
1515

1616
export function _resolveAnimationCurve(curve: any): any;

packages/core/ui/core/view/index.android.ts

Lines changed: 1 addition & 229 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Point, Position } from './view-interfaces';
22
import type { GestureTypes, GestureEventData } from '../../gestures';
33
import { getNativeScriptGlobals } from '../../../globals/global-utils';
4-
import { ViewCommon, isEnabledProperty, originXProperty, originYProperty, isUserInteractionEnabledProperty, testIDProperty, AndroidHelper, androidOverflowEdgeProperty, statusBarStyleProperty } from './view-common';
4+
import { ViewCommon, isEnabledProperty, originXProperty, originYProperty, isUserInteractionEnabledProperty, testIDProperty, AndroidHelper, statusBarStyleProperty } from './view-common';
55
import { paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, directionProperty } from '../../styling/style-properties';
66
import { layout } from '../../../utils';
77
import { Trace } from '../../../trace';
@@ -414,121 +414,6 @@ function getModalOptions(domId: number): DialogOptions {
414414
return modalMap.get(domId);
415415
}
416416

417-
const INSET_LEFT = 0;
418-
const INSET_TOP = 4;
419-
const INSET_RIGHT = 8;
420-
const INSET_BOTTOM = 12;
421-
const INSET_LEFT_CONSUMED = 16;
422-
const INSET_TOP_CONSUMED = 20;
423-
const INSET_RIGHT_CONSUMED = 24;
424-
const INSET_BOTTOM_CONSUMED = 28;
425-
426-
const OverflowEdgeIgnore = -1;
427-
const OverflowEdgeNone: number = 0;
428-
const OverflowEdgeLeft: number = 1 << 1;
429-
const OverflowEdgeTop: number = 1 << 2;
430-
const OverflowEdgeRight: number = 1 << 3;
431-
const OverflowEdgeBottom: number = 1 << 4;
432-
const OverflowEdgeDontApply: number = 1 << 5;
433-
const OverflowEdgeLeftDontConsume: number = 1 << 6;
434-
const OverflowEdgeTopDontConsume: number = 1 << 7;
435-
const OverflowEdgeRightDontConsume: number = 1 << 8;
436-
const OverflowEdgeBottomDontConsume: number = 1 << 9;
437-
const OverflowEdgeAllButLeft: number = 1 << 10;
438-
const OverflowEdgeAllButTop: number = 1 << 11;
439-
const OverflowEdgeAllButRight: number = 1 << 12;
440-
const OverflowEdgeAllButBottom: number = 1 << 13;
441-
442-
class Inset {
443-
private view: DataView;
444-
private data: ArrayBuffer;
445-
constructor(data: java.nio.ByteBuffer) {
446-
this.data = (<any>ArrayBuffer).from(data);
447-
this.view = new DataView(this.data);
448-
}
449-
450-
public get left(): number {
451-
return this.view.getInt32(INSET_LEFT, true);
452-
}
453-
454-
public set left(value: number) {
455-
this.view.setInt32(INSET_LEFT, value, true);
456-
}
457-
458-
public get top(): number {
459-
return this.view.getInt32(INSET_TOP, true);
460-
}
461-
462-
public set top(value: number) {
463-
this.view.setInt32(INSET_TOP, value, true);
464-
}
465-
466-
public get right(): number {
467-
return this.view.getInt32(INSET_RIGHT, true);
468-
}
469-
470-
public set right(value: number) {
471-
this.view.setInt32(INSET_RIGHT, value, true);
472-
}
473-
474-
public get bottom(): number {
475-
return this.view.getInt32(INSET_BOTTOM, true);
476-
}
477-
478-
public set bottom(value: number) {
479-
this.view.setInt32(INSET_BOTTOM, value, true);
480-
}
481-
482-
public get leftConsumed(): boolean {
483-
return this.view.getInt32(INSET_LEFT_CONSUMED, true) > 0;
484-
}
485-
486-
public set leftConsumed(value: boolean) {
487-
this.view.setInt32(INSET_LEFT_CONSUMED, value ? 1 : 0, true);
488-
}
489-
490-
public get topConsumed(): boolean {
491-
return this.view.getInt32(INSET_TOP_CONSUMED, true) > 0;
492-
}
493-
494-
public set topConsumed(value: boolean) {
495-
this.view.setInt32(INSET_TOP_CONSUMED, value ? 1 : 0, true);
496-
}
497-
498-
public get rightConsumed(): boolean {
499-
return this.view.getInt32(INSET_RIGHT_CONSUMED, true) > 0;
500-
}
501-
502-
public set rightConsumed(value: boolean) {
503-
this.view.setInt32(INSET_RIGHT_CONSUMED, value ? 1 : 0, true);
504-
}
505-
506-
public get bottomConsumed(): boolean {
507-
return this.view.getInt32(INSET_BOTTOM_CONSUMED, true) > 0;
508-
}
509-
510-
public set bottomConsumed(value: boolean) {
511-
this.view.setInt32(INSET_BOTTOM_CONSUMED, value ? 1 : 0, true);
512-
}
513-
514-
toString() {
515-
return `Inset: left=${this.left}, top=${this.top}, right=${this.right}, bottom=${this.bottom}, ` + `leftConsumed=${this.leftConsumed}, topConsumed=${this.topConsumed}, ` + `rightConsumed=${this.rightConsumed}, bottomConsumed=${this.bottomConsumed}`;
516-
}
517-
518-
toJSON() {
519-
return {
520-
left: this.left,
521-
top: this.top,
522-
right: this.right,
523-
bottom: this.bottom,
524-
leftConsumed: this.leftConsumed,
525-
topConsumed: this.topConsumed,
526-
rightConsumed: this.rightConsumed,
527-
bottomConsumed: this.bottomConsumed,
528-
};
529-
}
530-
}
531-
532417
export class View extends ViewCommon {
533418
public static androidBackPressedEvent = androidBackPressedEvent;
534419

@@ -539,8 +424,6 @@ export class View extends ViewCommon {
539424
private layoutChangeListenerIsSet: boolean;
540425
private layoutChangeListener: android.view.View.OnLayoutChangeListener;
541426
private _rootManager: androidx.fragment.app.FragmentManager;
542-
private insetListenerIsSet: boolean;
543-
private needsInsetListener: boolean;
544427

545428
declare nativeViewProtected: android.view.View;
546429

@@ -559,12 +442,6 @@ export class View extends ViewCommon {
559442
if (this.isLoaded && !this.layoutChangeListenerIsSet && isLayoutEvent) {
560443
this.setOnLayoutChangeListener();
561444
}
562-
563-
const isInsetEvent = typeof eventNames === 'string' ? eventNames.indexOf(ViewCommon.androidOverflowInsetEvent) !== -1 : false;
564-
// only avaiable on LayoutBase
565-
if (!this.insetListenerIsSet && isInsetEvent) {
566-
this.setInsetListener();
567-
}
568445
}
569446

570447
removeEventListener(eventNames: string, callback?: (data: EventData) => void, thisArg?: any) {
@@ -576,43 +453,6 @@ export class View extends ViewCommon {
576453
this.nativeViewProtected.removeOnLayoutChangeListener(this.layoutChangeListener);
577454
this.layoutChangeListenerIsSet = false;
578455
}
579-
580-
const isInsetEvent = typeof eventNames === 'string' ? eventNames.indexOf(ViewCommon.androidOverflowInsetEvent) !== -1 : false;
581-
582-
if (this.insetListenerIsSet && isInsetEvent && this.nativeViewProtected && (this.nativeViewProtected as any).setInsetListener) {
583-
(this.nativeViewProtected as any).setInsetListener(null);
584-
this.insetListenerIsSet = false;
585-
}
586-
}
587-
588-
private setInsetListener() {
589-
if (this.nativeViewProtected) {
590-
if ((this.nativeViewProtected as any).setInsetListener) {
591-
const ref = new WeakRef(this);
592-
(this.nativeViewProtected as any).setInsetListener(
593-
new org.nativescript.widgets.LayoutBase.WindowInsetListener({
594-
onApplyWindowInsets(param0) {
595-
const owner = ref.get();
596-
if (!owner) {
597-
return;
598-
}
599-
600-
const inset = new Inset(param0);
601-
const args = {
602-
eventName: ViewCommon.androidOverflowInsetEvent,
603-
object: this,
604-
inset,
605-
};
606-
owner.notify(args);
607-
},
608-
}),
609-
);
610-
this.insetListenerIsSet = true;
611-
}
612-
this.needsInsetListener = false;
613-
} else {
614-
this.needsInsetListener = true;
615-
}
616456
}
617457

618458
public _getChildFragmentManager(): androidx.fragment.app.FragmentManager {
@@ -673,35 +513,6 @@ export class View extends ViewCommon {
673513
return manager;
674514
}
675515

676-
[androidOverflowEdgeProperty.setNative](value: CoreTypes.AndroidOverflow) {
677-
const nativeView = this.nativeViewProtected as any;
678-
if (typeof value !== 'string' || nativeView === null || nativeView == undefined) {
679-
return;
680-
}
681-
682-
if (!('setOverflowEdge' in nativeView)) {
683-
return;
684-
}
685-
686-
switch (value) {
687-
case 'none':
688-
nativeView.setOverflowEdge(OverflowEdgeNone);
689-
break;
690-
case 'ignore':
691-
nativeView.setOverflowEdge(OverflowEdgeIgnore);
692-
break;
693-
default:
694-
{
695-
const edge = parseEdges(value);
696-
697-
if (edge != null) {
698-
nativeView.setOverflowEdge(edge);
699-
}
700-
}
701-
break;
702-
}
703-
}
704-
705516
@profile
706517
public onLoaded() {
707518
this._manager = null;
@@ -773,10 +584,6 @@ export class View extends ViewCommon {
773584
if (this.needsOnLayoutChangeListener()) {
774585
this.setOnLayoutChangeListener();
775586
}
776-
777-
if (!this.insetListenerIsSet && this.needsInsetListener) {
778-
this.setInsetListener();
779-
}
780587
}
781588

782589
public needsOnLayoutChangeListener() {
@@ -1624,43 +1431,8 @@ export class View extends ViewCommon {
16241431
}
16251432
}
16261433

1627-
const edgeMap: Record<string, number> = {
1628-
none: OverflowEdgeNone,
1629-
left: OverflowEdgeLeft,
1630-
top: OverflowEdgeTop,
1631-
right: OverflowEdgeRight,
1632-
bottom: OverflowEdgeBottom,
1633-
'dont-apply': OverflowEdgeDontApply,
1634-
'left-dont-consume': OverflowEdgeLeftDontConsume,
1635-
'top-dont-consume': OverflowEdgeTopDontConsume,
1636-
'right-dont-consume': OverflowEdgeRightDontConsume,
1637-
'bottom-dont-consume': OverflowEdgeBottomDontConsume,
1638-
'all-but-left': OverflowEdgeAllButLeft,
1639-
'all-but-top': OverflowEdgeAllButTop,
1640-
'all-but-right': OverflowEdgeAllButRight,
1641-
'all-but-bottom': OverflowEdgeAllButBottom,
1642-
};
1643-
1644-
function parseEdges(edges: string): number | null {
1645-
let result = 0;
1646-
const values = edges.split(',');
1647-
for (const raw of values) {
1648-
const value = edgeMap[raw.trim()];
1649-
if (value === undefined) continue;
1650-
// dont-apply overrides everything else
1651-
if (value === OverflowEdgeDontApply) return value;
1652-
result |= value;
1653-
}
1654-
return result === 0 ? null : result;
1655-
}
1656-
16571434
export class ContainerView extends View {
16581435
public iosOverflowSafeArea: boolean;
1659-
1660-
constructor() {
1661-
super();
1662-
this.androidOverflowEdge = 'none';
1663-
}
16641436
}
16651437

16661438
export class CustomLayoutView extends ContainerView {

packages/core/ui/core/view/index.d.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ export abstract class View extends ViewCommon {
9292
*/
9393
public static accessibilityFocusChangedEvent: string;
9494

95-
/**
96-
* String value used when hooking to androidOverflowInset event.
97-
*
98-
* @nsEvent {EventDataValue} androidOverflowInset
99-
*/
100-
public static androidOverflowInsetEvent: string;
101-
10295
/**
10396
* @private
10497
*/
@@ -837,11 +830,6 @@ export abstract class View extends ViewCommon {
837830
*/
838831
on(event: 'shownModally', callback: (args: ShownModallyData) => void, thisArg?: any);
839832

840-
/**
841-
* Raised after the view is shown as a modal dialog.
842-
*/
843-
on(event: 'androidOverflowInset', callback: (args: ShownModallyData) => void, thisArg?: any);
844-
845833
/**
846834
* Returns the current modal view that this page is showing (is parent of), if any.
847835
*/

0 commit comments

Comments
 (0)