Fix build and naming of State -> ViewData

This commit is contained in:
langleyd
2021-07-05 16:28:14 +01:00
parent acb88ffa12
commit 5889742845
4 changed files with 28 additions and 11 deletions
@@ -0,0 +1,22 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
struct RoomNotificationSettingsCellViewData {
let notificicationState: RoomNotificationState
let selected: Bool
}
@@ -45,7 +45,7 @@ final class RoomNotificationSettingsCoordinator: RoomNotificationSettingsCoordin
avatarUrl: room.summary.avatar,
mediaManager: room.mxSession.mediaManager
) : nil
let roomNotificationSettingsViewModel = RoomNotificationSettingsViewModel(roomNotificationRepository: repository, roomEncrypted: room.summary.isEncrypted, avatarViewData: avatarData)
let roomNotificationSettingsViewModel = RoomNotificationSettingsViewModel(roomNotificationService: repository, roomEncrypted: room.summary.isEncrypted, avatarViewData: avatarData)
let roomNotificationSettingsViewController = RoomNotificationSettingsViewController.instantiate(with: roomNotificationSettingsViewModel)
self.roomNotificationSettingsViewModel = roomNotificationSettingsViewModel
self.roomNotificationSettingsViewController = roomNotificationSettingsViewController
@@ -41,7 +41,7 @@ final class RoomNotificationSettingsViewController: UIViewController {
}()
private struct Row {
var cellState: RoomNotificationSettingsCell.State
var cellViewData: RoomNotificationSettingsCellViewData
var action: (() -> Void)?
}
@@ -149,8 +149,8 @@ final class RoomNotificationSettingsViewController: UIViewController {
private func updateSections() {
let rows = viewState.notificationOptions.map({ (setting) -> Row in
let cellState = RoomNotificationSettingsCell.State(notificicationState: setting, selected: viewState.notificationState == setting)
return Row(cellState: cellState,
let cellViewData = RoomNotificationSettingsCellViewData(notificicationState: setting, selected: viewState.notificationState == setting)
return Row(cellViewData: cellViewData,
action: {
self.viewModel.process(viewAction: .selectNotificationState(setting))
})
@@ -177,7 +177,7 @@ extension RoomNotificationSettingsViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let row = sections[indexPath.section].rows[indexPath.row]
let cell: RoomNotificationSettingsCell = tableView.dequeueReusableCell(for: indexPath)
cell.update(state: row.cellState)
cell.update(state: row.cellViewData)
cell.update(theme: theme)
return cell
}
@@ -18,12 +18,7 @@ import Reusable
class RoomNotificationSettingsCell: UITableViewCell {
struct State {
let notificicationState: RoomNotificationState
let selected: Bool
}
func update(state: State) {
func update(state: RoomNotificationSettingsCellViewData) {
textLabel?.font = .systemFont(ofSize: 17)
detailTextLabel?.font = .systemFont(ofSize: 16)
textLabel?.text = state.notificicationState.title