Skip to content

Commit

Permalink
Part of 1.2.0 (#105)
Browse files Browse the repository at this point in the history
* part of importing functionalyti

* added import functionality

* fixed nfc screen

* no message

* Fixed fetch context

Co-authored-by: Alexandr Chernyy <[email protected]>
  • Loading branch information
alexchornyi and pingus-nikalex authored Sep 16, 2021
1 parent 223c26d commit 7c5e217
Show file tree
Hide file tree
Showing 26 changed files with 1,849 additions and 71 deletions.
10 changes: 10 additions & 0 deletions DGCAWallet.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
</array>
</dict>
</plist>
134 changes: 124 additions & 10 deletions DGCAWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"repositoryURL": "https://github.com/eu-digital-green-certificates/dgc-certlogic-ios.git",
"state": {
"branch": "main",
"revision": "8f07a22ec2adc2335b4a4cb75b408c8c93d86208",
"revision": "80c9ff3697b3e3e0e875e5e0a41b2dbbfa4a9ca6",
"version": null
}
},
Expand Down
64 changes: 64 additions & 0 deletions DGCAWallet/Components/ImageTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-wallet-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/
//
// ImageTableViewCell.swift
// DGCAWallet
//
// Created by Alexandr Chernyy on 25.08.2021.
//


import UIKit

final class ImageTableViewCell: UITableViewCell {

@IBOutlet weak var imagePreviewView: UIImageView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var timeLabel: UILabel!

private var savedImage: SavedImage? {
didSet {
setupView()
}
}

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupView()
}

public func setImage(image: SavedImage) {
savedImage = image
}

private func setupView() {
guard let savedImage = savedImage else {
imagePreviewView.image = nil
nameLabel.text = ""
return
}
imagePreviewView.image = savedImage.image
nameLabel.text = savedImage.fileName
timeLabel.text = savedImage.dateString
}

}
75 changes: 75 additions & 0 deletions DGCAWallet/Components/PDFTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-wallet-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/
//
// PDFTableViewCell.swift
// DGCAWallet
//
// Created by Alexandr Chernyy on 25.08.2021.
//


import UIKit
import PDFKit

class PDFTableViewCell: UITableViewCell {

@IBOutlet weak var pdfView: UIView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var timeLabel: UILabel!

private var savedPDF: SavedPDF? {
didSet {
setupView()
}
}
private var pdfViewer: PDFView?

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupView()
}

public func setPDF(pdf: SavedPDF) {
savedPDF = pdf
}

private func setupView() {
guard let savedPDF = savedPDF else {
nameLabel.text = ""
return
}
if pdfViewer == nil {
pdfViewer = PDFView(frame: pdfView.bounds)
pdfViewer?.autoScales = true
let scrollView = pdfViewer?.subviews[0] as? UIScrollView
if scrollView != nil {
scrollView!.isScrollEnabled = false
}
pdfView.addSubview(pdfViewer!)
}
if let document = savedPDF.pdf {
pdfViewer!.document = document
}
nameLabel.text = savedPDF.fileName
timeLabel.text = savedPDF.dateString
}
}
11 changes: 11 additions & 0 deletions DGCAWallet/DGCAWallet.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
<string>TAG</string>
</array>
</dict>
</plist>
38 changes: 38 additions & 0 deletions DGCAWallet/Extensions/String+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-wallet-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/
//
// String+.swift
// DGCAWallet
//
// Created by Alexandr Chernyy on 23.08.2021.
//


import Foundation
import UIKit

extension String {
func convertBase64StringToImage () -> UIImage? {
guard let imageData = Data.init(base64Encoded: self, options: .init(rawValue: 0)) else { return nil }
let image = UIImage(data: imageData)
return image
}
}
53 changes: 53 additions & 0 deletions DGCAWallet/Extensions/UIImage+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-wallet-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/
//
// UIImage+.swift
// DGCAWallet
//
// Created by Alexandr Chernyy on 20.08.2021.
//


import UIKit

extension UIImage {
func qrCodeString() -> String? {
var qrAsString = ""
guard let detector = CIDetector(ofType: CIDetectorTypeQRCode,
context: nil,
options: [CIDetectorAccuracy: CIDetectorAccuracyHigh]),
let ciImage = CIImage(image: self),
let features = detector.features(in: ciImage) as? [CIQRCodeFeature] else {
return qrAsString
}
for feature in features {
guard let indeedMessageString = feature.messageString else {
continue
}
qrAsString += indeedMessageString
}
return qrAsString.isEmpty ? nil : qrAsString
}

func convertImageToBase64String () -> String {
return self.jpegData(compressionQuality: 1)?.base64EncodedString() ?? ""
}
}
17 changes: 12 additions & 5 deletions DGCAWallet/Extensions/UIViewController+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@
import UIKit

extension UIViewController {
static func loadFromNib() -> Self {
func instantiateFromNib<T: UIViewController>() -> T {
return T.init(nibName: String(describing: T.self), bundle: Bundle.init(for: Self.self))
}
return instantiateFromNib()
static func loadFromNib() -> Self {
func instantiateFromNib<T: UIViewController>() -> T {
return T.init(nibName: String(describing: T.self), bundle: Bundle.init(for: Self.self))
}
return instantiateFromNib()
}

@available(iOS 13.0, *)
var sceneDelegate: SceneDelegate? {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let delegate = windowScene.delegate as? SceneDelegate else { return nil }
return delegate
}
}
75 changes: 75 additions & 0 deletions DGCAWallet/Models/ImageDataStorage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-wallet-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/
//
// ImageDataStorage.swift
// DGCAWallet
//
// Created by Alexandr Chernyy on 23.08.2021.
//


import Foundation
import SwiftDGC

struct ImageDataStorage: Codable {
static var sharedInstance = ImageDataStorage()
static let storage = SecureStorage<ImageDataStorage>(fileName: "images_secure")

var images = [SavedImage]()

mutating func add(savedImage: SavedImage) {
let list = images
if list.contains(where: { image in
image.identifier == savedImage.identifier
}) {
return
}
images.append(savedImage)
save()
}

public func save() {
Self.storage.save(self)
}

public mutating func deleteImageWith(identifier: String) {
self.images = self.images.filter { $0.identifier != identifier }
save()
}

public func isImageExistWith(identifier: String) -> Bool {
let list = images
return list.contains(where: { image in
image.identifier == identifier
})
}
static func initialize(completion: @escaping () -> Void) {
storage.loadOverride(fallback: ImageDataStorage.sharedInstance) { success in
guard let result = success else {
return
}
let format = l10n("log.images")
print(String.localizedStringWithFormat(format, result.images.count))
ImageDataStorage.sharedInstance = result
completion()
}
}
}
Loading

0 comments on commit 7c5e217

Please sign in to comment.