mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
b475cc7e9a
* Add HealthChat API and extended profile services Expose OpenID tokens and homeserver credentials from the client proxy, and add fork-only services for the HealthChat member directory backend (api.healthchat.ch) plus a service that reads MSC4133 extended profile fields directly from the homeserver. Groundwork for the members tab and the profile screens. Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS * Show extended profile details on the profile screens Add a UserProfileScreenHook that lets the fork inject an extra Form section below the header of the user profile and room member details screens. The HealthChat implementation loads the MSC4133 extended profile fields and renders them with tappable phone/email/website links, hiding the section entirely for profiles without any fields. Strings live in a new fork-only HealthChat.strings table (de/en/fr, generated as HealthChatL10n via SwiftGen) since Untranslated.strings pins the English bundle. Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS * Add a member directory tab Add a HomeTabsHook that lets the fork append an extra tab to the home tab bar, and a HealthChat members flow behind it: a directory of all approved members from the HealthChat API with server-side search, pending-approval and error states, chat shortcuts and pushed member profiles. Chats and calls are handed back to the session flow via the hook's actions publisher. Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS * Let members edit their profile and invite others Add a native profile editor for the HealthChat extended profile fields (13 fields plus avatar, saved as a partial diff through the HealthChat API so displayname derivation and Zitadel sync stay server-side), an invitation sheet (email plus personal note) and a profile-completeness hint on the member directory. A new UserDetailsEditScreenHook lets the fork substitute the profile editor behind the settings user row — the stock display-name editor would let users edit a value the next profile update derives away. Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS
117 lines
4.0 KiB
Swift
117 lines
4.0 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 Foundation
|
|
|
|
enum HealthChatProfileEditScreenViewModelAction {
|
|
case dismiss
|
|
case displayCameraPicker
|
|
case displayMediaPicker
|
|
case displayFilePicker
|
|
}
|
|
|
|
struct HealthChatProfileEditScreenViewState: BindableState {
|
|
var initialProfile: HealthChatMember?
|
|
var loadFailed = false
|
|
|
|
var canEditAvatar = false
|
|
var selectedAvatarURL: URL?
|
|
var localMedia: MediaInfo?
|
|
|
|
var bindings = HealthChatProfileEditScreenViewStateBindings()
|
|
|
|
var avatarDidChange: Bool {
|
|
localMedia != nil || selectedAvatarURL != initialProfile?.avatarURL
|
|
}
|
|
|
|
/// The changed text fields as a partial update, nil when nothing changed.
|
|
var fieldsUpdate: HealthChatProfileUpdate? {
|
|
guard let initialProfile else { return nil }
|
|
|
|
var update = HealthChatProfileUpdate()
|
|
// nil leaves a field unchanged server-side, an empty string clears it.
|
|
func diff(_ binding: String, _ initialValue: String?) -> String? {
|
|
let value = binding.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
return value == (initialValue ?? "") ? nil : value
|
|
}
|
|
|
|
update.title = diff(bindings.title, initialProfile.title)
|
|
update.firstName = diff(bindings.firstName, initialProfile.firstName)
|
|
update.lastName = diff(bindings.lastName, initialProfile.lastName)
|
|
update.specialty = diff(bindings.specialty, initialProfile.specialty)
|
|
update.practiceName = diff(bindings.practiceName, initialProfile.practiceName)
|
|
update.businessCity = diff(bindings.businessCity, initialProfile.businessCity)
|
|
update.businessEmail = diff(bindings.businessEmail, initialProfile.businessEmail)
|
|
update.businessTel = diff(bindings.businessTel, initialProfile.businessTel)
|
|
update.furtherInfo = diff(bindings.furtherInfo, initialProfile.furtherInfo)
|
|
update.street = diff(bindings.street, initialProfile.street)
|
|
update.houseNumber = diff(bindings.houseNumber, initialProfile.houseNumber)
|
|
update.postalCode = diff(bindings.postalCode, initialProfile.postalCode)
|
|
update.website = diff(bindings.website, initialProfile.website)
|
|
|
|
return update == HealthChatProfileUpdate() ? nil : update
|
|
}
|
|
|
|
/// First name, last name, speciality, practice and city are required (web client parity).
|
|
var requiredFieldsAreValid: Bool {
|
|
let requiredFields = [bindings.firstName, bindings.lastName, bindings.specialty,
|
|
bindings.practiceName, bindings.businessCity]
|
|
guard requiredFields.allSatisfy({ !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }) else {
|
|
return false
|
|
}
|
|
|
|
let website = bindings.website.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
return website.isEmpty || URL(string: website) != nil
|
|
}
|
|
|
|
var canSave: Bool {
|
|
initialProfile != nil && requiredFieldsAreValid && (avatarDidChange || fieldsUpdate != nil)
|
|
}
|
|
|
|
var showDeleteImageAction: Bool {
|
|
localMedia != nil || selectedAvatarURL != nil
|
|
}
|
|
}
|
|
|
|
struct HealthChatProfileEditScreenViewStateBindings {
|
|
var title = ""
|
|
var firstName = ""
|
|
var lastName = ""
|
|
var specialty = ""
|
|
var practiceName = ""
|
|
var businessCity = ""
|
|
var businessEmail = ""
|
|
var businessTel = ""
|
|
var furtherInfo = ""
|
|
var street = ""
|
|
var houseNumber = ""
|
|
var postalCode = ""
|
|
var website = ""
|
|
|
|
var showMediaSheet = false
|
|
|
|
var alertInfo: AlertInfo<HealthChatProfileEditScreenAlertType>?
|
|
}
|
|
|
|
enum HealthChatProfileEditScreenAlertType {
|
|
case failedProcessingMedia
|
|
case unsavedChanges
|
|
case saveError
|
|
case unknown
|
|
}
|
|
|
|
enum HealthChatProfileEditScreenViewAction {
|
|
case cancel
|
|
case save
|
|
case retry
|
|
case presentMediaSource
|
|
case displayCameraPicker
|
|
case displayMediaPicker
|
|
case displayFilePicker
|
|
case removeImage
|
|
}
|