Adição da tela de animação no login
This commit is contained in:
BIN
Imagens para implantação /Videos/copmo ficou.mp4
Normal file
BIN
Imagens para implantação /Videos/copmo ficou.mp4
Normal file
Binary file not shown.
BIN
Imagens para implantação /Videos/copmo ficou.webm
Normal file
BIN
Imagens para implantação /Videos/copmo ficou.webm
Normal file
Binary file not shown.
@@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :set_tema
|
before_action :set_tema
|
||||||
|
before_action :preparar_splash
|
||||||
|
|
||||||
# Pundit: redireciona se não autorizado
|
# Pundit: redireciona se não autorizado
|
||||||
rescue_from Pundit::NotAuthorizedError do |e|
|
rescue_from Pundit::NotAuthorizedError do |e|
|
||||||
@@ -18,11 +19,17 @@ class ApplicationController < ActionController::Base
|
|||||||
@tema = current_user&.tema_preferido || 'dark'
|
@tema = current_user&.tema_preferido || 'dark'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Mostra a animação de abertura uma única vez, na primeira página HTML após o
|
||||||
|
# login. O flag é gravado em #after_sign_in_path_for (Devise) e nos logins do
|
||||||
|
# motorista (PIN/QR); aqui ele é lido e apagado (one-shot).
|
||||||
|
def preparar_splash
|
||||||
|
return unless request.get? && request.format.html?
|
||||||
|
|
||||||
|
@mostrar_splash = session.delete(:mostrar_splash)
|
||||||
|
end
|
||||||
|
|
||||||
def after_sign_in_path_for(resource)
|
def after_sign_in_path_for(resource)
|
||||||
if resource.motorista?
|
session[:mostrar_splash] = true
|
||||||
motorista_dashboard_path
|
resource.motorista? ? motorista_dashboard_path : dashboard_path
|
||||||
else
|
|
||||||
dashboard_path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ module Motorista
|
|||||||
|
|
||||||
if pin.length == 4 && user
|
if pin.length == 4 && user
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
session[:mostrar_splash] = true
|
||||||
AuditoriaLog.registrar(user: user, acao: :login, entidade: 'User',
|
AuditoriaLog.registrar(user: user, acao: :login, entidade: 'User',
|
||||||
entidade_id: user.id, request: request)
|
entidade_id: user.id, request: request)
|
||||||
redirect_to motorista_dashboard_path, notice: "Bem-vindo, #{user.nome.split.first}!"
|
redirect_to motorista_dashboard_path, notice: "Bem-vindo, #{user.nome.split.first}!"
|
||||||
@@ -33,6 +34,7 @@ module Motorista
|
|||||||
|
|
||||||
if user
|
if user
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
session[:mostrar_splash] = true
|
||||||
AuditoriaLog.registrar(user: user, acao: :login, entidade: 'User',
|
AuditoriaLog.registrar(user: user, acao: :login, entidade: 'User',
|
||||||
entidade_id: user.id, dados_novos: { via: 'qr_code' }, request: request)
|
entidade_id: user.id, dados_novos: { via: 'qr_code' }, request: request)
|
||||||
redirect_to motorista_dashboard_path, notice: "Bem-vindo, #{user.nome.split.first}!"
|
redirect_to motorista_dashboard_path, notice: "Bem-vindo, #{user.nome.split.first}!"
|
||||||
|
|||||||
@@ -63,6 +63,38 @@
|
|||||||
|
|
||||||
<body class="bg-[#0a0a0a] text-white min-h-screen">
|
<body class="bg-[#0a0a0a] text-white min-h-screen">
|
||||||
|
|
||||||
|
<%# ── Animação de abertura (uma vez, logo após o login) ── %>
|
||||||
|
<% if @mostrar_splash %>
|
||||||
|
<div id="splash-login"
|
||||||
|
class="fixed inset-0 z-[100] bg-[#0a0a0a] flex items-center justify-center"
|
||||||
|
onclick="encerrarSplash()">
|
||||||
|
<video id="splash-video" autoplay muted playsinline
|
||||||
|
class="max-w-[90vw] max-h-[90vh] w-auto h-auto object-contain">
|
||||||
|
<source src="/login-animacao.webm" type="video/webm">
|
||||||
|
<source src="/login-animacao.mp4" type="video/mp4">
|
||||||
|
</video>
|
||||||
|
<button type="button" onclick="event.stopPropagation(); encerrarSplash()"
|
||||||
|
class="absolute bottom-6 right-6 text-gray-400 hover:text-white text-sm border border-white/20 rounded-lg px-4 py-2">
|
||||||
|
Pular ✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var splash = document.getElementById('splash-login');
|
||||||
|
var video = document.getElementById('splash-video');
|
||||||
|
if (!splash) return;
|
||||||
|
window.encerrarSplash = function () {
|
||||||
|
splash.style.transition = 'opacity .4s';
|
||||||
|
splash.style.opacity = '0';
|
||||||
|
setTimeout(function () { splash.remove(); }, 400);
|
||||||
|
};
|
||||||
|
// Some quando o vídeo termina; fallback de segurança de 8s.
|
||||||
|
if (video) video.addEventListener('ended', window.encerrarSplash);
|
||||||
|
setTimeout(window.encerrarSplash, 8000);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%# ── Navbar ─────────────────────────────────────────── %>
|
<%# ── Navbar ─────────────────────────────────────────── %>
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<%= render 'layouts/navbar' %>
|
<%= render 'layouts/navbar' %>
|
||||||
|
|||||||
BIN
public/login-animacao.mp4
Normal file
BIN
public/login-animacao.mp4
Normal file
Binary file not shown.
BIN
public/login-animacao.webm
Normal file
BIN
public/login-animacao.webm
Normal file
Binary file not shown.
Reference in New Issue
Block a user