mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 13:05:21 +00:00
COVIDSafe code from version 1.1
This commit is contained in:
commit
3640e52eb2
330 changed files with 261540 additions and 0 deletions
54
CovidSafe/Feedback/Sources/Issue.swift
Normal file
54
CovidSafe/Feedback/Sources/Issue.swift
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Copyright © 2020 Australian Government All rights reserved.
|
||||
|
||||
import Foundation
|
||||
|
||||
let maxSummaryLength = 240
|
||||
public struct Issue {
|
||||
let summary: String
|
||||
let description: String
|
||||
let components: [String]
|
||||
let type: String
|
||||
let customFields: [String: AnyObject]
|
||||
|
||||
public init(summary: String, description: String, components: [String], type: String, customFields: [String: AnyObject] = [:], reporterUsernameOrEmail: String? = nil) {
|
||||
self.summary = summary
|
||||
self.description = description.withReporterUsernameOrEmailAppended(reporterUsernameOrEmail)
|
||||
self.components = components
|
||||
self.type = type
|
||||
self.customFields = customFields
|
||||
}
|
||||
|
||||
public init(feedback: String, components: [String], type: String, customFields: [String: AnyObject] = [:], reporterUsernameOrEmail: String? = nil) {
|
||||
switch feedback.unicodeScalars.count {
|
||||
case let count where count > maxSummaryLength:
|
||||
let truncatedSummary = String(feedback.unicodeScalars.prefix(maxSummaryLength))
|
||||
self.init(
|
||||
summary: truncatedSummary,
|
||||
description: feedback,
|
||||
components: components,
|
||||
type: type,
|
||||
customFields: customFields,
|
||||
reporterUsernameOrEmail: reporterUsernameOrEmail
|
||||
)
|
||||
default:
|
||||
self.init(
|
||||
summary: feedback,
|
||||
description: feedback,
|
||||
components: components,
|
||||
type: type,
|
||||
customFields: customFields,
|
||||
reporterUsernameOrEmail: reporterUsernameOrEmail
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
fileprivate func withReporterUsernameOrEmailAppended(_ reporterUsernameOrEmail: String?) -> String {
|
||||
guard let reporterUsernameOrEmail = reporterUsernameOrEmail else {
|
||||
return self
|
||||
}
|
||||
|
||||
return "\(self) \n\n Submitted by: \(reporterUsernameOrEmail)"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue