From 959ff56045676ee4be5fa0b063890a17fbf8f7b5 Mon Sep 17 00:00:00 2001
From: Oliver Wiese <oliver.wiese@fu-berlin.de>
Date: Sat, 26 Jan 2019 09:54:22 +0100
Subject: [PATCH] update security indicator animation

---
 enzevalos_iphone/AnimatedSendIcon.swift | 35 +++++++++++++++----------
 enzevalos_iphone/StudySettings.swift    |  3 ++-
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/enzevalos_iphone/AnimatedSendIcon.swift b/enzevalos_iphone/AnimatedSendIcon.swift
index a469e485..79a93830 100644
--- a/enzevalos_iphone/AnimatedSendIcon.swift
+++ b/enzevalos_iphone/AnimatedSendIcon.swift
@@ -26,30 +26,39 @@ class AnimatedSendIcon: UIView {
     var isPostcardOnTop = false
     var square = UIImageView(image: StudySettings.securityIndicator.imageOfSecureIndicator(background: true, open: false))
     var square2 = UIImageView(image: StudySettings.securityIndicator.imageOfInsecureIndicator(background: true))
-    let width = 100.0
-    let height = 70.0
+    let width: Double //=  100.0
+    let height: Double// = 70.0
     let f = 0.8
     var size = CGSize()
     var sizeSmall = CGSize()
-    let front = CGPoint(x: 30, y: 35)
+    let front = CGPoint(x: 30, y: 30)
     let back = CGPoint(x: 100, y: 15)
+    var scale = false
+    var scaleFactor = 1.0
     
     override init(frame: CGRect) {
+        if let w = square.image?.size.width {
+            scaleFactor = min(100.0 / Double(w), 2.6)
+            self.width = Double(w) * scaleFactor
+        }
+        else {
+            self.width = 100.0
+        }
+        if let h = square.image?.size.height {
+            self.height = Double(h) * scaleFactor
+        }
+        else {
+            self.height = 70.0
+        }
+        
+        
         super.init(frame: frame)
         self.isUserInteractionEnabled = false
         
         let resizing: ResizingBehavior = .aspectFit
-//        let context = UIGraphicsGetCurrentContext()!
-//        //// Resize to Target Frame
-//        CGContextSaveGState(context)
         let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 200, height: 110), target: CGRect(x: 40, y: -10, width: 113, height: 48))
-//        CGContextTranslateCTM(context, resizedFrame.minX, resizedFrame.minY)
-//        CGContextScaleCTM(context, resizedFrame.width / 200, resizedFrame.height / 110)
-//        
-//        self.view.transform = CGAffineTransformMakeScale(2, 2)
-        
+
         self.transform = CGAffineTransform(scaleX: resizedFrame.width / 200, y: resizedFrame.height / 110)
-        //        self = UIView(frame: frame) //UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 110))
         self.backgroundColor = UIColor.white
         
         size = CGSize(width: width, height: height)
@@ -64,8 +73,6 @@ class AnimatedSendIcon: UIView {
         
         self.addSubview(square)
         self.addSubview(square2)
-        
-//        CGContextRestoreGState(context)
     }
     
     required init?(coder aDecoder: NSCoder) {
diff --git a/enzevalos_iphone/StudySettings.swift b/enzevalos_iphone/StudySettings.swift
index 22ad9b8c..2a2ec0fa 100644
--- a/enzevalos_iphone/StudySettings.swift
+++ b/enzevalos_iphone/StudySettings.swift
@@ -80,7 +80,8 @@ class StudySettings {
     static var studyMode = true
     static var presentFirstQuestionaireMail = false
     static let parameters = [StudyParamter.Indicator]
-    static let securityIndicator = SecurityIndicator.padlock
+    static let securityIndicator = SecurityIndicator.letter
+
     
     
     static let bitcoinStudyBody =
-- 
GitLab