Skip to content

Commit e867295

Browse files
authored
Exposed views for the photo attachment picker (#206)
1 parent 63620fe commit e867295

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerHelperViews.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,42 @@ import StreamChat
66
import SwiftUI
77

88
/// View used to indicate that an asset is a video.
9-
struct VideoIndicatorView: View {
9+
public struct VideoIndicatorView: View {
1010

1111
@Injected(\.images) private var images
12-
13-
var body: some View {
12+
13+
public init() {}
14+
15+
public var body: some View {
1416
BottomLeftView {
1517
Image(uiImage: images.videoIndicator)
1618
.customizable()
1719
.frame(width: 22)
1820
.padding(2)
1921
.applyDefaultIconOverlayStyle()
22+
.modifier(ShadowModifier())
2023
}
2124
}
2225
}
2326

2427
/// View displaying the duration of the video.
25-
struct VideoDurationIndicatorView: View {
28+
public struct VideoDurationIndicatorView: View {
2629
@Injected(\.colors) private var colors
2730
@Injected(\.fonts) private var fonts
2831

2932
var duration: String
30-
31-
var body: some View {
33+
34+
public init(duration: String) {
35+
self.duration = duration
36+
}
37+
38+
public var body: some View {
3239
BottomRightView {
3340
Text(duration)
3441
.foregroundColor(Color(colors.staticColorText))
3542
.font(fonts.footnoteBold)
3643
.padding(.all, 4)
44+
.modifier(ShadowModifier())
3745
}
3846
}
3947
}

Sources/StreamChatSwiftUI/ChatChannel/Composer/PhotoAssetsUtils.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class PhotoAssetLoader: NSObject, ObservableObject {
9191
}
9292
}
9393

94-
extension PHAsset {
94+
public extension PHAsset {
9595
/// Return a formatted duration string of an asset.
9696
var durationString: String {
9797
let minutes = Int(duration / 60)
@@ -125,6 +125,10 @@ public struct PHFetchResultCollection: RandomAccessCollection, Equatable {
125125
public var endIndex: Int { fetchResult.count }
126126
public var startIndex: Int { 0 }
127127

128+
public init(fetchResult: PHFetchResult<PHAsset>) {
129+
self.fetchResult = fetchResult
130+
}
131+
128132
public subscript(position: Int) -> PHAsset {
129133
fetchResult.object(at: position)
130134
}

Sources/StreamChatSwiftUI/ChatChannel/Utils/ChatChannelHelpers.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public struct BottomRightView<Content: View>: View {
6464
/// View container that allows injecting another view in its bottom left corner.
6565
public struct BottomLeftView<Content: View>: View {
6666
var content: () -> Content
67-
67+
68+
public init(content: @escaping () -> Content) {
69+
self.content = content
70+
}
71+
6872
public var body: some View {
6973
HStack {
7074
VStack {

Sources/StreamChatSwiftUI/Utils/KeyboardHandling.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public struct HideKeyboardOnTapGesture: ViewModifier {
8181
}
8282

8383
/// Resigns first responder and hides the keyboard.
84-
func resignFirstResponder() {
84+
public func resignFirstResponder() {
8585
UIApplication.shared.sendAction(
8686
#selector(UIResponder.resignFirstResponder),
8787
to: nil,

Sources/StreamChatSwiftUI/Utils/Modifiers.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ struct ShadowViewModifier: ViewModifier {
2525
}
2626

2727
/// Modifier for adding shadow to a view.
28-
struct ShadowModifier: ViewModifier {
29-
func body(content: Content) -> some View {
28+
public struct ShadowModifier: ViewModifier {
29+
public init() {}
30+
31+
public func body(content: Content) -> some View {
3032
content
3133
.shadow(color: Color.black.opacity(0.1), radius: 10, x: 0, y: 12)
3234
.shadow(color: Color.black.opacity(0.1), radius: 1, x: 0, y: 1)

0 commit comments

Comments
 (0)