mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-27 15:06:12 +00:00
1152b5d737
* ios api
* ios wip
* android wip
* ios files folder
* ios get address on start
* android app files folder
* ios more backend
* android more backend
* translation
* ios image without text, remove preview
* android image without text, remove preview
* fix translation
* file name in previews and w/t text
* Revert "file name in previews and w/t text"
This reverts commit 0110570e55.
* ios filename in preview
* android filename in preview
* android wider images
* ios determine width on image for correct quote width
* ios images in previews wip
* ios square image in quote
* ios: update image layout
* android images in quotes
* android remove redundant modifier
* android clip to bounds
* android - image in right side of quote
* android refactor image view
* android - refactor, align quote text top
* android fix emoji view
* fix image layout
* full screen image view, fix quote layout
* android various size
* android fixed image width
* android meta on image
* ios: add drag gesture to hide full-screen image
* android: make image-only meta white
* refactor file.stored
* android: meta icon color
* android: open chat scrolled to last unread item
* copy/share image messages
* android: full screen image
* check file is loaded
* terminal: refactor view for messages with files
* android: change to onClick, only show stored file
* android: remove close sheet bar
* android: close image view on click
* translation
* android: pass showMenu to CIImageView to show menu on long click
* increase DropDown width
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
57 lines
1.8 KiB
Swift
57 lines
1.8 KiB
Swift
//
|
|
// CIImageView.swift
|
|
// SimpleX
|
|
//
|
|
// Created by JRoberts on 12/04/2022.
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct CIImageView: View {
|
|
@Environment(\.colorScheme) var colorScheme
|
|
let image: String
|
|
let file: CIFile?
|
|
let maxWidth: CGFloat
|
|
@Binding var imgWidth: CGFloat?
|
|
@State var showFullScreenImage = false
|
|
|
|
var body: some View {
|
|
VStack(alignment: .center, spacing: 6) {
|
|
if let uiImage = getStoredImage(file) {
|
|
imageView(uiImage)
|
|
.fullScreenCover(isPresented: $showFullScreenImage) {
|
|
ZStack {
|
|
Color.black.edgesIgnoringSafeArea(.all)
|
|
Image(uiImage: uiImage)
|
|
.resizable()
|
|
.scaledToFit()
|
|
}
|
|
.onTapGesture { showFullScreenImage = false }
|
|
.gesture(
|
|
DragGesture(minimumDistance: 80).onChanged { gesture in
|
|
let t = gesture.translation
|
|
if t.height > 60 && t.height > abs(t.width) {
|
|
showFullScreenImage = false
|
|
}
|
|
}
|
|
)
|
|
}
|
|
.onTapGesture { showFullScreenImage = true }
|
|
} else if let data = Data(base64Encoded: dropImagePrefix(image)),
|
|
let uiImage = UIImage(data: data) {
|
|
imageView(uiImage)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func imageView(_ img: UIImage) -> some View {
|
|
let w = img.size.width > img.size.height ? .infinity : maxWidth * 0.75
|
|
DispatchQueue.main.async { imgWidth = w }
|
|
return Image(uiImage: img)
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(maxWidth: w)
|
|
}
|
|
}
|