Implement pageLoader history + CreateRoom cancel

This commit is contained in:
miruka 2019-11-08 15:56:20 -04:00
parent ad34d2d171
commit b53acb3113
3 changed files with 32 additions and 0 deletions

View File

@ -34,6 +34,7 @@
- When qml syntax highlighting supports ES6 string interpolation, use that - When qml syntax highlighting supports ES6 string interpolation, use that
- Fixes - Fixes
- General way to show pages as loading until account is ready
- `code` not colored in room subtitle - `code` not colored in room subtitle
- In the "Leave me" room, "join > Hi > left" aren't combined - In the "Leave me" room, "join > Hi > left" aren't combined
- Event delegates changing height don't scroll the list - Event delegates changing height don't scroll the list

View File

@ -31,6 +31,16 @@ HBox {
pageLoader.showRoom(userId, roomId) pageLoader.showRoom(userId, roomId)
}) })
}, },
cancel: button => {
nameField.text = ""
topicField.text = ""
publicCheckBox.checked = false
encryptCheckBox.checked = false
blockOtherServersCheckBox.checked = false
pageLoader.showPrevious()
}
}) })

View File

@ -85,8 +85,13 @@ Item {
HLoader { HLoader {
id: pageLoader id: pageLoader
property bool isWide: width > theme.contentIsWideAbove property bool isWide: width > theme.contentIsWideAbove
// List of previously loaded [componentUrl, {properties}]
property var history: []
property int historyLength: 20
Component.onCompleted: { Component.onCompleted: {
if (! py.startupAnyAccountsSaved) { if (! py.startupAnyAccountsSaved) {
pageLoader.showPage("SignIn") pageLoader.showPage("SignIn")
@ -104,6 +109,9 @@ Item {
} }
function _show(componentUrl, properties={}) { function _show(componentUrl, properties={}) {
history.unshift([componentUrl, properties])
if (history.length > historyLength) history.pop()
pageLoader.setSource(componentUrl, properties) pageLoader.setSource(componentUrl, properties)
} }
@ -124,6 +132,19 @@ Item {
window.uiStateChanged() window.uiStateChanged()
} }
function showPrevious(timesBack=1) {
timesBack = Math.min(timesBack, history.length - 1)
if (timesBack < 1) return
let [componentUrl, properties] = history[timesBack]
_show(componentUrl, properties)
window.uiState.page = componentUrl
window.uiState.pageProperties = properties
window.uiStateChanged()
}
onStatusChanged: if (status == Loader.Ready) { onStatusChanged: if (status == Loader.Ready) {
item.forceActiveFocus() item.forceActiveFocus()
appearAnimation.start() appearAnimation.start()