Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/toolbox/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Button {
font-size: 17;
}

.box-shadow-demo .box-shadow-prop-controls TextField{
.box-shadow-demo .box-shadow-prop-controls TextField {
margin-left: 10;
padding: 5;
border-bottom-width: 1;
Expand Down
1 change: 1 addition & 0 deletions apps/toolbox/src/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Button text="dialogs" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
<Button text="forms" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
<Button text="glass-effects" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
<Button text="gutters" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
<Button text="image-async" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
<Button text="image-handling" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
<Button text="labels" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
Expand Down
10 changes: 10 additions & 0 deletions apps/toolbox/src/pages/gutters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { fromObject, EventData, Page } from '@nativescript/core';

export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = fromObject({
rowGap: 16,
columnGap: 16,
gap: 16,
});
}
49 changes: 49 additions & 0 deletions apps/toolbox/src/pages/gutters.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Page.actionBar>
<ActionBar title="Gutters" class="action-bar">
</ActionBar>
</Page.actionBar>
<ScrollView>
<StackLayout class="gutters-demo" padding="16">
<Label text="Flexbox row gap" textAlignment="center" marginBottom="16"/>
<FlexboxLayout width="200" flexWrap="wrap" rowGap="{{ rowGap }}">
<Label text="One" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Two" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Three" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Four" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Five" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
</FlexboxLayout>
<StackLayout orientation="horizontal" marginTop="16" horizontalAlignment="center">
<Label verticalAlignment="center" text="Type row gap:" />
<TextField hint="Gap" text="{{ rowGap }}" keyboardType="number" maxLength="2">
</TextField>
</StackLayout>
<Label text="Flexbox column gap" textAlignment="center" marginTop="16" marginBottom="16"/>
<FlexboxLayout width="300" flexWrap="wrap" columnGap="{{ columnGap }}">
<Label text="One" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Two" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Three" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Four" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Five" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
</FlexboxLayout>
<StackLayout orientation="horizontal" marginTop="16" horizontalAlignment="center">
<Label verticalAlignment="center" text="Type column gap:" />
<TextField hint="Gap" text="{{ columnGap }}" keyboardType="number" maxLength="2">
</TextField>
</StackLayout>
<Label text="Flexbox gap" textAlignment="center" marginTop="16" marginBottom="16"/>
<FlexboxLayout width="250" flexWrap="wrap" gap="{{ gap }}">
<Label text="One" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Two" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Three" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Four" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
<Label text="Five" textAlignment="center" backgroundColor="rgb(0 0 255 / 0.2)" borderColor="blue" borderWidth="1" borderRadius="8" padding="8" flexGrow="1"/>
</FlexboxLayout>
<StackLayout orientation="horizontal" marginTop="16" horizontalAlignment="center">
<Label verticalAlignment="center" text="Type gap:" />
<TextField hint="Gap" text="{{ gap }}" keyboardType="number" maxLength="2">
</TextField>
</StackLayout>
</StackLayout>
</ScrollView>
</Page>
2 changes: 1 addition & 1 deletion packages/core/debugger/dom-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PercentLength } from '../ui/styling/length-shared';
import { getSetProperties, getComputedCssValues } from '../ui/core/properties';
const ELEMENT_NODE_TYPE = 1;
const ROOT_NODE_TYPE = 9;
const propertyBlacklist = ['effectivePaddingLeft', 'effectivePaddingBottom', 'effectivePaddingRight', 'effectivePaddingTop', 'effectiveBorderTopWidth', 'effectiveBorderRightWidth', 'effectiveBorderBottomWidth', 'effectiveBorderLeftWidth', 'effectiveMinWidth', 'effectiveMinHeight', 'effectiveWidth', 'effectiveHeight', 'effectiveMarginLeft', 'effectiveMarginTop', 'effectiveMarginRight', 'effectiveMarginBottom', 'nodeName', 'nodeType', 'decodeWidth', 'decodeHeight', 'ng-reflect-items', 'domNode', 'touchListenerIsSet', 'bindingContext', 'nativeView'];
const propertyBlacklist = ['effectivePaddingLeft', 'effectivePaddingBottom', 'effectivePaddingRight', 'effectivePaddingTop', 'effectiveBorderTopWidth', 'effectiveBorderRightWidth', 'effectiveBorderBottomWidth', 'effectiveBorderLeftWidth', 'effectiveMinWidth', 'effectiveMinHeight', 'effectiveWidth', 'effectiveHeight', 'effectiveMarginLeft', 'effectiveMarginTop', 'effectiveMarginRight', 'effectiveMarginBottom', 'effectiveRowGap', 'effectiveColumnGap', 'nodeName', 'nodeType', 'decodeWidth', 'decodeHeight', 'ng-reflect-items', 'domNode', 'touchListenerIsSet', 'bindingContext', 'nativeView'];

