Remove duplicated code
This commit is contained in:
parent
96dff90608
commit
8d76cfdcd3
|
@ -240,18 +240,14 @@ struct StatusView: View {
|
|||
}
|
||||
|
||||
if let imageHeight = self.imageHeight, let imageWidth = self.imageWidth, imageHeight > 0 && imageWidth > 0 {
|
||||
return self.calculateHeight(width: Double(imageWidth), height: Double(imageHeight))
|
||||
let calculatedSize = ImageSizeService.shared.calculate(width: Double(imageWidth), height: Double(imageHeight))
|
||||
return calculatedSize.height
|
||||
}
|
||||
|
||||
// If we don't have image height and width in metadata, we have to use some constant height.
|
||||
return UIScreen.main.bounds.width * 0.75
|
||||
}
|
||||
|
||||
private func calculateHeight(width: Double, height: Double) -> CGFloat {
|
||||
let divider = width / UIScreen.main.bounds.size.width
|
||||
return height / divider
|
||||
}
|
||||
|
||||
private func getMainStatus(status: StatusModel) async throws -> StatusModel {
|
||||
guard let inReplyToId = status.inReplyToId else {
|
||||
return status
|
||||
|
|
|
@ -224,7 +224,8 @@ struct ImageViewer: View {
|
|||
|
||||
private func calculateStartingOffset() -> CGSize {
|
||||
// Image size on the screen.
|
||||
let imageOnScreenHeight = self.calculateHeight(width: self.imageWidth, height: self.imageHeight)
|
||||
let calculatedSize = ImageSizeService.shared.calculate(width: self.imageWidth, height: self.imageHeight)
|
||||
let imageOnScreenHeight = calculatedSize.height
|
||||
|
||||
// Calculate full space for image.
|
||||
let safeAreaInsetsTop = UIApplication.shared.keyWindow?.safeAreaInsets.top ?? 20.0
|
||||
|
@ -254,9 +255,4 @@ struct ImageViewer: View {
|
|||
return 88.0
|
||||
}
|
||||
}
|
||||
|
||||
private func calculateHeight(width: Double, height: Double) -> CGFloat {
|
||||
let divider = width / UIScreen.main.bounds.size.width
|
||||
return height / divider
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue