-
-
Notifications
You must be signed in to change notification settings - Fork 736
Expand file tree
/
Copy pathPhotoView.swift
More file actions
67 lines (61 loc) · 2.34 KB
/
PhotoView.swift
File metadata and controls
67 lines (61 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// PhotoView.swift
// SwiftUIExample
//
// Created by Silence on 2023/9/8.
// Copyright © 2023 洪欣. All rights reserved.
//
import SwiftUI
import HXPhotoPicker
@available(iOS 14.0, *)
struct PhotoView: View {
let asset: Asset
var body: some View {
GeometryReader { proxy in
ZStack {
Image(uiImage: asset.result.image)
.resizable()
.scaledToFill()
.frame(width: proxy.size.width, height: proxy.size.height)
.clipped()
if asset.result.urlReuslt.mediaType == .video {
Image(systemName: "play.fill")
.foregroundColor(.white)
.shadow(radius: 1)
.scaleEffect(2)
}
VStack {
Spacer()
HStack {
if asset.photoAsset.mediaSubType.isVideo {
Image(systemName: "video")
.foregroundColor(.white)
.shadow(radius: 1)
.padding([.leading, .bottom], 5)
Spacer()
Text(asset.videoDuration)
.font(.callout)
.foregroundColor(.white)
.shadow(radius: 1)
.padding([.trailing, .bottom], 5)
}else if asset.photoAsset.isGifAsset {
Spacer()
Text("GIF")
.font(.callout)
.foregroundColor(.white)
.shadow(radius: 1)
.padding([.trailing, .bottom], 5)
}else if asset.photoAsset.mediaSubType.isLivePhoto {
Spacer()
Text("LivePhoto")
.font(.callout)
.foregroundColor(.white)
.shadow(radius: 1)
.padding([.trailing, .bottom], 5)
}
}
}
}
}
}
}