import QtQuick 1.0
import QtQuick.Controls 1.0
import MeeGo 1.0

ApplicationWindow {
    id: appWindow
    visible: true
    width: 400
    height: 600

    property string instanceUrl: "https://cmx-im.000010086.xyz"
    property variant timelineData: [] // 使用 variant 来存储时间线数据

    PageStack {
        id: pageStack
        anchors.fill: parent

        Page {
            id: previewPage
            anchors.fill: parent
            color: "lightgray"

            Column {
                anchors.fill: parent
                spacing: 10

                Text {
                    text: "Public Timeline of " + appWindow.instanceUrl
                    font.bold: true
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                // 显示时间线内容
                ListView {
                    id: timelineView
                    anchors.fill: parent
                    model: appWindow.timelineData

                    delegate: Item {
                        width: timelineView.width
                        height: 50

                        Text {
                            text: modelData
                            anchors.verticalCenter: parent.verticalCenter
                        }
                    }
                }

                Row {
                    anchors.horizontalCenter: parent.horizontalCenter
                    spacing: 10

                    Button {
                        text: "Login"
                        onClicked: {
                            // 跳转到登录页面 (未实现)
                        }
                    }

                    Button {
                        text: "Change Instance"
                        onClicked: {
                            // 在这里可以实现切换实例地址的逻辑
                        }
                    }
                }
            }
        }
    }
}
