From 943e67a4c83bc1ccc03a41f01f9d9cbda79108b0 Mon Sep 17 00:00:00 2001 From: Panayot Cankov Date: Fri, 30 Sep 2016 12:20:07 +0300 Subject: [PATCH] Add flexbox, we have to figure out layout params --- apps/app/ui-tests-app/flexbox/flexbox.css | 28 ++ apps/app/ui-tests-app/flexbox/flexbox.ts | 55 ++++ apps/app/ui-tests-app/flexbox/flexbox.xml | 119 ++++++++ apps/app/ui-tests-app/mainPage.ts | 1 + tns-core-modules/tns-core-modules.base.d.ts | 1 + .../flexbox-layout/flexbox-layout-common.ts | 263 ++++++++++++++++++ .../flexbox-layout/flexbox-layout.android.ts | 124 +++++++++ .../flexbox-layout/flexbox-layout.d.ts | 71 +++++ .../ui/layouts/flexbox-layout/package.json | 2 + .../android/org.nativescript.widgets.d.ts | 62 +++++ 10 files changed, 726 insertions(+) create mode 100644 apps/app/ui-tests-app/flexbox/flexbox.css create mode 100644 apps/app/ui-tests-app/flexbox/flexbox.ts create mode 100644 apps/app/ui-tests-app/flexbox/flexbox.xml create mode 100644 tns-core-modules/ui/layouts/flexbox-layout/flexbox-layout-common.ts create mode 100644 tns-core-modules/ui/layouts/flexbox-layout/flexbox-layout.android.ts create mode 100644 tns-core-modules/ui/layouts/flexbox-layout/flexbox-layout.d.ts create mode 100644 tns-core-modules/ui/layouts/flexbox-layout/package.json diff --git a/apps/app/ui-tests-app/flexbox/flexbox.css b/apps/app/ui-tests-app/flexbox/flexbox.css new file mode 100644 index 000000000..0be39be0f --- /dev/null +++ b/apps/app/ui-tests-app/flexbox/flexbox.css @@ -0,0 +1,28 @@ +@keyframes select { + 0%, 100% { + transform: scale(1, 1); + } + 50% { + transform: scale(1.4, 1.4); + } +} +#container>Label { + border-width: 1; + border-color: black; + border-radius: 5; +} +#container>Label[selected="yes"] { + border-color: yellow; + /* animation-name: select; + animation-duration: 0.2s; + animation-fill-mode: forwards; + animation-iteration-count: 1;*/ +} + +.control { + font-size: 11; +} +.control Button { + padding: 2; + margin: 2; +} \ No newline at end of file diff --git a/apps/app/ui-tests-app/flexbox/flexbox.ts b/apps/app/ui-tests-app/flexbox/flexbox.ts new file mode 100644 index 000000000..592b855dd --- /dev/null +++ b/apps/app/ui-tests-app/flexbox/flexbox.ts @@ -0,0 +1,55 @@ +import {isAndroid} from "platform"; +import * as flexbox from "ui/layouts/flexbox-layout"; + +function set(what: string) { + return function(args) { + args.object.page.getViewById("container")[what] = args.object.text; + } +} + +export const flexDirection = set("flexDirection"); +export const flexWrap = set("flexWrap"); +export const justifyContent = set("justifyContent"); +export const alignItems = set("alignItems"); +export const alignContent = set("alignContent"); + +let lastSelection = null; +export function select(args) { + console.log("Select: " + args.object); + lastSelection = args.object; + + if (isAndroid) { + let layoutParams = lastSelection.android.getLayoutParams(); + console.log("Selection: " + lastSelection + ": " + layoutParams); + console.log(" - margin: " + layoutParams.topMargin + " " + layoutParams.rightMargin + " " + layoutParams.bottomMargin + " " + layoutParams.leftMargin); + } +} + +export function order({object}) { + if (!lastSelection) { + return; + } + let value = object.text; + console.log("Set order " + value + " " + lastSelection); + flexbox.FlexboxLayout.setOrder(lastSelection, object.text); +} + +export function flexGrow({object}) { + if (!lastSelection) { + return; + } + let value = object.text; + console.log("Set flexGrow " + value + " " + lastSelection); + flexbox.FlexboxLayout.setFlexGrow(lastSelection, object.text); +} + +export function flexShrink({object}) { + if (!lastSelection) { + return; + } + let value = object.text; + console.log("Set flexShrink " + value + " " + lastSelection); + flexbox.FlexboxLayout.setFlexShrink(lastSelection, object.text); +} + +// TODO: Align self \ No newline at end of file diff --git a/apps/app/ui-tests-app/flexbox/flexbox.xml b/apps/app/ui-tests-app/flexbox/flexbox.xml new file mode 100644 index 000000000..407a04343 --- /dev/null +++ b/apps/app/ui-tests-app/flexbox/flexbox.xml @@ -0,0 +1,119 @@ + + + +