Skip to content

Commit

Permalink
added exitOnBack in ProblemList component
Browse files Browse the repository at this point in the history
  • Loading branch information
mikensubuga committed Nov 6, 2020
1 parent a62e3e5 commit 896940a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion maths-club-app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Aug 05 09:58:33 EAT 2020
#Sun Nov 01 13:50:01 EAT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
16 changes: 4 additions & 12 deletions maths-club-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, NgZone, ViewEncapsulation } from "@angular/core";
import { Component, NgZone, ViewEncapsulation} from "@angular/core";
import { AppService } from "./services/app.service";
import { Router, RouterOutlet } from "@angular/router";
import { Router, RouterOutlet} from "@angular/router";
import { slideTransition } from "./animations";

import { environment } from "src/environments/environment";
Expand All @@ -10,7 +10,6 @@ import { Plugins, Capacitor, StatusBarStyle } from "@capacitor/core";
import { AnalyticsService } from "./services/analytics.service";
import { SeoService } from "./services/seo.service";
const { StatusBar, App } = Plugins;

@Component({
selector: "app-root",
templateUrl: "./app.component.html",
Expand All @@ -26,7 +25,7 @@ export class AppComponent {
analytics: AnalyticsService,
seo: SeoService,
private zone: NgZone,
private router: Router
private router: Router,
) {
// this.notifications.init()
analytics.init();
Expand All @@ -37,9 +36,7 @@ export class AppComponent {
} else {
// SEO only relevant whe not native
seo.init();
}
//exit on back
this.exitOnBack();
}
}
getRouteAnimationState(outlet: RouterOutlet) {
return (
Expand All @@ -63,9 +60,4 @@ export class AppComponent {
});
});
}
exitOnBack(){
if(Capacitor.isNative){
App.addListener('backButton', App.exitApp)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Component } from "@angular/core";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { ProblemService } from "../../services/problem.service";
import { fadeChildren } from "src/app/animations";
import * as Sentry from "@sentry/angular";
import { Plugins, Capacitor } from "@capacitor/core";
const { StatusBar, App } = Plugins;

@Component({
selector: "app-problems",
templateUrl: "./problems-list.component.html",
styleUrls: ["./problems-list.component.scss"],
animations: [fadeChildren],
})
export class ProblemsListComponent {
export class ProblemsListComponent implements OnInit, OnDestroy{
constructor(public problemService: ProblemService) {}

/**
Expand All @@ -18,4 +20,16 @@ export class ProblemsListComponent {
testClick(identifier: string) {
Sentry.captureMessage(`[${identifier}] UI Test Interaction Recorded`);
}

ngOnInit(){
if(Capacitor.isNative){
App.addListener('backButton', App.exitApp);
}
}

ngOnDestroy(){
if(Capacitor.isNative){
App.removeAllListeners();
}
}
}

0 comments on commit 896940a

Please sign in to comment.