Skip to content

Commit

Permalink
Minor refactoring (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivnsch committed Jun 10, 2020
1 parent 2b9e6d1 commit e4e7cc1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CoEpi/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

// what are exposure alerts
"whatExposure.title" = "What are exposure alerts?";
"whatExposure.HTMLbody" = "<body><p><font color='black' face='-apple-system' size='5'><b>Exposure alerts</b> indicate that you have been in close proximity (e.g. within several feet) to someone with symptoms also using a compatible app. <br /><br /><b>How does CoEpi work?</b> <br /><br /> CoEpi generates exposure alerts if your device has flagged another tracing app user who may have been infectious during your contact. <br /><br /> Based on the symptom report in the exposure alert, you can: <br /><br /> <b>• Monitor</b> yourself for symptoms in the days following the potential exposure<br /><br /> <b>• Self-isolate</b> within your household to reduce the risk of transmitting to others <br /><br /> <b>• Talk with a healthcare provider</b> about your exposure</font</p><body>";
"whatExposure.html_body" = "<body><p><font color='black' face='-apple-system' size='5'><b>Exposure alerts</b> indicate that you have been in close proximity (e.g. within several feet) to someone with symptoms also using a compatible app. <br /><br /><b>How does CoEpi work?</b> <br /><br /> CoEpi generates exposure alerts if your device has flagged another tracing app user who may have been infectious during your contact. <br /><br /> Based on the symptom report in the exposure alert, you can: <br /><br /> <b>• Monitor</b> yourself for symptoms in the days following the potential exposure<br /><br /> <b>• Self-isolate</b> within your household to reduce the risk of transmitting to others <br /><br /> <b>• Talk with a healthcare provider</b> about your exposure</font</p><body>";



Expand Down
4 changes: 2 additions & 2 deletions CoEpi/generated/strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ internal enum L10n {
}

internal enum WhatExposure {
/// <p><b>Exposure alerts</b> indicate that you have been in close proximity (e.g. within several feet) to someone with symptoms also using a compatible app. <br /><br /><b>How does CoEpi work?</b> <br /><br /> CoEpi generates exposure alerts if your device has flagged another tracing app user who may have been infectious during your contact. <br /><br /> Based on the symptom report in the exposure alert, you can: <br /><br /> <b>• Monitor</b> yourself for symptoms in the days following the potential exposure<br /><br /> <b>• Self-isolate</b> within your household to reduce the risk of transmitting to others <br /><br /> <b>• Talk with a healthcare provider</b> about your exposure</p>
internal static let htmLbody = L10n.tr("Localizable", "whatExposure.HTMLbody")
/// <body><p><font color='black' face='-apple-system' size='5'><b>Exposure alerts</b> indicate that you have been in close proximity (e.g. within several feet) to someone with symptoms also using a compatible app. <br /><br /><b>How does CoEpi work?</b> <br /><br /> CoEpi generates exposure alerts if your device has flagged another tracing app user who may have been infectious during your contact. <br /><br /> Based on the symptom report in the exposure alert, you can: <br /><br /> <b>• Monitor</b> yourself for symptoms in the days following the potential exposure<br /><br /> <b>• Self-isolate</b> within your household to reduce the risk of transmitting to others <br /><br /> <b>• Talk with a healthcare provider</b> about your exposure</font</p><body>
internal static let htmlBody = L10n.tr("Localizable", "whatExposure.html_body")
/// What are exposure alerts?
internal static let title = L10n.tr("Localizable", "whatExposure.title")
}
Expand Down
20 changes: 12 additions & 8 deletions CoEpi/ui/alerts/WhatAreAlertsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@ class WhatAreAlertsViewController: UIViewController {

titleLabel.text = L10n.WhatExposure.title

bodyLabel.attributedText = L10n.WhatExposure.htmLbody.htmlToAttributedString
bodyLabel.attributedText = L10n.WhatExposure.htmlBody.htmlToAttributedString
}
}

extension String {
private extension String {
var htmlToAttributedString: NSAttributedString? {
guard let data = data(using: .utf8) else { return NSAttributedString() }
guard let data = data(using: .utf8) else {
log.e("Couldn't encode string: \(self)")
return NSAttributedString()
}

do {
return try NSAttributedString(
data: data,
options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue],
options: [.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf8.rawValue],
documentAttributes: nil)
} catch {

} catch let e {
log.e("Couldn't create attributed string with: \(self), e: \(e)")
return NSAttributedString()
}
}
var htmlToString: String {
return htmlToAttributedString?.string ?? ""
}
}

0 comments on commit e4e7cc1

Please # to comment.