Browse Source

video and chat gallery

master
Danilo Di Cuia 3 years ago
parent
commit
0d2876baf3
  1. 5
      package.json
  2. 171
      src/Galleria.js
  3. 19
      src/Proiezione.js
  4. 7
      src/index.js
  5. 22
      src/logo_chat.svg
  6. BIN
      src/video.mp4

5
package.json

@ -22,6 +22,11 @@
"sort-by": "^1.2.0",
"web-vitals": "^2.1.4"
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",

171
src/Galleria.js

@ -0,0 +1,171 @@
import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import firebase from "firebase/app";
import { Button, CircularProgress, Fade } from "@mui/material";
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import IconButton from "@mui/material/IconButton";
import { Stack } from "@mui/system";
import logoSrc from "./logo_chat.svg";
export const Galleria = () => {
const { evento } = useParams();
const [messaggi, cambiaMessaggi] = useState([]);
const [loading, cambialoading] = useState(false);
const [indiceCorrente, cambiaindiceCorrente] = useState(1);
useEffect(() => {
var messagesRef = firebase.database().ref(`/messaggi/${evento}`);
messagesRef.on("value", function (snapshot) {
var messaggi = snapshot.val();
cambiaMessaggi(
Object.keys(messaggi)
.map((d) => {
return messaggi[d];
})
.filter((d) => d.approvato)
.sort((a, b) => a.timestamp - b.timestamp)
);
});
}, [evento]);
const messaggioDaMostrare = messaggi[indiceCorrente];
return (
<div>
<div
style={{
margin: "0 auto",
fontFamily: "Lineatura",
width: "90vw",
height: "100vh",
fontWeight: "bold",
color: "white",
display: "flex",
justifyContent: "space-around",
alignContent: "center",
alignItems: "center",
textAlign: "center",
}}
>
<Stack>
<div>
{messaggioDaMostrare && (
<ImagePlaceholder
messaggioDaMostrare={messaggioDaMostrare}
style={{
maxWidth: "100%",
maxHeight: "80vh",
}}
/>
)}
</div>
<Stack
style={{
display: "flex",
width: "100%",
position: "absolute",
top: "50%",
left: 0,
alignItems: "center",
justifyContent: "space-between",
padding: 20,
boxSizing: "border-box",
}}
direction="row"
>
{indiceCorrente > 0 && (
<IconButton
onClick={() => cambiaindiceCorrente(indiceCorrente + 1)}
>
<ArrowBackIcon style={{ fontSize: "3rem" }} />
</IconButton>
)}
{indiceCorrente > 0 && (
<IconButton
onClick={() => cambiaindiceCorrente(indiceCorrente + 1)}
>
<ArrowForwardIcon style={{ fontSize: "3rem" }} />
</IconButton>
)}
</Stack>
</Stack>
<img
src={logoSrc}
style={{
width: 120,
position: "absolute",
top: 20,
right: 20,
}}
/>
</div>
</div>
);
};
function ImagePlaceholder({ messaggioDaMostrare }) {
const [imageLoaded, setImageLoaded] = useState(false);
useEffect(() => {
if (messaggioDaMostrare.immagineURL) {
const image = new Image();
image.onload = () => {
setImageLoaded(true);
};
image.src = messaggioDaMostrare.immagineURL;
} else {
setImageLoaded(true);
}
}, [messaggioDaMostrare.immagineURL]);
return (
<Fade in={imageLoaded}>
<div>
{messaggioDaMostrare.immagineURL && (
<img
alt=""
src={messaggioDaMostrare.immagineURL}
style={{
maxWidth: "100%",
maxHeight: "80vh",
}}
/>
)}
<Messaggio messaggioDaMostrare={messaggioDaMostrare} />
</div>
</Fade>
);
}
const Messaggio = ({ messaggioDaMostrare }) => {
return (
<>
<h1
style={{
fontSize: messaggioDaMostrare.immagineURL ? 20 : 50,
textShadow:
"0px 0px 10px rgba(0,0,0,100), 0px 0px 10px rgba(0,0,0,100), 0px 0px 10px rgba(0,0,0,100)",
}}
>
{messaggioDaMostrare.testo}
</h1>
{messaggioDaMostrare.autore && (
<p
style={{
fontSize: 20,
display: "inline-block",
background: "black",
padding: "0px 6px",
paddingBottom: "4px",
}}
>
da {messaggioDaMostrare.autore}
</p>
)}
</>
);
};

