Skip to content

Commit

Permalink
feat: add ui support
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Apr 23, 2023
1 parent 8a0251d commit 1d6c09e
Show file tree
Hide file tree
Showing 69 changed files with 23,995 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [@nativescript/firebase-performance](packages/firebase-performance/README.md)
- [@nativescript/firebase-remote-config](packages/firebase-remote-config/README.md)
- [@nativescript/firebase-storage](packages/firebase-storage/README.md)
- [@nativescript/firebase-ui](packages/firebase-ui/README.md)

# How to use?

Expand Down
3 changes: 2 additions & 1 deletion apps/demo-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"@nativescript/firebase-messaging": "file:../../dist/packages/firebase-messaging",
"@nativescript/firebase-functions": "file:../../dist/packages/firebase-functions",
"@nativescript/firebase-app-check-debug": "file:../../dist/packages/firebase-app-check-debug",
"@nativescript/firebase-messaging-core": "file:../../dist/packages/firebase-messaging-core"
"@nativescript/firebase-messaging-core": "file:../../dist/packages/firebase-messaging-core",
"@nativescript/firebase-ui": "file:../../dist/packages/firebase-ui"
},
"devDependencies": {
"@nativescript/android": "~8.4.0",
Expand Down
1 change: 1 addition & 0 deletions apps/demo-angular/src/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const routes: Routes = [
{ path: 'firebase-performance', loadChildren: () => import('./plugin-demos/firebase-performance.module').then((m) => m.FirebasePerformanceModule) },
{ path: 'firebase-remote-config', loadChildren: () => import('./plugin-demos/firebase-remote-config.module').then((m) => m.FirebaseRemoteConfigModule) },
{ path: 'firebase-storage', loadChildren: () => import('./plugin-demos/firebase-storage.module').then((m) => m.FirebaseStorageModule) },
{ path: 'firebase-ui', loadChildren: () => import('./plugin-demos/firebase-ui.module').then((m) => m.FirebaseUiModule) },
];

@NgModule({
Expand Down
3 changes: 3 additions & 0 deletions apps/demo-angular/src/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,8 @@ export class HomeComponent {
{
name: 'firebase-storage',
},
{
name: 'firebase-ui',
},
];
}
8 changes: 8 additions & 0 deletions apps/demo-angular/src/plugin-demos/firebase-ui.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ActionBar title="firebase-ui" class="action-bar"> </ActionBar>
<StackLayout class="p-20">
<ScrollView class="h-full">
<StackLayout>
<Button text="Test firebase-ui" (tap)="demoShared.testIt()" class="btn btn-primary"></Button>
</StackLayout>
</ScrollView>
</StackLayout>
17 changes: 17 additions & 0 deletions apps/demo-angular/src/plugin-demos/firebase-ui.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedFirebaseUi } from '@demo/shared';
import {} from '@nativescript/firebase-ui';

@Component({
selector: 'demo-firebase-ui',
templateUrl: 'firebase-ui.component.html',
})
export class FirebaseUiComponent {
demoShared: DemoSharedFirebaseUi;

constructor(private _ngZone: NgZone) {}

ngOnInit() {
this.demoShared = new DemoSharedFirebaseUi();
}
}
10 changes: 10 additions & 0 deletions apps/demo-angular/src/plugin-demos/firebase-ui.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
import { FirebaseUiComponent } from './firebase-ui.component';

@NgModule({
imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: FirebaseUiComponent }])],
declarations: [FirebaseUiComponent],
schemas: [NO_ERRORS_SCHEMA],
})
export class FirebaseUiModule {}
34 changes: 34 additions & 0 deletions apps/demo-vue/app/plugin-demos/firebase-ui.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<Page>
<ActionBar>
<Label text="firebase-ui"/>
</ActionBar>

<GridLayout>
<Button class="info" :text="message"/>
</GridLayout>
</Page>
</template>

<script lang="ts">
import Vue from "nativescript-vue";
import { DemoSharedFirebaseUi } from '@demo/shared';
import { } from '@nativescript/firebase-ui';
export default Vue.extend({
computed: {
message() {
return "Test firebase-ui";
}
}
});
</script>

