add lua navigation
This commit is contained in:
@@ -35,19 +35,19 @@
|
||||
<div class="home-content">
|
||||
<div class="app-grid">
|
||||
<!-- Row 1 -->
|
||||
<div class="app-icon">
|
||||
<div class="app-icon" onclick="navigateTo('dialer')">
|
||||
<div class="app-icon-image" style="background-color: #4CAF50;">P</div>
|
||||
<span class="app-icon-label">Phone</span>
|
||||
</div>
|
||||
<div class="app-icon">
|
||||
<div class="app-icon" onclick="navigateTo('messages')">
|
||||
<div class="app-icon-image" style="background-color: #2196F3;">M</div>
|
||||
<span class="app-icon-label">Messages</span>
|
||||
</div>
|
||||
<div class="app-icon">
|
||||
<div class="app-icon" onclick="navigateTo('contacts')">
|
||||
<div class="app-icon-image" style="background-color: #FF9800;">C</div>
|
||||
<span class="app-icon-label">Contacts</span>
|
||||
</div>
|
||||
<div class="app-icon">
|
||||
<div class="app-icon" onclick="navigateTo('browser')">
|
||||
<div class="app-icon-image" style="background-color: #F44336;">B</div>
|
||||
<span class="app-icon-label">Browser</span>
|
||||
</div>
|
||||
@@ -61,7 +61,7 @@
|
||||
<div class="app-icon-image" style="background-color: #00BCD4;">C</div>
|
||||
<span class="app-icon-label">Camera</span>
|
||||
</div>
|
||||
<div class="app-icon">
|
||||
<div class="app-icon" onclick="navigateTo('settings')">
|
||||
<div class="app-icon-image" style="background-color: #607D8B;">S</div>
|
||||
<span class="app-icon-label">Settings</span>
|
||||
</div>
|
||||
@@ -110,10 +110,10 @@
|
||||
|
||||
<!-- Dock -->
|
||||
<div class="dock">
|
||||
<div class="dock-item" style="background-color: #4CAF50;">P</div>
|
||||
<div class="dock-item" style="background-color: #2196F3;">M</div>
|
||||
<div class="dock-item" style="background-color: #FF9800;">C</div>
|
||||
<div class="dock-item" style="background-color: #F44336;">B</div>
|
||||
<div class="dock-item" style="background-color: #4CAF50;" onclick="navigateTo('dialer')">P</div>
|
||||
<div class="dock-item" style="background-color: #2196F3;" onclick="navigateTo('messages')">M</div>
|
||||
<div class="dock-item" style="background-color: #FF9800;" onclick="navigateTo('contacts')">C</div>
|
||||
<div class="dock-item" style="background-color: #F44336;" onclick="navigateTo('browser')">B</div>
|
||||
</div>
|
||||
</body>
|
||||
</rml>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<link type="text/rcss" href="../ui/theme.rcss"/>
|
||||
<link type="text/rcss" href="../ui/components.rcss"/>
|
||||
<script src="../scripts/navigation.lua"></script>
|
||||
<title>Browser</title>
|
||||
<style>
|
||||
.browser-screen {
|
||||
@@ -172,7 +173,7 @@
|
||||
|
||||
<!-- Browser Toolbar -->
|
||||
<div class="browser-toolbar">
|
||||
<div class="browser-nav-btn" onclick="navigateTo('home')">←</div>
|
||||
<div class="browser-nav-btn" onclick="goBack()">←</div>
|
||||
<div class="browser-nav-btn disabled">→</div>
|
||||
<div class="browser-url-bar">
|
||||
<span class="browser-secure-icon">L</span>
|
||||
@@ -211,7 +212,7 @@
|
||||
|
||||
<!-- Bottom Bar -->
|
||||
<div class="browser-bottom-bar">
|
||||
<div class="browser-tab-btn" onclick="navigateTo('home')">
|
||||
<div class="browser-tab-btn" onclick="goHome()">
|
||||
<span class="browser-tab-icon">H</span>
|
||||
<span class="browser-tab-label">Home</span>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<link type="text/rcss" href="../ui/theme.rcss"/>
|
||||
<link type="text/rcss" href="../ui/components.rcss"/>
|
||||
<script src="../scripts/navigation.lua"></script>
|
||||
<title>Contacts</title>
|
||||
<style>
|
||||
.contacts-screen {
|
||||
@@ -70,7 +71,7 @@
|
||||
<body class="contacts-screen">
|
||||
<!-- App Bar -->
|
||||
<div class="app-bar">
|
||||
<div class="btn-icon" onclick="navigateTo('home')">←</div>
|
||||
<div class="btn-icon" onclick="goBack()">←</div>
|
||||
<span class="app-bar-title">Contacts</span>
|
||||
<div class="btn-icon">+</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<link type="text/rcss" href="../ui/theme.rcss"/>
|
||||
<link type="text/rcss" href="../ui/components.rcss"/>
|
||||
<script src="../scripts/navigation.lua"></script>
|
||||
<script src="../scripts/phone.lua"></script>
|
||||
<title>Phone</title>
|
||||
<style>
|
||||
@@ -106,7 +107,7 @@
|
||||
<body class="dialer-screen">
|
||||
<!-- App Bar -->
|
||||
<div class="app-bar">
|
||||
<div class="btn-icon" onclick="navigateTo('home')">←</div>
|
||||
<div class="btn-icon" onclick="goBack()">←</div>
|
||||
<span class="app-bar-title">Phone</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<link type="text/rcss" href="../ui/theme.rcss"/>
|
||||
<link type="text/rcss" href="../ui/components.rcss"/>
|
||||
<script src="../scripts/navigation.lua"></script>
|
||||
<title>Lock Screen</title>
|
||||
<style>
|
||||
.lock-screen {
|
||||
@@ -124,7 +125,7 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="lock-screen" onclick="navigateTo('home')">
|
||||
<body class="lock-screen" onclick="goHome()">
|
||||
<!-- Status Bar -->
|
||||
<div class="status-bar">
|
||||
<span class="status-bar-time">12:30</span>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<link type="text/rcss" href="../ui/theme.rcss"/>
|
||||
<link type="text/rcss" href="../ui/components.rcss"/>
|
||||
<script src="../scripts/navigation.lua"></script>
|
||||
<title>Messages</title>
|
||||
<style>
|
||||
.messages-screen {
|
||||
@@ -130,7 +131,7 @@
|
||||
<body class="messages-screen">
|
||||
<!-- App Bar -->
|
||||
<div class="app-bar">
|
||||
<div class="btn-icon" onclick="navigateTo('home')">←</div>
|
||||
<div class="btn-icon" onclick="goBack()">←</div>
|
||||
<span class="app-bar-title">Messages</span>
|
||||
<div class="btn-icon">Q</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<link type="text/rcss" href="../ui/theme.rcss"/>
|
||||
<link type="text/rcss" href="../ui/components.rcss"/>
|
||||
<script src="../scripts/navigation.lua"></script>
|
||||
<title>Settings</title>
|
||||
<style>
|
||||
.settings-screen {
|
||||
@@ -148,7 +149,7 @@
|
||||
<body class="settings-screen">
|
||||
<!-- App Bar -->
|
||||
<div class="app-bar">
|
||||
<div class="btn-icon" onclick="navigateTo('home')">←</div>
|
||||
<div class="btn-icon" onclick="goBack()">←</div>
|
||||
<span class="app-bar-title">Settings</span>
|
||||
<div class="btn-icon">Q</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- Navigation System for Virtual Smartphone
|
||||
-- Handles screen transitions and state management
|
||||
|
||||
-- Screen registry
|
||||
-- Screen registry - maps screen names to RML file paths
|
||||
local screens = {
|
||||
home = "screens/home.rml",
|
||||
home = "demo.rml",
|
||||
lock = "screens/lock.rml",
|
||||
dialer = "screens/dialer.rml",
|
||||
contacts = "screens/contacts.rml",
|
||||
@@ -12,33 +12,59 @@ local screens = {
|
||||
browser = "screens/browser.rml"
|
||||
}
|
||||
|
||||
-- Current screen state
|
||||
local current_screen = "home"
|
||||
local screen_history = {}
|
||||
-- Navigation history stack
|
||||
local history = {}
|
||||
|
||||
-- Navigate to a screen
|
||||
-- Current screen name
|
||||
local current_screen = "home"
|
||||
|
||||
-- Navigate to a screen by name
|
||||
function navigateTo(screen_name)
|
||||
if screens[screen_name] then
|
||||
-- Add current screen to history
|
||||
table.insert(screen_history, current_screen)
|
||||
local path = screens[screen_name]
|
||||
if path then
|
||||
-- Push current screen to history before navigating
|
||||
table.insert(history, current_screen)
|
||||
current_screen = screen_name
|
||||
|
||||
-- Load the new document
|
||||
-- Note: In RmlUi, we'd typically use document loading
|
||||
print("Navigating to: " .. screen_name)
|
||||
-- Load the new screen using C++ function
|
||||
local success = loadScreen(path)
|
||||
if success then
|
||||
print("Navigated to: " .. screen_name)
|
||||
else
|
||||
-- Restore previous state on failure
|
||||
current_screen = table.remove(history)
|
||||
print("Failed to navigate to: " .. screen_name)
|
||||
end
|
||||
return success
|
||||
else
|
||||
print("Unknown screen: " .. screen_name)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Go back to previous screen
|
||||
function goBack()
|
||||
if #screen_history > 0 then
|
||||
current_screen = table.remove(screen_history)
|
||||
print("Going back to: " .. current_screen)
|
||||
if #history > 0 then
|
||||
local previous = table.remove(history)
|
||||
local path = screens[previous]
|
||||
if path then
|
||||
current_screen = previous
|
||||
loadScreen(path)
|
||||
print("Back to: " .. previous)
|
||||
return true
|
||||
end
|
||||
else
|
||||
print("No history to go back to")
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Go to home screen (clear history)
|
||||
function goHome()
|
||||
history = {}
|
||||
current_screen = "home"
|
||||
loadScreen(screens.home)
|
||||
print("Navigated to home")
|
||||
end
|
||||
|
||||
-- Get current screen name
|
||||
@@ -46,9 +72,19 @@ function getCurrentScreen()
|
||||
return current_screen
|
||||
end
|
||||
|
||||
-- Check if we can go back
|
||||
function canGoBack()
|
||||
return #history > 0
|
||||
end
|
||||
|
||||
-- Clear navigation history
|
||||
function clearHistory()
|
||||
screen_history = {}
|
||||
history = {}
|
||||
end
|
||||
|
||||
-- Get history depth
|
||||
function getHistoryDepth()
|
||||
return #history
|
||||
end
|
||||
|
||||
print("Navigation system initialized")
|
||||
|
||||
Reference in New Issue
Block a user