Skip to content

Commit

Permalink
Add 'Open in app' button below QR code
Browse files Browse the repository at this point in the history
Prior to this change, it was not clear users could tap the qr code on mobile.
This change adds a button to touch-enabled browsers to ensure an optimal UX.

Fixes #342
  • Loading branch information
johanib committed Jan 30, 2025
1 parent de256fd commit abcd913
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions assets/scss/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ div.middle {

}

#open-in-app{
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 1.5rem;
}

#otpform {
width: 50%;
margin: 0 auto;
Expand Down
27 changes: 27 additions & 0 deletions assets/typescript/Component/MobileOnlyComponent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'jquery';
import {Component} from './Component';

export class MobileOnlyComponent implements Component {

private readonly onMobile;

constructor(private element: JQuery) {
this.onMobile = "ontouchstart" in document.documentElement;

if (this.onMobile) {
this.show();
} else {
this.hide();
}
}

public show() {
if (this.onMobile) {
this.element.show();
}
}

public hide() {
this.element.hide();
}
}
2 changes: 2 additions & 0 deletions assets/typescript/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AuthenticationPageService } from './AuthenticationPageService';
import { NotificationClient } from './Client/NotificationClient';
import { SlideableComponent } from './Component/SlideableComponent';
import { HideableComponent } from './Component/HideableComponent';
import {MobileOnlyComponent} from "./Component/MobileOnlyComponent";
import jQuery from 'jquery';

declare global {
Expand All @@ -23,6 +24,7 @@ window.bootstrapAuthentication = (statusApiUrl: string, notificationApiUrl: stri
const challengeExpiredComponent = new HideableComponent(jQuery('#challengeExpired'));
const statusErrorComponent = new HideableComponent(jQuery('#status-request-error'));
const notificationErrorComponent = new HideableComponent(jQuery('#notificationError'));
new MobileOnlyComponent(jQuery('#open-in-app'));

const authenticationPageService = new AuthenticationPageService(
pollingService,
Expand Down
4 changes: 4 additions & 0 deletions assets/typescript/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { StatusPollService } from './StatusPollService';
import { RegistrationStatusComponent } from './Component/RegistrationStatusComponent';
import { SlideableComponent } from './Component/SlideableComponent';
import jQuery from 'jquery';
import {MobileOnlyComponent} from "./Component/MobileOnlyComponent";

declare global {
interface Window {
Expand All @@ -25,5 +26,8 @@ window.bootstrapRegistration = (statusApiUrl: string, finalizedUrl: string, corr
finalizedUrl,
);
machine.start();

new MobileOnlyComponent(jQuery('#open-in-app'));

return machine;
};
6 changes: 6 additions & 0 deletions templates/default/authentication.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
<img src="{{ url('app_identity_authentication_qr') }}">
</a>

<div id="open-in-app" style="display: none;">
<a class="btn btn-primary" href="{{ authenticateUrl }}">
{{ 'open_tiqr_app' | trans }}
</a>
</div>

{{ 'login.qr.manual.message' | trans }} <a
onClick="authenticationPageService.switchToOtp()">{{ 'login.qr.manual.here' | trans }}</a>.
</div>
Expand Down
7 changes: 7 additions & 0 deletions templates/default/registration.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
<a href="{{ metadataUrl }}">
<img src="{{ url('app_identity_registration_qr', {'enrollmentKey': enrollmentKey}) }}">
</a>

<div id="open-in-app" style="display: none;">
<a class="btn btn-primary" href="{{ metadataUrl }}">
{{ 'open_tiqr_app' | trans }}
</a>
</div>

{{ 'enrol.download' | trans | raw }}
</div>
{% endblock %}
1 change: 1 addition & 0 deletions translations/messages.en.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
open_tiqr_app: Open the app on this device
login:
title: Log in with tiqr
challenge_expired: Login timeout. Try again or refresh this page.
Expand Down
1 change: 1 addition & 0 deletions translations/messages.nl.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
en: Engels
nl: Nederlands
open_tiqr_app: Open de app op dit apparaat
login:
title: Log in met tiqr
challenge_expired: Login timeout. Ververs de pagina om het nogmaals te proberen.
Expand Down

0 comments on commit abcd913

Please sign in to comment.