diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 8a3a0cf37b..7f5a36adac 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -266,19 +266,13 @@ struct SubsStatusIndicator: View { @AppStorage(DEFAULT_SHOW_SUBSCRIPTION_PERCENTAGE) private var showSubscriptionPercentage = false var body: some View { - ZStack { - if subs.total == 0 && !hasSess { - EmptyView() - } else { - Button { - showServersSummary = true - } label: { - HStack(spacing: 4) { - SubscriptionStatusIndicatorView(subs: subs, hasSess: hasSess) - if showSubscriptionPercentage { - SubscriptionStatusPercentageView(subs: subs, hasSess: hasSess) - } - } + Button { + showServersSummary = true + } label: { + HStack(spacing: 4) { + SubscriptionStatusIndicatorView(subs: subs, hasSess: hasSess) + if showSubscriptionPercentage { + SubscriptionStatusPercentageView(subs: subs, hasSess: hasSess) } } } diff --git a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift index 2e0dd9d9e4..477a78e36d 100644 --- a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift +++ b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift @@ -448,19 +448,23 @@ func subscriptionStatusColorAndPercentage(_ online: Bool, _ onionHosts: OnionHos let noConnColorAndPercent: (Color, Double, Double, Double) = (Color(uiColor: .tertiaryLabel), 1, 1, 0) let activeSubsRounded = roundedToQuarter(subs.shareOfActive) - return online && subs.total > 0 - ? ( - subs.ssActive == 0 - ? ( - hasSess ? (activeColor, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) : noConnColorAndPercent + return !online + ? noConnColorAndPercent + : ( + subs.total == 0 && !hasSess + ? (activeColor, 0, 0.33, 0) // On freshly installed app (without chats) and on app start + : ( + subs.ssActive == 0 + ? ( + hasSess ? (activeColor, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) : noConnColorAndPercent + ) + : ( // ssActive > 0 + hasSess + ? (activeColor, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) + : (.orange, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) // This would mean implementation error + ) ) - : ( // ssActive > 0 - hasSess - ? (activeColor, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) - : (.orange, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) // This would mean implementation error - ) ) - : noConnColorAndPercent } struct SMPServerSummaryView: View { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt index 310d4d163d..1a6ce3ce00 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt @@ -370,12 +370,8 @@ fun SubscriptionStatusIndicator(click: (() -> Unit)) { } } - if (subs.total == 0 && !hasSess) { - Box {} - } else { - SimpleButtonFrame(click = click) { - SubscriptionStatusIndicatorView(subs = subs, hasSess = hasSess) - } + SimpleButtonFrame(click = click) { + SubscriptionStatusIndicatorView(subs = subs, hasSess = hasSess) } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt index 4bb5474fa6..334335a80f 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt @@ -68,7 +68,6 @@ enum class SubscriptionColorType { data class SubscriptionStatus( val color: SubscriptionColorType, val variableValue: Float, - val opacity: Float, val statusPercent: Float ) @@ -78,7 +77,6 @@ fun subscriptionStatusColorAndPercentage( subs: SMPServerSubs, hasSess: Boolean ): SubscriptionStatus { - fun roundedToQuarter(n: Float): Float = when { n >= 1 -> 1f n <= 0 -> 0f @@ -86,23 +84,26 @@ fun subscriptionStatusColorAndPercentage( } val activeColor: SubscriptionColorType = if (socksProxy != null) SubscriptionColorType.ACTIVE_SOCKS_PROXY else SubscriptionColorType.ACTIVE - val noConnColorAndPercent = SubscriptionStatus(SubscriptionColorType.DISCONNECTED, 1f, 1f, 0f) + val noConnColorAndPercent = SubscriptionStatus(SubscriptionColorType.DISCONNECTED, 1f, 0f) val activeSubsRounded = roundedToQuarter(subs.shareOfActive) - return if (online && subs.total > 0) { - if (subs.ssActive == 0) { - if (hasSess) - SubscriptionStatus(activeColor, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) - else - noConnColorAndPercent - } else { // ssActive > 0 - if (hasSess) - SubscriptionStatus(activeColor, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) - else - // This would mean implementation error - SubscriptionStatus(SubscriptionColorType.ACTIVE_DISCONNECTED, activeSubsRounded, subs.shareOfActive, subs.shareOfActive) - } - } else noConnColorAndPercent + return if (!online) + noConnColorAndPercent + else if (subs.total == 0 && !hasSess) + // On freshly installed app (without chats) and on app start + SubscriptionStatus(activeColor, 0f, 0f) + else if (subs.ssActive == 0) { + if (hasSess) + SubscriptionStatus(activeColor, activeSubsRounded, subs.shareOfActive) + else + noConnColorAndPercent + } else { // ssActive > 0 + if (hasSess) + SubscriptionStatus(activeColor, activeSubsRounded, subs.shareOfActive) + else + // This would mean implementation error + SubscriptionStatus(SubscriptionColorType.ACTIVE_DISCONNECTED, activeSubsRounded, subs.shareOfActive) + } } @Composable