IM: Terms modal: Add service purpose description

This commit is contained in:
manuroe
2019-08-12 14:57:50 +02:00
parent 917b442f95
commit 3679164dab
5 changed files with 39 additions and 1 deletions
@@ -231,7 +231,8 @@ extension ServiceTermsModalScreenViewController: UITableViewDataSource {
let policy = policies[indexPath.row]
let checked = checkedPolicies.contains(indexPath.row)
cell.label.text = policy.name
cell.label.attributedText = self.cellLabel(for: policy)
cell.label.font = .systemFont(ofSize: 15)
cell.isEnabled = checked
cell.accessoryType = .disclosureIndicator
cell.backgroundColor = self.theme.backgroundColor
@@ -248,6 +249,29 @@ extension ServiceTermsModalScreenViewController: UITableViewDataSource {
return cell
}
func cellLabel(for policy: MXLoginPolicyData) -> NSAttributedString {
// TableViewCellWithCheckBoxAndLabel does not have a detailTextLabel
// Do it by hand
var labelDetail: String = ""
switch self.viewModel.serviceType {
case MXServiceTypeIdentityService:
labelDetail = VectorL10n.serviceTermsModalDescriptionForIdentityServer
case MXServiceTypeIntegrationManager:
labelDetail = VectorL10n.serviceTermsModalDescriptionForIntegrationManager
default: break
}
let label = NSMutableAttributedString(string: policy.name,
attributes: [.foregroundColor: theme.textPrimaryColor])
label.append(NSAttributedString(string: "\n"))
label.append(NSAttributedString(string: labelDetail,
attributes: [.foregroundColor: theme.textSecondaryColor]))
return label
}
}
extension ServiceTermsModalScreenViewController: UITableViewDelegate {
@@ -29,6 +29,9 @@ final class ServiceTermsModalScreenViewModel: ServiceTermsModalScreenViewModelTy
// MARK: Public
var policies: [MXLoginPolicyData]?
var serviceType: MXServiceType {
return serviceTerms.serviceType
}
weak var viewDelegate: ServiceTermsModalScreenViewModelViewDelegate?
weak var coordinatorDelegate: ServiceTermsModalScreenViewModelCoordinatorDelegate?
@@ -32,6 +32,7 @@ protocol ServiceTermsModalScreenViewModelCoordinatorDelegate: class {
protocol ServiceTermsModalScreenViewModelType {
var policies: [MXLoginPolicyData]? { get set }
var serviceType: MXServiceType { get }
var viewDelegate: ServiceTermsModalScreenViewModelViewDelegate? { get set }
var coordinatorDelegate: ServiceTermsModalScreenViewModelCoordinatorDelegate? { get set }