Skip to content

Commit 148dfba

Browse files
authored
feat: added contacts (#224)
1 parent 54dc54f commit 148dfba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3429
-20
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [@nativescript/biometrics](packages/biometrics/README.md)
77
- [@nativescript/brightness](packages/brightness/README.md)
88
- [@nativescript/camera](packages/camera/README.md)
9+
- [@nativescript/contacts](packages/contacts/README.md)
910
- [@nativescript/datetimepicker](packages/datetimepicker/README.md)
1011
- [@nativescript/debug-android](packages/debug-android/README.md)
1112
- [@nativescript/debug-ios](packages/debug-ios/README.md)

apps/demo-angular/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"main": "./src/main.ts",
33
"dependencies": {
44
"@nativescript/core": "file:../../node_modules/@nativescript/core",
5-
"@nativescript/biometrics": "file:../../dist/packages/biometrics",
6-
"@nativescript/theme-switcher": "file:../../dist/packages/theme-switcher",
5+
"@nativescript/contacts": "file:../../dist/packages/contacts",
76
"@nativescript/animated-circle": "file:../../dist/packages/animated-circle",
87
"@nativescript/appavailability": "file:../../dist/packages/appavailability",
8+
"@nativescript/apple-sign-in": "file:../../dist/packages/apple-sign-in",
99
"@nativescript/auto-fit-text": "file:../../dist/packages/auto-fit-text",
1010
"@nativescript/background-http": "file:../../dist/packages/background-http",
11+
"@nativescript/biometrics": "file:../../dist/packages/biometrics",
1112
"@nativescript/brightness": "file:../../dist/packages/brightness",
1213
"@nativescript/camera": "file:../../dist/packages/camera",
1314
"@nativescript/datetimepicker": "file:../../dist/packages/datetimepicker",
@@ -19,6 +20,7 @@
1920
"@nativescript/facebook": "file:../../dist/packages/facebook",
2021
"@nativescript/fingerprint-auth": "file:../../dist/packages/fingerprint-auth",
2122
"@nativescript/geolocation": "file:../../dist/packages/geolocation",
23+
"@nativescript/google-maps": "file:../../dist/packages/google-maps",
2224
"@nativescript/google-signin": "file:../../dist/packages/google-signin",
2325
"@nativescript/imagepicker": "file:../../dist/packages/imagepicker",
2426
"@nativescript/ios-security": "file:../../dist/packages/ios-security",
@@ -28,10 +30,9 @@
2830
"@nativescript/picker": "file:../../dist/packages/picker",
2931
"@nativescript/shared-notification-delegate": "file:../../dist/packages/shared-notification-delegate",
3032
"@nativescript/social-share": "file:../../dist/packages/social-share",
33+
"@nativescript/theme-switcher": "file:../../dist/packages/theme-switcher",
3134
"@nativescript/twitter": "file:../../dist/packages/twitter",
32-
"@nativescript/zip": "file:../../dist/packages/zip",
33-
"@nativescript/apple-sign-in": "file:../../dist/packages/apple-sign-in",
34-
"@nativescript/google-maps": "file:../../dist/packages/google-maps"
35+
"@nativescript/zip": "file:../../dist/packages/zip"
3536
},
3637
"devDependencies": {
3738
"@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
@@ -15,6 +15,7 @@ const routes: Routes = [
1515
{ path: 'biometrics', loadChildren: () => import('./plugin-demos/biometrics.module').then(m => m.BiometricsModule) },
1616
{ path: 'brightness', loadChildren: () => import('./plugin-demos/brightness.module').then(m => m.BrightnessModule) },
1717
{ path: 'camera', loadChildren: () => import('./plugin-demos/camera.module').then(m => m.CameraModule) },
18+
{ path: 'contacts', loadChildren: () => import('./plugin-demos/contacts.module').then(m => m.ContactsModule) },
1819
{ path: 'datetimepicker', loadChildren: () => import('./plugin-demos/datetimepicker.module').then(m => m.DatetimepickerModule) },
1920
{ path: 'debug-android', loadChildren: () => import('./plugin-demos/debug-android.module').then(m => m.DebugAndroidModule) },
2021
{ path: 'debug-ios', loadChildren: () => import('./plugin-demos/debug-ios.module').then(m => m.DebugIosModule) },

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export class HomeComponent {
3030
{
3131
name: 'camera'
3232
},
33+
{
34+
name: 'contacts'
35+
},
3336
{
3437
name: 'datetimepicker'
3538
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ActionBar title="contacts" class="action-bar"> </ActionBar>
2+
<StackLayout class="p-20">
3+
<ScrollView class="h-full">
4+
<StackLayout>
5+
<Button text="Test contacts" (tap)="demoShared.testIt()" class="btn btn-primary"></Button>
6+
</StackLayout>
7+
</ScrollView>
8+
</StackLayout>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, NgZone } from '@angular/core';
2+
import { DemoSharedContacts } from '@demo/shared';
3+
import { } from '@nativescript/contacts';
4+
5+
@Component({
6+
selector: 'demo-contacts',
7+
templateUrl: 'contacts.component.html',
8+
})
9+
export class ContactsComponent {
10+
11+
demoShared: DemoSharedContacts;
12+
13+
constructor(private _ngZone: NgZone) {}
14+
15+
ngOnInit() {
16+
this.demoShared = new DemoSharedContacts();
17+
}
18+
19+
}
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 { ContactsComponent } from './contacts.component';
4+
5+
@NgModule({
6+
imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: ContactsComponent }])],
7+
declarations: [ContactsComponent],
8+
schemas: [ NO_ERRORS_SCHEMA]
9+
})
10+
export class ContactsModule {}

