mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
d9524130fa
Pending approval and an incomplete profile were only visible in the members tab, which a new user has no reason to open.
68 lines
2.5 KiB
Swift
68 lines
2.5 KiB
Swift
//
|
|
// Copyright 2026 Novaloop AG
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Compound
|
|
import SwiftUI
|
|
|
|
/// The account status advertised in the app's settings. Renders nothing while loading,
|
|
/// for approved accounts with a complete profile, and when the status can't be read.
|
|
///
|
|
/// Neither banner is dismissible — both resolve server-side.
|
|
struct HealthChatAccountStatusSection: View {
|
|
// Owned by the hook, not the view: the settings screen rebuilds this section on
|
|
// every body pass, and a view-owned loader would fire a request each time.
|
|
private let loader: HealthChatAccountStatusLoader
|
|
private let completeProfileAction: () -> Void
|
|
|
|
init(loader: HealthChatAccountStatusLoader, completeProfileAction: @escaping () -> Void = { }) {
|
|
self.loader = loader
|
|
self.completeProfileAction = completeProfileAction
|
|
}
|
|
|
|
var body: some View {
|
|
switch loader.status {
|
|
case .unknown, .ok:
|
|
EmptyView()
|
|
case .pendingApproval:
|
|
Section {
|
|
ListRow(label: .default(title: HealthChatL10n.screenMemberDirectoryPendingTitle,
|
|
description: HealthChatL10n.screenMemberDirectoryPendingApproval,
|
|
icon: \.time),
|
|
kind: .label)
|
|
}
|
|
case .incompleteProfile(let message):
|
|
Section {
|
|
ListRow(label: .default(title: HealthChatL10n.commonProfileIncomplete,
|
|
description: message,
|
|
icon: \.info),
|
|
kind: .label)
|
|
|
|
ListRow(label: .action(title: HealthChatL10n.actionCompleteProfile, icon: \.userProfile),
|
|
kind: .button(action: completeProfileAction))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - Previews
|
|
|
|
struct HealthChatAccountStatusSection_Previews: PreviewProvider, TestablePreview {
|
|
static var previews: some View {
|
|
Form {
|
|
HealthChatAccountStatusSection(loader: .init(status: .pendingApproval))
|
|
}
|
|
.compoundList()
|
|
.previewDisplayName("Pending approval")
|
|
|
|
Form {
|
|
HealthChatAccountStatusSection(loader: .init(status: .incompleteProfile(message: "Bitte vervollständigen Sie Ihr Profil, bevor Sie die Benutzersuche verwenden")))
|
|
}
|
|
.compoundList()
|
|
.previewDisplayName("Incomplete profile")
|
|
}
|
|
}
|