Skip to content

Commit

Permalink
#785 - Show graph in slider is now rightly extending + paddings
Browse files Browse the repository at this point in the history
  • Loading branch information
graphefruit committed Sep 2, 2024
1 parent c8e1ee7 commit de977c0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,10 @@
</ion-card>
</swiper-slide>
<swiper-slide *ngIf='brew.flow_profile'>
<ion-card class='long-card brew-layout graph-card' style='z-index:-9999' [style.height.px]="getElementHeight()" [style.width.px]="getElementWidth()">
<!--Z-index -1 to let it scroll all good-->
<ion-card class='long-card brew-layout' style='z-index:-1'>
<ion-card-content class='no-ion-col-vertical-padding ion-padding-top' >
<graph-display-card [chartWidth]='getElementOffsetWidth()' [chartHeight]='getElementOffsetHeight()' [flowProfilePath]='brew.flow_profile'></graph-display-card>
<graph-display-card *ngIf='informationContainerWidth' [chartWidth]='informationContainerWidth' [chartHeight]='informationContainerHeight' [flowProfilePath]='brew.flow_profile'></graph-display-card>
</ion-card-content>
</ion-card>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,16 @@
position: relative;

width: 100%;
height: 100%;

height: auto;
}

.add-bottom-spacing{
margin-bottom:20px;
}



}


63 changes: 31 additions & 32 deletions src/components/brew-information/brew-information.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@angular/core';
import { Brew } from '../../classes/brew/brew';
import { UISettingsStorage } from '../../services/uiSettingsStorage';
import { ModalController, Platform } from '@ionic/angular';
import { MenuController, ModalController, Platform } from '@ionic/angular';
import { BREW_ACTION } from '../../enums/brews/brewAction';
import { BrewPopoverActionsComponent } from '../../app/brew/brew-popover-actions/brew-popover-actions.component';
import { Bean } from '../../classes/bean/bean';
Expand Down Expand Up @@ -53,14 +53,16 @@ export class BrewInformationComponent implements OnInit {
@ViewChild('card', { read: ElementRef })
public cardEl: ElementRef;

public slideOpts = {
allowTouchMove: false,
speed: 400,
slide: 4,
};

@ViewChild('swiper', { static: false }) public brewInformationSlider:
| ElementRef
| undefined;

@ViewChild('ionCardParent', { static: false }) public ionCardParent:
| ElementRef
| any;

@ViewChild('brewInformationContainer', { read: ElementRef, static: false })
public brewInformationContainer: ElementRef;

Expand All @@ -77,6 +79,9 @@ export class BrewInformationComponent implements OnInit {

public settings: Settings = null;

public informationContainerHeight: number = undefined;
public informationContainerWidth: number = undefined;

constructor(
private readonly uiSettingsStorage: UISettingsStorage,
public readonly uiBrewHelper: UIBrewHelper,
Expand All @@ -95,7 +100,8 @@ export class BrewInformationComponent implements OnInit {
private readonly uiFileHelper: UIFileHelper,
private readonly uiBeanHelper: UIBeanHelper,
private readonly visualizerService: VisualizerService,
private readonly uiGraphHelper: UIGraphHelper
private readonly uiGraphHelper: UIGraphHelper,
private readonly menu: MenuController
) {}

public ngOnInit() {
Expand All @@ -104,6 +110,25 @@ export class BrewInformationComponent implements OnInit {
this.bean = this.brew.getBean();
this.preparation = this.brew.getPreparation();
this.mill = this.brew.getMill();

setTimeout(() => {
/**We calculcate the information here, to avoid expression-changed in angular, because it always triggered while scrolling cause of calucation functions**/
this.informationContainerHeight =
this.brewInformationContainer?.nativeElement?.offsetHeight - 50;
this.informationContainerWidth =
this.brewInformationContainer?.nativeElement?.offsetWidth - 50;

/**If we slide on a bigger tablet, somehow ionic triggering the menu when sliding from right to left, thats why we need to attach us to touchstart/end and to ignore the slide...**/
this.brewInformationSlider?.nativeElement.swiper.on(
'touchStart',
() => {
this.menu.swipeGesture(false);
}
);
this.brewInformationSlider?.nativeElement.swiper.on('touchEnd', () => {
this.menu.swipeGesture(true);
});
}, 150);
}
}

Expand Down Expand Up @@ -146,32 +171,6 @@ export class BrewInformationComponent implements OnInit {
await this.uiGraphHelper.detailBrewGraph(this.brew);
}

public getElementOffsetWidth() {
if (this.brewInformationContainer?.nativeElement?.offsetWidth) {
return this.brewInformationContainer?.nativeElement?.offsetWidth - 50;
}
return 0;
}
public getElementOffsetHeight() {
if (this.brewInformationContainer?.nativeElement?.offsetHeight) {
return this.brewInformationContainer?.nativeElement?.offsetHeight - 50;
}
return 0;
}

public getElementHeight() {
if (this.ionCardParent?.el.offsetHeight) {
return this.ionCardParent?.el.offsetHeight;
}
return 200;
}
public getElementWidth() {
if (this.ionCardParent?.el.offsetWidth) {
return this.ionCardParent?.el.offsetWidth;
}
return 200;
}

public async showBrewActions(event): Promise<void> {
event.stopPropagation();
event.stopImmediatePropagation();
Expand Down
6 changes: 0 additions & 6 deletions src/popover/welcome-popover/welcome-popover.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import { UIPreparationHelper } from '../../services/uiPreparationHelper';
styleUrls: ['./welcome-popover.component.scss'],
})
export class WelcomePopoverComponent implements OnInit {
public slideOpts = {
allowTouchMove: false,
speed: 400,
slide: 4,
};

public slide: number = 1;
@ViewChild('slider', { static: false }) public welcomeSlider:
| ElementRef
Expand Down

0 comments on commit de977c0

Please sign in to comment.