apps/demo/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
"repository": "<fill-your-repository-here>",
66
"dependencies": {
77
"@nativescript/core": "file:../../node_modules/@nativescript/core",
8-
"@nativescript/biometrics": "file:../../packages/biometrics",
8+
"@nativescript/contacts": "file:../../packages/contacts",
99
"@nativescript/animated-circle": "file:../../packages/animated-circle",
1010
"@nativescript/appavailability": "file:../../packages/appavailability",
11+
"@nativescript/apple-sign-in": "file:../../packages/apple-sign-in",
1112
"@nativescript/auto-fit-text": "file:../../packages/auto-fit-text",
1213
"@nativescript/background-http": "file:../../packages/background-http",
14+
"@nativescript/biometrics": "file:../../packages/biometrics",
1315
"@nativescript/brightness": "file:../../packages/brightness",
1416
"@nativescript/camera": "file:../../packages/camera",
1517
"@nativescript/datetimepicker": "file:../../packages/datetimepicker",
@@ -21,6 +23,7 @@
2123
"@nativescript/facebook": "file:../../packages/facebook",
2224
"@nativescript/fingerprint-auth": "file:../../packages/fingerprint-auth",
2325
"@nativescript/geolocation": "file:../../packages/geolocation",
26+
"@nativescript/google-maps": "file:../../packages/google-maps",
2427
"@nativescript/google-signin": "file:../../packages/google-signin",
2528
"@nativescript/imagepicker": "file:../../packages/imagepicker",
2629
"@nativescript/ios-security": "file:../../packages/ios-security",
@@ -32,9 +35,7 @@
3235
"@nativescript/social-share": "file:../../packages/social-share",
3336
"@nativescript/theme-switcher": "file:../../packages/theme-switcher",
3437
"@nativescript/twitter": "file:../../packages/twitter",
35-
"@nativescript/zip": "file:../../packages/zip",
36-
"@nativescript/apple-sign-in": "file:../../packages/apple-sign-in",
37-
"@nativescript/google-maps": "file:../../packages/google-maps"
38+
"@nativescript/zip": "file:../../packages/zip"
3839
},
3940
"devDependencies": {
4041
"@nativescript/android": "~8.1.1",

apps/demo/src/app.scss

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
11
@import 'nativescript-theme-core/scss/light';
2-
@import 'nativescript-theme-core/scss/index';
2+
@import 'nativescript-theme-core/scss/index';
3+
4+
Button {
5+
text-transform: none;
6+
height: 54;
7+
android-elevation: 0;
8+
android-dynamic-elevation-offset: 0;
9+
padding: 0;
10+
margin: 0;
11+
12+
&.btn {
13+
padding: 0;
14+
margin: 2 0 2 0;
15+
16+
&.btn-primary {
17+
background-color: rgb(95, 185, 249);
18+
}
19+
}
20+
}
21+
TextField {
22+
border-bottom-width: 1;
23+
border-bottom-color: transparent;
24+
font-size: 17;
25+
placeholder-color: rgb(201, 201, 201);
26+
padding-top: 0;
27+
padding-bottom: 0;
28+
margin-top: 0;
29+
margin-bottom: 0;
30+
height: 29;
31+
}

apps/demo/src/app.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Application } from '@nativescript/core';
2-
import { LoginManager } from '@nativescript/facebook';
2+
// uncomment to test facebook login
3+
// import { LoginManager } from '@nativescript/facebook';
34

