From 14f79df72f4fb866667bfbbcdc456b60562bc1a5 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:07:37 +0400 Subject: [PATCH] variableValueAsPercentage --- .../Shared/Views/ChatList/ChatListView.swift | 2 +- .../Views/ChatList/ServersSummaryView.swift | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 11644d1378..cd663add00 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -278,7 +278,7 @@ struct SubsStatusIndicator: View { Button { showServersSummary = true } label: { - SubscriptionStatusView(activeSubs: subs.ssActive, pendingSubs: subs.ssPending) + SubscriptionStatusView(activeSubs: subs.ssActive, pendingSubs: subs.ssPending, variableValueAsPercentage: true) } .onAppear { startInitialTimer() diff --git a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift index 145c878ffa..10aa4b184d 100644 --- a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift +++ b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift @@ -291,6 +291,7 @@ struct SubscriptionStatusView: View { @EnvironmentObject var m: ChatModel var activeSubs: Int var pendingSubs: Int + var variableValueAsPercentage: Bool = false var body: some View { let netInfo = m.networkInfo @@ -320,13 +321,18 @@ struct SubscriptionStatusView: View { } } + // We manipulate variableValue so all "wifi" sections are filled only with 100% active subs, + // unless variableValueAsPercentage is true; same for cellularbarsColor var wifiColor: (Color, Double, Double) { if activeSubs > 0 { - let wifiVariableValue = ( // wifi has 3 sections - activeSubsPercentage >= 1 ? 1 - : (activeSubsPercentage >= 0.5 && activeSubsPercentage < 1) ? 0.6 - : (activeSubsPercentage > 0 && activeSubsPercentage < 0.5) ? 0.3 - : 0 + let wifiVariableValue = ( + variableValueAsPercentage ? activeSubsPercentage + : ( // "wifi" has 3 sections + activeSubsPercentage >= 1 ? 1 + : (activeSubsPercentage >= 0.5 && activeSubsPercentage < 1) ? 0.6 + : (activeSubsPercentage > 0 && activeSubsPercentage < 0.5) ? 0.3 + : 0 + ) ) return (.accentColor, wifiVariableValue, activeSubsPercentage) } else { @@ -336,12 +342,15 @@ struct SubscriptionStatusView: View { var cellularbarsColor: (Color, Double, Double) { if activeSubs > 0 { - let wifiVariableValue = ( // cellularbars has 4 sections - activeSubsPercentage >= 1 ? 1 - : (activeSubsPercentage >= 0.67 && activeSubsPercentage < 1) ? 0.7 - : (activeSubsPercentage >= 0.33 && activeSubsPercentage < 0.67) ? 0.45 - : (activeSubsPercentage > 0 && activeSubsPercentage < 0.33) ? 0.2 - : 0 + let wifiVariableValue = ( + variableValueAsPercentage ? activeSubsPercentage + : ( // "cellularbars" has 4 sections + activeSubsPercentage >= 1 ? 1 + : (activeSubsPercentage >= 0.67 && activeSubsPercentage < 1) ? 0.7 + : (activeSubsPercentage >= 0.33 && activeSubsPercentage < 0.67) ? 0.45 + : (activeSubsPercentage > 0 && activeSubsPercentage < 0.33) ? 0.2 + : 0 + ) ) return (.accentColor, wifiVariableValue, activeSubsPercentage) } else {