replaced segmented control with buttons to launch seperate page views

This commit is contained in:
Morgan McMillian 2016-11-12 06:22:29 -08:00
parent 7fcfaac2bc
commit af24b6ae69
4 changed files with 121 additions and 76 deletions

View file

@ -267,7 +267,4 @@ Container {
return "" return ""
} }
} }
onCreationCompleted: {
console.log(" My Height is " + postitem.preferredHeight)
}
} }

View file

@ -173,78 +173,119 @@ Page {
} }
} }
SegmentedControl { Divider {
Option {
id: opt_posts
text: qsTr("Posts")
}
Option {
id: opt_following
text: qsTr("Following")
}
Option {
id: opt_followers
text: qsTr("Followers")
}
onSelectedOptionChanged: {
if (selectedOption == opt_posts) {
threadModel.clear()
getPosts(user.id)
} else if (selectedOption == opt_following) {
threadModel.clear()
// do something
} else if (selectedOption == opt_followers) {
threadModel.clear()
// do something
}
}
} }
ListView { Container {
id: threadView layout: StackLayout {
//preferredHeight: threadModel.size() orientation: LayoutOrientation.LeftToRight
//preferredHeight: ( height of content row + content padding ) * count of entires in ListView
dataModel: ArrayDataModel {
id: threadModel
} }
listItemComponents: [ Container {
ListItemComponent { leftPadding: ui.sdu(1)
id: root rightPadding: ui.sdu(.5)
PostItem { Button {
id: postitem text: qsTr("Posts")
onClicked: {
var page = postPage.createObject()
pnut.userStreamReceived.connect(page.loadThread);
pnut.getUserStream(user.id)
//page.follow.connect(pnut.followUser)
//page.unfollow.connect(pnut.unfollowUser)
//page.block.connect(pnut.blockUser)
//page.unblock.connect(pnut.unblockUser)
//page.mute.connect(pnut.muteUser)
//page.unmute.connect(pnut.unmuteUser)
nav.push(page);
} }
} }
]
function sendReply(text, pid) {
pnut.sendReply(text, pid);
} }
function getUserName() { Container {
return _app.setting("username") leftPadding: ui.sdu(.5)
rightPadding: ui.sdu(.5)
Button {
text: qsTr("Following")
}
} }
function viewProfile(userobj) { Container {
var page = profilePage.createObject(); leftPadding: ui.sdu(.5)
page.user = userobj rightPadding: ui.sdu(1)
page.follow.connect(follow) Button {
page.unfollow.connect(unfollow) text: qsTr("Followers")
page.block.connect(block)
page.unblock.connect(unblock)
page.mute.connect(mute)
page.unmute.connect(unmute)
nav.push(page);
}
function ccOnReply() {
if (_app.setting("cc") === "true") {
return true
} else {
return false
} }
} }
} }
// SegmentedControl {
// Option {
// id: opt_posts
// text: qsTr("Posts")
// }
// Option {
// id: opt_following
// text: qsTr("Following")
// }
// Option {
// id: opt_followers
// text: qsTr("Followers")
// }
// onSelectedOptionChanged: {
// if (selectedOption == opt_posts) {
// threadModel.clear()
// getPosts(user.id)
// } else if (selectedOption == opt_following) {
// threadModel.clear()
// // do something
// } else if (selectedOption == opt_followers) {
// threadModel.clear()
// // do something
// }
// }
// }
// ListView {
// id: threadView
// //preferredHeight: threadModel.size()
// //preferredHeight: ( height of content row + content padding ) * count of entires in ListView
// dataModel: ArrayDataModel {
// id: threadModel
// }
// listItemComponents: [
// ListItemComponent {
// id: root
// PostItem {
// id: postitem
// }
// }
// ]
// function sendReply(text, pid) {
// pnut.sendReply(text, pid);
// }
// function getUserName() {
// return _app.setting("username")
// }
// function viewProfile(userobj) {
// var page = profilePage.createObject();
// page.user = userobj
// page.follow.connect(follow)
// page.unfollow.connect(unfollow)
// page.block.connect(block)
// page.unblock.connect(unblock)
// page.mute.connect(mute)
// page.unmute.connect(unmute)
// nav.push(page);
// }
// function ccOnReply() {
// if (_app.setting("cc") === "true") {
// return true
// } else {
// return false
// }
// }
// }
} }
} }
function loadThread(data) { // function loadThread(data) {
threadModel.append(data); // threadModel.append(data);
} // }
actions: [ actions: [
ActionItem { ActionItem {
@ -287,4 +328,11 @@ Page {
enabled: (_app.setting("username") === user.username) ? false : true enabled: (_app.setting("username") === user.username) ? false : true
} }
] ]
attachedObjects: [
ComponentDefinition {
id: postPage
source: "ThreadPage.qml"
}
]
} }

View file

@ -74,15 +74,15 @@ NavigationPane {
function viewProfile(userobj) { function viewProfile(userobj) {
var page = profilePage.createObject(); var page = profilePage.createObject();
page.user = userobj page.user = userobj
pnut.userStreamReceived.connect(page.loadThread) //pnut.userStreamReceived.connect(page.loadThread)
pnut.getUserStream(userobj.id) //pnut.getUserStream(userobj.id)
page.follow.connect(pnut.followUser) page.follow.connect(pnut.followUser)
page.unfollow.connect(pnut.unfollowUser) page.unfollow.connect(pnut.unfollowUser)
page.block.connect(pnut.blockUser) page.block.connect(pnut.blockUser)
page.unblock.connect(pnut.unblockUser) page.unblock.connect(pnut.unblockUser)
page.mute.connect(pnut.muteUser) page.mute.connect(pnut.muteUser)
page.unmute.connect(pnut.unmuteUser) page.unmute.connect(pnut.unmuteUser)
page.getPosts.connect(pnut.getUserStream) //page.getPosts.connect(pnut.getUserStream)
nav.push(page); nav.push(page);
} }
function sendReply(text, pid) { function sendReply(text, pid) {

View file

@ -84,19 +84,19 @@
<name>ProfilePage</name> <name>ProfilePage</name>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="127"/> <location filename="../assets/ProfilePage.qml" line="127"/>
<location filename="../assets/ProfilePage.qml" line="183"/> <location filename="../assets/ProfilePage.qml" line="206"/>
<source>Following</source> <source>Following</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="140"/> <location filename="../assets/ProfilePage.qml" line="140"/>
<location filename="../assets/ProfilePage.qml" line="187"/> <location filename="../assets/ProfilePage.qml" line="213"/>
<source>Followers</source> <source>Followers</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="153"/> <location filename="../assets/ProfilePage.qml" line="153"/>
<location filename="../assets/ProfilePage.qml" line="179"/> <location filename="../assets/ProfilePage.qml" line="187"/>
<source>Posts</source> <source>Posts</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -106,32 +106,32 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="251"/> <location filename="../assets/ProfilePage.qml" line="292"/>
<source>Unfollow</source> <source>Unfollow</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="251"/> <location filename="../assets/ProfilePage.qml" line="292"/>
<source>Follow</source> <source>Follow</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="264"/> <location filename="../assets/ProfilePage.qml" line="305"/>
<source>Unmute</source> <source>Unmute</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="264"/> <location filename="../assets/ProfilePage.qml" line="305"/>
<source>Mute</source> <source>Mute</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="277"/> <location filename="../assets/ProfilePage.qml" line="318"/>
<source>Unblock</source> <source>Unblock</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="277"/> <location filename="../assets/ProfilePage.qml" line="318"/>
<source>Block</source> <source>Block</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>