Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bradmartin/nativescript-wear-os
Consolidated repo for WearOS with NativeScript
https://github.com/bradmartin/nativescript-wear-os
android nativescript watches wear-os wearable wearable-devices
Last synced: 2 months ago
JSON representation
Consolidated repo for WearOS with NativeScript
- Host: GitHub
- URL: https://github.com/bradmartin/nativescript-wear-os
- Owner: bradmartin
- License: apache-2.0
- Created: 2018-12-21T22:24:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-30T03:53:01.000Z (over 1 year ago)
- Last Synced: 2024-10-10T22:41:05.148Z (2 months ago)
- Topics: android, nativescript, watches, wear-os, wearable, wearable-devices
- Language: TypeScript
- Size: 6.28 MB
- Stars: 35
- Watchers: 7
- Forks: 7
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
NativeScript-Wear-OS is a NativeScript plugin that provides layouts and utilities specific to WearOS.---
## Installation
NativeScript Version 7+:
```bash
tns plugin add nativescript-wear-os
```NativeScript version prior to 7:
```bash
tns plugin add [email protected]
```---
### Ambient Mode Support
##### Documentation: _https://developer.android.com/training/wearables/apps/always-on_
1. Add the `WAKE_LOCK` permission to your AndroidManifest.xml
```xml
```2. Copy the `ambient-activity.ts` in the root of this project's demo app and use it to replace the default Android Activity loaded by NativeScript. [NativeScript docs HERE about using a custom Android Activity.](https://docs.nativescript.org/core-concepts/android-runtime/advanced-topics/extend-application-activity#extending-activity)
3. Update the AndroidManifest.xml for your application to use the correct activity. Change the `android:name` value of the `activity` node to point to the same name used inside the `ambient-activity.ts` file inside the `@JavaProxy()` decorator at the top of the file.
```xml
```4. Update your webpack.config to include the custom Android Activity. Snippet below copied from the demo app.
```javascript
// Add your custom Activities, Services and other Android app components here.
const appComponents = [
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity',
resolve(__dirname, 'app/ambient-activity'),
];
```---
### WearOsLayout
A base layout for Wear OS apps built with NativeScript that automatically handles calculating the inset for circle watch faces. To disable the layout from automatically adjusting the inset set `disableInsetConstraint="true"` on the `WearOsLayout` instance. The default is false and does not have to be set.
This has no effect on square watches.
```xml
```
| Circle Watch | Square Watch |
| ----------------------------------------------------------- | :---------------------------------------------------------: |
| ![Cirlce Watch Usage](./screenshots/base-layout/circle.png) | ![Square Watch Usage](./screenshots/base-layout/square.png) |---
### WearOsListView
```xml
```
##### API
_useScalingScroll_ - If true, the items in the listview will scale during the scroll layout change event.
![ListView Gif](./screenshots/listview/demo.gif)
---
### BoxInsetLayout
```xml
```
![BoxInsetLayout Usage](./screenshots/box-inset/boxinset.png)
### Dialogs
This plugin uses an Android WearOS specific library [SmartWearOs](https://github.com/bradmartin/SmartWearOs).
The plugin has a success dialog and failure/error dialog to present on WearOS. These mimic the behavior of the built in Confirmation Activity on WearOS. With the option of setting the time before it is dismissed/hidden from the user.
#### Usage
```typescript
import {
showFailure,
showSuccess,
} from 'nativescript-wear-os/packages/dialogs';showSuccess('Great choice! NativeScript is awesome.', 4).then(() => {
console.log('success dialog complete.');
});
```![Success Activity](./screenshots/success-activity.png)
![Failure Activity](./screenshots/failure-activity.png)## [Change Log](./CHANGELOG.md)