TimePickerSheetBuilder

class TimePickerSheetBuilder(title: String = "请选择", value: Int = 0, start: Int = 0, endInclude: Int = 86399, textStyle: TextStyle = AppText.Normal.Title.default, mode: TimePickerMode = TimePickerMode.HMS, itemText: (Int, String) -> String = { _, item -> item }, cancelText: String = "取消", confirmText: String = "确定", onCancelClick: suspend CoroutineScope.() -> Boolean = { true }, onConfirmClick: suspend CoroutineScope.(Int, List<Int>) -> Boolean = { _, _ -> true }) : SheetBuilder

时间选择器底部弹窗构建器

从底部弹出的时间选择面板,包含标题栏(取消/确定按钮)和时间滚轮选择器。 支持时分秒多种选择模式,可配置时间范围。 时间值以一天内的秒数表示(0~86399)。 确认后通过 onConfirmClick 回调返回选中的秒数值和各分量列表。

可在展示前通过 setCurrentTime 方法将选中时间设置为指定时间戳对应的时分秒。

Author

d10ng

Parameters

title

标题文字,默认 "请选择"

value

当前选中的时间,以一天内的秒数表示(0~86399),默认 0(即 00:00:00)

start

可选时间范围的起始秒数,默认 0

endInclude

可选时间范围的结束秒数(包含),默认 86399(即 23:59:59)

textStyle

选项文字样式,默认 AppText.Normal.Title.default

mode

选择器模式(时分秒组合),默认 TimePickerMode.HMS

itemText

选项文字自定义函数,第一个参数为列索引,第二个为默认文字

cancelText

取消按钮文字,默认 "取消"

confirmText

确定按钮文字,默认 "确定"

onCancelClick

取消按钮点击回调,返回 true 则自动关闭弹窗

onConfirmClick

确定按钮点击回调,第一个参数为选中的秒数值,第二个参数为时/分/秒分量列表,返回 true 则自动关闭弹窗

Constructors

Link copied to clipboard
constructor(title: String = "请选择", value: Int = 0, start: Int = 0, endInclude: Int = 86399, textStyle: TextStyle = AppText.Normal.Title.default, mode: TimePickerMode = TimePickerMode.HMS, itemText: (Int, String) -> String = { _, item -> item }, cancelText: String = "取消", confirmText: String = "确定", onCancelClick: suspend CoroutineScope.() -> Boolean = { true }, onConfirmClick: suspend CoroutineScope.(Int, List<Int>) -> Boolean = { _, _ -> true })

Properties

Link copied to clipboard
Link copied to clipboard
var topMargin: @Composable () -> Dp
Link copied to clipboard
val visibleFlow: MutableStateFlow<Boolean>

Functions

Link copied to clipboard
open override fun Build()

构建弹窗内容

Link copied to clipboard
fun dismiss()

隐藏弹窗

Link copied to clipboard
fun setCurrentTime(timestamp: Long = Clock.System.now().toEpochMilliseconds())

设置选择当前时间

Link copied to clipboard
fun SheetBuilder.TitleBar(title: String = "请选择", cancelText: String = "取消", confirmText: String = "确定", onCancelClick: suspend CoroutineScope.() -> Boolean = { true }, onConfirmClick: suspend CoroutineScope.() -> Boolean = { true })

弹窗标题栏