fix(ui): correccion padding superior Android nativo y tabs de modulos virtuales garantizados
This commit is contained in:
Binary file not shown.
@@ -1,8 +1,7 @@
|
|||||||
package com.oemspot.onevercontrol;
|
package com.oemspot.onevercontrol;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.WindowCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
|
||||||
import com.getcapacitor.BridgeActivity;
|
import com.getcapacitor.BridgeActivity;
|
||||||
|
|
||||||
public class MainActivity extends BridgeActivity {
|
public class MainActivity extends BridgeActivity {
|
||||||
@@ -10,15 +9,8 @@ public class MainActivity extends BridgeActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// Prevenir que la barra de estado superior y la barra de navegación inferior del sistema tapen la app
|
// Asegurar que la ventana respete limpiamente las barras del sistema (Status Bar y Navigation Bar)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content), (view, insets) -> {
|
// evitando solapamientos y eliminando espacios vacíos redundantes
|
||||||
int top = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top;
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||||
int bottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
|
|
||||||
int left = insets.getInsets(WindowInsetsCompat.Type.systemBars()).left;
|
|
||||||
int right = insets.getInsets(WindowInsetsCompat.Type.systemBars()).right;
|
|
||||||
|
|
||||||
view.setPadding(left, top, right, bottom);
|
|
||||||
return insets;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
|
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<item name="android:fitsSystemWindows">true</item>
|
|
||||||
<item name="android:background">@null</item>
|
<item name="android:background">@null</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,16 @@ export function getBaseUrl(): string {
|
|||||||
// 1. URL personalizada en localStorage (útil para configurar IP de backend en tablet)
|
// 1. URL personalizada en localStorage (útil para configurar IP de backend en tablet)
|
||||||
const savedUrl = localStorage.getItem('on_ever_api_url');
|
const savedUrl = localStorage.getItem('on_ever_api_url');
|
||||||
if (savedUrl && savedUrl.trim()) {
|
if (savedUrl && savedUrl.trim()) {
|
||||||
const trimmed = savedUrl.trim();
|
let trimmed = savedUrl.trim();
|
||||||
|
// Si en una tablet Android (Capacitor) guardan solo "/api/v1" o una ruta relativa,
|
||||||
|
// en la app nativa debe resolverse hacia la IP LAN del backend
|
||||||
|
if (Capacitor.isNativePlatform() && trimmed.startsWith('/')) {
|
||||||
|
return `http://192.168.0.100:8000${trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed}`;
|
||||||
|
}
|
||||||
|
// Si ingresaron la IP sin protocolo (ej: "192.168.0.100:8000" o "192.168.0.100:8000/api/v1")
|
||||||
|
if (!trimmed.startsWith('http://') && !trimmed.startsWith('https://') && !trimmed.startsWith('/')) {
|
||||||
|
trimmed = `http://${trimmed}`;
|
||||||
|
}
|
||||||
return trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed;
|
return trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,8 @@ html, body {
|
|||||||
touch-action: manipulation;
|
touch-action: manipulation;
|
||||||
overscroll-behavior-y: contain;
|
overscroll-behavior-y: contain;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
margin: 0;
|
||||||
/* Safe Area Insets para prevenir solapamiento con la barra de estado y de navegación de Android */
|
padding: 0;
|
||||||
padding-top: env(safe-area-inset-top, 0px);
|
|
||||||
padding-bottom: env(safe-area-inset-bottom, 0px);
|
|
||||||
padding-left: env(safe-area-inset-left, 0px);
|
|
||||||
padding-right: env(safe-area-inset-right, 0px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
|
|||||||
@@ -297,32 +297,56 @@ export const ControlPostView: React.FC = () => {
|
|||||||
// Lista de carriles/pestañas del puesto actual (Paridad escritorio FormularioPuestoControlHost)
|
// Lista de carriles/pestañas del puesto actual (Paridad escritorio FormularioPuestoControlHost)
|
||||||
const laneTabs = useMemo<LaneTab[]>(() => {
|
const laneTabs = useMemo<LaneTab[]>(() => {
|
||||||
const tabs: LaneTab[] = [];
|
const tabs: LaneTab[] = [];
|
||||||
if (config?.entry_modules) {
|
if (config?.entry_modules && config.entry_modules.length > 0) {
|
||||||
config.entry_modules.forEach((m) => {
|
config.entry_modules.forEach((m) => {
|
||||||
tabs.push({
|
tabs.push({
|
||||||
key: `entry-${m.id}`,
|
key: `entry-${m.id || (m as any).modulo_id}`,
|
||||||
moduleId: m.id,
|
moduleId: m.id || (m as any).modulo_id,
|
||||||
direction: 'ENTRY',
|
direction: 'ENTRY',
|
||||||
name: m.name,
|
name: m.name || (m as any).nombre || 'ENTRADA VISITAS',
|
||||||
address: m.address,
|
address: m.address,
|
||||||
tipo_acceso_nombre: m.tipo_acceso_nombre,
|
tipo_acceso_nombre: m.tipo_acceso_nombre,
|
||||||
es_acceso_peatonal: m.es_acceso_peatonal,
|
es_acceso_peatonal: m.es_acceso_peatonal,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (config?.exit_modules) {
|
if (config?.exit_modules && config.exit_modules.length > 0) {
|
||||||
config.exit_modules.forEach((m) => {
|
config.exit_modules.forEach((m) => {
|
||||||
tabs.push({
|
tabs.push({
|
||||||
key: `exit-${m.id}`,
|
key: `exit-${m.id || (m as any).modulo_id}`,
|
||||||
moduleId: m.id,
|
moduleId: m.id || (m as any).modulo_id,
|
||||||
direction: 'EXIT',
|
direction: 'EXIT',
|
||||||
name: m.name,
|
name: m.name || (m as any).nombre || 'SALIDA VISITAS',
|
||||||
address: m.address,
|
address: m.address,
|
||||||
tipo_acceso_nombre: m.tipo_acceso_nombre,
|
tipo_acceso_nombre: m.tipo_acceso_nombre,
|
||||||
es_acceso_peatonal: m.es_acceso_peatonal,
|
es_acceso_peatonal: m.es_acceso_peatonal,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback garantizado: si la estación actual no tiene módulos asignados en DB o está cargando,
|
||||||
|
// mostrar siempre los carriles virtuales de Entrada y Salida para que el operador pueda trabajar
|
||||||
|
if (tabs.length === 0) {
|
||||||
|
tabs.push({
|
||||||
|
key: 'entry-default',
|
||||||
|
moduleId: 100009,
|
||||||
|
direction: 'ENTRY',
|
||||||
|
name: 'ENTRADA VISITAS',
|
||||||
|
address: 90,
|
||||||
|
tipo_acceso_nombre: 'Barrera Pulso',
|
||||||
|
es_acceso_peatonal: false,
|
||||||
|
});
|
||||||
|
tabs.push({
|
||||||
|
key: 'exit-default',
|
||||||
|
moduleId: 100010,
|
||||||
|
direction: 'EXIT',
|
||||||
|
name: 'SALIDA VISITAS',
|
||||||
|
address: 91,
|
||||||
|
tipo_acceso_nombre: 'Barrera Pulso',
|
||||||
|
es_acceso_peatonal: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return tabs;
|
return tabs;
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
||||||
@@ -1155,26 +1179,13 @@ export const ControlPostView: React.FC = () => {
|
|||||||
<main className="desktop-main-area">
|
<main className="desktop-main-area">
|
||||||
{/* Cabecera Superior: Tabs Entrada/Salida + Reloj + Menú Hamburguesa (☰) */}
|
{/* Cabecera Superior: Tabs Entrada/Salida + Reloj + Menú Hamburguesa (☰) */}
|
||||||
<header className="desktop-top-header">
|
<header className="desktop-top-header">
|
||||||
{/* Pestañas de Carriles: ENTRADA VISITAS / SALIDA DE VISITAS */}
|
{/* Pestañas de Carriles: Módulos Virtuales Asociados */}
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem', overflowX: 'auto', scrollbarWidth: 'none' }}>
|
||||||
{laneTabs.map((tab) => {
|
{laneTabs.map((tab) => {
|
||||||
const isActive = tab.key === activeLaneTabKey;
|
const isActive = tab.key === activeLaneTabKey;
|
||||||
const isEntry = tab.direction === 'ENTRY';
|
const isEntry = tab.direction === 'ENTRY';
|
||||||
const dotColor = isEntry ? '#10B981' : '#EF4444';
|
const dotColor = isEntry ? '#10B981' : '#EF4444';
|
||||||
let tabLabel = isEntry ? 'ENTRADA VISITAS' : 'SALIDA DE VISITAS';
|
const tabLabel = tab.name ? tab.name.toUpperCase() : (isEntry ? 'ENTRADA VISITAS' : 'SALIDA DE VISITAS');
|
||||||
if (tab.name) {
|
|
||||||
const norm = tab.name.trim().toUpperCase();
|
|
||||||
if (
|
|
||||||
norm !== 'ENTRADA' &&
|
|
||||||
norm !== 'SALIDA' &&
|
|
||||||
norm !== 'ENTRADA VISITAS' &&
|
|
||||||
norm !== 'SALIDA DE VISITAS' &&
|
|
||||||
!norm.includes('ENTRADA') &&
|
|
||||||
!norm.includes('SALIDA')
|
|
||||||
) {
|
|
||||||
tabLabel += ` (${tab.name})`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
@@ -1191,9 +1202,10 @@ export const ControlPostView: React.FC = () => {
|
|||||||
backgroundColor: dotColor,
|
backgroundColor: dotColor,
|
||||||
boxShadow: isActive ? `0 0 8px ${dotColor}` : 'none',
|
boxShadow: isActive ? `0 0 8px ${dotColor}` : 'none',
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
|
flexShrink: 0,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span>{tabLabel}</span>
|
<span style={{ whiteSpace: 'nowrap' }}>{tabLabel}</span>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user