Implemented resizing TAN image
This commit is contained in:
parent
c50a64f2ee
commit
8f15bd25b3
|
@ -65,6 +65,7 @@
|
|||
"Enter TAN Dialog Title" = "Enter TAN";
|
||||
"TAN procedure" = "TAN procedure";
|
||||
"TAN medium" = "TAN medium";
|
||||
"Size" = "Size";
|
||||
"TAN hint from your bank:" = "Hint from your bank:";
|
||||
"Enter TAN:" = "TAN";
|
||||
"Decoding error" = "Decoding error";
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
"Enter TAN Dialog Title" = "TAN-Abfrage";
|
||||
"TAN procedure" = "TAN Verfahren";
|
||||
"TAN medium" = "TAN Medium";
|
||||
"Size" = "Größe";
|
||||
"TAN hint from your bank:" = "Hinweis Ihrer Bank:";
|
||||
"Enter TAN:" = "TAN";
|
||||
"Decoding error" = "Dekodierungsfehler";
|
||||
|
|
|
@ -8,17 +8,64 @@ struct ImageTanView: View {
|
|||
|
||||
private var imageData: Data
|
||||
|
||||
@State private var imageWidth: CGFloat
|
||||
|
||||
private let imageMinWidth: CGFloat
|
||||
|
||||
private let imageMaxWidth: CGFloat
|
||||
|
||||
private let step: CGFloat
|
||||
|
||||
|
||||
init(_ tanChallenge: ImageTanChallenge) {
|
||||
self.tanChallenge = tanChallenge
|
||||
|
||||
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 {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue