Implemented resizing TAN image

This commit is contained in:
dankito 2020-08-04 00:53:34 +02:00
parent c50a64f2ee
commit 8f15bd25b3
3 changed files with 50 additions and 1 deletions

View File

@ -65,6 +65,7 @@
"Enter TAN Dialog Title" = "Enter TAN"; "Enter TAN Dialog Title" = "Enter TAN";
"TAN procedure" = "TAN procedure"; "TAN procedure" = "TAN procedure";
"TAN medium" = "TAN medium"; "TAN medium" = "TAN medium";
"Size" = "Size";
"TAN hint from your bank:" = "Hint from your bank:"; "TAN hint from your bank:" = "Hint from your bank:";
"Enter TAN:" = "TAN"; "Enter TAN:" = "TAN";
"Decoding error" = "Decoding error"; "Decoding error" = "Decoding error";

View File

@ -65,6 +65,7 @@
"Enter TAN Dialog Title" = "TAN-Abfrage"; "Enter TAN Dialog Title" = "TAN-Abfrage";
"TAN procedure" = "TAN Verfahren"; "TAN procedure" = "TAN Verfahren";
"TAN medium" = "TAN Medium"; "TAN medium" = "TAN Medium";
"Size" = "Größe";
"TAN hint from your bank:" = "Hinweis Ihrer Bank:"; "TAN hint from your bank:" = "Hinweis Ihrer Bank:";
"Enter TAN:" = "TAN"; "Enter TAN:" = "TAN";
"Decoding error" = "Dekodierungsfehler"; "Decoding error" = "Dekodierungsfehler";

View File

@ -8,17 +8,64 @@ struct ImageTanView: View {
private var imageData: Data private var imageData: Data
@State private var imageWidth: CGFloat
private let imageMinWidth: CGFloat
private let imageMaxWidth: CGFloat
private let step: CGFloat
init(_ tanChallenge: ImageTanChallenge) { init(_ tanChallenge: ImageTanChallenge) {
self.tanChallenge = tanChallenge self.tanChallenge = tanChallenge
self.imageData = tanChallenge.image.imageBytesAsNSData() self.imageData = tanChallenge.image.imageBytesAsNSData()
let screenWidth = UIScreen.main.bounds.width
let screenWidthQuarter = screenWidth / 4
self.imageMinWidth = screenWidthQuarter < 150 ? 150 : screenWidthQuarter // don't know whey but iOS seems that it doesn't scale image smaller than 150
self.imageMaxWidth = screenWidth
let range = imageMaxWidth - imageMinWidth
self._imageWidth = State(initialValue: imageMinWidth + range / 2)
self.step = range / 20
} }
var body: some View { var body: some View {
UIKitImageView(data: self.imageData) Section {
HStack {
Text("Size")
Spacer()
Rectangle()
.fill(Color.gray)
.frame(width: 6, height: 9)
Slider(value: $imageWidth, in: imageMinWidth...imageMaxWidth, step: step)
Rectangle()
.fill(Color.gray)
.frame(width: 16, height: 19)
} }
HStack {
Spacer()
UIKitImageView(data: self.imageData)
.frame(width: imageWidth, height: imageWidth)
.padding(.horizontal, -32.0)
Spacer()
}
}
}
} }