mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
feat(StateView): add auto-switch functionality for loading state
This commit is contained in:
@@ -14,10 +14,24 @@ Item {
|
||||
property int viewState: StateView.State.Loading
|
||||
property string errorText: "Something went wrong."
|
||||
property bool retryable: true
|
||||
property bool autoSwitchContent: true
|
||||
property int autoSwitchDelay: 500
|
||||
property alias contentItem: contentSlot.data
|
||||
|
||||
|
||||
signal retryRequested()
|
||||
|
||||
|
||||
Timer {
|
||||
id: autoSwitchTimer
|
||||
interval: root.autoSwitchDelay
|
||||
repeat: false
|
||||
running: root.autoSwitchContent && root.viewState === StateView.State.Loading
|
||||
|
||||
onTriggered: root.viewState = StateView.State.Content
|
||||
}
|
||||
|
||||
|
||||
|
||||
StackLayout {
|
||||
anchors.fill: parent
|
||||
currentIndex: root.viewState
|
||||
|
||||
Reference in New Issue
Block a user