fixed stream preferences and added mentions tab

This commit is contained in:
Morgan McMillian 2016-10-22 12:25:59 -07:00
parent 3f28d7eb89
commit dd8273bd18
9 changed files with 176 additions and 85 deletions

View file

@ -1,6 +1,7 @@
1
36
38
AppCover.qml
icons/at.png
icons/bell-slash.png
icons/bell.png
icons/comments.png
@ -34,5 +35,6 @@ NewPostSheet.qml
PostItem.qml
ProfilePage.qml
RefreshItem.qml
SettingsPage.qml
StreamTab.qml
ThreadPage.qml

View file

@ -3,16 +3,17 @@ import bb.cascades 1.4
Page {
id: settingsPage
signal modifySetting(string setting, variant value)
titleBar: TitleBar {
title: qsTr("Settings")
}
signal reload()
ScrollView {
Container {
layout: StackLayout {}
Container {
topPadding: 15.0
topPadding: ui.sdu(2)
}
Container {
layout: DockLayout {}
@ -22,75 +23,85 @@ Page {
verticalAlignment: VerticalAlignment.Center
leftPadding: ui.sdu(3)
Label {
text: "This is my toggle"
text: qsTr("Unified Home")
textStyle.fontSize: FontSize.Medium
textStyle.fontWeight: FontWeight.Bold
}
Label {
text: qsTr("Include mentions in home stream")
textStyle.fontSize: FontSize.Small
}
}
Container {
rightPadding: ui.sdu(3)
horizontalAlignment: HorizontalAlignment.Right
verticalAlignment: VerticalAlignment.Center
ToggleButton {
checked: true
checked: _app.setting("unified")
onCheckedChanged: {
if (checked) {
modifySetting("datenew", true)
_app.setSetting("unified", true)
reload()
} else {
modifySetting("datenew", false)
_app.setSetting("unified", false)
reload()
}
}
accessibility.name: "unified"
}
}
}
Divider {}
Container {
layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill
Container {
leftPadding: ui.sdu(3)
rightPadding: ui.sdu(3)
DropDown {
title: "Dropdown"
preferredWidth: 1440.0
onSelectedIndexChanged: {
modifySetting("sort", selectedValue)
}
Option {
text: "Option Zero"
value: 0
selected: sort == 0
}
Option {
text: "Option Three"
value: 3
selected: sort == 3
}
Option {
text: "Option One"
value: 1
selected: sort == 1
}
Option {
text: "Option Two"
value: 2
selected: sort == 2
}
}
}
}
Divider {}
Container {
layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill
leftPadding: 30.0
rightPadding: 30.0
Button {
preferredWidth: 1440.0
text: "Button"
onClicked: {
console.log("button")
}
}
}
Divider {}
// Container {
// layout: DockLayout {}
// horizontalAlignment: HorizontalAlignment.Fill
// Container {
// leftPadding: ui.sdu(3)
// rightPadding: ui.sdu(3)
// DropDown {
// title: "Dropdown"
// preferredWidth: 1440.0
// onSelectedIndexChanged: {
// modifySetting("sort", selectedValue)
// }
// Option {
// text: "Option Zero"
// value: 0
// selected: sort == 0
// }
// Option {
// text: "Option Three"
// value: 3
// selected: sort == 3
// }
// Option {
// text: "Option One"
// value: 1
// selected: sort == 1
// }
// Option {
// text: "Option Two"
// value: 2
// selected: sort == 2
// }
// }
// }
// }
// Divider {}
// Container {
// layout: DockLayout {}
// horizontalAlignment: HorizontalAlignment.Fill
// leftPadding: 30.0
// rightPadding: 30.0
// Button {
// preferredWidth: 1440.0
// text: "Button"
// onClicked: {
// console.log("button")
// }
// }
// }
// Divider {}
}
}
}

View file

