2020-10-19 13:20:02 +03:00
/ *
2020-10-19 20:34:47 +03:00
Copyright ( C ) 2020 Sebastian J . Wolf and other contributors
2020-10-19 13:20:02 +03:00
This file is part of Fernschreiber .
Fernschreiber is free software: you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Fernschreiber is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Fernschreiber . If not , see < http: //www.gnu.org/licenses/>.
* /
import QtQuick 2.6
import Sailfish . Silica 1.0
import "./"
import "../"
import "../../pages"
Item {
id: tabViewItem
property alias count: tabView . count
height: Screen . width
opacity: count > 0 ? 1.0 : 0.0
Behavior on height { PropertyAnimation { duration: 300 } }
Behavior on opacity { PropertyAnimation { duration: 300 } }
Item {
id: tabViewHeader
/ *
2020-10-19 22:06:28 +03:00
* Tab view was prepared for
* shared media / links / … , but for this
2020-10-19 13:20:02 +03:00
* we need message search with filters
* /
height: visible ? headerGrid.height : 0
clip: true
2020-11-03 00:51:12 +03:00
visible: tabView . count > 0
2020-10-19 13:20:02 +03:00
anchors {
left: parent . left
right: parent . right
top: parent . top
}
Grid {
id: headerGrid
width: parent . width
columns: tabView . count
Repeater {
2020-11-16 23:38:55 +03:00
model: tabModel
2020-10-19 13:20:02 +03:00
delegate: BackgroundItem {
id: headerItem
2020-11-16 23:38:55 +03:00
property bool loaded: image !== "" && title !== ""
2020-10-19 13:20:02 +03:00
width: loaded ? ( headerGrid . width / tabView . count ) : 0
opacity: loaded ? 1.0 : 0.0
2020-11-17 12:09:06 +03:00
Behavior on opacity { FadeAnimation { } }
2020-10-19 13:20:02 +03:00
height: Theme . itemSizeLarge
property int itemIndex: index
2020-11-16 23:38:55 +03:00
property bool itemIsActive: tabView . currentIndex === itemIndex
2020-10-19 13:20:02 +03:00
Icon {
id: headerIcon
2020-11-16 23:38:55 +03:00
source: image
2020-10-19 13:20:02 +03:00
highlighted: headerItem . pressed || headerItem . itemIsActive
anchors {
top: parent . top
horizontalCenter: parent . horizontalCenter
}
}
Label {
2020-11-16 23:38:55 +03:00
text: title
2020-10-19 13:20:02 +03:00
width: parent . width
horizontalAlignment: Text . AlignHCenter
anchors.top: headerIcon . bottom
highlighted: headerItem . pressed || headerItem . itemIsActive
font.pixelSize: Theme . fontSizeTiny
}
onClicked: {
2020-11-16 23:38:55 +03:00
pageContent . scrollDown ( )
2020-10-19 13:20:02 +03:00
tabView . openTab ( itemIndex )
}
}
}
}
}
ListView {
id: tabView
orientation: ListView . Horizontal
clip: true
snapMode: ListView . SnapOneItem
highlightRangeMode: ListView . StrictlyEnforceRange
highlightFollowsCurrentItem: true
boundsBehavior: Flickable . StopAtBounds
currentIndex: 0
highlightMoveDuration: 500
property int maxHeight: tabViewItem . height - tabViewHeader . height
anchors {
top: tabViewHeader . bottom
left: parent . left
right: parent . right
bottom: parent . bottom
}
function openTab ( index ) {
currentIndex = index ;
}
2020-11-16 23:38:55 +03:00
model: ListModel {
2020-10-19 13:20:02 +03:00
id: tabModel
}
2020-11-16 23:38:55 +03:00
delegate: Loader {
2020-10-19 13:20:02 +03:00
width: tabView . width
2020-11-16 23:38:55 +03:00
height: tabView . maxHeight
asynchronous: true
source: Qt . resolvedUrl ( tab + ".qml" )
2020-10-19 13:20:02 +03:00
}
}
2020-11-16 23:38:55 +03:00
Component.onCompleted: {
2020-11-28 21:11:51 +03:00
if ( ! ( ( isPrivateChat || isSecretChat ) && chatPartnerGroupId === myUserId . toString ( ) ) ) {
2020-11-16 23:38:55 +03:00
tabModel . append ( {
tab: "ChatInformationTabItemMembersGroups" ,
2020-11-28 21:11:51 +03:00
title: ( chatInformationPage . isPrivateChat || chatInformationPage . isSecretChat ) ? qsTr ( "Groups" , "Button: groups in common (short)" ) : qsTr ( "Members" , "Button: Group Members" ) ,
2020-11-16 23:38:55 +03:00
image: "image://theme/icon-m-people"
} ) ;
2020-10-19 13:20:02 +03:00
}
2020-11-28 21:11:51 +03:00
if ( ! ( isPrivateChat || isSecretChat ) && ( groupInformation . status . can_restrict_members || groupInformation . status [ "@type" ] === "chatMemberStatusCreator" ) ) {
2020-11-16 23:38:55 +03:00
tabModel . append ( {
tab: "ChatInformationTabItemSettings" ,
title: qsTr ( "Settings" , "Button: Chat Settings" ) ,
image: "image://theme/icon-m-developer-mode"
} ) ;
2020-10-19 13:20:02 +03:00
}
2020-11-16 23:38:55 +03:00
// tabModel.append({tab:"ChatInformationTabItemDebug"});
2020-10-19 13:20:02 +03:00
}
}