-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathRecentRoomsView.swift
More file actions
69 lines (58 loc) 路 2.13 KB
/
Copy pathRecentRoomsView.swift
File metadata and controls
69 lines (58 loc) 路 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// RecentRoomsView.swift
// Mio
//
// Created by Finn Behrens on 13.06.21.
// Copyright 漏 2021 Kilian Koeltzsch. All rights reserved.
//
import SwiftUI
import MatrixSDK
import NioKit
struct RecentRoomsView: View {
@EnvironmentObject var store: AccountStore
@Binding var selectedNavigationItem: SelectedNavigationItem?
@Binding var selectedRoomId: MXRoom.MXRoomId?
let rooms: [NIORoom]
private var joinedRooms: [NIORoom] {
rooms.filter {$0.room.summary.membership == .join}
}
private var invitedRooms: [NIORoom] {
rooms.filter {$0.room.summary.membership == .invite}
}
var body: some View {
NavigationView {
List {
if !invitedRooms.isEmpty {
RoomsListSection(
sectionHeader: L10n.RecentRooms.PendingInvitations.header,
rooms: invitedRooms,
onLeaveAlertTitle: L10n.RecentRooms.PendingInvitations.Leave.alertTitle,
selectedRoomId: $selectedRoomId
)
}
RoomsListSection(
sectionHeader: invitedRooms.isEmpty ? nil : L10n.RecentRooms.Rooms.header ,
rooms: joinedRooms,
onLeaveAlertTitle: L10n.RecentRooms.Leave.alertTitle,
selectedRoomId: $selectedRoomId
)
}
.listStyle(SidebarListStyle())
.navigationTitle("Mio")
.frame(minWidth: Style.minSidebarWidth)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button(action: { self.selectedNavigationItem = .newConversation }) {
Label(L10n.RecentRooms.AccessibilityLabel.newConversation,
systemImage: SFSymbol.newConversation.rawValue)
}
}
}
}
}
}
struct RecentRoomsView_Previews: PreviewProvider {
static var previews: some View {
RecentRoomsView(selectedNavigationItem: .constant(nil), selectedRoomId: .constant(nil), rooms: [])
}
}