From 792ee522b518c264ecd62320d2db85ebbd85090a Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:56:12 +0400 Subject: [PATCH] refactor --- .../Views/ChatList/ServersSummaryView.swift | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift index 6639f15e7f..94e94e3939 100644 --- a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift +++ b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift @@ -452,30 +452,40 @@ struct SMPServerSummaryView: View { Section("Statistics") { infoRow("Starting from", localTimestamp(statsStartedAt)) infoRow("Messages sent directly", "\(stats._sentDirect)") - infoRow(" attempts", "\(stats._sentDirectAttempts)") + indentedInfoRow("attempts", "\(stats._sentDirectAttempts)") infoRow("Messages sent via proxy", "\(stats._sentViaProxy)") - infoRow(" attempts", "\(stats._sentViaProxyAttempts)") + indentedInfoRow("attempts", "\(stats._sentViaProxyAttempts)") infoRow("Messages sent to proxy", "\(stats._sentProxied)") - infoRow(" attempts", "\(stats._sentProxiedAttempts)") - infoRow("Send AUTH errors", "\(stats._sentAuthErrs)") - infoRow(" QUOTA errors", "\(stats._sentQuotaErrs)") - infoRow(" expired", "\(stats._sentExpiredErrs)") - infoRow(" other errors", "\(stats._sentOtherErrs)") + indentedInfoRow("attempts", "\(stats._sentProxiedAttempts)") + infoRow("Sending AUTH errors", "\(stats._sentAuthErrs)") + indentedInfoRow("QUOTA errors", "\(stats._sentQuotaErrs)") + indentedInfoRow("expired", "\(stats._sentExpiredErrs)") + indentedInfoRow("other errors", "\(stats._sentOtherErrs)") infoRow("Messages received", "\(stats._recvMsgs)") - infoRow(" duplicates", "\(stats._recvDuplicates)") - infoRow(" decryption", "\(stats._recvCryptoErrs)") - infoRow(" other errors", "\(stats._recvErrs)") + indentedInfoRow("duplicates", "\(stats._recvDuplicates)") + indentedInfoRow("decryption", "\(stats._recvCryptoErrs)") + indentedInfoRow("other errors", "\(stats._recvErrs)") infoRow("Connections created", "\(stats._connCreated)") - infoRow(" secured", "\(stats._connSecured)") - infoRow(" completed", "\(stats._connCompleted)") + indentedInfoRow("secured", "\(stats._connSecured)") + indentedInfoRow("completed", "\(stats._connCompleted)") infoRow("Connections deleted", "\(stats._connDeleted)") infoRow("Connections subscribed", "\(stats._connSubscribed)") - infoRow(" attempts", "\(stats._connSubAttempts)") - infoRow(" errors", "\(stats._connSubErrs)") + indentedInfoRow("attempts", "\(stats._connSubAttempts)") + indentedInfoRow("errors", "\(stats._connSubErrs)") } } } +private func indentedInfoRow(_ title: LocalizedStringKey, _ value: String) -> some View { + HStack { + Text(title) + .padding(.leading, 24) + Spacer() + Text(value) + .foregroundStyle(.secondary) + } +} + struct XFTPServerSummaryView: View { var summary: XFTPServerSummary var statsStartedAt: Date @@ -536,15 +546,15 @@ struct XFTPServerSummaryView: View { Section("Statistics") { infoRow("Starting from", localTimestamp(statsStartedAt)) infoRow("Chunks uploaded", "\(stats._uploads)") - infoRow(" attempts", "\(stats._uploadAttempts)") - infoRow(" errors", "\(stats._uploadErrs)") + indentedInfoRow("attempts", "\(stats._uploadAttempts)") + indentedInfoRow("errors", "\(stats._uploadErrs)") infoRow("Chunks downloaded", "\(stats._downloads)") - infoRow(" attempts", "\(stats._downloadAttempts)") - infoRow(" AUTH errors", "\(stats._downloadAuthErrs)") - infoRow(" other errors", "\(stats._downloadErrs)") + indentedInfoRow("attempts", "\(stats._downloadAttempts)") + indentedInfoRow("AUTH errors", "\(stats._downloadAuthErrs)") + indentedInfoRow("other errors", "\(stats._downloadErrs)") infoRow("Chunks deleted", "\(stats._deletions)") - infoRow(" attempts", "\(stats._deleteAttempts)") - infoRow(" errors", "\(stats._deleteErrs)") + indentedInfoRow("attempts", "\(stats._deleteAttempts)") + indentedInfoRow("errors", "\(stats._deleteErrs)") } } }