Skip to content

Commit 9cb53a5

Browse files
Multiples improvements
1 parent 85e2bc6 commit 9cb53a5

5 files changed

Lines changed: 95 additions & 8 deletions

File tree

public/ios-prompt.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
function isIos() {
3+
return /iphone|ipad|ipod/i.test(window.navigator.userAgent);
4+
}
5+
6+
function isInStandaloneMode() {
7+
return window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone;
8+
}
9+
10+
if (isIos() && !isInStandaloneMode()) {
11+
const div = document.createElement("div");
12+
div.style.position = "fixed";
13+
div.style.bottom = "0";
14+
div.style.left = "0";
15+
div.style.right = "0";
16+
div.style.background = "#000";
17+
div.style.color = "#fff";
18+
div.style.padding = "10px";
19+
div.style.textAlign = "center";
20+
div.style.zIndex = "9999";
21+
div.innerHTML = `
22+
📲 <strong>Instale o app!</strong><br />
23+
Toque no botão <strong>compartilhar</strong> no Safari
24+
e depois em <strong>“Adicionar à Tela de Início”</strong>.
25+
`;
26+
document.body.appendChild(div);
27+
28+
setTimeout(() => div.remove(), 5000);
29+
}

public/manifest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "Undershows",
3+
"short_name": "Undershows",
4+
"start_url": "/",
5+
"display": "standalone",
6+
"orientation": "portrait",
7+
"background_color": "#000000",
8+
"theme_color": "#000000",
9+
"icons": [
10+
{
11+
"src": "/images/icons/icon-192x192-v2.png",
12+
"sizes": "192x192",
13+
"type": "image/png",
14+
"purpose": "any maskable"
15+
},
16+
{
17+
"src": "/images/icons/icon-512x512-v2.png",
18+
"sizes": "512x512",
19+
"type": "image/png",
20+
"purpose": "any maskable"
21+
}
22+
]
23+
}

public/register-sw.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if ("serviceWorker" in navigator) {
2+
window.addEventListener("load", () => {
3+
navigator.serviceWorker
4+
.register("/service-worker.js")
5+
.then(reg => console.log("✅ Service Worker registrado com sucesso", reg))
6+
.catch(err => console.error("🛑 Erro ao registrar Service Worker", err));
7+
});
8+
}

public/service-worker.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const CACHE_NAME = "undershows-static-v1";
2+
const urlsToCache = [
3+
"/manifest.json",
4+
"/images/icons/icon-192x192-v2.png",
5+
"/images/icons/icon-512x512-v2.png"
6+
];
7+
8+
self.addEventListener("install", event => {
9+
event.waitUntil(
10+
caches.open(CACHE_NAME).then(cache => cache.addAll(urlsToCache))
11+
);
12+
});
13+
14+
self.addEventListener("fetch", event => {
15+
if (urlsToCache.includes(new URL(event.request.url).pathname)) {
16+
event.respondWith(
17+
caches.match(event.request).then(response => response || fetch(event.request))
18+
);
19+
}
20+
});

src/pages/index.astro

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ function formatDate(dateStr) {
4343

4444
<html lang="pt-BR">
4545
<head>
46+
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
47+
<meta http-equiv="Pragma" content="no-cache" />
48+
<meta http-equiv="Expires" content="0" />
4649
<meta charset="utf-8" />
4750
<title>Undershows – Agenda de Shows</title>
4851
<meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -54,13 +57,12 @@ function formatDate(dateStr) {
5457

5558
body {
5659
margin: 0;
57-
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
58-
sans-serif;
59-
background: linear-gradient(180deg, #5b2366, #ff2f7a);
60+
font-family: system-ui, sans-serif;
6061
min-height: 100vh;
6162
color: #000;
6263
display: flex;
6364
justify-content: center;
65+
background-image: radial-gradient(ellipse at center, #f05291, gray);
6466
}
6567

6668
main {
@@ -174,13 +176,17 @@ function formatDate(dateStr) {
174176
}
175177

176178
.ticket-btn {
177-
display: block;
179+
display: flex;
180+
align-items: center;
181+
justify-content: center;
182+
gap: 8px;
183+
178184
width: 100%;
179185
padding: 12px 0;
180186
background: #000;
181187
color: #f5f5f5;
182-
text-decoration: none;
183188
font-weight: 800;
189+
text-decoration: none;
184190
font-size: 0.98rem;
185191
border: none;
186192
margin: 0;
@@ -191,9 +197,10 @@ function formatDate(dateStr) {
191197
}
192198

193199
.ticket-btn .emoji {
194-
font-size: 1.3rem;
195-
vertical-align: -2px;
196-
margin-right: 6px;
200+
font-size: 1.6rem;
201+
line-height: 1;
202+
display: flex;
203+
align-items: center;
197204
}
198205

199206
.empty {

0 commit comments

Comments
 (0)