Skip to content

Catch all events on top of app #android #nativescript #angular #propagation #bubbling #5564

@Evil2l

Description

@Evil2l

Dear friend, we, the rest of the NativeScript community really
appreciate your feedback! While we are doing all we can to take care of every
issue, sometimes we get overwhelmed. Because of that, we will consider issues
that are not constructive or problems that cannot be reproduced "dead".
Additionally, we will treat feature requests or bug reports with unanswered
questions regarding the behavior/reproduction for more than 20 days "dead". All
"dead" issues will get closed.

Please, provide the details below:

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

Yes, with no result

Tell us about the problem

My app has a timer that starts from the very beginning and show modal window after it ends, and any of user actions should restart that timer.
I want to catch all events on top of application based on typescript/angular. That could be gestures events or any kind off all possible user events.

Which platform(s) does your issue occur on?

Android only

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.4.2
  • Cross-platform modules: 3.4.1
  • Runtime(s): 3.4.1
  • Plugin(s): 3.4.1

Please tell us how to recreate the issue in as much detail as possible.

The best approach would be to get your code running in the NativeScript Playground and share the link with us, along with any additional details or steps to reproduce needed for examining the issue there.

Create any type of Layout with few child components inside and try to get all events from children on Layout wrapper.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

wrapper.component.html

<FlexboxLayout
        id="content"
        (tap)="ck()"
        flexDirection="column"
        class="app-background">
    <progress-bar *ngIf='isProgressVisible'></progress-bar>
    <page-router-outlet></page-router-outlet>
</FlexboxLayout>

wrapper.component.ts

import {Component, OnDestroy, OnInit, ViewContainerRef} from '@angular/core';
import {AppService} from '../../core/services/app.service';
import {Subscription} from 'rxjs/Subscription';
import { timer } from 'rxjs/observable/timer';
import 'rxjs/add/operator/switchMap';
import {ModalDialogOptions, ModalDialogService} from 'nativescript-angular/modal-dialog';
import {PresenceConfirmComponent} from '../../shared/components';
@Component({
    selector: 'app-wrapper',
    templateUrl: './screening-app/wrapper/wrapper.component.html',
})
export class AppWrapperComponent implements OnInit, OnDestroy {
    isProgressVisible: boolean;
    private progressSubscription: Subscription;
    constructor(private globalService: AppService,
                private viewContainerRef: ViewContainerRef,
                private modalService: ModalDialogService) {
    }
    ngOnInit() {
        this.initSubscriptions ();
        this.initTimer();
        this.resetTimer();
    }
    initSubscriptions () {
        this.progressSubscription = this.globalService.progressTransfer
            .subscribe(e => {
                this.isProgressVisible = !!e;
            });
    }
    private resetTimer(): void {
        this.globalService.resetTimer();
    }
    private initTimer(): void {
        this.globalService.gestureEventsHandler
            .switchMap(() => timer(this.globalService.timerValue))
            .subscribe(() =>{
                    const confirmMessageOptions: ModalDialogOptions = {
                        context: {promptMsg: 'prompt message'},
                        fullscreen: false,
                        viewContainerRef: this.viewContainerRef
                    };
                    this.modalService.showModal(PresenceConfirmComponent, confirmMessageOptions);
            })
    }
    ck () {
        this.resetTimer();
    }
    ngOnDestroy() {
        this.progressSubscription.unsubscribe();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions