Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
</config-file>
<config-file parent="/*" target="AndroidManifest.xml">
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
</config-file>
<config-file parent="/*" target="AndroidManifest.xml">
<queries>
Expand Down
3 changes: 3 additions & 0 deletions src/core/components/sheet-modal/sheet-modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
isolation: isolate;

Expand All @@ -23,6 +24,8 @@
z-index: 3; // ion-backdrop has z-index 2
transform: translateY(100%);
transition: transform 300ms ease-in;
width: 100%;
max-width: 500px;
}

&.active {
Expand Down
8 changes: 6 additions & 2 deletions src/core/components/sheet-modal/sheet-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class CoreSheetModalComponent<T extends CoreModalComponent> implements Af

private element: HTMLElement;
private wrapperElement = new CorePromisedValue<HTMLElement>();
private content?: HTMLElement;

constructor({ nativeElement: element }: ElementRef<HTMLElement>) {
this.element = element;
Expand Down Expand Up @@ -61,7 +62,7 @@ export class CoreSheetModalComponent<T extends CoreModalComponent> implements Af
*/
async show(): Promise<T> {
const wrapper = await this.wrapperElement;
const element = await AngularFrameworkDelegate.attachViewToDom(wrapper, this.component, this.componentProps ?? {});
this.content = await AngularFrameworkDelegate.attachViewToDom(wrapper, this.component, this.componentProps ?? {});

await CoreUtils.nextTick();

Expand All @@ -71,7 +72,7 @@ export class CoreSheetModalComponent<T extends CoreModalComponent> implements Af
await CoreUtils.nextTick();
await CoreUtils.wait(300);

const instance = CoreDirectivesRegistry.resolve(element, this.component);
const instance = CoreDirectivesRegistry.resolve(this.content, this.component);

if (!instance) {
throw new Error('Modal not mounted properly');
Expand All @@ -84,10 +85,13 @@ export class CoreSheetModalComponent<T extends CoreModalComponent> implements Af
* Hide modal.
*/
async hide(): Promise<void> {
const wrapper = await this.wrapperElement;

this.element.classList.remove('active');

await CoreUtils.nextTick();
await CoreUtils.wait(300);
await AngularFrameworkDelegate.removeViewFromDom(wrapper, this.content);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
--background-color: var(--ion-background-color, #fff);
--bars-color: var(--ion-text-color, #000);

position: relative;

canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,7 @@ export class CoreFileUploaderAudioHistogramComponent implements AfterViewInit, O
this.context = this.canvas?.getContext('2d');
this.buffer = new Uint8Array(this.analyser.fftSize);

if (this.context && this.canvas) {
const styles = getComputedStyle(this.element);

this.canvas.width = this.canvas.clientWidth;
this.canvas.height = this.canvas.clientHeight;
this.context.fillStyle = styles.getPropertyValue('--background-color');
this.context.lineCap = 'round';
this.context.lineWidth = CoreFileUploaderAudioHistogramComponent.BARS_WIDTH;
this.context.strokeStyle = styles.getPropertyValue('--bars-color');
}

this.updateCanvas(this.element.clientWidth, this.element.clientHeight);
this.draw();
}

Expand All @@ -77,6 +67,10 @@ export class CoreFileUploaderAudioHistogramComponent implements AfterViewInit, O
return;
}

if (this.canvas.width !== this.element.clientWidth || this.canvas.height !== this.element.clientHeight) {
this.updateCanvas(this.element.clientWidth, this.element.clientHeight);
}

const width = this.canvas.width;
const height = this.canvas.height;
const barsWidth = CoreFileUploaderAudioHistogramComponent.BARS_WIDTH;
Expand Down Expand Up @@ -157,4 +151,25 @@ export class CoreFileUploaderAudioHistogramComponent implements AfterViewInit, O
}
}

/**
* Set canvas element dimensions and configure styles.
*
* @param width Canvas width.
* @param height Canvas height.
*/
private updateCanvas(width: number, height: number): void {
if (!this.canvas || !this.context) {
return;
}

const styles = getComputedStyle(this.element);

this.canvas.width = width;
this.canvas.height = height;
this.context.fillStyle = styles.getPropertyValue('--background-color');
this.context.lineCap = 'round';
this.context.lineWidth = CoreFileUploaderAudioHistogramComponent.BARS_WIDTH;
this.context.strokeStyle = styles.getPropertyValue('--bars-color');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent<C
* @inheritdoc
*/
ngOnDestroy(): void {
this.media$.value?.recorder.stop();
const recorder = this.media$.value?.recorder;

if (recorder && recorder.state !== 'inactive') {
recorder.stop();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export class CoreModalsService {

modal.result.finally(async () => {
await sheetModal.hide();
await AngularFrameworkDelegate.removeViewFromDom(container, element);

element.remove();
viewContainer?.removeAttribute('aria-hidden');
});

Expand Down