Skip to content

Commit 147577f

Browse files
committed
feat(theme-switcher): create new plugin
1 parent 72c275c commit 147577f

25 files changed

+496
-128
lines changed

apps/demo-angular/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"main": "./src/main.ts",
33
"dependencies": {
44
"@nativescript/core": "file:../../node_modules/@nativescript/core",
5-
"@nativescript/debug-ios": "file:../../dist/packages/debug-ios",
5+
"@nativescript/theme-switcher": "file:../../dist/packages/theme-switcher",
66
"@nativescript/animated-circle": "file:../../dist/packages/animated-circle",
77
"@nativescript/appavailability": "file:../../dist/packages/appavailability",
88
"@nativescript/auto-fit-text": "file:../../dist/packages/auto-fit-text",
@@ -11,11 +11,14 @@
1111
"@nativescript/camera": "file:../../dist/packages/camera",
1212
"@nativescript/datetimepicker": "file:../../dist/packages/datetimepicker",
1313
"@nativescript/debug-android": "file:../../dist/packages/debug-android",
14+
"@nativescript/debug-ios": "file:../../dist/packages/debug-ios",
1415
"@nativescript/detox": "file:../../dist/packages/detox",
1516
"@nativescript/directions": "file:../../dist/packages/directions",
1617
"@nativescript/email": "file:../../dist/packages/email",
18+
"@nativescript/facebook": "file:../../dist/packages/facebook",
1719
"@nativescript/fingerprint-auth": "file:../../dist/packages/fingerprint-auth",
1820
"@nativescript/geolocation": "file:../../dist/packages/geolocation",
21+
"@nativescript/google-signin": "file:../../dist/packages/google-signin",
1922
"@nativescript/imagepicker": "file:../../dist/packages/imagepicker",
2023
"@nativescript/ios-security": "file:../../dist/packages/ios-security",
2124
"@nativescript/iqkeyboardmanager": "file:../../dist/packages/iqkeyboardmanager",
@@ -24,10 +27,8 @@
2427
"@nativescript/picker": "file:../../dist/packages/picker",
2528
"@nativescript/shared-notification-delegate": "file:../../dist/packages/shared-notification-delegate",
2629
"@nativescript/social-share": "file:../../dist/packages/social-share",
27-
"@nativescript/zip": "file:../../dist/packages/zip",
28-
"@nativescript/facebook": "file:../../dist/packages/facebook",
29-
"@nativescript/google-signin": "file:../../dist/packages/google-signin",
30-
"@nativescript/twitter": "file:../../dist/packages/twitter"
30+
"@nativescript/twitter": "file:../../dist/packages/twitter",
31+
"@nativescript/zip": "file:../../dist/packages/zip"
3132
},
3233
"devDependencies": {
3334
"@nativescript/android": "~8.1.1",

apps/demo-angular/src/app-routing.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const routes: Routes = [
3131
{ path: 'picker', loadChildren: () => import('./plugin-demos/picker.module').then(m => m.PickerModule) },
3232
{ path: 'shared-notification-delegate', loadChildren: () => import('./plugin-demos/shared-notification-delegate.module').then(m => m.SharedNotificationDelegateModule) },
3333
{ path: 'social-share', loadChildren: () => import('./plugin-demos/social-share.module').then(m => m.SocialShareModule) },
34+
{ path: 'theme-switcher', loadChildren: () => import('./plugin-demos/theme-switcher.module').then(m => m.ThemeSwitcherModule) },
3435
{ path: 'twitter', loadChildren: () => import('./plugin-demos/twitter.module').then(m => m.TwitterModule) },
3536
{ path: 'zip', loadChildren: () => import('./plugin-demos/zip.module').then(m => m.ZipModule) }
3637
];

apps/demo-angular/src/home.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ export class HomeComponent {
7878
{
7979
name: 'social-share'
8080
},
81+
{
82+
name: 'theme-switcher'
83+
},
8184
{
8285
name: 'twitter'
8386
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ActionBar title="theme-switcher" class="action-bar"> </ActionBar>
2+
<StackLayout class="p-20">
3+
<ScrollView class="h-full">
4+
<StackLayout>
5+
<Button text="Test theme-switcher" (tap)="demoShared.testIt()" class="btn btn-primary"></Button>
6+
</StackLayout>
7+
</ScrollView>
8+
</StackLayout>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Component, NgZone } from '@angular/core';
2+
import { DemoSharedThemeSwitcher } from '@demo/shared';
3+
import {} from '@nativescript/theme-switcher';
4+
5+
@Component({
6+
selector: 'demo-theme-switcher',
7+
templateUrl: 'theme-switcher.component.html',
8+
})
9+
export class ThemeSwitcherComponent {
10+
demoShared: DemoSharedThemeSwitcher;
11+
12+
constructor(private _ngZone: NgZone) {}
13+
14+
ngOnInit() {
15+
this.demoShared = new DemoSharedThemeSwitcher();
16+
}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
3+
import { ThemeSwitcherComponent } from './theme-switcher.component';
4+
5+
@NgModule({
6+
imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: ThemeSwitcherComponent }])],
7+
declarations: [ThemeSwitcherComponent],
8+
schemas: [NO_ERRORS_SCHEMA],
9+
})
10+
export class ThemeSwitcherModule {}