4-
LoginManager.init();
5+
// LoginManager.init();
56

67
Application.run({ moduleName: 'app-root' });

apps/demo/src/main-page.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
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+
<Button text="apple-sign-in" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1011
<Button text="auto-fit-text" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1112
<Button text="background-http" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1213
<Button text="biometrics" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1314
<Button text="brightness" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1415
<Button text="camera" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
16+
<Button text="contacts" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1517
<Button text="datetimepicker" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1618
<Button text="debug-android" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
1719
<Button text="debug-ios" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
@@ -21,6 +23,7 @@
2123
<Button text="facebook" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2224
<Button text="fingerprint-auth" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2325
<Button text="geolocation" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
26+
<Button text="google-maps" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2427
<Button text="google-signin" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2528
<Button text="imagepicker" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
2629
<Button text="ios-security" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
@@ -33,8 +36,6 @@
3336
<Button text="theme-switcher" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
3437
<Button text="twitter" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
3538
<Button text="zip" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
36-
<Button text="apple-sign-in" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
37-
<Button text="google-maps" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
3839
</StackLayout>
3940
</ScrollView>
4041
</StackLayout>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Observable, EventData, Page } from '@nativescript/core';
2+
import { DemoSharedContacts } from '@demo/shared';
3+
import { } from '@nativescript/contacts';
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 DemoSharedContacts {
11+
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
2+
<Page.actionBar>
3+
<ActionBar title="@nativescript/contacts" icon="" class="action-bar">
4+
</ActionBar>
5+
</Page.actionBar>
6+
<GridLayout class="p-20" rows="*,*">
7+
<ScrollView row="0" class="h-full">
8+
<StackLayout>
9+
<Button text="Contacts.getContact" tap="{{ getContact }}" class="btn btn-primary"/>
10+
<TextField hint="Paste contact id here to fetch below..." textChange="{{ contactIdChange }}" padding="5" />
11+
<Button text="Contacts.getContactById" tap="{{ getContactById }}" class="btn btn-primary"/>
12+
<TextField hint="Type contact name to find..." textChange="{{ contactNameChange }}" ios:padding="5" />
13+
<Button text="Contacts.getContactsByName" tap="{{ getContactsByName }}" class="btn btn-primary"/>
14+
<Button text="Contacts.getAllContacts" tap="{{ getAllContacts }}" class="btn btn-primary"/>
15+
</StackLayout>
16+
</ScrollView>
17+
<TextView row="1" text="{{ result }}" editable="true" padding="10" borderWidth="1" borderRadius="4" borderColor="#ccc" fontSize="12" />
18+
19+
</GridLayout>
20+
</Page>

nx.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@
112112
},
113113
"google-maps": {
114114
"tags": []
115+
},
116+
"contacts": {
117+
"tags": []
115118
}
116119
},
117120
"workspaceLayout": {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@types/sprintf-js": "^1.1.0",
3636
"husky": "^5.1.3",
3737
"mkdirp": "^1.0.4",
38+
"nativescript-permissions": "^1.3.12",
3839
"nativescript-vue": "~2.9.0",
3940
"nativescript-vue-template-compiler": "~2.9.0",
4041
"ng-packagr": "^12.0.0",
@@ -46,7 +47,7 @@
4647
"zone.js": "~0.11.1"
4748
},
4849
"lint-staged": {
49-
"**/*.{js,ts,scss,json,html}": [
50+
"**/*.{js,ts,scss,json,html,xml}": [
5051
"npx prettier --write"
5152
]
5253
}

0 commit comments

Comments
 (0)