From cf533a7b6d6607aefd39c06978578bb2b453eb3d Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Fri, 10 May 2019 05:05:28 -0300 Subject: [PATCH] feat(android): elevation shadow support (#7136) --- apps/app/ui-tests-app/css/elevation.css | 43 ++++++++++ apps/app/ui-tests-app/css/elevation.ts | 20 +++++ apps/app/ui-tests-app/css/elevation.xml | 25 ++++++ apps/app/ui-tests-app/css/main-page.ts | 1 + tns-core-modules/ui/button/button.android.ts | 26 +++++- .../ui/core/view-base/view-base.ts | 2 +- tns-core-modules/ui/core/view/view-common.ts | 14 ++++ tns-core-modules/ui/core/view/view.android.ts | 84 ++++++++++++++++++- tns-core-modules/ui/core/view/view.d.ts | 10 +++ .../ui/styling/style-properties.ts | 6 ++ tns-core-modules/ui/styling/style/style.d.ts | 8 +- tns-core-modules/ui/styling/style/style.ts | 8 +- 12 files changed, 236 insertions(+), 11 deletions(-) create mode 100644 apps/app/ui-tests-app/css/elevation.css create mode 100644 apps/app/ui-tests-app/css/elevation.ts create mode 100644 apps/app/ui-tests-app/css/elevation.xml diff --git a/apps/app/ui-tests-app/css/elevation.css b/apps/app/ui-tests-app/css/elevation.css new file mode 100644 index 000000000..5ebb8a2ab --- /dev/null +++ b/apps/app/ui-tests-app/css/elevation.css @@ -0,0 +1,43 @@ +Label, Button { + text-align: center; + padding: 10; + margin: 16; + background-color: #bbb; +} + +.elevation-0 { + android-elevation: 0; +} + +.elevation-2 { + android-elevation: 2; +} + +.elevation-4 { + android-elevation: 4; +} + +.elevation-4:highlighted { + android-elevation: 2; +} + +.elevation-8 { + android-elevation: 8; +} + +.elevation-10 { + android-elevation: 10; +} + +.pressed-z-10 { + android-dynamic-elevation-offset: 10; +} + +.round { + color: #fff; + background-color: #ff1744; + border-radius: 50%; /* TODO kills elevation */ + width: 80; + height: 80; + android-elevation: 8; +} \ No newline at end of file diff --git a/apps/app/ui-tests-app/css/elevation.ts b/apps/app/ui-tests-app/css/elevation.ts new file mode 100644 index 000000000..dd7e54701 --- /dev/null +++ b/apps/app/ui-tests-app/css/elevation.ts @@ -0,0 +1,20 @@ +import { Button } from "tns-core-modules/ui/button/button"; +import { EventData } from "tns-core-modules/ui/page/page"; + +const states = [ + { class: "", text: "default elevation" }, + { class: "elevation-10", text: "elevetion 10" }, + { class: "elevation-10 pressed-z-10", text: "elevetion 10 pressed-z 10" }, + { class: "elevation-0", text: "elevetion 0" }, +] +let currentState = 0; + +export function buttonTap(args: EventData) { + let btn: Button = args.object as Button; + currentState++; + if (currentState >= states.length) { + currentState = 0; + } + btn.className = states[currentState].class; + btn.text = states[currentState].text; +} \ No newline at end of file diff --git a/apps/app/ui-tests-app/css/elevation.xml b/apps/app/ui-tests-app/css/elevation.xml new file mode 100644 index 000000000..37a492e92 --- /dev/null +++ b/apps/app/ui-tests-app/css/elevation.xml @@ -0,0 +1,25 @@ + + + +