function lazy<T>(action: () => T): () => T {
let _value: T;
Expand Down
Binary file modified packages/core/platforms/android/widgets-release.aar
Binary file not shown.
4 changes: 4 additions & 0 deletions packages/core/ui/core/view-base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ export abstract class ViewBase extends Observable {
public effectiveBorderRightWidth: number;
public effectiveBorderBottomWidth: number;
public effectiveBorderLeftWidth: number;
public effectiveRowGap: number;
public effectiveColumnGap: number;

/**
* @private
Expand Down Expand Up @@ -1569,6 +1571,8 @@ ViewBase.prototype.effectiveBorderTopWidth = 0;
ViewBase.prototype.effectiveBorderRightWidth = 0;
ViewBase.prototype.effectiveBorderBottomWidth = 0;
ViewBase.prototype.effectiveBorderLeftWidth = 0;
ViewBase.prototype.effectiveRowGap = 0;
ViewBase.prototype.effectiveColumnGap = 0;
ViewBase.prototype._isViewBase = true;
ViewBase.prototype.recycleNativeView = 'never';
ViewBase.prototype.reusable = false;
Expand Down
22 changes: 22 additions & 0 deletions packages/core/ui/layouts/flexbox-layout/flexbox-layout-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { View, CSSType } from '../../core/view';
import { CssProperty, ShorthandProperty, makeParser, makeValidator } from '../../core/properties';
import { unsetValue } from '../../core/properties/property-shared';
import { Style } from '../../styling/style';
import { CoreTypes } from '../../../core-types';

export type Basis = 'auto' | number;

Expand Down Expand Up @@ -181,6 +182,27 @@ export abstract class FlexboxLayoutBase extends LayoutBase {
this.style.alignContent = value;
}

get gap(): string | CoreTypes.LengthType {
return this.style.gap;
}
set gap(value: string | CoreTypes.LengthType) {
this.style.gap = value;
}

get rowGap(): CoreTypes.LengthType {
return this.style.rowGap;
}
set rowGap(value: CoreTypes.LengthType) {
this.style.rowGap = value;
}

get columnGap(): CoreTypes.LengthType {
return this.style.columnGap;
}
set columnGap(value: CoreTypes.LengthType) {
this.style.columnGap = value;
}

public static setOrder(view: View, order: number) {
validateArgs(view).style.order = order;
}
Expand Down
17 changes: 17 additions & 0 deletions packages/core/ui/layouts/flexbox-layout/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FlexDirection, FlexWrap, JustifyContent, AlignItems, AlignContent, Flex
import { CoreTypes } from '../../../core-types';
import { View } from '../../core/view';
import { Length } from '../../styling/length-shared';
import { columnGapProperty, rowGapProperty } from '../../styling/style-properties';

export * from './flexbox-layout-common';

Expand Down Expand Up @@ -132,6 +133,22 @@ export class FlexboxLayout extends FlexboxLayoutBase {
this.nativeViewProtected.setAlignContent(alignContentMap[alignContent]);
}

[rowGapProperty.getDefault](): CoreTypes.LengthType {
return rowGapProperty.defaultValue;
}
[rowGapProperty.setNative](value: CoreTypes.LengthType) {
const gap = value ? Length.toDevicePixels(value, 0) : 0;
this.nativeViewProtected.setRowGap(Math.max(gap, 0));
}

[columnGapProperty.getDefault](): CoreTypes.LengthType {
return columnGapProperty.defaultValue;
}
[columnGapProperty.setNative](value: CoreTypes.LengthType) {
const gap = value ? Length.toDevicePixels(value, 0) : 0;
this.nativeViewProtected.setColumnGap(Math.max(gap, 0));
}

public _updateNativeLayoutParams(child: View): void {
super._updateNativeLayoutParams(child);

Expand Down
20 changes: 19 additions & 1 deletion packages/core/ui/layouts/flexbox-layout/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LayoutBase } from '../layout-base';
import { Style } from '../../styling/style';
import { CssProperty } from '../../core/properties';
import { View } from '../../core/view';
import { CoreTypes } from '../../enums';
import { CoreTypes } from '../../../core-types';

export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
export type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
Expand Down Expand Up @@ -68,6 +68,24 @@ export class FlexboxLayout extends LayoutBase {
* @nsProperty
*/
public alignContent: AlignContent;
/**
* Gets or sets the gaps between rows and columns
*
* @nsProperty
*/
public gap: string | CoreTypes.LengthType;
/**
* Gets or sets the gap between rows
*
* @nsProperty
*/
public rowGap: CoreTypes.LengthType;
/**
* Gets or sets the gap between columns
*
* @nsProperty
*/
public columnGap: CoreTypes.LengthType;

public static setOrder(view: View, order: number);
public static getOrder(view: View): number;
Expand Down
Loading
Loading