|
1 |
| -<a align="center" href="https://www.npmjs.com/package/@nstudio/nativescript-checkbox"> |
2 |
| - <h3 align="center">NativeScript Checkbox</h3> |
3 |
| -</a> |
4 |
| -<h4 align="center">A NativeScript plugin to provide a checkbox widget, radio buttons are also possible.</h4> |
| 1 | +<!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️--> |
| 2 | +<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 3 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 4 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 5 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 6 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 7 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 8 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 9 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 10 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 11 | + DO NOT EDIT THIS READEME DIRECTLY! Edit "bluesprint.md" instead. |
| 12 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 13 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 14 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 15 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 16 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 17 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 18 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 19 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 20 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> |
| 21 | +<h1 align="center">@nativescript-community/ui-checkbox</h1> |
| 22 | +<p align="center"> |
| 23 | + <a href="https://npmcharts.com/compare/@nativescript-community/ui-checkbox?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/@nativescript-community/ui-checkbox.svg" height="20"/></a> |
| 24 | +<a href="https://www.npmjs.com/package/@nativescript-community/ui-checkbox"><img alt="NPM Version" src="https://img.shields.io/npm/v/@nativescript-community/ui-checkbox.svg" height="20"/></a> |
| 25 | + </p> |
5 | 26 |
|
6 | 27 | <p align="center">
|
7 |
| - <a href="https://www.npmjs.com/package/@nstudio/nativescript-checkbox"> |
8 |
| - <img src="https://github.com/nstudio/nativescript-checkbox/workflows/Build%20CI/badge.svg" alt="Action Build"> |
9 |
| - </a> |
10 |
| - <a href="https://www.npmjs.com/package/@nstudio/nativescript-checkbox"> |
11 |
| - <img src="https://img.shields.io/npm/dt/nativescript-checkbox.svg?label=npm%20downloads" alt="npm"> |
12 |
| - </a> |
13 |
| - <a href="https://github.com/@nstudio/nativescript-checkbox/stargazers"> |
14 |
| - <img src="https://img.shields.io/github/stars/@nstudio/nativescript-checkbox.svg" alt="stars"> |
15 |
| - </a> |
16 |
| - <br /> |
| 28 | + <b>NativeScript plugin for checkbox.</b></br> |
| 29 | + <sub><sub> |
17 | 30 | </p>
|
18 | 31 |
|
19 |
| ---- |
| 32 | +<br /> |
20 | 33 |
|
21 |
| -### Installation |
22 | 34 |
|
23 |
| -From your command prompt/terminal go to your app's root folder and execute: |
| 35 | +| <img src="https://github.com/nativescript-community/ui-checkbox/raw/master/images/demo-ios.gif" height="500" /> | <img src="https://github.com/nativescript-community/ui-checkbox/raw/master/images/demo-android.gif" height="500" /> | |
| 36 | +| --- | ----------- | |
| 37 | +| iOS Demo | Android Demo | |
24 | 38 |
|
25 |
| -#### NativeScript 7+: |
26 | 39 |
|
27 |
| -```bash |
28 |
| -ns plugin add @nstudio/nativescript-checkbox |
29 |
| -``` |
| 40 | +[](#table-of-contents) |
30 | 41 |
|
31 |
| -#### NativeScript prior to 7: |
| 42 | +## Table of Contents |
32 | 43 |
|
33 |
| -```bash |
34 |
| -tns plugin add @nstudio/ [email protected] |
35 |
| -``` |
| 44 | +* [Installation](#installation) |
| 45 | + * [Platform controls used:](#platform-controls-used) |
| 46 | +* [API](#api) |
| 47 | +* [Properties](#properties) |
| 48 | +* [Events](#events) |
| 49 | +* [API](#api-1) |
| 50 | +* [Css Styling](#css-styling) |
| 51 | +* [Styling [Android]](#styling-android) |
| 52 | + * [Angular Usage Sample:](#angular-usage-sample) |
| 53 | + * [NativeScript-Vue Usage Sample](#nativescript-vue-usage-sample) |
| 54 | +* [Demos](#demos) |
| 55 | +* [Demos and Development](#demos-and-development) |
| 56 | + * [Setup](#setup) |
| 57 | + * [Build](#build) |
| 58 | + * [Demos](#demos-1) |
| 59 | +* [Questions](#questions) |
| 60 | + |
| 61 | + |
| 62 | +[](#installation) |
| 63 | + |
| 64 | +## Installation |
| 65 | +Run the following command from the root of your project: |
| 66 | + |
| 67 | +`ns plugin add @nativescript-community/ui-checkbox` |
36 | 68 |
|
37 | 69 | #### Platform controls used:
|
38 | 70 |
|
39 | 71 | | Android | iOS |
|
40 | 72 | | ---------------------------------------------------------------------------------------- | ---------------------------------------------------- |
|
41 | 73 | | [Android CheckBox](https://developer.android.com/reference/android/widget/CheckBox.html) | [BEMCheckBox](http://cocoapods.org/pods/BEMCheckBox) |
|
42 | 74 |
|
43 |
| -## Sample Usage |
44 | 75 |
|
45 |
| -| Android Sample | iOS Sample | |
46 |
| -| ---------------------------------- | ------------------------------------- | |
47 |
| -|  |  | |
| 76 | +[](#api) |
| 77 | + |
| 78 | +## API |
| 79 | + |
| 80 | + |
| 81 | +[](#properties) |
| 82 | + |
| 83 | +## Properties |
| 84 | + |
| 85 | +- **checked** - boolean |
| 86 | +- **text** - text to use with the checkbox |
| 87 | +- **fillColor** - Color of the checkbox element |
| 88 | +- **boxType** - Either 'square' (default) or 'circle'. It's recommended to use 'circle' for radiobuttons. Note that plugin version 3.0.0 switched the default for iOS to 'square' for alignment with Android. Still want `circle` on iOS and `square` on Android? Just make the `boxType` value conditional. |
| 89 | + |
| 90 | + |
| 91 | +[](#events) |
| 92 | + |
| 93 | +## Events |
| 94 | + |
| 95 | +- **checkedChange** - Use a reference to the CheckBox component to grab it's `checked` property when this event fires to see the new value. |
| 96 | + |
48 | 97 |
|
49 |
| -## Usage |
| 98 | +[](#api) |
| 99 | + |
| 100 | +## API |
| 101 | + |
| 102 | +- **toggle()** - Change the checked state of the view to the inverse of its current state. |
| 103 | + |
| 104 | + |
| 105 | +[](#css-styling) |
| 106 | + |
| 107 | +## Css Styling |
| 108 | + |
| 109 | +- **color** - set the text label color |
| 110 | +- **font-size** - checkbox is sized to text from here : default 15 |
| 111 | +- **border-width** - set the line width of the checkbox element: iOS only |
| 112 | + |
| 113 | + |
| 114 | +[](#styling-android) |
| 115 | + |
| 116 | +## Styling [Android] |
| 117 | + |
| 118 | +- **checkStyle** - set to the name of your drawable |
| 119 | +- **checkPadding** - set the padding of the checkbox |
50 | 120 |
|
51 | 121 | ###
|
52 | 122 |
|
|
56 | 126 | xmlns:CheckBox="@nstudio/nativescript-checkbox" loaded="pageLoaded">
|
57 | 127 | <ActionBar title="Native Checkbox" />
|
58 | 128 | <StackLayout>
|
59 |
| - <CheckBox:CheckBox checked="{{ checkProp }}" text="{{ myCheckText }}" fillColor="{{ myCheckColor }}" id="myCheckbox" /> |
| 129 | + <CheckBox:CheckBox checked="checkProp" text="myCheckText" fillColor="myCheckColor" id="myCheckbox" /> |
60 | 130 | <CheckBox:CheckBox text="CheckBox Label" checked="false" />
|
61 | 131 | </StackLayout>
|
62 | 132 | </Page>
|
@@ -141,56 +211,63 @@ And in your template, use it as:
|
141 | 211 |
|
142 | 212 | Use `checked` instead of `v-model`. [See #99](https://github.com/nstudio/nativescript-checkbox/issues/99).
|
143 | 213 |
|
144 |
| -## Properties |
145 | 214 |
|
146 |
| -- **checked** - boolean |
147 |
| -- **text** - text to use with the checkbox |
148 |
| -- **fillColor** - Color of the checkbox element |
149 |
| -- **boxType** - Either 'square' (default) or 'circle'. It's recommended to use 'circle' for radiobuttons. Note that plugin version 3.0.0 switched the default for iOS to 'square' for alignment with Android. Still want `circle` on iOS and `square` on Android? Just make the `boxType` value conditional. |
150 | 215 |
|
151 |
| -## Events |
| 216 | +[](#demos) |
152 | 217 |
|
153 |
| -- **checkedChange** - Use a reference to the CheckBox component to grab it's `checked` property when this event fires to see the new value. |
| 218 | +## Demos |
| 219 | +This repository includes Angular, Vue.js, and Svelte demos. In order to run these execute the following in your shell: |
| 220 | +```shell |
| 221 | +$ git clone https://github.com/@nativescript-community/ui-checkbox |
| 222 | +$ cd ui-checkbox |
| 223 | +$ npm i |
| 224 | +$ npm run setup |
| 225 | +$ npm run build # && npm run build.angular |
| 226 | +$ cd demo-ng # or demo-vue or demo-svelte |
| 227 | +$ ns run ios|android |
| 228 | +``` |
154 | 229 |
|
155 |
| -## API |
156 | 230 |
|
157 |
| -- **toggle()** - Change the checked state of the view to the inverse of its current state. |
| 231 | +[](#demos-and-development) |
158 | 232 |
|
159 |
| -## Css Styling |
| 233 | +## Demos and Development |
160 | 234 |
|
161 |
| -- **color** - set the text label color |
162 |
| -- **font-size** - checkbox is sized to text from here : default 15 |
163 |
| -- **border-width** - set the line width of the checkbox element: iOS only |
164 | 235 |
|
165 |
| -## Styling [Android] |
| 236 | +### Setup |
166 | 237 |
|
167 |
| -- **checkStyle** - set to the name of your drawable |
168 |
| -- **checkPadding** - set the padding of the checkbox |
| 238 | +To run the demos, you must clone this repo **recursively**. |
| 239 | + |
| 240 | +``` |
| 241 | +git clone https://github.com/@nativescript-community/ui-checkbox.git --recursive |
| 242 | +``` |
169 | 243 |
|
170 |
| -Add the following to `app/App_Resources/Android/drawable/checkbox_grey.xml` |
| 244 | +**Install Dependencies:** |
| 245 | +```bash |
| 246 | +npm i # or 'yarn install' or 'pnpm install' |
| 247 | +``` |
| 248 | + |
| 249 | +**Interactive Menu:** |
171 | 250 |
|
172 |
| -```xml |
173 |
| -<?xml version="1.0" encoding="utf-8"?> |
| 251 | +To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts. |
174 | 252 |
|
175 |
| -<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
176 |
| - <item android:state_enabled="false" android:state_checked="true" android:drawable="@drawable/ic_checkbox_checked_incomplete" /> |
177 |
| - <item android:state_enabled="false" android:state_checked="false" android:drawable="@drawable/ic_checkbox_grey_incomplete" /> |
178 |
| - <item android:state_checked="true" android:drawable="@drawable/ic_checkbox_checked_grey"/> |
179 |
| - <item android:state_checked="false" android:drawable="@drawable/ic_checkbox_grey" /> |
180 |
| -</selector> |
| 253 | +### Build |
| 254 | + |
| 255 | +```bash |
| 256 | +npm run build |
| 257 | + |
| 258 | +npm run build.angular # or for Angular |
181 | 259 | ```
|
182 | 260 |
|
183 |
| -## Radiobuttons, anyone? |
| 261 | +### Demos |
| 262 | + |
| 263 | +```bash |
| 264 | +npm run demo.[ng|react|svelte|vue].[ios|android] |
184 | 265 |
|
185 |
| -Want to use radiobutton behavior for your checkboxes (only one option possible within a group)? |
186 |
| -Set `boxType="circle"` and check out the second tab in the [Angular demo](demo-ng/), here's a screenshot: |
| 266 | +npm run demo.svelte.ios # Example |
| 267 | +``` |
187 | 268 |
|
188 |
| -<img src="./screens/radiobuttons.png" width="225px"/> |
| 269 | +[](#questions) |
189 | 270 |
|
190 |
| -## Contributing & Running Demo Apps |
| 271 | +## Questions |
191 | 272 |
|
192 |
| -- Execute from root: |
193 |
| - - For android: `npm run demo.android` |
194 |
| - - For iOS: `npm run demo.ios` |
195 |
| - - `npm run demo.ng.android` (for angular android) |
196 |
| - - `npm run demo.ng.ios` (for angular ios) |
| 273 | +If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord). |
0 commit comments