Skip to content

Commit 4ee9cbd

Browse files
authored
Вернул потерявшуюся фичу удаления чата (#116)
1 parent 0825618 commit 4ee9cbd

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

SwiftUI-WorkoutApp/Screens/Messages/DialogList/DialogListView.swift

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,40 @@ private extension DialogListView {
9595
}
9696

9797
var dialogList: some View {
98-
ScrollView {
99-
LazyVStack(spacing: 22) {
100-
ForEach(viewModel.list) { model in
101-
NavigationLink {
102-
DialogView(
103-
dialog: model,
104-
markedAsReadClbk: {
105-
viewModel.markAsRead(model, with: defaults)
106-
}
107-
)
108-
} label: {
109-
DialogRowView(
110-
model: .init(
111-
avatarURL: model.anotherUserImageURL,
112-
authorName: model.anotherUserName.valueOrEmpty,
113-
dateText: model.lastMessageDateString,
114-
messageText: model.lastMessageFormatted,
115-
unreadCount: model.unreadMessagesCount
116-
)
117-
)
98+
List {
99+
ForEach(viewModel.list) { model in
100+
dialogListItem(model)
101+
.listRowInsets(.init(top: 12, leading: 16, bottom: 12, trailing: 16))
102+
.listRowBackground(Color.swBackground)
103+
.listRowSeparator(.hidden)
104+
}
105+
.onDelete(perform: initiateDeletion)
106+
}
107+
.listStyle(.plain)
108+
}
109+
110+
func dialogListItem(_ model: DialogResponse) -> some View {
111+
DialogRowView(
112+
model: .init(
113+
avatarURL: model.anotherUserImageURL,
114+
authorName: model.anotherUserName.valueOrEmpty,
115+
dateText: model.lastMessageDateString,
116+
messageText: model.lastMessageFormatted,
117+
unreadCount: model.unreadMessagesCount
118+
)
119+
)
120+
.background {
121+
NavigationLink {
122+
DialogView(
123+
dialog: model,
124+
markedAsReadClbk: {
125+
viewModel.markAsRead(model, with: defaults)
118126
}
119-
}
120-
.onDelete(perform: initiateDeletion)
127+
)
128+
} label: {
129+
EmptyView()
121130
}
122-
.padding([.top, .horizontal])
131+
.opacity(0)
123132
}
124133
}
125134

0 commit comments

Comments
 (0)