Skip to content

Commit 0304829

Browse files
localized texts, code cleanup
1 parent 84284d2 commit 0304829

File tree

4 files changed

+46
-23
lines changed

4 files changed

+46
-23
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerView.swift

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,9 @@ public struct MessageComposerView<Factory: ViewFactory>: View, KeyboardReadable
4141
public var body: some View {
4242
VStack(spacing: 0) {
4343
if quotedMessage != nil {
44-
ZStack {
45-
Text("Reply to Message")
46-
.font(fonts.bodyBold)
47-
48-
HStack {
49-
Spacer()
50-
Button(action: {
51-
withAnimation {
52-
quotedMessage = nil
53-
}
54-
}, label: {
55-
DiscardButtonView()
56-
})
57-
}
58-
}
59-
.frame(height: 32)
44+
QuotedMessageHeaderView(
45+
quotedMessage: $quotedMessage
46+
)
6047
}
6148

6249
HStack(alignment: .bottom) {
@@ -217,3 +204,30 @@ public struct ComposerInputView<Factory: ViewFactory>: View {
217204
!addedFileURLs.isEmpty || !addedAssets.isEmpty
218205
}
219206
}
207+
208+
/// View for the quoted message header.
209+
struct QuotedMessageHeaderView: View {
210+
211+
@Injected(\.fonts) var fonts
212+
213+
@Binding var quotedMessage: ChatMessage?
214+
215+
var body: some View {
216+
ZStack {
217+
Text(L10n.Composer.Title.reply)
218+
.font(fonts.bodyBold)
219+
220+
HStack {
221+
Spacer()
222+
Button(action: {
223+
withAnimation {
224+
quotedMessage = nil
225+
}
226+
}, label: {
227+
DiscardButtonView()
228+
})
229+
}
230+
}
231+
.frame(height: 32)
232+
}
233+
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/QuotedMessageView.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,15 @@ struct QuotedMessageView: View {
136136
}
137137

138138
if !quotedMessage.imageAttachments.isEmpty {
139-
return "Photo"
139+
return L10n.Composer.Quoted.photo
140140
} else if !quotedMessage.giphyAttachments.isEmpty {
141-
return "Giphy"
141+
return L10n.Composer.Quoted.giphy
142142
} else if !quotedMessage.fileAttachments.isEmpty {
143-
return quotedMessage.fileAttachments[0].title ?? "File"
143+
return quotedMessage.fileAttachments[0].title ?? ""
144144
} else if !quotedMessage.videoAttachments.isEmpty {
145-
return "Video"
146-
} else if !quotedMessage.linkAttachments.isEmpty {
147-
return "Link"
145+
return L10n.Composer.Quoted.video
148146
}
149147

150-
return "Unknown"
148+
return ""
151149
}
152150
}

Sources/StreamChatSwiftUI/Generated/L10n.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ internal enum L10n {
119119
/// Send a message
120120
internal static var message: String { L10n.tr("Localizable", "composer.placeholder.message") }
121121
}
122+
internal enum Quoted {
123+
/// Giphy
124+
internal static var giphy: String { L10n.tr("Localizable", "composer.quoted.giphy") }
125+
/// Photo
126+
internal static var photo: String { L10n.tr("Localizable", "composer.quoted.photo") }
127+
/// Video
128+
internal static var video: String { L10n.tr("Localizable", "composer.quoted.video") }
129+
}
122130
internal enum Suggestions {
123131
internal enum Commands {
124132
/// Instant Commands

Sources/StreamChatSwiftUI/Resources/en.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
"composer.files.add-more" = "Add more files";
7171
"composer.images.no-access-library" = "You have not granted access to the photo library.";
7272
"composer.images.access-settings" = "Change in Settings";
73+
"composer.quoted.photo" = "Photo";
74+
"composer.quoted.video" = "Video";
75+
"composer.quoted.giphy" = "Giphy";
7376

7477
"composer.suggestions.commands.header" = "Instant Commands";
7578
"message.sending.attachment-uploading-failed" = "UPLOADING FAILED";

0 commit comments

Comments
 (0)