Skip to content

Commit 1a6be7b

Browse files
committed
Move the authorText view in to a variables
1 parent ceb496c commit 1a6be7b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Shared/Views/CommentsView.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ struct CommentView: View {
4444
let comment: Comment
4545
let postAuthor: String
4646
let nestLevel: Int
47+
48+
var authorText: some View {
49+
if comment.author == postAuthor {
50+
return Text(comment.author).foregroundColor(.accentColor)
51+
} else {
52+
return Text(comment.author)
53+
}
54+
}
4755

4856
var body: some View {
4957
Group {
@@ -57,12 +65,7 @@ struct CommentView: View {
5765
/// Content
5866
VStack(alignment: .leading) {
5967
HStack {
60-
if comment.author == postAuthor {
61-
Text(comment.author)
62-
.foregroundColor(.accentColor)
63-
} else {
64-
Text(comment.author)
65-
}
68+
authorText
6669
Image(systemName: "arrow.up")
6770
Text("\(comment.score)")
6871
}

0 commit comments

Comments
 (0)