Skip to content

Commit

Permalink
Merge pull request #19 from bradmartin/ns-7-update
Browse files Browse the repository at this point in the history
Ns 7 update
  • Loading branch information
bradmartin authored Sep 11, 2020
2 parents b7689f9 + 4c66cca commit a90fb42
Show file tree
Hide file tree
Showing 67 changed files with 15,262 additions and 1,081 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build CI

# Trigger the workflow on push
on: [push]

jobs:
job1:
name: Android Builds
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Base Setup
run: npm run ci.base.setup

- name: Lint
run: npm run ci.tslint

- name: Build Vanilla Android Demo App
run: npm run ci.vanilla.android.build
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"singleQuote": true,
"semi": true
"semi": true,
"arrowParens": "avoid",
"trailingComma": "none"
}
78 changes: 0 additions & 78 deletions .travis.yml

This file was deleted.

28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,33 @@ NativeScript-Wear-OS is a NativeScript plugin that provides layouts and utilitie
</h4>

<p align="center">
<a href="https://www.npmjs.com/package/nativescript-gif">
<img src="https://github.com/bradmartin/nativescript-wear-os/workflows/Build%20CI/badge.svg" alt="Action Build">
</a>
<a href="https://www.npmjs.com/package/nativescript-wear-os">
<img src="https://img.shields.io/npm/v/nativescript-wear-os.svg" alt="npm">
</a>
<a href="https://www.npmjs.com/package/nativescript-wear-os">
<img src="https://img.shields.io/npm/dt/nativescript-wear-os.svg?label=npm%20downloads" alt="npm">
</a>
<a href="https://github.com/bradmartin/nativescript-wear-os/stargazers">
<img src="https://img.shields.io/github/stars/bradmartin/nativescript-wear-os.svg" alt="stars">
</a>
<a href="https://github.com/bradmartin/nativescript-wear-os/network">
<img src="https://img.shields.io/github/forks/bradmartin/nativescript-wear-os.svg" alt="forks">
</a>
<a href="https://github.com/bradmartin/nativescript-wear-os/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/bradmartin/nativescript-wear-os.svg" alt="license">
</a>
</p>

---

## 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
Expand All @@ -56,9 +58,9 @@ tns plugin add nativescript-wear-os
```javascript
// Add your custom Activities, Services and other Android app components here.
const appComponents = [
'tns-core-modules/ui/frame',
'tns-core-modules/ui/frame/activity',
resolve(__dirname, 'app/ambient-activity')
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity',
resolve(__dirname, 'app/ambient-activity'),
];
```

