-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(slider): add linear-gradient support for track background #11015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(slider): add linear-gradient support for track background #11015
Conversation
Enable using CSS linear-gradient for the Slider component's track. This allows setting gradient backgrounds via the background-image CSS property or programmatically. On Android: - Creates LinearGradient shader applied to ShapeDrawable - Sets gradient on both progress and background layers of SeekBar On iOS: - Creates CAGradientLayer and renders to UIImage - Sets resizable track images for min/max track states Closes NativeScript#5940
|
View your CI Pipeline Execution ↗ for commit 8805f91
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit c3326e5
☁️ Nx Cloud last updated this comment at |
Add sample page to toolbox demonstrating gradient slider backgrounds: - Default slider for comparison - Various gradient styles (rainbow, sunset, ocean, purple) - Gradient with explicit color stops - Disabled gradient slider example
|
Nice work @omairqazi29 I pushed up one adjustment to use newer/preferred iOS 10+ (non-deprecated) graphics APIs since NativeScript is right now a iOS 12/13 min target 👍 |
| // | ||
| if (value && value.image instanceof LinearGradient) { | ||
| this._applyGradientToTrack(value.image); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually unfortunately @omairqazi29 it does not work on Android if able to check this.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NathanWalker Fixed using ShapeDrawable with LinearGradient shader as shown in #5940 example.

Awesome noted. |
…ativeScript#11020) [skip ci] Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.13.1 to 2.14.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](step-security/harden-runner@f4a75cf...20cf305) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.14.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ipt#11021) [skip ci] Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.6.0 to 6.1.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@a26af69...83679a8) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: 6.1.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…Script#11022) [skip ci] Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5.0.0 to 6.0.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@330a01c...b7c566a) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…cript#11023) [skip ci] Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.5 to 4.31.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@fdbfb4d...5d4e8d1) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 4.31.9 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…t#11024) [skip ci] Bumps [actions/setup-java](https://github.com/actions/setup-java) from 5.0.0 to 5.1.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@dded088...f2beeb2) --- updated-dependencies: - dependency-name: actions/setup-java dependency-version: 5.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- project: devtools 0.0.2-next.1 - project: webpack5 5.0.31-next.1 - project: core 9.0.11-next.2 - project: vite 1.0.4-next.1
- project: devtools 0.0.2-next.2 - project: webpack5 5.0.31-next.2 - project: core 9.0.12-next.0 - project: vite 1.0.4-next.2
- project: devtools 0.0.2-next.4 - project: webpack5 5.0.30-next.1 - project: core 9.0.12-next.2 - project: vite 1.0.6-next.1
- project: webpack5 5.0.31-next.0
- project: webpack5 5.0.31-next.1 - project: vite 1.0.6-next.2
- project: webpack5 5.0.32-next.0
|
Pushed up one last improvement to android but wanted you to see where it all landed:
|
|
Thanks again for all your work here @omairqazi29! |


Summary
linear-gradientfor the Slider component's track backgroundAndroid Implementation
android.graphics.LinearGradientshader from CSS gradient color stopsShapeDrawablewrapped inClipDrawablefor progress clippingiOS Implementation
CAGradientLayerwith colors and positions from CSS gradientUIImageresizableImageWithCapInsetsResizingModeUsage
Via CSS
Programmatically
Test plan
Closes #5940