@ -150,10 +150,7 @@ NavigationPane {
title: qsTr("Reload")
ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: {
postModel.clear()
pnut.beforeId = 0
pnut.sinceId = 0
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
reload()
}
imageSource: "asset:///icons/ic_reload.png"
},
@ -251,10 +248,7 @@ NavigationPane {
function update_user_page(user) {
nav.top.user = user
postModel.clear()
pnut.beforeId = 0
pnut.sinceId = 0
pnut.getStream(endpoint, Pnut.STREAM_OLDER)
reload()
}
function update_app_cover(count) {
@ -271,15 +265,7 @@ NavigationPane {
page.destroy();
}
onCreationCompleted: {
switch (stream_type) {
case "Home":
endpoint = "/posts/streams/unified"
break;
case "Global":
default:
endpoint = "/posts/streams/global"
break;
}
setEndpoint()
if (_app.setting("access_token") && _app.setting("access_token").length > 0) {
console.log("__I think I'm authenticated")
pnut.getUserInfo()
@ -291,10 +277,32 @@ NavigationPane {
timer.stop()
}
}
function setEndpoint() {
switch (stream_type) {
case "Home":
var hometype = (_app.setting("unified") === "true") ? "unified" : "me"
endpoint = "/posts/streams/" + hometype
break;
case "Mentions":
endpoint = "/users/me/mentions"
break;
case "Global":
default:
endpoint = "/posts/streams/global"
break;
}
}
function login() {
pnut.authorize()
}
function logout() {
pnut.logout()
}
function reload() {
setEndpoint()
postModel.clear()
pnut.beforeId = 0
pnut.sinceId = 0
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
}
}

BIN
assets/icons/at.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -25,7 +25,9 @@ TabbedPane {
Menu.definition: MenuDefinition {
settingsAction: SettingsActionItem {
onTriggered: {
//
var page = settingsPage.createObject()
page.reload.connect(activePane.reload)
activePane.push(page)
}
}
actions: [
@ -39,11 +41,23 @@ TabbedPane {
]
}
activeTab: globalStream
activeTab: {
switch(_app.setting("activetab")) {
case "GlobalTab":
return globalStream
break;
case "HomeTab":
return homeStream
break;
default:
return globalStream
}
}
Tab {
id: homeStream
title: qsTr("Home")
objectName: "HomeTab"
delegate: Delegate {
StreamTab {
title: qsTr("Home")
@ -62,9 +76,32 @@ TabbedPane {
}
}
Tab {
id: mentionStream
title: qsTr("Mentions")
objectName: "MentionTab"
delegate: Delegate {
StreamTab {
title: qsTr("Mentions")
stream_type: "Mentions"
onOpenLogin: {
loginSheet.open()
}
onCloseLogin: {
loginSheet.close()
}
}
}
imageSource: "asset:///icons/at.png"
onUnreadContentCountChanged: {
_activeFrame.setGlobalUnread(unreadContentCount)
}
}
Tab {
id: globalStream
title: qsTr("Global")
objectName: "GlobalTab"
delegate: Delegate {
StreamTab {
title: qsTr("Global")
@ -83,12 +120,20 @@ TabbedPane {
}
}
onActiveTabChanged: {
_app.setSetting("activetab", activeTab.objectName)
}
attachedObjects: [
LoginSheet {
id: loginSheet
onLogin: {
activePane.login()
}
},
ComponentDefinition {
id: settingsPage
source: "SettingsPage.qml"
}
]

View file

@ -1 +1 @@
181
200

View file

@ -75,6 +75,7 @@ config_pri_assets {
$$quote($$BASEDIR/assets/SettingsPage.qml) \
$$quote($$BASEDIR/assets/StreamTab.qml) \
$$quote($$BASEDIR/assets/ThreadPage.qml) \
$$quote($$BASEDIR/assets/icons/at.png) \
$$quote($$BASEDIR/assets/icons/bell-slash.png) \
$$quote($$BASEDIR/assets/icons/bell.png) \
$$quote($$BASEDIR/assets/icons/comments.png) \

View file

@ -201,7 +201,7 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
{
case Pnut::OK:
{
if (endpoint.startsWith("/posts/streams/"))
if (endpoint.startsWith("/posts/streams/") || endpoint == "/users/me/mentions")
{
Pnut::RequestType rtype = rtype_map[id];
emit streamReceived(variant.toMap()["data"].toList(), rtype);

View file

@ -126,6 +126,24 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>
<location filename="../assets/SettingsPage.qml" line="7"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/SettingsPage.qml" line="26"/>
<source>Unified Home</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/SettingsPage.qml" line="31"/>
<source>Include mentions in home stream</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StreamTab</name>
<message>
@ -139,7 +157,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="161"/>
<location filename="../assets/StreamTab.qml" line="158"/>
<source>To Bottom</source>
<translation type="unfinished"></translation>
</message>
@ -152,19 +170,25 @@
<context>
<name>main</name>
<message>
<location filename="../assets/main.qml" line="33"/>
<location filename="../assets/main.qml" line="35"/>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/main.qml" line="46"/>
<location filename="../assets/main.qml" line="49"/>
<location filename="../assets/main.qml" line="59"/>
<location filename="../assets/main.qml" line="63"/>
<source>Home</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/main.qml" line="67"/>
<location filename="../assets/main.qml" line="70"/>
<location filename="../assets/main.qml" line="81"/>
<location filename="../assets/main.qml" line="85"/>
<source>Mentions</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/main.qml" line="103"/>
<location filename="../assets/main.qml" line="107"/>
<source>Global</source>
<translation type="unfinished"></translation>
</message>