-
-
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
Open
omairqazi29
wants to merge
2
commits into
NativeScript:main
Choose a base branch
from
omairqazi29:feat/slider-linear-gradient-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { Observable, EventData, Page } from '@nativescript/core'; | ||
|
|
||
| let page: Page; | ||
|
|
||
| export function navigatingTo(args: EventData) { | ||
| page = <Page>args.object; | ||
| page.bindingContext = new SlidersModel(); | ||
| } | ||
|
|
||
| export class SlidersModel extends Observable { | ||
| constructor() { | ||
| super(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page"> | ||
| <Page.actionBar> | ||
| <ActionBar title="Sliders" icon="" class="action-bar"> | ||
| </ActionBar> | ||
| </Page.actionBar> | ||
|
|
||
| <GridLayout class="sliders-demo-page"> | ||
| <ScrollView> | ||
| <StackLayout ios:padding="20" visionos:padding="40"> | ||
|
|
||
| <Label text="Default Slider" class="h3" marginTop="24" /> | ||
| <Slider minValue="0" maxValue="100" value="50" marginTop="12" /> | ||
|
|
||
| <Label text="Gradient Slider (CSS)" class="h3" marginTop="24" /> | ||
| <Label text="background: linear-gradient(to right, orangered, green, lightblue)" class="caption" /> | ||
| <Slider class="gradient-slider" minValue="0" maxValue="100" value="50" marginTop="12" /> | ||
|
|
||
| <Label text="Rainbow Gradient" class="h3" marginTop="24" /> | ||
| <Label text="background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)" class="caption" /> | ||
| <Slider class="rainbow-slider" minValue="0" maxValue="100" value="70" marginTop="12" /> | ||
|
|
||
| <Label text="Two-Color Gradient" class="h3" marginTop="24" /> | ||
| <Label text="background: linear-gradient(to right, #ff6b6b, #4ecdc4)" class="caption" /> | ||
| <Slider class="two-color-slider" minValue="0" maxValue="100" value="30" marginTop="12" /> | ||
|
|
||
| <Label text="Sunset Gradient" class="h3" marginTop="24" /> | ||
| <Label text="background: linear-gradient(to right, #f12711, #f5af19)" class="caption" /> | ||
| <Slider class="sunset-slider" minValue="0" maxValue="100" value="60" marginTop="12" /> | ||
|
|
||
| <Label text="Ocean Gradient" class="h3" marginTop="24" /> | ||
| <Label text="background: linear-gradient(to right, #2193b0, #6dd5ed)" class="caption" /> | ||
| <Slider class="ocean-slider" minValue="0" maxValue="100" value="40" marginTop="12" /> | ||
|
|
||
| <Label text="Purple Gradient" class="h3" marginTop="24" /> | ||
| <Label text="background: linear-gradient(to right, #8e2de2, #4a00e0)" class="caption" /> | ||
| <Slider class="purple-slider" minValue="0" maxValue="100" value="80" marginTop="12" /> | ||
|
|
||
| <Label text="Gradient with Color Stops" class="h3" marginTop="24" /> | ||
| <Label text="background: linear-gradient(to right, red 0%, yellow 50%, green 100%)" class="caption" /> | ||
| <Slider class="stops-slider" minValue="0" maxValue="100" value="50" marginTop="12" /> | ||
|
|
||
| <Label text="Disabled Gradient Slider" class="h3" marginTop="24" /> | ||
| <Slider class="gradient-slider" minValue="0" maxValue="100" value="50" isEnabled="false" marginTop="12" /> | ||
|
|
||
| </StackLayout> | ||
| </ScrollView> | ||
| </GridLayout> | ||
| </Page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks for this @omairqazi29 💯 Possible to add a quick sample page which would have a Slider with this style gradient on it in the toolbox?
You can copy/paste this page for example: https://github.com/NativeScript/NativeScript/blob/main/apps/toolbox/src/pages/switch.xml into a
sliders.{xml,ts}and add slider to it with this gradient style. It's super helpful to confirm behavior on your end but also for us to confirm as well.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.
Done, PFA, thanks!