Skip to content

Commit

Permalink
[Feat] #473 - Disable withdrawn user
Browse files Browse the repository at this point in the history
  • Loading branch information
jim4020key committed Jul 24, 2023
1 parent ae563ed commit ff46b6e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions HappyAnding/HappyAnding/Extensions/View/View+Navigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ struct NavigationViewModifier: ViewModifier {
func body(content: Content) -> some View {
content

.navigationDestination(for: User?.self) { data in
ShowProfileView(viewModel: ShowProfileViewModel(data: data ?? User()))
.navigationDestination(for: User.self) { data in
ShowProfileView(viewModel: ShowProfileViewModel(data: data))
}
.navigationDestination(for: Curation.self) { data in
ReadCurationView(viewModel: ReadCurationViewModel(data: data))
Expand Down
23 changes: 15 additions & 8 deletions HappyAnding/HappyAnding/ViewModel/ReadShortcutViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class ReadShortcutViewModel: ObservableObject {

@Published private(set) var shortcut: Shortcuts

/// ReadShortcutView
// ReadShortcutView
@Published var isDeletingShortcut = false
@Published var isEditingShortcut = false
@Published var isUpdatingShortcut = false
Expand All @@ -32,32 +32,39 @@ final class ReadShortcutViewModel: ObservableObject {
@Published var isEditingComment = false
@Published var isUndoingCommentEdit = false

/// ReadShortcutViewHeader
@Published var userInformation: User? = nil
// ReadShortcutViewHeader
@Published var userInformation: User
@Published var numberOfLike = 0
@Published private(set) var userGrade = Image(systemName: "person.crop.circle.fill")

/// ReadShortcutCommentView
// ReadShortcutCommentView
@Published var isDeletingComment = false
@Published var deletedComment = Comment(user_nickname: "", user_id: "", date: "", depth: 0, contents: "")

/// UpdateShortcutView
// UpdateShortcutView
@Published var updatedLink = ""
@Published var updateDescription = ""
@Published var isLinkValid = false
@Published var isDescriptionValid = false

init(data: Shortcuts) {
self.userInformation = User()
self.shortcut = shortcutsZipViewModel.fetchShortcutDetail(id: data.id) ?? data
self.isMyLike = shortcutsZipViewModel.checkLikedShortrcut(shortcutID: data.id)
self.isMyFirstLike = isMyLike
self.comments = shortcutsZipViewModel.fetchComment(shortcutID: data.id)
shortcutsZipViewModel.fetchUser(userID: data.author,
self.numberOfLike = data.numberOfLike
fetchUser()
}

private func fetchUser() {
shortcutsZipViewModel.fetchUser(userID: shortcut.author,
isCurrentUser: false) { user in
self.userInformation = user
let grade = self.shortcutsZipViewModel.checkShortcutGrade(userID: self.userInformation.id)
let image = self.shortcutsZipViewModel.fetchShortcutGradeImage(isBig: false, shortcutGrade: grade)
self.userGrade = image
}
self.userGrade = shortcutsZipViewModel.fetchShortcutGradeImage(isBig: false, shortcutGrade: shortcutsZipViewModel.checkShortcutGrade(userID: userInformation?.id ?? "!"))
self.numberOfLike = data.numberOfLike
}

func checkIfDownloaded() {
Expand Down
14 changes: 7 additions & 7 deletions HappyAnding/HappyAnding/Views/Components/UserNameCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import SwiftUI

- description:
- 해당 뷰는 넓이가 부모 프레임에 꽉차도록 만들어졌습니다. 여백이 필요한 경우 부모프레임 또는 해당 뷰를 불러온 후 설정해주세요.

*/
struct UserNameCell: View {
var userInformation: User?
var gradeImage: Image?
var userInformation: User
var gradeImage: Image

var body: some View {
HStack {
Expand All @@ -31,7 +31,7 @@ struct UserNameCell: View {
.frame(width: 24, height: 24)
.foregroundColor(.gray3)

if let userInformation, !userInformation.nickname.isEmpty {
if !userInformation.nickname.isEmpty {
Text(userInformation.nickname)
.shortcutsZipBody2()
.foregroundColor(.gray4)
Expand All @@ -43,7 +43,7 @@ struct UserNameCell: View {

Spacer()

if userInformation?.nickname != nil {
if !userInformation.id.isEmpty {
Image(systemName: "chevron.right")
.shortcutsZipFootnote()
.foregroundColor(.gray4)
Expand All @@ -57,12 +57,12 @@ struct UserNameCell: View {
.foregroundColor(.gray1)
)
.navigationLinkRouter(data: self.userInformation)
.disabled(self.userInformation == nil)
.disabled(self.userInformation.id.isEmpty)
}
}

struct UserNameCell_Previews: PreviewProvider {
static var previews: some View {
UserNameCell()
UserNameCell(userInformation: User(), gradeImage: Image(systemName: "person.crop.circle.fill"))
}
}

0 comments on commit ff46b6e

Please sign in to comment.