diff --git a/yobble/Resources/Localizable.xcstrings b/yobble/Resources/Localizable.xcstrings index 0a9b5fb..7a53e5d 100644 --- a/yobble/Resources/Localizable.xcstrings +++ b/yobble/Resources/Localizable.xcstrings @@ -320,6 +320,9 @@ } } }, + "Ваш рейтинг" : { + "comment" : "Messenger settings rating title" + }, "Введите код" : { }, @@ -1600,7 +1603,7 @@ } }, "Недоступно" : { - "comment" : "Message profile rating unavailable" + "comment" : "Message profile rating unavailable\nMessenger settings rating unavailable" }, "Неизвестная ошибка" : { "localizations" : { @@ -1633,7 +1636,7 @@ } }, "Неизвестный пользователь" : { - "comment" : "Deleted user display name\nMessage profile fallback title\nUnknown chat title", + "comment" : "Deleted user display name\nMessage profile fallback title\nMessenger settings unknown user\nUnknown chat title", "localizations" : { "en" : { "stringUnit" : { diff --git a/yobble/Views/Tab/Settings/SettingsView.swift b/yobble/Views/Tab/Settings/SettingsView.swift index cf402f0..2781633 100644 --- a/yobble/Views/Tab/Settings/SettingsView.swift +++ b/yobble/Views/Tab/Settings/SettingsView.swift @@ -169,7 +169,7 @@ struct SettingsView: View { displayName: messengerDisplayName(for: profile), presenceStatus: nil, statusTags: messengerStatusTags(for: profile), - isOfficial: self.messengerProfile?.isVerified ?? false + isOfficial: profile.isVerified ) .listRowInsets(EdgeInsets(top: 16, leading: 0, bottom: 8, trailing: 0)) .listRowBackground(Color.clear) @@ -362,42 +362,34 @@ struct SettingsView: View { return formatter }() + @ViewBuilder private var aboutSection: some View { - if messengerProfile != nil || isMessengerProfileLoading || messengerProfileError != nil { - Section { + if let _ = messengerProfile { + Section() { card { VStack(spacing: 0) { - - if let login = loginDisplay { - infoRow( - title: NSLocalizedString("Юзернейм", comment: ""), - value: login - ) - }else{ - infoRow( - title: NSLocalizedString("Юзернейм", comment: ""), - value: "Неизвестный пользователь" - ) - } - - if let membership = membershipDescription { - rowDivider - infoRow( - title: NSLocalizedString("Дата регистрации в Yobble", comment: ""), - value: membership - ) - } - - if loginDisplay != nil || membershipDescription != nil { - rowDivider - } - infoRow( - title: NSLocalizedString("Ваш рейтинг", comment: "Message profile rating title"), - value: ratingDisplayValue + title: NSLocalizedString("Юзернейм", comment: ""), + value: loginDisplay ?? NSLocalizedString("Неизвестный пользователь", comment: "Messenger settings unknown user") ) + +// if let membership = membershipDescription { +// rowDivider +// infoRow( +// title: NSLocalizedString("Дата регистрации в Yobble", comment: ""), +// value: membership +// ) +// } +// +// rowDivider +// infoRow( +// title: NSLocalizedString("Ваш рейтинг", comment: "Messenger settings rating title"), +// value: ratingDisplayValue +// ) } } + .listRowInsets(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0)) + .listRowBackground(Color.clear) } } } @@ -424,14 +416,14 @@ struct SettingsView: View { } .padding(.vertical, 4) } - + private func iconBackground(color: Color, @ViewBuilder content: () -> Content) -> some View { RoundedRectangle(cornerRadius: 14, style: .continuous) .fill(color) .frame(width: 44, height: 44) .overlay(content()) } - + private func card(@ViewBuilder content: () -> Content) -> some View { VStack(alignment: .leading, spacing: 16) { content() @@ -443,6 +435,27 @@ struct SettingsView: View { .fill(Color(UIColor.secondarySystemGroupedBackground)) ) } + + private var rowDivider: some View { + Divider() + .padding(.vertical, 12) + } + + private var loginDisplay: String? { + let login = messengerProfile?.login.trimmingCharacters(in: .whitespacesAndNewlines) ?? "" + guard !login.isEmpty else { return nil } + return "@\(login)" + } + + private var membershipDescription: String? { + guard let createdAt = messengerProfile?.createdAt else { return nil } + let formatted = SettingsView.membershipFormatter.string(from: createdAt) + return formatted + } + + private var ratingDisplayValue: String { + NSLocalizedString("Недоступно", comment: "Messenger settings rating unavailable") + } } private struct LegacySupportBanner: View {