Skip to content

Commit a4f562b

Browse files
Merge pull request #30 from bradmartin/master
Add indicator color option, cleaned up README
2 parents bc722c3 + 6f5a5c4 commit a4f562b

File tree

4 files changed

+87
-63
lines changed

4 files changed

+87
-63
lines changed

README.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
# NativeScript Slides for iOS and Android
2-
###_The plugin formally known as nativescript-intro-slides_
2+
### _The plugin formally known as nativescript-intro-slides_
33

4-
###Intro slides example:
4+
### Intro slides example:
55
[![Nativescript Slides. Click to Play](https://img.youtube.com/vi/kGby8qtSDjM/0.jpg)](https://www.youtube.com/embed/kGby8qtSDjM)
66

7-
###Image carousel example:
7+
### Image carousel example:
88
[![Nativescript Slides. Click to Play](https://img.youtube.com/vi/RsEqGAKm62k/0.jpg)](https://www.youtube.com/embed/RsEqGAKm62k)
99

1010
_videos by [Brad Martin](https://github.com/bradmartin)_
1111

12-
##Example Usage:
13-
###XML
12+
## Example Usage:
13+
### XML
1414
```xml
1515

16-
<Slides:SlideContainer>
17-
<Slides:Slide class="slide-1">
18-
<Label text="This is Panel 1" />
19-
</Slides:Slide>
20-
<Slides:Slide class="slide-2">
21-
<Label text="This is Panel 2" />
22-
</Slides:Slide>
23-
<Slides:Slide class="slide-3">
24-
<Label text="This is Panel 3" />
25-
</Slides:Slide>
26-
<Slides:Slide class="slide-4">
27-
<Label text="This is Panel 4" />
28-
</Slides:Slide>
29-
<Slides:Slide class="slide-5">
30-
<Label text="This is Panel 5" />
31-
</Slides:Slide>
16+
<Slides:SlideContainer id="slides" pageIndicators="true" indicatorsColor="#fff">
17+
<Slides:Slide class="slide-1">
18+
<Label text="This is Panel 1" />
19+
</Slides:Slide>
20+
<Slides:Slide class="slide-2">
21+
<Label text="This is Panel 2" />
22+
</Slides:Slide>
23+
<Slides:Slide class="slide-3">
24+
<Label text="This is Panel 3" />
25+
</Slides:Slide>
26+
<Slides:Slide class="slide-4">
27+
<Label text="This is Panel 4" />
28+
</Slides:Slide>
29+
<Slides:Slide class="slide-5">
30+
<Label text="This is Panel 5" />
31+
</Slides:Slide>
3232
</Slides:SlideContainer>
3333

3434
```
35-
###CSS
35+
### CSS
3636
```css
3737
.slide-1{
3838
background-color: darkslateblue;
@@ -67,24 +67,31 @@ when using the intro slide plugin you need at least two ``<Slides:Slide>`` views
6767

6868
add as many ``<Slides:Slide>`` as you want.
6969

70-
the `SlideContainer` class also has public `nextSlide` and `previousSlide` functions so you can add your own previous and next buttons as needed.
70+
### Methods for SlideContainer
7171

72-
the `<Slides:SlideContainer>` element also has a property called `loop` which is a boolean value and if set to true will cause the slide to be an endless loop. The suggested use case would be for a Image Carousel or something of that nature.
72+
- **nextSlide()** - navigate to the next slide (right direction)
73+
- **previousSlide()** - navigate to the previous slide (left direction)
7374

74-
the `<Slides:SlideContainer>` element also has a property called `velocityScrolling` which is a boolean value and if set to true will calculate transitions speeds based on the finger movement speed.
75+
### Attributes for SlideContainer
7576

76-
the `<Slides:SlideContainer>` element also has a property called `pageIndicators` which will add indicator dots to the bottom of your slides.
77+
- **loop : boolean** - If true will cause the slide to be an endless loop. The suggested use case would be for a Image Carousel or something of that nature.
7778

78-
the `<Slides:SlideContainer>` element also has a property called `interval` which is a integer value and the value is in milliseconds. The suggested use case would be for a Image Carousel or something of that nature which can change the image for every fixed intervals. In unloaded function call `page.getViewById("your_id").stopSlideshow()` to unregister it (your_id is the id given to `<Slides:SlideContainer>`), it can be restarted with `startSlidShow`.
79+
- **velocityScrolling : boolean** - If true will calculate transitions speeds based on the finger movement speed.
7980

80-
the `<Slides:SlideContainer>` element also has a property called `disablePan` which is used to disable panning when set to true. So that you can call nextSlide() function to change the slide. If slides is used to get details about users like email, phone number ,username etc in this case you don't want users to move from one slide to another slide without filling details. So, you can disablePan option.
81+
- **pageIndicators : boolean** - If true adds indicator dots to the bottom of your slides.
82+
83+
- **indicatorsColor : string** - color of the indicator dots.
84+
85+
- **interval : integer** - value is in milliseconds. The suggested use case would be for a Image Carousel or something of that nature which can change the image for every fixed intervals. In unloaded function call `page.getViewById("your_id").stopSlideshow()` to unregister it (your_id is the id given to `<Slides:SlideContainer>`), it can be restarted with `startSlidShow`.
86+
87+
- **disablePan : boolean** - If true panning is disabled. So that you can call nextSlide()/previousSlide() functions to change the slide. If slides is used to get details about users like email, phone number, username etc. in this case you don't want users to move from one slide to another slide without filling details.
8188

8289
#### Angular 2 compatibility
8390
To use the slides with Angular2 and the `registerElement` from `nativescript-angular` you will want to set the `SlideContainer`'s property of `angular` to `true`. Then in your angular component in the `ngAfterViewInit`. you will want to have an instance of your slide container to call the function `constructView()`.
8491

8592
#### Android Optional Attributes
86-
- `androidTranslucentStatusBar`: boolean - If true, the Android status bar will be translucent on devices that support it. (Android sdk >= 19).
87-
- `androidTranslucentNavBar`: boolean - If true, the Android navigation bar will be translucent on devices that support it. (Android sdk >= 19).
93+
- **androidTranslucentStatusBar : boolean** - If true the Android status bar will be translucent on devices that support it. (Android sdk >= 19).
94+
- **androidTranslucentNavBar : boolean** - If true the Android navigation bar will be translucent on devices that support it. (Android sdk >= 19).
8895

8996
#### Plugin Development Work Flow:
9097

@@ -138,7 +145,7 @@ to
138145
_please note this will change the panning gesture for your entire project._
139146

140147

141-
###Thanks to these awesome contributors!
148+
### Thanks to these awesome contributors!
142149

143150
[Brad Martin](https://github.com/bradmartin)
144151

@@ -149,10 +156,10 @@ _please note this will change the panning gesture for your entire project._
149156
And thanks to [Nathan Walker](https://github.com/NathanWalker) for setting up the {N} plugin seed that was used to help get this plugin up and running. More info can be found about it here:
150157
https://github.com/NathanWalker/nativescript-plugin-seed
151158

152-
##Contributing guidelines
159+
## Contributing guidelines
153160
[Contributing guidelines](https://github.com/TheOriginalJosh/nativescript-swiss-army-knife/blob/master/CONTRIBUTING.md)
154161

155-
##License
162+
## License
156163

157164
[MIT](/LICENSE)
158165

demo/package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"nativescript": {
3-
"id": "org.nativescript.demo",
4-
"tns-android": {
5-
"version": "2.0.0"
6-
},
7-
"tns-ios": {
8-
"version": "2.0.0"
9-
}
10-
},
11-
"dependencies": {
12-
"nativescript-slides": "file:..",
13-
"tns-core-modules": "^2.0.1"
14-
},
15-
"devDependencies": {
16-
"babel-traverse": "6.9.0",
17-
"babel-types": "6.9.0",
18-
"babylon": "6.8.0",
19-
"filewalker": "0.1.2",
20-
"lazy": "1.0.11",
21-
"nativescript-dev-typescript": "^0.3.1",
22-
"typescript": "^1.8.7"
23-
}
24-
}
2+
"nativescript": {
3+
"id": "org.nativescript.demo",
4+
"tns-android": {
5+
"version": "2.0.0"
6+
},
7+
"tns-ios": {
8+
"version": "2.0.0"
9+
}
10+
},
11+
"dependencies": {
12+
"nativescript-slides": "file:..",
13+
"tns-core-modules": "^2.0.1"
14+
},
15+
"devDependencies": {
16+
"babel-traverse": "6.9.0",
17+
"babel-types": "6.9.1",
18+
"babylon": "6.8.0",
19+
"filewalker": "0.1.2",
20+
"lazy": "1.0.11",
21+
"nativescript-dev-typescript": "^0.3.1",
22+
"typescript": "^1.8.7"
23+
}
24+
}

nativescript-slides.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export declare class SlideContainer extends AbsoluteLayout {
2525
private _disablePan;
2626
private _footer;
2727
private _pageIndicators;
28+
private _indicatorsColor;
2829
pageIndicators: boolean;
30+
indicatorsColor: string;
2931
hasNext: boolean;
3032
hasPrevious: boolean;
3133
interval: number;
@@ -53,10 +55,10 @@ export declare class SlideContainer extends AbsoluteLayout {
5355
private applySwipe(pageWidth);
5456
private showRightSlide(panelMap, offset?, endingVelocity?);
5557
private showLeftSlide(panelMap, offset?, endingVelocity?);
56-
private buildFooter(pageCount?, activeIndex?);
58+
private buildFooter(pageCount, activeIndex, iColor);
5759
private setwidthPercent(view, percentage);
5860
private newFooterButton(name);
5961
private buildSlideMap(views);
60-
createIndicator(): Label;
62+
createIndicator(indicatorColor: string): Label;
6163
setActivePageIndicator(index: number): void;
6264
}

nativescript-slides.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class SlideContainer extends AbsoluteLayout {
5050
private _disablePan: boolean;
5151
private _footer: StackLayout;
5252
private _pageIndicators: boolean;
53+
private _indicatorsColor: string;
5354

5455
/* page indicator stuff*/
5556
get pageIndicators(): boolean {
@@ -59,6 +60,13 @@ export class SlideContainer extends AbsoluteLayout {
5960
this._pageIndicators = value;
6061
}
6162

63+
get indicatorsColor(): string {
64+
return this._indicatorsColor;
65+
}
66+
set indicatorsColor(value: string) {
67+
this._indicatorsColor = value;
68+
}
69+
6270
get hasNext(): boolean {
6371
return !!this.currentPanel.right;
6472
}
@@ -211,7 +219,14 @@ export class SlideContainer extends AbsoluteLayout {
211219
});
212220

213221
if (this.pageIndicators) {
214-
this._footer = this.buildFooter(slides.length, 0);
222+
223+
let iColor = this.indicatorsColor;
224+
//check if invalid and set to white (#fff)
225+
if (!Color.isValid(iColor)) {
226+
iColor = '#fff';
227+
}
228+
229+
this._footer = this.buildFooter(slides.length, 0, iColor);
215230
this.insertChild(this._footer, this.getChildrenCount());
216231
// this.setActivePageIndicator(0);
217232
}
@@ -479,7 +494,7 @@ export class SlideContainer extends AbsoluteLayout {
479494
/**
480495
* currently deprecated.... will come back to life for navigation dots.
481496
* */
482-
private buildFooter(pageCount: number = 5, activeIndex: number = 0): StackLayout {
497+
private buildFooter(pageCount: number = 5, activeIndex: number = 0, iColor: string): StackLayout {
483498
let footerInnerWrap = new StackLayout();
484499

485500
footerInnerWrap.height = 50;
@@ -494,7 +509,7 @@ export class SlideContainer extends AbsoluteLayout {
494509

495510
let i = 0;
496511
while (i < pageCount) {
497-
footerInnerWrap.addChild(this.createIndicator());
512+
footerInnerWrap.addChild(this.createIndicator(iColor));
498513
i++;
499514
}
500515

@@ -541,9 +556,9 @@ export class SlideContainer extends AbsoluteLayout {
541556
return slideMap[0];
542557
}
543558

544-
createIndicator(): Label {
559+
createIndicator(indicatorColor: string): Label {
545560
let indicator = new Label();
546-
indicator.backgroundColor = new Color('#fff');
561+
indicator.backgroundColor = new Color(indicatorColor);
547562
indicator.opacity = 0.4;
548563
indicator.width = 10;
549564
indicator.height = 10;

0 commit comments

Comments
 (0)