Skip to content

Commit 2cb3100

Browse files
committed
fmt
1 parent 233353d commit 2cb3100

File tree

1 file changed

+53
-37
lines changed

1 file changed

+53
-37
lines changed

README.md

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,40 @@
44
[![npm](https://img.shields.io/npm/dt/nativescript-checkbox.svg?label=npm%20downloads)](https://www.npmjs.com/package/nativescript-checkbox)
55

66
# NativeScript CheckBox :white_check_mark:
7+
78
A NativeScript plugin for the native checkbox widget.
89

9-
#### Platform controls used:
10-
Android | iOS
11-
---------- | -------
12-
[Android CheckBox](https://developer.android.com/reference/android/widget/CheckBox.html) | [BEMCheckBox](http://cocoapods.org/pods/BEMCheckBox)
10+
#### Platform controls used:
1311

12+
| Android | iOS |
13+
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------- |
14+
| [Android CheckBox](https://developer.android.com/reference/android/widget/CheckBox.html) | [BEMCheckBox](http://cocoapods.org/pods/BEMCheckBox) |
1415

1516
## Sample Usage
1617

17-
Android Sample | iOS Sample
18-
-------- | ---------
19-
![Sample1](./screens/checkbox.gif) | ![Sample2](./screens/iosCheckbox.gif)
18+
| Android Sample | iOS Sample |
19+
| ---------------------------------- | ------------------------------------- |
20+
| ![Sample1](./screens/checkbox.gif) | ![Sample2](./screens/iosCheckbox.gif) |
2021

2122
## Installation
23+
2224
From your command prompt/terminal go to your app's root folder and execute:
2325

2426
#### NS 3.0+
27+
2528
`tns plugin add nativescript-checkbox`
2629

2730
#### NS < 3.0
31+
2832
`tns plugin add [email protected]`
2933

3034
## Usage
3135

3236
###
37+
3338
```XML
34-
<Page
35-
xmlns="http://schemas.nativescript.org/tns.xsd"
39+
<Page
40+
xmlns="http://schemas.nativescript.org/tns.xsd"
3641
xmlns:CheckBox="nativescript-checkbox" loaded="pageLoaded">
3742
<ActionBar title="Native Checkbox" />
3843
<StackLayout>
@@ -42,7 +47,8 @@ From your command prompt/terminal go to your app's root folder and execute:
4247
</Page>
4348
```
4449

45-
###
50+
###
51+
4652
```TS
4753
import { CheckBox } from 'nativescript-checkbox';
4854
import { topmost } from 'ui/frame';
@@ -65,30 +71,32 @@ public getCheckProp() {
6571
import { TNSCheckBoxModule } from 'nativescript-checkbox/angular';
6672

6773
@NgModule({
68-
imports: [TNSCheckBoxModule],
69-
// etc.
74+
imports: [TNSCheckBoxModule]
75+
// etc.
7076
})
7177
export class YourModule {}
7278

7379
// component:
74-
export class SomeComponent {
75-
@ViewChild("CB1") FirstCheckBox: ElementRef;
76-
constructor() {}
77-
public toggleCheck() {
78-
this.FirstCheckBox.nativeElement.toggle();
79-
}
80-
81-
public getCheckProp() {
82-
console.log('checked prop value = ' + this.FirstCheckBox.nativeElement.checked);
83-
}
80+
export class SomeComponent {
81+
@ViewChild('CB1') FirstCheckBox: ElementRef;
82+
constructor() {}
83+
public toggleCheck() {
84+
this.FirstCheckBox.nativeElement.toggle();
85+
}
86+
87+
public getCheckProp() {
88+
console.log(
89+
'checked prop value = ' + this.FirstCheckBox.nativeElement.checked
90+
);
91+
}
8492
}
8593
```
8694

8795
```html
8896
<StackLayout>
89-
<CheckBox #CB1 text="CheckBox Label" checked="false"></CheckBox>
90-
<Button (tap)="toggleCheck()" text="Toggle it!"></Button>
91-
<Button (tap)="getCheckProp()" text="Check Property"></Button>
97+
<CheckBox #CB1 text="CheckBox Label" checked="false"></CheckBox>
98+
<button (tap)="toggleCheck()" text="Toggle it!"></button>
99+
<button (tap)="getCheckProp()" text="Check Property"></button>
92100
</StackLayout>
93101
```
94102

@@ -97,12 +105,16 @@ export class SomeComponent {
97105
In your `main.js` (The file where the root Vue instance is created) register the element
98106

99107
```js
100-
Vue.registerElement('CheckBox', () => require('nativescript-checkbox').CheckBox, {
101-
model: {
102-
prop: 'checked',
103-
event: 'checkedChange'
104-
}
105-
})
108+
Vue.registerElement(
109+
'CheckBox',
110+
() => require('nativescript-checkbox').CheckBox,
111+
{
112+
model: {
113+
prop: 'checked',
114+
event: 'checkedChange'
115+
}
116+
}
117+
);
106118
```
107119

108120
And in your template, use it
@@ -129,14 +141,16 @@ And in your template, use it
129141
## Css Styling
130142

131143
- **color** - set the text label color
132-
- **font-size** - checkbox is sized to text from here : default 15
144+
- **font-size** - checkbox is sized to text from here : default 15
133145
- **border-width** - set the line width of the checkbox element: iOS only
134146

135147
## Styling [Android]
148+
136149
- **checkStyle** - set to the name of your drawable
137150
- **checkPadding** - set the padding of the checkbox
138151

139152
Add the following to `app/App_Resources/Android/drawable/checkbox_grey.xml`
153+
140154
```xml
141155
<?xml version="1.0" encoding="utf-8"?>
142156

@@ -149,22 +163,24 @@ Add the following to `app/App_Resources/Android/drawable/checkbox_grey.xml`
149163
```
150164

151165
## Radiobuttons, anyone?
166+
152167
Want to use radiobutton behavior for your checkboxes (only one option possible within a group)?
153168
Set `boxType="circle"` and check out the second tab in the [Angular demo](demo-ng/), here's a screenshot:
154169

155170
<img src="./screens/radiobuttons.png" width="225px"/>
156171

157172
## Demo Setup
158-
* npm i
159-
* npm run preparedemo
160-
* npm run demo.ios
161173

174+
- npm i
175+
- npm run preparedemo
176+
- npm run demo.ios
162177

163178
#### Contributors
164179

165180
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
166181

167-
| [<img src="https://avatars0.githubusercontent.com/u/6006148?v=3" width="100px;"/><br /><sub>Brad Martin</sub>](https://bradmartin.net/) | [<img src="https://avatars2.githubusercontent.com/u/1542376?v=3" width="100px;"/><br /><sub>Steve McNiven-Scott</sub>](https://github.com/sitefinitysteve) | [<img src="https://avatars3.githubusercontent.com/u/6695919?v=3" width="100px;"/><br /><sub>Osei Fortune</sub>](https://github.com/triniwiz) | [<img src="https://avatars2.githubusercontent.com/u/457187?v=3" width="100px;"/><br /><sub>Nathan Walker</sub>](https://github.com/NathanWalker) |
168-
|---|---|---|---|---|
182+
| [<img src="https://avatars0.githubusercontent.com/u/6006148?v=3" width="100px;"/><br /><sub>Brad Martin</sub>](https://bradmartin.net/) | [<img src="https://avatars2.githubusercontent.com/u/1542376?v=3" width="100px;"/><br /><sub>Steve McNiven-Scott</sub>](https://github.com/sitefinitysteve) | [<img src="https://avatars3.githubusercontent.com/u/6695919?v=3" width="100px;"/><br /><sub>Osei Fortune</sub>](https://github.com/triniwiz) | [<img src="https://avatars2.githubusercontent.com/u/457187?v=3" width="100px;"/><br /><sub>Nathan Walker</sub>](https://github.com/NathanWalker) |
183+
| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
184+
169185

170186
<!-- ALL-CONTRIBUTORS-LIST:END -->

0 commit comments

Comments
 (0)