<style scoped lang="scss">
.info {
font-size: 20;
horizontal-align: center;
vertical-align: center;
}
</style>
3 changes: 2 additions & 1 deletion apps/demo-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"@nativescript/firebase-remote-config": "file:../../packages/firebase-remote-config",
"@nativescript/firebase-storage": "file:../../packages/firebase-storage",
"@nativescript/firebase-app-check-debug": "file:../../packages/firebase-app-check-debug",
"@nativescript/firebase-messaging-core": "file:../../packages/firebase-messaging-core"
"@nativescript/firebase-messaging-core": "file:../../packages/firebase-messaging-core",
"@nativescript/firebase-ui": "file:../../packages/firebase-ui"
},
"devDependencies": {
"@nativescript/android": "~8.4.0",
Expand Down
3 changes: 2 additions & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"@nativescript/firebase-storage": "file:../../packages/firebase-storage",
"@nativescript/google-signin": "^1.0.0-alpha.9",
"@nativescript/firebase-app-check-debug": "file:../../packages/firebase-app-check-debug",
"@nativescript/firebase-messaging-core": "file:../../packages/firebase-messaging-core"
"@nativescript/firebase-messaging-core": "file:../../packages/firebase-messaging-core",
"@nativescript/firebase-ui": "file:../../packages/firebase-ui"
},
"devDependencies": {
"@nativescript/android": "~8.4.0",
Expand Down
1 change: 1 addition & 0 deletions apps/demo/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '@nativescript/firebase-messaging';
import '@nativescript/firebase-performance';
import '@nativescript/firebase-remote-config';
import '@nativescript/firebase-storage';
import '@nativescript/firebase-ui';

import { Admob } from '@nativescript/firebase-admob';

Expand Down
1 change: 1 addition & 0 deletions apps/demo/src/main-page.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Button text="firebase-messaging-core" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
<Button text="firebase-ui" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
<Page.actionBar>
<ActionBar title="Plugin Demos" icon="" class="action-bar"/>
</Page.actionBar>
Expand Down
3 changes: 3 additions & 0 deletions apps/demo/src/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export class MainViewModel extends Observable {
{
name: 'firebase-firestore',
},
{
name: 'firebase-ui',
},
];

viewDemo(args) {
Expand Down
39 changes: 39 additions & 0 deletions apps/demo/src/plugin-demos/firebase-ui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Observable, EventData, Page } from '@nativescript/core';
import { DemoSharedFirebaseUi } from '@demo/shared';
import { firebase } from '@nativescript/firebase-core';
import { AppleProvider, EmailProvider, GithubProvider, GoogleProvider, MicrosoftProvider, TwitterProvider, YahooProvider } from '@nativescript/firebase-ui';

export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = new DemoModel();
}

export class DemoModel extends DemoSharedFirebaseUi {
show() {
firebase()
.ui()
.show({
providers: [new AppleProvider(), new GoogleProvider(), new TwitterProvider(), new GithubProvider(), new EmailProvider(), new MicrosoftProvider(), new YahooProvider()],
})
.then((result) => {
console.log(result.user);
console.log(result.hasCredentialForLinking);
console.log(result.providerType);
})
.catch((error) => {
console.error('show error:', error);
});
}

signOut() {
firebase()
.ui()
.signOut()
.then(() => {
console.log('signOut complete');
})
.catch((e) => {
console.error('signOut error:', e);
});
}
}
15 changes: 15 additions & 0 deletions apps/demo/src/plugin-demos/firebase-ui.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Page.actionBar>
<ActionBar title="firebase-ui" icon="" class="action-bar">
</ActionBar>
</Page.actionBar>
<StackLayout class="p-20">
<ScrollView class="h-full">
<StackLayout>
<Button text="Show UI" tap="{{ show }}" class="btn btn-primary"/>
<Button text="Sign out" tap="{{ signOut }}" class="btn btn-primary"/>

</StackLayout>
</ScrollView>
</StackLayout>
</Page>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugins",
"version": "3.0.0",
"version": "3.1.0",
"license": "MIT",
"scripts": {
"postinstall": "husky install && npx ts-patch install",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-admob/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-admob",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Admob",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-analytics",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Analytics",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-app-check-debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-app-check-debug",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - App Check",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-app-check/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-app-check",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - App Check",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-auth",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Auth",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-core",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Core",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-crashlytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-crashlytics",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Crashlytics",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-database",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Database",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-dynamic-links/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-dynamic-links",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Dynamic Links",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-firestore",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Firestore",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-firestore/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
platform :ios, '12.0'
pod 'FirebaseFirestore', '~>10.7.0'
pod 'Firebase/Firestore', '~>10.7.0'
2 changes: 1 addition & 1 deletion packages/firebase-functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-functions",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Functions",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-in-app-messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-in-app-messaging",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - In App Messaging",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-installations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-installations",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Installations",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-messaging-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-messaging-core",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Push Messaging Core",
"main": "index",
"typings": "index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import FirebaseMessaging
#if canImport(FirebaseAuth)
import FirebaseAuth
#endif
#if canImport(FirebaseAuthUI)
import FirebaseAuthUI
#endif
import NSCFirebaseMessagingCore

@objc(NSCUIApplicationDelegate)
Expand Down Expand Up @@ -95,11 +98,19 @@ public class NSCUIApplicationDelegate: UIResponder , UIApplicationDelegate {


@objc public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
var result = false
#if canImport(FirebaseAuth)
result = Auth.auth().canHandle(url)
if(Auth.auth().canHandle(url)){
return true
}
#endif

#if canImport(FirebaseAuthUI)
let sourceApplication = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String?
if(FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication) ?? false){
return true
}
#endif
return result
return false
}


Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-messaging",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Messaging",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-performance/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-performance",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Performancee",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-remote-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-remote-config",
"version": "3.0.0",
"version": "3.1.0",
"description": "NativeScript Firebase - Remote Config",
"main": "index",
"typings": "index.d.ts",
Expand Down
Loading

0 comments on commit 1d6c09e

Please sign in to comment.