Browse Source

change the X and picture button so that landscape is all functional (if not great-looking)

kb/add-usage-guide
Trent Larson 6 months ago
parent
commit
a230506d96
  1. 4
      project.task.yaml
  2. 48
      src/components/GiftedPhotoDialog.vue

4
project.task.yaml

@ -3,6 +3,7 @@ tasks :
- bug - landscape doesn't show full camera - bug - landscape doesn't show full camera
- but - portrait stretches pic - but - portrait stretches pic
- add to readme - check version, close tabs & restart phone if necessary
- bug maybe - a new give remembers the previous project - bug maybe - a new give remembers the previous project
- alert & stop if give amount < 0 - alert & stop if give amount < 0
- onboarding video - onboarding video
@ -57,7 +58,7 @@ tasks :
- .1 hide project-create button on project page if not registered - .1 hide project-create button on project page if not registered
- .1 hide offer & give buttons on project list page if not registered - .1 hide offer & give buttons on project list page if not registered
- .1 add cursor-pointer on the icons for giving on the project page, and on the list of projects on the discover page - .1 add cursor-pointer on the icons for giving on the project page, and on the list of projects on the discover page
- .2 record when InfiniteScroll hits the end of the list and don't trigger any more loads - .2 record when InfiniteScroll hits the end of the list and don't trigger any more loads (feed, project list, give & offer lists)
- bug - turning notifications on from the help screen did not stay, though account screen toggle did stay (From Jason on iPhone.) - bug - turning notifications on from the help screen did not stay, though account screen toggle did stay (From Jason on iPhone.)
- refactor - supply the projectId to the OfferDialog just like we do with the GiftedDialog offerId (in the "open" method, maybe as well as an attribute) - refactor - supply the projectId to the OfferDialog just like we do with the GiftedDialog offerId (in the "open" method, maybe as well as an attribute)
@ -121,6 +122,7 @@ tasks :
- .5 show seed phrase in a QR code for transfer to another device - .5 show seed phrase in a QR code for transfer to another device
- .5 on DiscoverView, switch to a filter UI (eg. just from friend - .5 on DiscoverView, switch to a filter UI (eg. just from friend
- .5 don't show "Offer" on project screen if they aren't registered - .5 don't show "Offer" on project screen if they aren't registered
- 01 especially for iOS, check for new version & update, eg. https://stackoverflow.com/questions/52221805/any-way-yet-to-auto-update-or-just-clear-the-cache-on-a-pwa-on-ios
- 24 Move to Vite - 24 Move to Vite
- 32 accept images for projects - 32 accept images for projects

48
src/components/GiftedPhotoDialog.vue

@ -1,15 +1,13 @@
<template> <template>
<div v-if="visible" class="dialog-overlay"> <div v-if="visible" class="dialog-overlay">
<!-- Breadcrumb -->
<div class="dialog"> <div class="dialog">
<!-- Back -->
<div class="text-lg text-center font-light relative px-7"> <div class="text-lg text-center font-light relative px-7">
<h1 <div
class="text-lg text-center px-2 py-1 absolute -right-2 -top-1" class="text-lg text-center px-2 py-1 absolute -right-2 top-6 z-10"
@click="close()" @click="close()"
> >
<fa icon="xmark" class="fa-fw"></fa> <fa icon="xmark" class="fa-fw"></fa>
</h1> </div>
</div> </div>
<!-- Heading --> <!-- Heading -->
@ -30,6 +28,7 @@
> >
<span>Upload</span> <span>Upload</span>
</button> </button>
<!-- TODO remove, this and console.logs -->
<!--{{ imageHeight }} {{ imageWidth }} {{ imageWarning }}--> <!--{{ imageHeight }} {{ imageWidth }} {{ imageWarning }}-->
<button <button
@click="retryImage" @click="retryImage"
@ -38,20 +37,17 @@
<span>Retry</span> <span>Retry</span>
</button> </button>
</div> </div>
<div <div class="flex justify-center">
:style="'height: ' + imageHeight + 'px; width: ' + imageWidth + 'px;'" <img :src="URL.createObjectURL(blob)" class="mt-2 rounded" />
>
<img :src="URL.createObjectURL(blob)" class="mt-2" />
</div> </div>
</div> </div>
<div v-else> <div v-else>
<!-- <!--
Camera "resolution" doesn't change how it shows on screen but rather stretches the result, eg the following which just stretches it vertically: Camera "resolution" doesn't change how it shows on screen but rather stretches the result, eg the following which just stretches it vertically:
:resolution="{ width: 375, height: 812 }" :resolution="{ width: 375, height: 812 }"
It even messes up when trying to match the ratio with imageHeight and imageWidth.
--> -->
<camera facingMode="environment" autoplay ref="camera"> <camera facingMode="environment" autoplay ref="camera">
<div class="absolute top-0 w-full flex justify-center pb-4"> <div class="absolute bottom-0 w-full flex justify-center pb-8">
<button <button
@click="takeImage" @click="takeImage"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-2 rounded-full" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-2 rounded-full"
@ -113,17 +109,29 @@ export default class GiftedPhotoDialog extends Vue {
open(setImageFn: (arg: string) => void) { open(setImageFn: (arg: string) => void) {
this.visible = true; this.visible = true;
const bottomNav = document.querySelector("#QuickNav") as HTMLElement;
if (bottomNav) {
bottomNav.style.display = "none";
}
this.setImage = setImageFn; this.setImage = setImageFn;
} }
close() { close() {
this.visible = false; this.visible = false;
const bottomNav = document.querySelector("#QuickNav") as HTMLElement;
if (bottomNav) {
bottomNav.style.display = "";
}
this.blob = null; this.blob = null;
} }
async takeImage(/* payload: MouseEvent */) { async takeImage(/* payload: MouseEvent */) {
const cameraComponent = this.$refs.camera as InstanceType<typeof Camera>; const cameraComponent = this.$refs.camera as InstanceType<typeof Camera>;
console.log("cameraComponent", cameraComponent, cameraComponent.resolution); console.log(
"cameraComponent on snapshot",
cameraComponent,
cameraComponent.resolution,
);
this.imageHeight = cameraComponent?.resolution?.height; this.imageHeight = cameraComponent?.resolution?.height;
this.imageWidth = cameraComponent?.resolution?.width; this.imageWidth = cameraComponent?.resolution?.width;
const initialImageRatio = this.imageWidth / this.imageHeight; const initialImageRatio = this.imageWidth / this.imageHeight;
@ -141,12 +149,14 @@ export default class GiftedPhotoDialog extends Vue {
window.innerHeight, window.innerHeight,
); );
if (initialImageRatio > 1 && windowRatio < 1) { if (initialImageRatio > 1 && windowRatio < 1) {
// the image is wider than it is tall, and the window is taller than it is wide
this.imageWarning = "?"; this.imageWarning = "?";
// For some reason, mobile in portrait orientation renders a horizontally-stretched image. // For some reason, mobile in portrait orientation renders a horizontally-stretched image.
// We're gonna force it opposite. // We're gonna force it opposite.
this.imageHeight = cameraComponent?.resolution?.width; this.imageHeight = cameraComponent?.resolution?.width;
this.imageWidth = cameraComponent?.resolution?.height; this.imageWidth = cameraComponent?.resolution?.height;
} else if (initialImageRatio < 1 && windowRatio > 1) { } else if (initialImageRatio < 1 && windowRatio > 1) {
// the image is taller than it is wide, and the window is wider than it is tall
// Haven't seen this happen, but just in case. // Haven't seen this happen, but just in case.
this.imageWarning = "??"; this.imageWarning = "??";
this.imageHeight = cameraComponent?.resolution?.width; this.imageHeight = cameraComponent?.resolution?.width;
@ -160,9 +170,11 @@ export default class GiftedPhotoDialog extends Vue {
this.imageHeight, this.imageHeight,
); );
if (newImageRatio < windowRatio) { if (newImageRatio < windowRatio) {
// the image is a taller ratio than the window, so fit the height first
this.imageHeight = window.innerHeight / 2; this.imageHeight = window.innerHeight / 2;
this.imageWidth = this.imageHeight * newImageRatio; this.imageWidth = this.imageHeight * newImageRatio;
} else { } else {
// the image is a wider ratio than the window, so fit the width first
this.imageWidth = window.innerWidth / 2; this.imageWidth = window.innerWidth / 2;
this.imageHeight = this.imageWidth / newImageRatio; this.imageHeight = this.imageWidth / newImageRatio;
} }
@ -211,9 +223,9 @@ export default class GiftedPhotoDialog extends Vue {
} }
} }
photoSnapped() { photoSnapped() {
console.log("snap_photo clicked");
const video = document.querySelector("#video"); const video = document.querySelector("#video");
const canvas = document.querySelector("#canvas"); const canvas = document.querySelector("#canvas");
console.log("snap_photo clicked");
if ( if (
canvas instanceof HTMLCanvasElement && canvas instanceof HTMLCanvasElement &&
video instanceof HTMLVideoElement video instanceof HTMLVideoElement
@ -221,9 +233,17 @@ export default class GiftedPhotoDialog extends Vue {
canvas canvas
?.getContext("2d") ?.getContext("2d")
?.drawImage(video, 0, 0, canvas.width, canvas.height); ?.drawImage(video, 0, 0, canvas.width, canvas.height);
const image_data_url = canvas?.toDataURL("image/jpeg"); // ... or set the blob:
// canvas?.toBlob(
// (blob) => {
// this.blob = blob;
// },
// "image/jpeg",
// 1,
// );
// data url of the image // data url of the image
const image_data_url = canvas?.toDataURL("image/jpeg");
console.log(image_data_url); console.log(image_data_url);
} }
} }

Loading…
Cancel
Save