Expand Down Expand Up @@ -156,7 +158,7 @@ The plugin has a success dialog and failure/error dialog to present on WearOS. T
```typescript
import {
showFailure,
showSuccess
showSuccess,
} from 'nativescript-wear-os/packages/dialogs';

showSuccess('Great choice! NativeScript is awesome.', 4).then(() => {
Expand Down
29 changes: 14 additions & 15 deletions demo/app/ambient-activity.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/// <reference path="./typings/androidx-wear-1.0.0.d.ts" />
/// <reference path="../node_modules/tns-platform-declarations/android.d.ts" />

import * as application from 'tns-core-modules/application';
import {
AndroidActivityCallbacks,
setActivityCallbacks
} from 'tns-core-modules/ui/frame';
} from '@nativescript/core';

@NativeClass()
@JavaProxy('com.nativescript.AmbientActivity')
@Interfaces([androidx.wear.ambient.AmbientModeSupport.AmbientCallbackProvider])
class Activity extends androidx.appcompat.app.AppCompatActivity
class Activity
extends androidx.appcompat.app.AppCompatActivity
implements androidx.wear.ambient.AmbientModeSupport.AmbientCallbackProvider {
private _callbacks: AndroidActivityCallbacks;

Expand Down Expand Up @@ -95,6 +93,7 @@ class Activity extends androidx.appcompat.app.AppCompatActivity
}
}

@NativeClass()
class MyAmbientCallback extends androidx.wear.ambient.AmbientModeSupport
.AmbientCallback {
/** If the display is low-bit in ambient mode. i.e. it requires anti-aliased fonts. */
Expand Down Expand Up @@ -122,10 +121,10 @@ class MyAmbientCallback extends androidx.wear.ambient.AmbientModeSupport
object: this,
data: {
isLowBitAmbient: this.mIsLowBitAmbient,
doBurnInProtection: this.mDoBurnInProtection
}
doBurnInProtection: this.mDoBurnInProtection,
},
};
application.notify(eventData);
global.NativeScriptGlobals.events.notify(eventData);
}

public onExitAmbient(): void {
Expand All @@ -135,10 +134,10 @@ class MyAmbientCallback extends androidx.wear.ambient.AmbientModeSupport
object: this,
data: {
isLowBitAmbient: this.mIsLowBitAmbient,
doBurnInProtection: this.mDoBurnInProtection
}
doBurnInProtection: this.mDoBurnInProtection,
},
};
application.notify(eventData);
global.NativeScriptGlobals.events.notify(eventData);
}

public onUpdateAmbient(): void {
Expand All @@ -148,9 +147,9 @@ class MyAmbientCallback extends androidx.wear.ambient.AmbientModeSupport
object: this,
data: {
isLowBitAmbient: this.mIsLowBitAmbient,
doBurnInProtection: this.mDoBurnInProtection
}
doBurnInProtection: this.mDoBurnInProtection,
},
};
application.notify(eventData);
global.NativeScriptGlobals.events.notify(eventData);
}
}
4 changes: 2 additions & 2 deletions demo/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import * as application from 'tns-core-modules/application';
application.run({ moduleName: 'app-root' });
import { Application } from '@nativescript/core';
Application.run({ moduleName: 'app-root' });
2 changes: 1 addition & 1 deletion demo/app/box-inset-page/box-inset-page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Frame } from 'tns-core-modules/ui/frame';
import { Frame } from '@nativescript/core';

export function pageLoaded() {
console.log('page loaded');
Expand Down
2 changes: 1 addition & 1 deletion demo/app/circular-progress-page/circular-progress-page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Frame } from 'tns-core-modules/ui/frame';
import { Frame } from '@nativescript/core';
export function pageLoaded() {
console.log('page loaded');
}
Expand Down
7 changes: 3 additions & 4 deletions demo/app/main-page.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as observable from 'tns-core-modules/data/observable';
import * as pages from 'tns-core-modules/ui/page';
import { EventData, Page } from '@nativescript/core';
import { HelloWorldModel } from './main-view-model';

// Event handler for Page 'loaded' event attached in main-page.xml
export function navigatingTo(args: observable.EventData) {
export function navigatingTo(args: EventData) {
// Get the event sender
const page = <pages.Page>args.object;
const page = <Page>args.object;
page.actionBarHidden = true;
page.bindingContext = new HelloWorldModel(page);
}
8 changes: 3 additions & 5 deletions demo/app/main-page.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" actionBarHidden="true"
xmlns:wear="nativescript-wear-os/packages/listview"
xmlns:wol="nativescript-wear-os/packages/wear-os-layout"
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" actionBarHidden="true"
xmlns:wear="nativescript-wear-os/packages/listview"
xmlns:wol="nativescript-wear-os/packages/wear-os-layout"
xmlns:sdl="nativescript-wear-os/packages/swipe-dismiss-layout">
<GridLayout rows="*, *" columns="*">
<!-- <StackLayout row="0" col="0">
Expand All @@ -22,9 +22,7 @@
<wol:WearOsLayout class="swipePage" height="100%" width="100%">
<ScrollView height="100%">
<StackLayout>
<Button id="swipeToggleButton" class="purpleButton" text="Enable/Disable Swipe Behavior" tap="{{ toggleSwipeBehavior }}" />
<Label text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." textWrap="true"/>
<Button id="swipeToggleButton" class="purpleButton" text="Enable/Disable Behavior" tap="{{ toggleSwipeBehavior }}" />
<Label text="Some Label text." textWrap="true"/>
</StackLayout>
</ScrollView>
Expand Down
40 changes: 16 additions & 24 deletions demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import {
Application,
Frame,
Observable,
ObservableArray,
Page
} from '@nativescript/core';
import * as themes from 'nativescript-themes';
import { SwipeDismissLayout } from 'nativescript-wear-os';
import {
confirm,
ItemEventData,
showFailure,
showSuccess
} from 'nativescript-wear-os/packages/dialogs';
import { ItemEventData } from 'nativescript-wear-os/packages/listview';
import * as application from 'tns-core-modules/application';
import { Observable } from 'tns-core-modules/data/observable';
import { ObservableArray } from 'tns-core-modules/data/observable-array';
import { Frame, Page, topmost } from 'tns-core-modules/ui/frame';
showSuccess,
SwipeDismissLayout
} from 'nativescript-wear-os';
import { Prop } from './prop';
import { hideOffScreenLayout, showOffScreenLayout } from './utils';

Expand Down Expand Up @@ -52,9 +55,8 @@ export class HelloWorldModel extends Observable {

constructor(page: Page) {
super();

const x = page.getViewById('swipePage');
this._swipeLayout = x as SwipeDismissLayout;
const x = page.getViewById('swipePage') as unknown;
this._swipeLayout = <SwipeDismissLayout>x;
console.log(this._swipeLayout.android);
this._swipeLayout.on(SwipeDismissLayout.dimissedEvent, args => {
console.log('dimissedEvent', args.object);
Expand All @@ -63,20 +65,20 @@ export class HelloWorldModel extends Observable {
this.isSwipeLayoutVisible = false;
});

application.on('exitAmbient', args => {
Application.on('exitAmbient', args => {
console.log('app has EXITED ambient mode...');
themes.applyTheme('default.css');
});

application.on('enterAmbient', args => {
Application.on('enterAmbient', args => {
console.log('app has ENTERED ambient mode...');
themes.applyTheme('ambient.css');
});
}

onItemTap(args: ItemEventData) {
const x = this.items.getItem(args.index);
const frame = topmost().currentPage.frame as Frame;
const frame = Frame.topmost().currentPage.frame as Frame;

console.log('tapped item', x);

Expand Down Expand Up @@ -117,14 +119,4 @@ export class HelloWorldModel extends Observable {
this.isSwipeLayoutVisible = true;
}
}

toggleSwipeBehavior() {
const x = (this._swipeLayout as any).swipeable;
console.log('is the swipe layout swipeable?', x);
// if (x) {
// this._swipeLayout.swipeable = false;
// } else {
// this._swipeLayout.swipeable = true;
// }
}
}
9 changes: 0 additions & 9 deletions demo/app/package.json

This file was deleted.

Loading

0 comments on commit a90fb42

Please sign in to comment.