Skip to content

Commit c4f239a

Browse files
committed
Fix comment button
1 parent b4d00ac commit c4f239a

File tree

3 files changed

+51
-42
lines changed

3 files changed

+51
-42
lines changed

Packages/Sources/ArticleFeature/ArticleScreen.swift

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -291,42 +291,49 @@ public struct ArticleScreen: View {
291291
}
292292

293293
HStack(alignment: .bottom, spacing: 8) {
294-
TextField("Message", text: $store.commentText.removeDuplicates(), axis: .vertical)
295-
.font(.subheadline)
296-
.foregroundStyle(Color.Labels.primary)
297-
.lineLimit(1...10)
298-
.focused($focus, equals: ArticleFeature.State.Field.comment)
299-
.padding(.horizontal, 8)
300-
.padding(.vertical, 7)
301-
.background(Color.Background.teritary)
302-
.clipShape(RoundedRectangle(cornerRadius: 18))
303-
.overlay {
304-
RoundedRectangle(cornerRadius: 18)
305-
.stroke(Color.Separator.secondary, lineWidth: 0.33)
294+
TextField(text: $store.commentText.removeDuplicates()) {
295+
Text("Comment...", bundle: .module)
296+
.font(.subheadline)
297+
.foregroundStyle(Color.Labels.quintuple)
298+
}
299+
.font(.subheadline)
300+
.foregroundStyle(Color.Labels.primary)
301+
.lineLimit(1...10)
302+
.focused($focus, equals: ArticleFeature.State.Field.comment)
303+
.padding(.horizontal, 8)
304+
.padding(.vertical, 7)
305+
.background(Color.Background.teritary)
306+
.clipShape(RoundedRectangle(cornerRadius: 18))
307+
.overlay {
308+
RoundedRectangle(cornerRadius: 18)
309+
.stroke(Color.Separator.secondary, lineWidth: 0.33)
306310
}
307311

308-
Button {
309-
store.send(.sendCommentButtonTapped)
310-
} label: {
311-
ZStack {
312-
Circle()
313-
.fill(tintColor)
314-
315-
if store.isUploadingComment {
316-
ProgressView()
317-
.progressViewStyle(.circular)
318-
.tint(Color.Labels.primaryInvariably)
319-
} else {
320-
Image(systemSymbol: .arrowUp)
321-
.font(.body)
322-
.fontWeight(.medium)
323-
.foregroundStyle(Color.Labels.primaryInvariably)
312+
if !store.commentText.isEmpty {
313+
Button {
314+
store.send(.sendCommentButtonTapped)
315+
} label: {
316+
ZStack {
317+
Circle()
318+
.fill(tintColor)
319+
320+
if store.isUploadingComment {
321+
ProgressView()
322+
.progressViewStyle(.circular)
323+
.tint(Color.Labels.primaryInvariably)
324+
} else {
325+
Image(systemSymbol: .arrowUp)
326+
.font(.body)
327+
.fontWeight(.medium)
328+
.foregroundStyle(Color.Labels.primaryInvariably)
329+
}
324330
}
331+
.frame(width: 34, height: 34)
325332
}
326-
.frame(width: 34, height: 34)
333+
.disabled(store.isUploadingComment)
327334
}
328-
.disabled(store.isUploadingComment)
329335
}
336+
.animation(.default, value: store.commentText.isEmpty)
330337
}
331338
.padding(.horizontal, 12)
332339
.padding(.top, 8)
@@ -491,7 +498,9 @@ extension UIApplication {
491498
}
492499

493500
#Preview("Test comments") {
494-
NavigationStack {
501+
@Shared(.userSession) var userSession
502+
userSession = UserSession(userId: 1, token: "1", isHidden: false)
503+
return NavigationStack {
495504
ArticleScreen(
496505
store: Store(
497506
initialState: ArticleFeature.State(

Packages/Sources/ArticleFeature/Resources/Localizable.xcstrings

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
}
5252
}
5353
},
54+
"Comment..." : {
55+
"localizations" : {
56+
"ru" : {
57+
"stringUnit" : {
58+
"state" : "translated",
59+
"value" : "Комментарий..."
60+
}
61+
}
62+
}
63+
},
5464
"Comments (%@):" : {
5565
"localizations" : {
5666
"ru" : {
@@ -121,16 +131,6 @@
121131
}
122132
}
123133
},
124-
"Message" : {
125-
"localizations" : {
126-
"ru" : {
127-
"stringUnit" : {
128-
"state" : "translated",
129-
"value" : "Сообщение"
130-
}
131-
}
132-
}
133-
},
134134
"OK" : {
135135
"localizations" : {
136136
"ru" : {

Packages/Sources/Models/Articles/ArticlePreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public struct ArticlePreview: Sendable, Hashable, Identifiable {
5959
public extension ArticlePreview {
6060
static let mock = ArticlePreview(
6161
id: 123456,
62-
date: Date(timeIntervalSince1970: 1234567890),
62+
date: Date.now,
6363
authorId: 123456,
6464
authorName: "Lorem Ipsum",
6565
commentsAmount: 69,

0 commit comments

Comments
 (0)