--[[ @module tsb_light_page @summary 亮度演示页面 @version 1.0 @date 2026.03.04 @author 李一玮 @usage 本文件是亮度演示页面,展示亮度的各种用法。 ]] local tsb_light_page = {} -- 页面UI元素 local main_container = nil local common_ui = require("tsb_common_page") -- 创建UI function tsb_light_page.create_ui() main_container = airui.container({ x = 0, y = 0, w = 480, h = 320, color = 0xF5F5F5, }) --------------------- 标题栏 ------------------------ local title_bar = airui.container({ parent = main_container, x = 0, y = 0, w = 480, h = 30, color = 0xF2E2C5, }) airui.label({ parent = title_bar, text = "亮度管理", x = 190, y = 8, w = 100, h = 20, font_size = 16, color = 0xFFFFFF, }) -- 标题栏公共信息展示 common_ui.add_battery_display(title_bar) common_ui.create_back_button(title_bar, tsb_light_page.cleanup) --------------------------------------------------- -- 滚动容器 local scroll_container = airui.container({ parent = main_container, x = 0, y = 30, w = 480, h = 270, color = 0xFFFFFF, }) --------------------- 屏幕亮度控制 ------------------------ -- 亮度标签 airui.label({ parent = scroll_container, text = "屏幕亮度控制", x = 180, y = 50, w = 100, h = 30, font_size = 16, }) -- 亮度进度条 local brightness_bar = airui.bar({ parent = scroll_container, x = 20, y = 90, w = 440, h = 20, value = 50, min = 10, max = 100, radius = 5, show_progress_text = true, indicator_color = 0x2196F3, progress_text_format = "%d%%", }) -- 亮度控制按钮 -- 降低亮度按钮 local decrease_brightness_btn = airui.button({ parent = scroll_container, x = 100, y = 140, w = 110, h = 40, text = "降低亮度", on_click = function(self) local current = brightness_bar:get_value() if current > 10 then current = current - 10 brightness_bar:set_value(current, true) brightness_value_label:set_text(current .. "%") log.info("set_brightness", "亮度降低到:" .. current .. "%") end end }) -- 提升亮度按钮 local increase_brightness_btn = airui.button({ parent = scroll_container, x = 280, y = 140, w = 110, h = 40, text = "提升亮度", on_click = function(self) local current = brightness_bar:get_value() if current < 100 then current = current + 10 brightness_bar:set_value(current, true) brightness_value_label:set_text(current .. "%") log.info("set_brightness", "亮度提升到:" .. current .. "%") end end }) --------------------------------------------------- -- 底部信息 common_ui.create_status_bar(main_container) end -- 初始化页面 function tsb_light_page.init(params) tsb_light_page.create_ui() end -- 清理页面 function tsb_light_page.cleanup() if main_container then main_container:destroy() main_container = nil end end return tsb_light_page