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

View file

@ -3,16 +3,17 @@ import bb.cascades 1.4
Page { Page {
id: settingsPage id: settingsPage
signal modifySetting(string setting, variant value)
titleBar: TitleBar { titleBar: TitleBar {
title: qsTr("Settings") title: qsTr("Settings")
} }
signal reload()
ScrollView { ScrollView {
Container { Container {
layout: StackLayout {} layout: StackLayout {}
Container { Container {
topPadding: 15.0 topPadding: ui.sdu(2)
} }
Container { Container {
layout: DockLayout {} layout: DockLayout {}
@ -22,75 +23,85 @@ Page {
verticalAlignment: VerticalAlignment.Center verticalAlignment: VerticalAlignment.Center
leftPadding: ui.sdu(3) leftPadding: ui.sdu(3)
Label { 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 { Container {
rightPadding: ui.sdu(3) rightPadding: ui.sdu(3)
horizontalAlignment: HorizontalAlignment.Right horizontalAlignment: HorizontalAlignment.Right
verticalAlignment: VerticalAlignment.Center
ToggleButton { ToggleButton {
checked: true checked: _app.setting("unified")
onCheckedChanged: { onCheckedChanged: {
if (checked) { if (checked) {
modifySetting("datenew", true) _app.setSetting("unified", true)
reload()
} else { } else {
modifySetting("datenew", false) _app.setSetting("unified", false)
reload()
} }
} }
accessibility.name: "unified"
} }
} }
} }
Divider {} Divider {}
Container { // Container {
layout: DockLayout {} // layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill // horizontalAlignment: HorizontalAlignment.Fill
Container { // Container {
leftPadding: ui.sdu(3) // leftPadding: ui.sdu(3)
rightPadding: ui.sdu(3) // rightPadding: ui.sdu(3)
DropDown { // DropDown {
title: "Dropdown" // title: "Dropdown"
preferredWidth: 1440.0 // preferredWidth: 1440.0
onSelectedIndexChanged: { // onSelectedIndexChanged: {
modifySetting("sort", selectedValue) // modifySetting("sort", selectedValue)
} // }
Option { // Option {
text: "Option Zero" // text: "Option Zero"
value: 0 // value: 0
selected: sort == 0 // selected: sort == 0
} // }
Option { // Option {
text: "Option Three" // text: "Option Three"
value: 3 // value: 3
selected: sort == 3 // selected: sort == 3
} // }
Option { // Option {
text: "Option One" // text: "Option One"
value: 1 // value: 1
selected: sort == 1 // selected: sort == 1
} // }
Option { // Option {
text: "Option Two" // text: "Option Two"
value: 2 // value: 2
selected: sort == 2 // selected: sort == 2
} // }
} // }
} // }
} // }
Divider {} // Divider {}
Container { // Container {
layout: DockLayout {} // layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill // horizontalAlignment: HorizontalAlignment.Fill
leftPadding: 30.0 // leftPadding: 30.0
rightPadding: 30.0 // rightPadding: 30.0
Button { // Button {
preferredWidth: 1440.0 // preferredWidth: 1440.0
text: "Button" // text: "Button"
onClicked: { // onClicked: {
console.log("button") // console.log("button")
} // }
} // }
} // }
Divider {} // Divider {}
} }
} }
} }

View file

@ -150,10 +150,7 @@ NavigationPane {
title: qsTr("Reload") title: qsTr("Reload")
ActionBar.placement: ActionBarPlacement.InOverflow ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: { onTriggered: {
postModel.clear() reload()
pnut.beforeId = 0
pnut.sinceId = 0
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
} }
imageSource: "asset:///icons/ic_reload.png" imageSource: "asset:///icons/ic_reload.png"
}, },
@ -251,10 +248,7 @@ NavigationPane {
function update_user_page(user) { function update_user_page(user) {
nav.top.user = user nav.top.user = user
postModel.clear() reload()
pnut.beforeId = 0
pnut.sinceId = 0
pnut.getStream(endpoint, Pnut.STREAM_OLDER)
} }
function update_app_cover(count) { function update_app_cover(count) {
@ -271,15 +265,7 @@ NavigationPane {
page.destroy(); page.destroy();
} }
onCreationCompleted: { onCreationCompleted: {
switch (stream_type) { setEndpoint()
case "Home":
endpoint = "/posts/streams/unified"
break;
case "Global":
default:
endpoint = "/posts/streams/global"
break;
}
if (_app.setting("access_token") && _app.setting("access_token").length > 0) { if (_app.setting("access_token") && _app.setting("access_token").length > 0) {
console.log("__I think I'm authenticated") console.log("__I think I'm authenticated")
pnut.getUserInfo() pnut.getUserInfo()
@ -291,10 +277,32 @@ NavigationPane {
timer.stop() 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() { function login() {
pnut.authorize() pnut.authorize()
} }
function logout() { function logout() {
pnut.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 { Menu.definition: MenuDefinition {
settingsAction: SettingsActionItem { settingsAction: SettingsActionItem {
onTriggered: { onTriggered: {
// var page = settingsPage.createObject()
page.reload.connect(activePane.reload)
activePane.push(page)
} }
} }
actions: [ 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 { Tab {
id: homeStream id: homeStream
title: qsTr("Home") title: qsTr("Home")
objectName: "HomeTab"
delegate: Delegate { delegate: Delegate {
StreamTab { StreamTab {
title: qsTr("Home") 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 { Tab {
id: globalStream id: globalStream
title: qsTr("Global") title: qsTr("Global")
objectName: "GlobalTab"
delegate: Delegate { delegate: Delegate {
StreamTab { StreamTab {
title: qsTr("Global") title: qsTr("Global")
@ -83,12 +120,20 @@ TabbedPane {
} }
} }
onActiveTabChanged: {
_app.setSetting("activetab", activeTab.objectName)
}
attachedObjects: [ attachedObjects: [
LoginSheet { LoginSheet {
id: loginSheet id: loginSheet
onLogin: { onLogin: {
activePane.login() 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/SettingsPage.qml) \
$$quote($$BASEDIR/assets/StreamTab.qml) \ $$quote($$BASEDIR/assets/StreamTab.qml) \
$$quote($$BASEDIR/assets/ThreadPage.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \
$$quote($$BASEDIR/assets/icons/at.png) \
$$quote($$BASEDIR/assets/icons/bell-slash.png) \ $$quote($$BASEDIR/assets/icons/bell-slash.png) \
$$quote($$BASEDIR/assets/icons/bell.png) \ $$quote($$BASEDIR/assets/icons/bell.png) \
$$quote($$BASEDIR/assets/icons/comments.png) \ $$quote($$BASEDIR/assets/icons/comments.png) \

View file

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

View file

@ -126,6 +126,24 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </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> <context>
<name>StreamTab</name> <name>StreamTab</name>
<message> <message>
@ -139,7 +157,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="161"/> <location filename="../assets/StreamTab.qml" line="158"/>
<source>To Bottom</source> <source>To Bottom</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -152,19 +170,25 @@
<context> <context>
<name>main</name> <name>main</name>
<message> <message>
<location filename="../assets/main.qml" line="33"/> <location filename="../assets/main.qml" line="35"/>
<source>Logout</source> <source>Logout</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/main.qml" line="46"/> <location filename="../assets/main.qml" line="59"/>
<location filename="../assets/main.qml" line="49"/> <location filename="../assets/main.qml" line="63"/>
<source>Home</source> <source>Home</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/main.qml" line="67"/> <location filename="../assets/main.qml" line="81"/>
<location filename="../assets/main.qml" line="70"/> <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> <source>Global</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>