NCUtility.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. //
  2. // NCUtility.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 25/06/18.
  6. // Copyright © 2018 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import Foundation
  24. import SVGKit
  25. import KTVHTTPCache
  26. import NCCommunication
  27. import PDFKit
  28. import Accelerate
  29. class NCUtility: NSObject {
  30. @objc static let shared: NCUtility = {
  31. let instance = NCUtility()
  32. return instance
  33. }()
  34. private var activityIndicator: UIActivityIndicatorView? // = UIActivityIndicatorView(style: .whiteLarge)
  35. private var viewActivityIndicator: UIView?
  36. private var viewBackgroundActivityIndicator: UIView?
  37. func setLayoutForView(key: String, serverUrl: String, layout: String, sort: String, ascending: Bool, groupBy: String, directoryOnTop: Bool, titleButton: String, itemForLine: Int) {
  38. let string = layout + "|" + sort + "|" + "\(ascending)" + "|" + groupBy + "|" + "\(directoryOnTop)" + "|" + titleButton + "|" + "\(itemForLine)"
  39. var keyStore = key
  40. if serverUrl != "" {
  41. keyStore = serverUrl
  42. }
  43. UICKeyChainStore.setString(string, forKey: keyStore, service: NCGlobal.shared.serviceShareKeyChain)
  44. }
  45. func setLayoutForView(key: String, serverUrl: String, layout: String) {
  46. var sort: String
  47. var ascending: Bool
  48. var groupBy: String
  49. var directoryOnTop: Bool
  50. var titleButton: String
  51. var itemForLine: Int
  52. (_, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: NCGlobal.shared.layoutViewFavorite, serverUrl: serverUrl)
  53. setLayoutForView(key: key, serverUrl: serverUrl, layout: layout, sort: sort, ascending: ascending, groupBy: groupBy, directoryOnTop: directoryOnTop, titleButton: titleButton, itemForLine: itemForLine)
  54. }
  55. func getLayoutForView(key: String, serverUrl: String, sort: String = "fileName", ascending: Bool = true, titleButton: String = "_sorted_by_name_a_z_") -> (layout: String, sort: String, ascending: Bool, groupBy: String, directoryOnTop: Bool, titleButton: String, itemForLine: Int) {
  56. var keyStore = key
  57. if serverUrl != "" {
  58. keyStore = serverUrl
  59. }
  60. guard let string = UICKeyChainStore.string(forKey: keyStore, service: NCGlobal.shared.serviceShareKeyChain) else {
  61. setLayoutForView(key: key, serverUrl: serverUrl, layout: NCGlobal.shared.layoutList, sort: sort, ascending: ascending, groupBy: "none", directoryOnTop: true, titleButton: titleButton, itemForLine: 3)
  62. return (NCGlobal.shared.layoutList, sort, ascending, "none", true, titleButton, 3)
  63. }
  64. let array = string.components(separatedBy: "|")
  65. if array.count == 7 {
  66. let sort = NSString(string: array[2])
  67. let directoryOnTop = NSString(string: array[4])
  68. let itemForLine = NSString(string: array[6])
  69. return (array[0], array[1], sort.boolValue, array[3], directoryOnTop.boolValue, array[5], Int(itemForLine.intValue))
  70. }
  71. setLayoutForView(key: key, serverUrl: serverUrl, layout: NCGlobal.shared.layoutList, sort: sort, ascending: ascending, groupBy: "none", directoryOnTop: true, titleButton: titleButton, itemForLine: 3)
  72. return (NCGlobal.shared.layoutList, sort, ascending, "none", true, titleButton, 3)
  73. }
  74. func convertSVGtoPNGWriteToUserData(svgUrlString: String, fileName: String?, width: CGFloat?, rewrite: Bool, account: String, closure: @escaping (String?) -> ()) {
  75. var fileNamePNG = ""
  76. guard let svgUrlString = svgUrlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
  77. return closure(nil)
  78. }
  79. guard let iconURL = URL(string: svgUrlString) else {
  80. return closure(nil)
  81. }
  82. if fileName == nil {
  83. fileNamePNG = iconURL.deletingPathExtension().lastPathComponent + ".png"
  84. } else {
  85. fileNamePNG = fileName!
  86. }
  87. let imageNamePath = CCUtility.getDirectoryUserData() + "/" + fileNamePNG
  88. if !FileManager.default.fileExists(atPath: imageNamePath) || rewrite == true {
  89. NCCommunication.shared.downloadContent(serverUrl: iconURL.absoluteString) { (account, data, errorCode, errorMessage) in
  90. if errorCode == 0 && data != nil {
  91. if let image = UIImage.init(data: data!) {
  92. var newImage: UIImage = image
  93. if width != nil {
  94. let ratio = image.size.height / image.size.width
  95. let newSize = CGSize(width: width!, height: width! * ratio)
  96. let renderFormat = UIGraphicsImageRendererFormat.default()
  97. renderFormat.opaque = false
  98. let renderer = UIGraphicsImageRenderer(size: CGSize(width: newSize.width, height: newSize.height), format: renderFormat)
  99. newImage = renderer.image {
  100. (context) in
  101. image.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height))
  102. }
  103. }
  104. guard let pngImageData = newImage.pngData() else {
  105. return closure(nil)
  106. }
  107. try? pngImageData.write(to: URL(fileURLWithPath:imageNamePath))
  108. return closure(imageNamePath)
  109. } else {
  110. guard let svgImage: SVGKImage = SVGKImage(data: data) else {
  111. return closure(nil)
  112. }
  113. if width != nil {
  114. let scale = svgImage.size.height / svgImage.size.width
  115. svgImage.size = CGSize(width: width!, height: width! * scale)
  116. }
  117. guard let image: UIImage = svgImage.uiImage else {
  118. return closure(nil)
  119. }
  120. guard let pngImageData = image.pngData() else {
  121. return closure(nil)
  122. }
  123. try? pngImageData.write(to: URL(fileURLWithPath:imageNamePath))
  124. return closure(imageNamePath)
  125. }
  126. } else {
  127. return closure(nil)
  128. }
  129. }
  130. } else {
  131. return closure(imageNamePath)
  132. }
  133. }
  134. @objc func isSimulatorOrTestFlight() -> Bool {
  135. guard let path = Bundle.main.appStoreReceiptURL?.path else {
  136. return false
  137. }
  138. return path.contains("CoreSimulator") || path.contains("sandboxReceipt")
  139. }
  140. @objc func isSimulator() -> Bool {
  141. guard let path = Bundle.main.appStoreReceiptURL?.path else {
  142. return false
  143. }
  144. return path.contains("CoreSimulator")
  145. }
  146. @objc func isRichDocument(_ metadata: tableMetadata) -> Bool {
  147. guard let mimeType = CCUtility.getMimeType(metadata.fileNameView) else {
  148. return false
  149. }
  150. guard let richdocumentsMimetypes = NCManageDatabase.shared.getCapabilitiesServerArray(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes) else {
  151. return false
  152. }
  153. if richdocumentsMimetypes.count > 0 && mimeType.components(separatedBy: ".").count > 2 {
  154. let mimeTypeArray = mimeType.components(separatedBy: ".")
  155. let mimeType = mimeTypeArray[mimeTypeArray.count - 2] + "." + mimeTypeArray[mimeTypeArray.count - 1]
  156. for richdocumentMimetype: String in richdocumentsMimetypes {
  157. if richdocumentMimetype.contains(mimeType) {
  158. return true
  159. }
  160. }
  161. }
  162. return false
  163. }
  164. @objc func isDirectEditing(account: String, contentType: String) -> String? {
  165. var editor: String?
  166. guard let results = NCManageDatabase.shared.getDirectEditingEditors(account: account) else {
  167. return editor
  168. }
  169. for result: tableDirectEditingEditors in results {
  170. for mimetype in result.mimetypes {
  171. if mimetype == contentType {
  172. editor = result.editor
  173. }
  174. // HARDCODE
  175. // https://github.com/nextcloud/text/issues/913
  176. if mimetype == "text/markdown" && contentType == "text/x-markdown" {
  177. editor = result.editor
  178. }
  179. }
  180. for mimetype in result.optionalMimetypes {
  181. if mimetype == contentType {
  182. editor = result.editor
  183. }
  184. }
  185. }
  186. // HARDCODE
  187. if editor == "" {
  188. editor = NCGlobal.shared.editorText
  189. }
  190. return editor
  191. }
  192. @objc func removeAllSettings() {
  193. URLCache.shared.memoryCapacity = 0
  194. URLCache.shared.diskCapacity = 0
  195. KTVHTTPCache.cacheDeleteAllCaches()
  196. NCManageDatabase.shared.clearDatabase(account: nil, removeAccount: true)
  197. CCUtility.removeGroupDirectoryProviderStorage()
  198. CCUtility.removeGroupLibraryDirectory()
  199. CCUtility.removeDocumentsDirectory()
  200. CCUtility.removeTemporaryDirectory()
  201. CCUtility.createDirectoryStandard()
  202. CCUtility.deleteAllChainStore()
  203. }
  204. @objc func permissionsContainsString(_ metadataPermissions: String, permissions: String) -> Bool {
  205. for char in permissions {
  206. if metadataPermissions.contains(char) == false {
  207. return false
  208. }
  209. }
  210. return true
  211. }
  212. @objc func getCustomUserAgentOnlyOffice() -> String {
  213. let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")!
  214. if UIDevice.current.userInterfaceIdiom == .pad {
  215. return "Mozilla/5.0 (iPad) Nextcloud-iOS/\(appVersion)"
  216. }else{
  217. return "Mozilla/5.0 (iPhone) Mobile Nextcloud-iOS/\(appVersion)"
  218. }
  219. }
  220. @objc func pdfThumbnail(url: URL, width: CGFloat = 240) -> UIImage? {
  221. guard let data = try? Data(contentsOf: url), let page = PDFDocument(data: data)?.page(at: 0) else {
  222. return nil
  223. }
  224. let pageSize = page.bounds(for: .mediaBox)
  225. let pdfScale = width / pageSize.width
  226. // Apply if you're displaying the thumbnail on screen
  227. let scale = UIScreen.main.scale * pdfScale
  228. let screenSize = CGSize(width: pageSize.width * scale, height: pageSize.height * scale)
  229. return page.thumbnail(of: screenSize, for: .mediaBox)
  230. }
  231. @objc func isQuickLookDisplayable(metadata: tableMetadata) -> Bool {
  232. return true
  233. }
  234. @objc func ocIdToFileId(ocId: String?) -> String? {
  235. guard let ocId = ocId else { return nil }
  236. let items = ocId.components(separatedBy: "oc")
  237. if items.count < 2 { return nil }
  238. guard let intFileId = Int(items[0]) else { return nil }
  239. return String(intFileId)
  240. }
  241. func getUserStatus(userIcon: String?, userStatus: String?, userMessage: String?) -> (onlineStatus: UIImage?, statusMessage: String) {
  242. var onlineStatus: UIImage?
  243. var statusMessage: String = ""
  244. var messageUserDefined: String = ""
  245. if userStatus?.lowercased() == "online" {
  246. onlineStatus = UIImage.init(named: "userStatusOnline")!.image(color: UIColor(red: 103.0/255.0, green: 176.0/255.0, blue: 134.0/255.0, alpha: 1.0), size: 50)
  247. messageUserDefined = NSLocalizedString("_online_", comment: "")
  248. }
  249. if userStatus?.lowercased() == "away" {
  250. onlineStatus = UIImage.init(named: "userStatusAway")!.image(color: UIColor(red: 233.0/255.0, green: 166.0/255.0, blue: 75.0/255.0, alpha: 1.0), size: 50)
  251. messageUserDefined = NSLocalizedString("_away_", comment: "")
  252. }
  253. if userStatus?.lowercased() == "dnd" {
  254. onlineStatus = UIImage.init(named: "userStatusDnd")?.resizeImage(size: CGSize(width: 100, height: 100), isAspectRation: false)
  255. messageUserDefined = NSLocalizedString("_dnd_", comment: "")
  256. }
  257. if userStatus?.lowercased() == "offline" || userStatus?.lowercased() == "invisible" {
  258. onlineStatus = UIImage.init(named: "userStatusOffline")!.image(color: .black, size: 50)
  259. messageUserDefined = NSLocalizedString("_invisible_", comment: "")
  260. }
  261. if let userIcon = userIcon {
  262. statusMessage = userIcon + " "
  263. }
  264. if let userMessage = userMessage {
  265. statusMessage = statusMessage + userMessage
  266. }
  267. statusMessage = statusMessage.trimmingCharacters(in: .whitespaces)
  268. if statusMessage == "" {
  269. statusMessage = messageUserDefined
  270. }
  271. return(onlineStatus, statusMessage)
  272. }
  273. func imageFromVideo(url: URL, at time: TimeInterval) -> UIImage? {
  274. let asset = AVURLAsset(url: url)
  275. let assetIG = AVAssetImageGenerator(asset: asset)
  276. assetIG.appliesPreferredTrackTransform = true
  277. assetIG.apertureMode = AVAssetImageGenerator.ApertureMode.encodedPixels
  278. let cmTime = CMTime(seconds: time, preferredTimescale: 60)
  279. let thumbnailImageRef: CGImage
  280. do {
  281. thumbnailImageRef = try assetIG.copyCGImage(at: cmTime, actualTime: nil)
  282. } catch let error {
  283. print("Error: \(error)")
  284. return nil
  285. }
  286. return UIImage(cgImage: thumbnailImageRef)
  287. }
  288. func createImageFrom(fileName: String, ocId: String, etag: String, typeFile: String) {
  289. var originalImage, scaleImagePreview, scaleImageIcon: UIImage?
  290. let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
  291. let fileNamePathPreview = CCUtility.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag)!
  292. let fileNamePathIcon = CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)!
  293. if FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return }
  294. if !CCUtility.fileProviderStorageExists(ocId, fileNameView: fileName) { return }
  295. if typeFile != NCGlobal.shared.metadataTypeFileImage && typeFile != NCGlobal.shared.metadataTypeFileVideo { return }
  296. if typeFile == NCGlobal.shared.metadataTypeFileImage {
  297. originalImage = UIImage.init(contentsOfFile: fileNamePath)
  298. scaleImagePreview = originalImage?.resizeImage(size: CGSize(width: NCGlobal.shared.sizePreview, height: NCGlobal.shared.sizePreview), isAspectRation: false)
  299. scaleImageIcon = originalImage?.resizeImage(size: CGSize(width: NCGlobal.shared.sizeIcon, height: NCGlobal.shared.sizeIcon), isAspectRation: false)
  300. try? scaleImagePreview?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathPreview))
  301. try? scaleImageIcon?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathIcon))
  302. } else if typeFile == NCGlobal.shared.metadataTypeFileVideo {
  303. let videoPath = NSTemporaryDirectory()+"tempvideo.mp4"
  304. NCUtilityFileSystem.shared.linkItem(atPath: fileNamePath, toPath: videoPath)
  305. originalImage = imageFromVideo(url: URL(fileURLWithPath: videoPath), at: 0)
  306. try? originalImage?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathPreview))
  307. try? originalImage?.jpegData(compressionQuality: 0.7)?.write(to: URL(fileURLWithPath: fileNamePathIcon))
  308. }
  309. }
  310. @objc func getVersionApp() -> String {
  311. if let dictionary = Bundle.main.infoDictionary {
  312. if let version = dictionary["CFBundleShortVersionString"], let build = dictionary["CFBundleVersion"] {
  313. return "\(version).\(build)"
  314. }
  315. }
  316. return ""
  317. }
  318. func loadImage(named: String, color: UIColor = NCBrandColor.shared.gray, size: CGFloat = 50, symbolConfiguration: Any? = nil) -> UIImage {
  319. var image: UIImage?
  320. if #available(iOS 13.0, *) {
  321. if let symbolConfiguration = symbolConfiguration {
  322. image = UIImage(systemName: named, withConfiguration: symbolConfiguration as? UIImage.Configuration)?.imageColor(color)
  323. } else {
  324. image = UIImage(systemName: named)?.imageColor(color)
  325. }
  326. if image == nil {
  327. image = UIImage(named: named)?.image(color: color, size: size)
  328. }
  329. } else {
  330. image = UIImage(named: named)?.image(color: color, size: size)
  331. }
  332. if image != nil {
  333. return image!
  334. }
  335. return UIImage(named: "file")!.image(color: color, size: size)
  336. }
  337. @objc func createAvatar(image: UIImage, size: CGFloat) -> UIImage {
  338. var avatarImage = image
  339. let rect = CGRect(x: 0, y: 0, width: size, height: size)
  340. UIGraphicsBeginImageContextWithOptions(rect.size, false, 3.0)
  341. UIBezierPath.init(roundedRect: rect, cornerRadius: rect.size.height).addClip()
  342. avatarImage.draw(in: rect)
  343. avatarImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
  344. UIGraphicsEndImageContext()
  345. return avatarImage
  346. }
  347. // MARK: -
  348. @objc func startActivityIndicator(backgroundView: UIView?, blurEffect: Bool, bottom: CGFloat = 0, style: UIActivityIndicatorView.Style = .whiteLarge) {
  349. if self.activityIndicator != nil {
  350. stopActivityIndicator()
  351. }
  352. self.activityIndicator = UIActivityIndicatorView(style: style)
  353. guard let activityIndicator = self.activityIndicator else { return }
  354. DispatchQueue.main.async {
  355. if self.viewBackgroundActivityIndicator != nil { return }
  356. activityIndicator.color = NCBrandColor.shared.label
  357. activityIndicator.hidesWhenStopped = true
  358. activityIndicator.translatesAutoresizingMaskIntoConstraints = false
  359. let sizeActivityIndicator = activityIndicator.frame.height + 50
  360. self.viewActivityIndicator = UIView.init(frame: CGRect(x: 0, y: 0, width: sizeActivityIndicator, height: sizeActivityIndicator))
  361. self.viewActivityIndicator?.translatesAutoresizingMaskIntoConstraints = false
  362. self.viewActivityIndicator?.layer.cornerRadius = 10
  363. self.viewActivityIndicator?.layer.masksToBounds = true
  364. self.viewActivityIndicator?.backgroundColor = .clear
  365. #if !EXTENSION
  366. if backgroundView == nil {
  367. if let window = UIApplication.shared.keyWindow {
  368. self.viewBackgroundActivityIndicator?.removeFromSuperview()
  369. self.viewBackgroundActivityIndicator = NCViewActivityIndicator(frame: window.bounds)
  370. window.addSubview(self.viewBackgroundActivityIndicator!)
  371. self.viewBackgroundActivityIndicator?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  372. self.viewBackgroundActivityIndicator?.backgroundColor = .clear
  373. }
  374. } else {
  375. self.viewBackgroundActivityIndicator = backgroundView
  376. }
  377. #else
  378. self.viewBackgroundActivityIndicator = backgroundView
  379. #endif
  380. // VIEW ACTIVITY INDICATOR
  381. guard let viewActivityIndicator = self.viewActivityIndicator else { return }
  382. viewActivityIndicator.addSubview(activityIndicator)
  383. if blurEffect {
  384. let blurEffect = UIBlurEffect(style: .regular)
  385. let blurEffectView = UIVisualEffectView(effect: blurEffect)
  386. blurEffectView.frame = viewActivityIndicator.frame
  387. viewActivityIndicator.insertSubview(blurEffectView, at: 0)
  388. }
  389. NSLayoutConstraint.activate([
  390. viewActivityIndicator.widthAnchor.constraint(equalToConstant: sizeActivityIndicator),
  391. viewActivityIndicator.heightAnchor.constraint(equalToConstant: sizeActivityIndicator),
  392. activityIndicator.centerXAnchor.constraint(equalTo: viewActivityIndicator.centerXAnchor),
  393. activityIndicator.centerYAnchor.constraint(equalTo: viewActivityIndicator.centerYAnchor)
  394. ])
  395. // BACKGROUD VIEW ACTIVITY INDICATOR
  396. guard let viewBackgroundActivityIndicator = self.viewBackgroundActivityIndicator else { return }
  397. viewBackgroundActivityIndicator.addSubview(viewActivityIndicator)
  398. var verticalConstant: CGFloat = 0
  399. if bottom > 0 {
  400. verticalConstant = (viewBackgroundActivityIndicator.frame.size.height / 2) - bottom
  401. }
  402. NSLayoutConstraint.activate([
  403. viewActivityIndicator.centerXAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerXAnchor),
  404. viewActivityIndicator.centerYAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerYAnchor, constant: verticalConstant)
  405. ])
  406. activityIndicator.startAnimating()
  407. }
  408. }
  409. @objc func stopActivityIndicator() {
  410. DispatchQueue.main.async {
  411. self.activityIndicator?.stopAnimating()
  412. self.activityIndicator?.removeFromSuperview()
  413. self.activityIndicator = nil
  414. self.viewActivityIndicator?.removeFromSuperview()
  415. self.viewActivityIndicator = nil
  416. if self.viewBackgroundActivityIndicator is NCViewActivityIndicator {
  417. self.viewBackgroundActivityIndicator?.removeFromSuperview()
  418. }
  419. self.viewBackgroundActivityIndicator = nil
  420. }
  421. }
  422. }
  423. // MARK: -
  424. class NCViewActivityIndicator: UIView {
  425. // MARK: - View Life Cycle
  426. override init(frame: CGRect) {
  427. super.init(frame: frame)
  428. }
  429. required init?(coder: NSCoder) {
  430. fatalError("init(coder:) has not been implemented")
  431. }
  432. }