Skip to content

Commit 307d9a8

Browse files
committed
feat(Adaptive navigation) Primary nav sidebar POC
- introduce `PrimaryNavSidebar{Button}` components - update the main sections SVG icons - added a basic QML test suite - add a SB page for the sidebar POC Fixes #19593
1 parent 2966e3b commit 307d9a8

File tree

22 files changed

+1260
-46
lines changed

22 files changed

+1260
-46
lines changed
Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Layouts
4+
5+
import StatusQ
6+
import StatusQ.Core
7+
import StatusQ.Core.Theme
8+
import StatusQ.Controls
9+
import StatusQ.Components
10+
import StatusQ.Popups
11+
12+
import Models
13+
import Storybook
14+
15+
import shared.controls.chat.menuItems
16+
17+
import utils
18+
19+
import AppLayouts.Profile.stores as ProfileStores
20+
21+
import mainui
22+
23+
SplitView {
24+
id: root
25+
26+
orientation: Qt.Vertical
27+
28+
Logs { id: logs }
29+
30+
QtObject {
31+
id: d
32+
33+
readonly property var sectionsModel: SectionsModel {}
34+
35+
property bool acVisible
36+
37+
property int activeSectionType: Constants.appSection.wallet
38+
property string activeSectionId: "id2"
39+
}
40+
41+
Item {
42+
SplitView.fillWidth: true
43+
SplitView.fillHeight: true
44+
45+
Label {
46+
anchors.centerIn: parent
47+
visible: secondaryWindow.visible
48+
text: "Interact with the sidebar in the secondary window"
49+
}
50+
Button {
51+
anchors.centerIn: parent
52+
text: "Reopen"
53+
visible: !secondaryWindow.visible
54+
onClicked: secondaryWindow.visible = true
55+
}
56+
}
57+
58+
Window {
59+
id: secondaryWindow
60+
visible: true
61+
width: 800
62+
height: 640
63+
title: "PrimaryNavSidebar"
64+
color: Theme.palette.baseColor4 // doesn't get the proper StatusQ palette w/o Theme.xxx
65+
66+
ColumnLayout {
67+
anchors.fill: parent
68+
anchors.margins: 12
69+
anchors.leftMargin: 12 + (secondaryWindow.isLandscape ? sidebar.width : 0)
70+
Behavior on anchors.leftMargin {PropertyAnimation {duration: ThemeUtils.AnimationDuration.Fast}}
71+
72+
StatusButton {
73+
icon.name: "more"
74+
visible: sidebar.interactive
75+
onClicked: sidebar.open()
76+
77+
tooltip.text: "Open sidebar"
78+
tooltip.orientation: StatusToolTip.Orientation.Bottom
79+
}
80+
StatusBaseText {
81+
Layout.fillWidth: true
82+
wrapMode: Text.Wrap
83+
text: "Active section type/id: %1/\"%2\"".arg(d.activeSectionType).arg(d.activeSectionId)
84+
}
85+
StatusBaseText {
86+
Layout.fillWidth: true
87+
wrapMode: Text.Wrap
88+
text: "Window size: %1x%2 (%3)".arg(secondaryWindow.width).arg(secondaryWindow.height).arg(secondaryWindow.isLandscape ? "landscape" : "portrait")
89+
}
90+
StatusBaseText {
91+
Layout.fillWidth: true
92+
wrapMode: Text.Wrap
93+
text: "Sidebar position: %1".arg(sidebar.position)
94+
}
95+
StatusBaseText {
96+
Layout.fillWidth: true
97+
wrapMode: Text.Wrap
98+
text: secondaryWindow.isLandscape ? "Sidebar is always visible, pushes the content (background not dimmed)"
99+
: "Open the sidebar by dragging on the left edge, or click the above button (background dimmed)"
100+
}
101+
Item { Layout.fillHeight: true }
102+
}
103+
104+
readonly property bool isLandscape: secondaryWindow.width > secondaryWindow.height
105+
106+
PrimaryNavSidebar {
107+
id: sidebar
108+
height: parent.height
109+
110+
visible: secondaryWindow.isLandscape
111+
interactive: !secondaryWindow.isLandscape
112+
113+
sectionsModel: d.sectionsModel
114+
115+
acVisible: d.acVisible
116+
acHasUnseenNotifications: ctrlAcHasUnseenNotifications.checked // <- ActivityCenterStore.hasUnseenNotifications
117+
acUnreadNotificationsCount: ctrlAcUnreadNotificationsCount.value // <- ActivityCenterStore.unreadNotificationsCount
118+
119+
profileStore: ProfileStores.ProfileStore {
120+
id: profileStore
121+
readonly property string pubKey: "0xdeadbeef"
122+
readonly property string compressedPubKey: "zxDeadBeef"
123+
readonly property string name: "John Doe"
124+
readonly property string icon: ModelsData.icons.rarible
125+
readonly property int colorId: 7
126+
readonly property bool usesDefaultName: false
127+
property int currentUserStatus: Constants.currentUserStatus.automatic
128+
}
129+
130+
getEmojiHashFn: function(pubKey) { // <- root.utilsStore.getEmojiHash(pubKey)
131+
if (pubKey === "")
132+
return ""
133+
134+
return["👨🏻‍🍼", "🏃🏿‍♂️", "🌇", "🤶🏿", "🏮","🤷🏻‍♂️", "🤦🏻", "📣", "🤎", "👷🏽", "😺", "🥞", "🔃", "🧝🏽‍♂️"]
135+
}
136+
getLinkToProfileFn: function(pubKey) { // <- root.rootStore.contactsStore.getLinkToProfile(pubKey)
137+
return Constants.userLinkPrefix + pubKey
138+
}
139+
140+
communityPopupMenu: Component {
141+
StatusMenu {
142+
id: communityContextMenu
143+
144+
required property var model
145+
required property int index
146+
147+
readonly property bool isSpectator: model.spectated && !model.joined
148+
149+
onClosed: destroy()
150+
151+
StatusAction {
152+
text: qsTr("Invite People")
153+
icon.name: "share-ios"
154+
objectName: "invitePeople"
155+
}
156+
157+
StatusAction {
158+
text: qsTr("Community Info")
159+
icon.name: "info"
160+
}
161+
162+
StatusAction {
163+
text: qsTr("Community Rules")
164+
icon.name: "text"
165+
}
166+
167+
StatusMenuSeparator {}
168+
169+
MuteChatMenuItem {
170+
enabled: !model.muted
171+
title: qsTr("Mute Community")
172+
}
173+
174+
StatusAction {
175+
enabled: model.muted
176+
text: qsTr("Unmute Community")
177+
icon.name: "notification"
178+
}
179+
180+
StatusAction {
181+
text: qsTr("Mark as read")
182+
icon.name: "check-circle"
183+
}
184+
185+
StatusAction {
186+
text: qsTr("Edit Shared Addresses")
187+
icon.name: "wallet"
188+
enabled: {
189+
if (model.memberRole === Constants.memberRole.owner || communityContextMenu.isSpectator)
190+
return false
191+
return true
192+
}
193+
}
194+
195+
StatusMenuSeparator { visible: leaveCommunityMenuItem.enabled }
196+
197+
StatusAction {
198+
id: leaveCommunityMenuItem
199+
objectName: "leaveCommunityMenuItem"
200+
// allow to leave community for the owner in non-production builds
201+
enabled: model.memberRole !== Constants.memberRole.owner || !production
202+
text: {
203+
if (communityContextMenu.isSpectator)
204+
return qsTr("Close Community")
205+
return qsTr("Leave Community")
206+
}
207+
icon.name: communityContextMenu.isSpectator ? "close-circle" : "arrow-left"
208+
type: StatusAction.Type.Danger
209+
}
210+
}
211+
}
212+
213+
showEnabledSectionsOnly: ctrlShowEnabledSectionsOnly.checked
214+
marketEnabled: ctrlMarketEnabled.checked
215+
browserEnabled: ctrlBrowserEnabled.checked
216+
nodeEnabled: ctrlNodeEnabled.checked
217+
thirdpartyServicesEnabled: ctrlThirdPartyServices.checked
218+
showCreateCommunityBadge: ctrlShowCreateCommunityBadge.checked
219+
profileSectionHasNotification: ctrlSettingsHasNotification.checked
220+
221+
onItemActivated: function (sectionType, id) {
222+
logs.logEvent("onItemActivated", ["sectionType", "sectionId"], arguments)
223+
sectionsModel.setActiveSection(id)
224+
d.activeSectionType = sectionType
225+
d.activeSectionId = id
226+
}
227+
onActivityCenterRequested: function (shouldShow) {
228+
logs.logEvent("onActivityCenterRequested", ["shouldShow"], arguments)
229+
d.acVisible = shouldShow
230+
}
231+
onSetCurrentUserStatusRequested: function (status) {
232+
profileStore.currentUserStatus = status
233+
logs.logEvent("onSetCurrentUserStatusRequested", ["status"], arguments) // <- root.rootStore.setCurrentUserStatus(status)
234+
}
235+
onViewProfileRequested: logs.logEvent("onViewProfileRequested", ["pubKey"], arguments) // <- Global.openProfilePopup(pubKey)
236+
}
237+
}
238+
239+
LogsAndControlsPanel {
240+
SplitView.minimumHeight: 330
241+
SplitView.preferredHeight: 330
242+
SplitView.fillWidth: true
243+
244+
logsView.logText: logs.logText
245+
246+
RowLayout {
247+
anchors.fill: parent
248+
249+
ColumnLayout {
250+
Label { text: "Sections config:" }
251+
Switch {
252+
id: ctrlShowEnabledSectionsOnly
253+
text: "Show enabled sections only"
254+
checked: true
255+
}
256+
Switch {
257+
id: ctrlMarketEnabled
258+
text: "Market enabled"
259+
checked: true
260+
}
261+
Switch {
262+
id: ctrlBrowserEnabled
263+
text: "Browser enabled"
264+
checked: true
265+
}
266+
Switch {
267+
id: ctrlNodeEnabled
268+
text: "Node mgmt enabled"
269+
checked: false
270+
}
271+
Switch {
272+
id: ctrlThirdPartyServices
273+
text: "Third party services enabled"
274+
checked: true
275+
}
276+
Switch {
277+
id: ctrlSettingsHasNotification
278+
text: "Settings has notification"
279+
}
280+
Switch {
281+
id: ctrlShowCreateCommunityBadge
282+
text: "Show create community badge"
283+
}
284+
}
285+
286+
ColumnLayout {
287+
Layout.fillWidth: true
288+
Label { text: "Activity Center:" }
289+
Switch {
290+
id: ctrlAcHasUnseenNotifications
291+
text: "Has unseen notifications"
292+
checked: true
293+
}
294+
RowLayout {
295+
Label { text: "Notifications count:" }
296+
SpinBox {
297+
id: ctrlAcUnreadNotificationsCount
298+
from: 0
299+
to: 101
300+
value: 4
301+
editable: true
302+
}
303+
}
304+
Item { Layout.fillHeight: true }
305+
}
306+
}
307+
}
308+
}
309+
310+
// category: Panels
311+
// status: good
312+
// https://www.figma.com/design/pJgiysu3rw8XvL4wS2Us7W/DS?node-id=4185-86833&t=lNokXnXl5AHjxHan-0
313+
// https://www.figma.com/design/pJgiysu3rw8XvL4wS2Us7W/DS?node-id=4185-86833&t=hN6bacud6gPREDcH-0

storybook/qmlTests/tests/tst_HomePage.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Item {
136136
key: "1;0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8884", searchStr: "Fab"}, // Fab
137137
{tag: "chat", sectionType: Constants.appSection.chat, key: "2;id1", searchStr: "Punx"}, // 1-1 chat
138138
{tag: "group chat", sectionType: Constants.appSection.chat, key: "2;id5", searchStr: "Channel Y_3"}, // group chat
139-
{tag: "community", sectionType: Constants.appSection.community, key: "3;id15", searchStr: "Dribb"}, // Dribble
139+
{tag: "community", sectionType: Constants.appSection.community, key: "3;id106", searchStr: "Dribb"}, // Dribble
140140
{tag: "dApp", sectionType: Constants.appSection.dApp, key: "999;https://dapp.test/2", searchStr: "dapp 2"}, // Test dApp 2
141141
{tag: "settings", sectionType: Constants.appSection.profile, key: "4;1", searchStr: "passw"}, // Settings/Password
142142
]

0 commit comments

Comments
 (0)