Skip to content

Commit

Permalink
Merge pull request #275 from elwinschmitz/603--scroll
Browse files Browse the repository at this point in the history
AB#603 Add method to ScrollDown within ConversationSections
  • Loading branch information
elwinschmitz authored Oct 1, 2019
2 parents 9fdc623 + d6f6add commit 161ab7f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class ChooseCredentialTypeComponent extends PersonalComponent {
public submitCredentialType() {
console.log('Chosen credential type: ', this.credentialTypeChoice);
this.typeChosen = true;
this.conversationService.scrollToEnd();

// Here should be checked whether Digital ID already present
if (this.credentialTypeChoice === 'apply-to-program') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export class EnrollInProgramComponent extends PersonalComponent {

public submit() {
this.hasAnswered = true;
this.conversationService.scrollToEnd();
}

public async submitConfirm() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export class SelectAppointmentComponent extends PersonalComponent {

public submitTimeslot() {
this.timeslotSubmitted = true;
this.conversationService.scrollToEnd();
}

public changeConfirmAction($event) {
Expand Down
12 changes: 11 additions & 1 deletion interfaces/PA-App/src/app/personal/personal.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class PersonalPage implements OnInit {
public isDebug: boolean = environment.isDebug;
public showDebug: boolean = environment.showDebug;

private scrollSpeed = environment.useAnimation ? 600 : 0;

public availableSections = {
[PersonalComponents.chooseCredentialType]: ChooseCredentialTypeComponent,
[PersonalComponents.createIdentity]: IdentityFormComponent,
Expand All @@ -59,6 +61,14 @@ export class PersonalPage implements OnInit {
this.conversationService.sectionCompleted$.subscribe((response: string) => {
this.insertSection(response);
});
// Listen for scroll events
this.conversationService.shouldScroll$.subscribe((toY: number) => {
if (toY === -1) {
return this.ionContent.scrollToBottom(this.scrollSpeed);
}

this.ionContent.scrollToPoint(0, toY, this.scrollSpeed);
});
}

ngOnInit() {
Expand Down Expand Up @@ -98,7 +108,7 @@ export class PersonalPage implements OnInit {
}

public scrollDown() {
this.ionContent.scrollToBottom(600);
this.ionContent.scrollToBottom(this.scrollSpeed);
}

public debugClearAllStorage() {
Expand Down
8 changes: 8 additions & 0 deletions interfaces/PA-App/src/app/services/conversation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class ConversationService {
private sectionCompletedSource = new Subject<string>();
public sectionCompleted$ = this.sectionCompletedSource.asObservable();

private shouldScrollSource = new Subject<number>();
public shouldScroll$ = this.shouldScrollSource.asObservable();

constructor() {
console.log('ConversationService()');

Expand All @@ -32,12 +35,17 @@ export class ConversationService {

public startLoading() {
this.state.isLoading = true;
this.scrollToEnd();
}

public stopLoading() {
this.state.isLoading = false;
}

public scrollToEnd() {
this.shouldScrollSource.next(-1);
}

private getHistory() {
// Define a hard-coded history (for now):
const history = [
Expand Down

0 comments on commit 161ab7f

Please sign in to comment.