basic ui elements

This commit is contained in:
2026-01-15 23:52:09 +01:00
parent b56f667a3a
commit ebf80052f0
13 changed files with 2655 additions and 33 deletions

View File

@@ -0,0 +1,54 @@
-- Navigation System for Virtual Smartphone
-- Handles screen transitions and state management
-- Screen registry
local screens = {
home = "screens/home.rml",
lock = "screens/lock.rml",
dialer = "screens/dialer.rml",
contacts = "screens/contacts.rml",
messages = "screens/messages.rml",
settings = "screens/settings.rml",
browser = "screens/browser.rml"
}
-- Current screen state
local current_screen = "home"
local screen_history = {}
-- Navigate to a screen
function navigateTo(screen_name)
if screens[screen_name] then
-- Add current screen to history
table.insert(screen_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)
else
print("Unknown screen: " .. screen_name)
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)
else
print("No history to go back to")
end
end
-- Get current screen name
function getCurrentScreen()
return current_screen
end
-- Clear navigation history
function clearHistory()
screen_history = {}
end
print("Navigation system initialized")

80
assets/scripts/phone.lua Normal file
View File

@@ -0,0 +1,80 @@
-- Phone/Dialer functionality for Virtual Smartphone
-- Dial pad state
local dial_number = ""
local max_digits = 15
-- Add a digit to the dial display
function dialPress(digit)
if #dial_number < max_digits then
dial_number = dial_number .. digit
updateDialDisplay()
print("Dialed: " .. digit .. " | Number: " .. dial_number)
end
end
-- Clear the last digit
function dialBackspace()
if #dial_number > 0 then
dial_number = dial_number:sub(1, -2)
updateDialDisplay()
print("Backspace | Number: " .. dial_number)
end
end
-- Clear all digits
function dialClear()
dial_number = ""
updateDialDisplay()
print("Cleared dial pad")
end
-- Update the dial display element
function updateDialDisplay()
local display = document:GetElementById("dial-display")
if display then
-- Format number with dashes for readability
local formatted = formatPhoneNumber(dial_number)
display.inner_rml = formatted
end
end
-- Format phone number for display
function formatPhoneNumber(number)
local len = #number
if len == 0 then
return ""
elseif len <= 3 then
return number
elseif len <= 6 then
return number:sub(1, 3) .. "-" .. number:sub(4)
elseif len <= 10 then
return "(" .. number:sub(1, 3) .. ") " .. number:sub(4, 6) .. "-" .. number:sub(7)
else
return "+1 (" .. number:sub(1, 3) .. ") " .. number:sub(4, 6) .. "-" .. number:sub(7, 10)
end
end
-- Make a call (simulated)
function makeCall()
if #dial_number > 0 then
print("Calling: " .. dial_number)
-- In a real app, this would initiate a call
-- For now, just show feedback
else
print("No number to call")
end
end
-- End a call (simulated)
function endCall()
print("Call ended")
dialClear()
end
-- Get the current dial number
function getDialNumber()
return dial_number
end
print("Phone system initialized")