apps/demo/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,34 @@
44
"license": "SEE LICENSE IN <your-license-filename>",
55
"repository": "<fill-your-repository-here>",
66
"dependencies": {
7+
"@nativescript/core": "file:../../node_modules/@nativescript/core",
8+
"@nativescript/theme-switcher": "file:../../packages/theme-switcher",
79
"@nativescript/animated-circle": "file:../../packages/animated-circle",
810
"@nativescript/appavailability": "file:../../packages/appavailability",
911
"@nativescript/auto-fit-text": "file:../../packages/auto-fit-text",
1012
"@nativescript/background-http": "file:../../packages/background-http",
1113
"@nativescript/brightness": "file:../../packages/brightness",
1214
"@nativescript/camera": "file:../../packages/camera",
13-
"@nativescript/core": "file:../../node_modules/@nativescript/core",
1415
"@nativescript/datetimepicker": "file:../../packages/datetimepicker",
1516
"@nativescript/debug-android": "file:../../packages/debug-android",
1617
"@nativescript/debug-ios": "file:../../packages/debug-ios",
1718
"@nativescript/detox": "file:../../packages/detox",
1819
"@nativescript/directions": "file:../../packages/directions",
1920
"@nativescript/email": "file:../../packages/email",
21+
"@nativescript/facebook": "file:../../packages/facebook",
2022
"@nativescript/fingerprint-auth": "file:../../packages/fingerprint-auth",
2123
"@nativescript/geolocation": "file:../../packages/geolocation",
24+
"@nativescript/google-signin": "file:../../packages/google-signin",
2225
"@nativescript/imagepicker": "file:../../packages/imagepicker",
2326
"@nativescript/ios-security": "file:../../packages/ios-security",
2427
"@nativescript/iqkeyboardmanager": "file:../../packages/iqkeyboardmanager",
2528
"@nativescript/local-notifications": "file:../../packages/local-notifications",
26-
"@nativescript/localize": "file:../../dist/packages/localize",
29+
"@nativescript/localize": "file:../../packages/localize",
2730
"@nativescript/picker": "file:../../packages/picker",
2831
"@nativescript/shared-notification-delegate": "file:../../packages/shared-notification-delegate",
2932
"@nativescript/social-share": "file:../../packages/social-share",
30-
"@nativescript/zip": "file:../../packages/zip",
31-
"@nativescript/facebook": "file:../../packages/facebook",
32-
"@nativescript/google-signin": "file:../../packages/google-signin",
33-
"@nativescript/twitter": "file:../../packages/twitter"
33+
"@nativescript/twitter": "file:../../packages/twitter",
34+
"@nativescript/zip": "file:../../packages/zip"
3435
},
3536
"devDependencies": {
3637
"@nativescript/android": "~8.1.1",

apps/demo/src/main-page.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<StackLayout>
88
<Button text="animated-circle" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
99
<Button text="appavailability" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
10-
1110
<Button text="auto-fit-text" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1211
<Button text="background-http" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1312
<Button text="brightness" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
@@ -18,9 +17,10 @@
1817
<Button text="detox" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1918
<Button text="directions" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2019
<Button text="email" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
20+
<Button text="facebook" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2121
<Button text="fingerprint-auth" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2222
<Button text="geolocation" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
23-
23+
<Button text="google-signin" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2424
<Button text="imagepicker" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2525
<Button text="ios-security" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2626
<Button text="iqkeyboardmanager" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
@@ -29,10 +29,9 @@
2929
<Button text="picker" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
3030
<Button text="shared-notification-delegate" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
3131
<Button text="social-share" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
32+
<Button text="theme-switcher" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
33+
<Button text="twitter" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
3234
<Button text="zip" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
33-
<Button text="facebook" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
34-
<Button text="google-signin" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
35-
<Button text="twitter" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
3635
</StackLayout>
3736
</ScrollView>
3837
</StackLayout>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Observable, EventData, Page } from '@nativescript/core';
2+
import { DemoSharedThemeSwitcher } from '@demo/shared';
3+
import {} from '@nativescript/theme-switcher';
4+
5+
export function navigatingTo(args: EventData) {
6+
const page = <Page>args.object;
7+
page.bindingContext = new DemoModel();
8+
}
9+
10+
export class DemoModel extends DemoSharedThemeSwitcher {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
2+
<Page.actionBar>
3+
<ActionBar title="theme-switcher" icon="" class="theme-action-bar">
4+
</ActionBar>
5+
</Page.actionBar>
6+
<StackLayout class="p-20">
7+
<ScrollView class="h-full">
8+
<StackLayout>
9+
<Button text="Test theme-switcher" tap="{{ testIt }}" class="theme-btn"/>
10+
</StackLayout>
11+
</ScrollView>
12+
</StackLayout>
13+
</Page>

0 commit comments

Comments
 (0)