19
src/Proiezione.js

@ -27,6 +27,22 @@ export const Proiezione = () => {
});
});
messagesRef.on("child_removed", function (snapshot) {
console.log("child_removed");
var messaggio = snapshot.val();
cambiaMessaggi((oldArray) => {
const newArray = [];
oldArray.forEach((d) => {
if (d.id !== messaggio.id) {
newArray.push(d);
}
});
newArray.sort((a, b) => b.timestamp - a.timestamp);
cambiaMessaggiApprovati(newArray.filter((d) => d.approvato));
return newArray;
});
});
messagesRef.on("child_changed", function (snapshot) {
console.log("child_changed");
const messaggio = snapshot.val();
@ -108,7 +124,6 @@ const Messaggio = ({ messaggiApprovati }) => {
}
}, [indiceCorrente]);
console.log(imageWidth);
return (
<div className={"fade-" + fadeProp}>
<div
@ -138,6 +153,7 @@ const Messaggio = ({ messaggiApprovati }) => {
)}
<h1
style={{
fontSize: messaggioDaMostrare.immagineURL ? 20 : 50,
textShadow:
"0px 0px 10px rgba(0,0,0,100), 0px 0px 10px rgba(0,0,0,100), 0px 0px 10px rgba(0,0,0,100)",
}}
@ -147,6 +163,7 @@ const Messaggio = ({ messaggiApprovati }) => {
{messaggioDaMostrare.autore && (
<p
style={{
fontSize: 20,
display: "inline-block",
background: "black",
padding: "0px 6px",

7
src/index.js

@ -15,8 +15,8 @@ import Checkbox from "@mui/material/Checkbox";
import { Proiezione } from "./Proiezione";
import { MyForm } from "./MyForm";
import { Admin } from "./Admin";
import { Button } from "@mui/material";
import { Stack } from "@mui/system";
import { Galleria } from "./Galleria";
const firebaseConfig = {
apiKey: "AIzaSyBWE1l8WV_7eyKT-PMu0Kq2w_WiV0SUhJw",
@ -79,8 +79,9 @@ ReactDOM.createRoot(document.getElementById("root")).render(
<Router>
<Routes>
<Route path="/" element={<MyForm />} />
<Route path="proiezione" element={<Proiezione />} />
<Route path="admin" element={<Admin />} />
<Route path="/eventi/:evento" element={<Galleria />} />
<Route path="proiezione/:evento" element={<Proiezione />} />
<Route path="admin/:evento" element={<Admin />} />
</Routes>
</Router>
);

22
src/logo_chat.svg

@ -0,0 +1,22 @@
<svg width="1382" height="1382" viewBox="0 0 1382 1382" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="690.606" cy="690.606" r="690.606" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M471.443 270.553L479.853 579.504L506.282 560.436L510.916 566.859C506.282 560.436 506.281 560.436 506.282 560.436L506.283 560.435L506.287 560.433L560.842 521.074L574.884 540.537L520.329 579.896L520.326 579.898L520.325 579.899L520.324 579.899C520.324 579.9 520.324 579.9 515.652 573.424L520.324 579.899L457.096 625.516L447.451 271.206L471.443 270.553Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M740.358 235.969L734.577 169.074L710.666 171.141L716.867 242.899L525.175 299.449L531.966 322.468L718.976 267.3L740.732 519.051L764.643 516.985L742.466 260.37L957.534 196.924L950.743 173.904L740.358 235.969Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1037.72 292.455L1025.6 668.986L1001.62 668.214L1013.74 291.683L1037.72 292.455Z" fill="white"/>
<path d="M1030.48 719.538C1030.48 729.984 1022.02 738.452 1011.57 738.452C1001.12 738.452 992.654 729.984 992.654 719.538C992.654 709.093 1001.12 700.625 1011.57 700.625C1022.02 700.625 1030.48 709.093 1030.48 719.538Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1011.57 721.008C1012.38 721.008 1013.04 720.349 1013.04 719.538C1013.04 718.728 1012.38 718.069 1011.57 718.069C1010.76 718.069 1010.1 718.728 1010.1 719.538C1010.1 720.349 1010.76 721.008 1011.57 721.008ZM1011.57 738.452C1022.02 738.452 1030.48 729.984 1030.48 719.538C1030.48 709.093 1022.02 700.625 1011.57 700.625C1001.12 700.625 992.654 709.093 992.654 719.538C992.654 729.984 1001.12 738.452 1011.57 738.452Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M820.935 291.209L817.756 302.781C814.526 314.541 808.057 328.983 798.865 339.855L791.116 349.018L772.79 333.522L780.538 324.358C786.935 316.793 792.052 305.747 794.614 296.423L797.793 284.852L820.935 291.209Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M562.275 653.479L593.776 840.449L571.683 848.666L508.539 744.572L530.169 856.044L508.105 864.514L395.241 676.823L415.809 664.455L493.67 793.937L472.184 683.209L494.224 674.699L559.697 782.633L538.609 657.466L562.275 653.479Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M698.033 571.927L709.453 671.003C711.956 654.168 715.204 638.671 719.452 626.55C722.013 619.243 725.209 612.352 729.394 607.072C733.602 601.764 740.018 596.674 748.771 596.674C757.235 596.674 763.563 601.297 767.798 606.554C771.902 611.649 774.852 618.234 777.098 625.058C781.628 638.811 784.41 657.057 786.152 676.194C789.659 714.713 789.204 760.025 788.381 787.948L788.027 799.943L764.038 799.235L764.391 787.241C765.208 759.559 765.623 715.411 762.251 678.37C760.554 659.728 757.96 643.67 754.303 632.565C752.456 626.958 750.61 623.475 749.107 621.609C749.002 621.479 748.905 621.363 748.814 621.26C748.637 621.452 748.433 621.689 748.203 621.979C746.411 624.241 744.28 628.272 742.101 634.488C737.787 646.799 734.348 664.521 731.745 685.078C726.568 725.974 725.023 775.334 725.21 808.331L701.289 809.773L674.191 574.675L698.033 571.927ZM749.699 620.484C749.699 620.487 749.667 620.508 749.605 620.535C749.667 620.493 749.698 620.48 749.699 620.484ZM748.084 620.553C748.025 620.527 747.996 620.506 747.996 620.502C747.996 620.498 748.025 620.511 748.084 620.553Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M637.622 675.744L658.242 828.138L634.459 831.356L613.839 678.962L637.622 675.744Z" fill="white"/>
<path d="M638.785 633.205C638.785 643.651 630.316 652.119 619.87 652.119C609.424 652.119 600.955 643.651 600.955 633.205C600.955 622.76 609.424 614.292 619.87 614.292C630.316 614.292 638.785 622.76 638.785 633.205Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M619.87 634.675C620.684 634.675 621.341 634.016 621.341 633.205C621.341 632.395 620.684 631.736 619.87 631.736C619.056 631.736 618.399 632.395 618.399 633.205C618.399 634.016 619.056 634.675 619.87 634.675ZM619.87 652.119C630.316 652.119 638.785 643.651 638.785 633.205C638.785 622.76 630.316 614.292 619.87 614.292C609.424 614.292 600.955 622.76 600.955 633.205C600.955 643.651 609.424 652.119 619.87 652.119Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M928.303 568.945L927.157 557L903.267 559.291L904.413 571.236C904.859 575.892 905.337 580.966 905.84 586.398C905.155 586.125 904.452 585.875 903.731 585.65C894.954 582.917 886.234 584.783 878.771 588.613C871.375 592.409 864.469 598.464 858.275 605.688C845.857 620.17 834.733 641.177 827.245 665.216C819.758 689.254 816.986 712.863 818.985 731.834C819.981 741.297 822.227 750.203 826.16 757.527C830.128 764.916 836.246 771.403 845.024 774.137C853.802 776.87 862.522 775.004 869.984 771.174C877.38 767.379 884.286 761.323 890.481 754.099C900.173 742.796 909.077 727.517 916.079 709.924C919.019 750.266 921.491 790.623 922.458 822.011C872.638 835.762 815.143 851.877 751.073 870.644C699.844 885.65 661.754 901.668 635.989 917.579C623.11 925.532 612.901 933.706 605.67 942.063C598.475 950.378 593.612 959.608 592.97 969.475C591.586 990.736 609.251 1004.73 630.523 1012.8C652.749 1021.23 684.614 1025.8 724.183 1025.8C837.45 1025.8 895.487 1005.18 923.682 969.131C937.788 951.098 943.416 930.405 945.661 909.601C947.354 893.906 947.173 877.221 946.998 861.2V861.199V861.196C946.946 856.383 946.894 851.63 946.894 846.982C946.894 844.796 946.881 842.529 946.856 840.185C962.01 836.019 976.387 832.085 989.962 828.37L989.975 828.366L989.985 828.363C1021.8 819.657 1049.21 812.156 1071.91 805.698L1083.46 802.415L1076.89 779.331L1065.35 782.614C1043.07 788.951 1015.87 796.395 984.193 805.064L984.183 805.067L984.119 805.084C972.13 808.366 959.499 811.822 946.252 815.461C943.631 741.18 933.631 624.505 928.303 568.945ZM757.819 893.676C819.408 875.636 874.653 860.122 922.894 846.789L922.894 846.982C922.894 852.263 922.949 857.426 923.003 862.484C923.169 878.184 923.325 892.881 921.799 907.027C919.823 925.338 915.119 941.124 904.778 954.345C884.078 980.808 836.759 1001.8 724.183 1001.8C685.986 1001.8 657.403 997.331 639.037 990.362C619.717 983.033 616.644 975.257 616.919 971.034C617.106 968.159 618.67 963.718 623.819 957.767C628.932 951.859 636.984 945.171 648.599 937.999C671.821 923.659 707.652 908.371 757.819 893.676ZM896.594 608.565C897.668 608.899 899.492 609.968 901.451 613.615C903.444 617.328 905.11 622.94 905.903 630.468C907.484 645.481 905.349 665.753 898.596 687.435C891.842 709.118 882.088 727.017 872.261 738.477C867.333 744.224 862.776 747.898 859.026 749.822C855.343 751.713 853.235 751.557 852.161 751.223C851.087 750.888 849.263 749.82 847.305 746.172C845.311 742.459 843.646 736.847 842.853 729.319C841.272 714.306 843.406 694.035 850.16 672.352C856.913 650.669 866.668 632.77 876.494 621.31C881.422 615.563 885.979 611.889 889.729 609.965C893.412 608.074 895.521 608.23 896.594 608.565Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M322.013 539.983C316.273 546.945 310.869 559.702 310.869 581.97C310.869 632.989 340 685.085 371.421 735.307C374.879 740.835 378.369 746.348 381.837 751.827C393.771 770.681 405.449 789.13 414.705 806.368C426.55 828.425 435.627 850.564 435.627 871.113C435.627 882.199 432.809 891.423 427.67 898.77C422.583 906.042 415.803 910.648 409.179 913.552C396.609 919.062 383.057 919.056 378 919.054L377.712 919.054C362.767 919.054 340.408 910.43 322.013 894.849C303.109 878.838 286.869 854.205 286.869 821.029V809.029H310.869V821.029C310.869 845.589 322.688 863.969 337.525 876.536C352.87 889.534 369.931 895.054 377.712 895.054C382.745 895.054 391.865 894.937 399.543 891.571C403.167 889.982 406.02 887.85 408.004 885.013C409.935 882.252 411.627 877.998 411.627 871.113C411.627 856.883 405.109 839.226 393.561 817.722C384.751 801.316 373.713 783.873 361.877 765.171C358.335 759.574 354.721 753.865 351.075 748.036C320.117 698.553 286.869 640.857 286.869 581.97C286.869 556.008 293.176 537.231 303.495 524.715C313.89 512.107 327.541 506.9 339.682 506.9C350.814 506.9 366.589 512.158 379.265 526.317C392.154 540.713 401.024 563.327 400.182 596.757C400.086 600.551 399.866 604.486 399.513 608.568L398.479 620.523L374.568 618.455L375.602 606.5C375.915 602.884 376.107 599.437 376.189 596.152C376.916 567.298 369.271 551.135 361.384 542.325C353.284 533.278 344.023 530.9 339.682 530.9C334.431 530.9 327.675 533.114 322.013 539.983Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M671.314 342.44C675.88 344.425 679.403 347.775 682.077 351.595C698.13 374.538 686.671 400.258 672.739 418.534C658.173 437.641 636.838 454.531 620.507 464.415L617.982 465.943C617.36 471.319 617.031 476.537 617.035 481.497C617.055 500.963 622.097 512.55 629.686 517.387C631.674 518.655 633.107 518.714 634.952 518.096C637.408 517.274 640.794 515.048 644.889 510.698C653.053 502.026 660.866 488.37 666.962 475.426L672.074 464.569L693.787 474.793L688.675 485.65C682.287 499.216 673.182 515.658 662.363 527.15C656.967 532.881 650.344 538.253 642.571 540.855C634.187 543.662 625.17 542.971 616.784 537.625C598.372 525.887 593.057 503.078 593.035 481.52C593.014 459.234 598.544 434.006 606.478 411.616C614.363 389.364 625.118 368.516 636.486 355.521C641.971 349.251 648.994 343.177 657.296 341.253C661.785 340.213 666.633 340.405 671.314 342.44ZM625.061 432.097C635.376 424.052 645.836 414.237 653.652 403.984C666.557 387.056 668.652 374.272 662.412 365.354C662.279 365.163 662.159 365.006 662.053 364.876C660.78 365.459 658.205 367.145 654.549 371.323C645.99 381.108 636.484 398.792 629.1 419.632C627.646 423.733 626.294 427.902 625.061 432.097ZM661.535 364.339C661.535 364.339 661.54 364.342 661.549 364.349C661.54 364.343 661.535 364.339 661.535 364.339Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M836.03 349.69C835.866 320.293 860.249 304.4 883.554 304.4C908.815 304.4 923.088 324.142 927.432 332.571L932.93 343.238L911.597 354.233L906.099 343.567C903.221 337.983 895.231 328.4 883.554 328.4C869.922 328.4 859.958 336.832 860.029 349.556C860.05 353.337 862.202 357.926 869.086 364.29C874.904 369.669 882.385 374.802 891.033 380.736C892.642 381.84 894.292 382.972 895.979 384.139C906.206 391.21 917.569 399.418 926.324 409.329C935.274 419.461 942.131 432.082 942.131 447.829C942.131 463.951 934.584 476.278 923.435 484.024C912.7 491.481 899.124 494.431 886.29 493.891C873.427 493.35 860.053 489.257 849.608 481.09C838.874 472.697 831.457 460.089 831.457 443.982V431.982H855.457V443.982C855.457 451.974 858.874 457.869 864.392 462.184C870.198 466.724 878.493 469.542 887.298 469.912C896.132 470.284 904.225 468.146 909.742 464.313C914.844 460.769 918.131 455.604 918.131 447.829C918.131 439.681 914.751 432.479 908.337 425.218C901.729 417.738 892.603 410.983 882.329 403.879C880.85 402.857 879.337 401.82 877.804 400.77C869.224 394.895 860.016 388.589 852.795 381.914C844.267 374.031 836.106 363.515 836.03 349.69Z" fill="white"/>
<path d="M597.209 1167.07L574.992 1174.04C573.623 1169.71 571.295 1165.98 568.007 1162.83C564.831 1159.61 561.007 1157.4 556.536 1156.19C549.434 1154.27 542.707 1155.12 536.356 1158.77C530.004 1162.41 525.866 1167.78 523.941 1174.88C522.017 1181.99 522.876 1188.71 526.519 1195.07C530.162 1201.42 535.535 1205.56 542.636 1207.48C547.108 1208.69 551.514 1208.76 555.854 1207.67C560.306 1206.53 564.214 1204.43 567.579 1201.39L583.238 1218.62C576.89 1224.34 569.63 1228.21 561.459 1230.23C553.288 1232.25 544.995 1232.12 536.578 1229.84C523.251 1226.23 513.2 1218.51 506.425 1206.7C499.586 1194.78 497.972 1182.15 501.584 1168.83C505.172 1155.59 512.927 1145.55 524.851 1138.71C536.774 1131.87 549.355 1130.24 562.594 1133.83C571.011 1136.11 578.236 1140.19 584.268 1146.06C590.301 1151.93 594.615 1158.93 597.209 1167.07Z" fill="white"/>
<path d="M700.462 1155.72L692.379 1250.75L669.299 1248.79L672.359 1212.81L626.198 1208.88L623.138 1244.86L600.058 1242.9L608.141 1147.86L631.221 1149.83L628.161 1185.8L674.322 1189.73L677.382 1153.75L700.462 1155.72Z" fill="white"/>
<path d="M742.002 1232.59L737.125 1248.86L711.918 1251.49L743.341 1152.31L769.903 1149.53L821.147 1240.08L795.94 1242.71L787.807 1227.81L742.002 1232.59ZM775.778 1205.77L759.185 1175.45L749.217 1208.55L775.778 1205.77Z" fill="white"/>
<path d="M834.048 1161.25L815.617 1166.17L809.644 1143.79L868.885 1127.97L874.859 1150.35L856.428 1155.27L875.052 1225.05L852.672 1231.02L834.048 1161.25Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

BIN
src/video.mp4

Binary file not shown.
Loading…
Cancel
Save