--[[ @module tsb_wlan_page @summary 网络配置页面 @version 1.0 @date 2026.03.17 @author 李一玮 @usage 本文件是网络配置页面,展示网络配置的各种用法。 ]] local tsb_wlan_page = {} -- 页面UI元素 local main_container = nil local common_ui = require("tsb_common_page") -- 创建UI function tsb_wlan_page.create_ui() main_container = airui.container({ x = 0, y = 0, w = 480, h = 320, color = 0xFFFFFF, }) --------------------- 标题栏 ------------------------ local title_bar = airui.container({ parent = main_container, x = 0, y = 0, w = 480, h = 30, color = 0xCE93D8, }) airui.label({ parent = title_bar, text = "网络设置", x = 200, y = 10, w = 80, h = 20, font_size = 16, color = 0xFFFFFF, }) -- 标题栏公共信息展示 common_ui.add_battery_display(title_bar) common_ui.create_back_button(title_bar, tsb_wlan_page.cleanup) --------------------------------------------------- -- 滚动容器 local scroll_container = airui.container({ parent = main_container, x = 0, y = 30, w = 480, h = 260, color = 0xFFFFFF, }) local keyboard1 = airui.keyboard({ x = 0, y = 0, w = 480, h = 160, -- x, y, 键盘默认打开ALIGN_BOTTOM_MID,位置从中下方开始计算 mode = "lower", -- 键盘模式,可选 "text"/"upper"/"lower"/"numeric" auto_hide = true, -- 自动隐藏键盘 bg_color = 0xf1f1f1, -- 键盘背景颜色为灰色,可选,不设置则透明 on_commit = function() -- 确认事件回调,只有在按下确认键时才会触发 log.info("keyboard", "commit") end }) --------------------- 4G网络配置 ------------------------ -- 4G网络容器 local network4g_container = airui.container({ parent = scroll_container, x = 20, y = 10, w = 440, h = 80, color = 0xF5F5F5, radius = 8, }) -- 4G网络标题 airui.label({ parent = network4g_container, text = "4G网络配置", x = 10, y = 10, w = 120, h = 30, font_size = 16, color = 0xCE93D8, }) -- 4G开关标签 airui.label({ parent = network4g_container, text = "4G网络:", x = 10, y = 40, w = 80, h = 30, font_size = 14, }) -- 4G开关状态 local network4g_status = airui.label({ parent = network4g_container, text = "开启", x = 80, y = 40, w = 60, h = 30, font_size = 14, color = 0x4CAF50, }) -- 4G开关按钮 local network4g_switch = airui.button({ parent = network4g_container, x = 350, y = 40, w = 80, h = 30, text = "关闭", on_click = function(self) local current_status = network4g_status:get_text() if current_status == "开启" then network4g_status:set_text("关闭") network4g_status:set_color(0xF44336) self:set_text("开启") log.info("set_4g", "关闭4G网络") -- 这里可以添加关闭4G网络的逻辑 else network4g_status:set_text("开启") network4g_status:set_color(0x4CAF50) self:set_text("关闭") log.info("set_4g", "开启4G网络") -- 这里可以添加开启4G网络的逻辑 end end }) --------------------------------------------------- --------------------- WIFI配置 ------------------------ -- WIFI配置容器 local wifi_container = airui.container({ parent = scroll_container, x = 20, y = 100, w = 440, h = 160, color = 0xF5F5F5, radius = 8, }) -- WIFI配置标题 airui.label({ parent = wifi_container, text = "WIFI配置", x = 10, y = 10, w = 100, h = 30, font_size = 16, color = 0xCE93D8, }) -- WIFI开关标签 airui.label({ parent = wifi_container, text = "WIFI:", x = 10, y = 40, w = 60, h = 30, font_size = 14, }) -- WIFI开关状态 local wifi_status = airui.label({ parent = wifi_container, text = "开启", x = 80, y = 40, w = 60, h = 30, font_size = 14, color = 0x4CAF50, }) -- WIFI开关按钮 local wifi_switch = airui.button({ parent = wifi_container, x = 350, y = 40, w = 80, h = 30, text = "关闭", on_click = function(self) local current_status = wifi_status:get_text() if current_status == "开启" then wifi_status:set_text("关闭") wifi_status:set_color(0xF44336) self:set_text("开启") log.info("set_wifi", "关闭WIFI") -- 这里可以添加关闭WIFI的逻辑 else wifi_status:set_text("开启") wifi_status:set_color(0x4CAF50) self:set_text("关闭") log.info("set_wifi", "开启WIFI") -- 这里可以添加开启WIFI的逻辑 end end }) -- WIFI名称标签 airui.label({ parent = wifi_container, text = "WIFI名称:", x = 10, y = 80, w = 100, h = 30, font_size = 14, }) -- WIFI名称输入框 local wifi_name_input = airui.textarea({ parent = wifi_container, x = 110, y = 80, w = 200, h = 30, text = "", keyboard = keyboard1 }) -- WIFI密码标签 airui.label({ parent = wifi_container, text = "WIFI密码:", x = 10, y = 120, w = 100, h = 30, font_size = 14, }) -- WIFI密码输入框 local wifi_password_input = airui.textarea({ parent = wifi_container, x = 110, y = 120, w = 200, h = 30, text = "", keyboard = keyboard1 }) -- 连接按钮 local connect_wifi_btn = airui.button({ parent = wifi_container, x = 320, y = 90, w = 100, h = 40, text = "连接", on_click = function(self) local wifi_name = wifi_name_input:get_text() local wifi_password = wifi_password_input:get_text() log.info("set_wifi", "连接WIFI:" .. wifi_name) -- 这里可以添加连接WIFI的逻辑 end }) --------------------------------------------------- --------------------- 网络状态 ------------------------ -- 网络状态容器 local network_status_container = airui.container({ parent = scroll_container, x = 20, y = 280, w = 440, h = 100, color = 0xF5F5F5, radius = 8, }) -- 网络状态标题 airui.label({ parent = network_status_container, text = "网络状态", x = 10, y = 10, w = 100, h = 30, font_size = 16, color = 0xCE93D8, }) -- IP地址标签 airui.label({ parent = network_status_container, text = "IP地址:", x = 10, y = 40, w = 80, h = 30, font_size = 14, }) -- IP地址值 airui.label({ parent = network_status_container, text = "192.168.1.100", x = 100, y = 40, w = 200, h = 30, font_size = 14, }) -- 信号强度标签 airui.label({ parent = network_status_container, text = "信号强度:", x = 10, y = 70, w = 80, h = 30, font_size = 14, }) -- 信号强度值 airui.label({ parent = network_status_container, text = "90%", x = 100, y = 70, w = 50, h = 30, font_size = 14, }) --------------------------------------------------- -- 底部信息 common_ui.create_status_bar(main_container) end -- 初始化页面 function tsb_wlan_page.init(params) tsb_wlan_page.create_ui() end -- 清理页面 function tsb_wlan_page.cleanup() if main_container then main_container:destroy() main_container = nil end end return tsb_wlan_page