Skip to content

feat: Add ContactCard ViewModel, sharing and header components - #821

Open
Elouan1411 wants to merge 9 commits into
vcard-3-viewmodel-primitivesfrom
vcard-4-viewmodel-headers
Open

feat: Add ContactCard ViewModel, sharing and header components#821
Elouan1411 wants to merge 9 commits into
vcard-3-viewmodel-primitivesfrom
vcard-4-viewmodel-headers

Conversation

@Elouan1411

Copy link
Copy Markdown
Contributor

No description provided.

@Elouan1411 Elouan1411 changed the title feat: Add ContactCard state, primitives and small components  feat: Add ContactCard ViewModel, sharing and header components  Jul 23, 2026
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from a610d66 to b7b36a8 Compare July 24, 2026 07:00
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from b7b36a8 to c5063f4 Compare July 24, 2026 07:23
@Elouan1411 Elouan1411 changed the title feat: Add ContactCard ViewModel, sharing and header components  feat: Add ContactCard ViewModel, sharing and header components Jul 24, 2026
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch 2 times, most recently from 57135d9 to 64dc46e Compare July 24, 2026 08:09
@Elouan1411
Elouan1411 requested a review from Copilot July 24, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds contact-card state management and Compose preview components.

Changes:

  • Adds card loading, editing, saving, and deletion.
  • Adds QR-code header with avatar.
  • Adds contact details and social-link presentation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
ContactCardViewModel.kt Manages card state and persistence.
QrCodeHeader.kt Renders the vCard QR header.
LinksRow.kt Displays available link types.
ContactVCardBloc.kt Composes the contact-card preview.
Comments suppressed due to low confidence (1)

Ui/Compose/ContactCard/src/main/kotlin/com/infomaniak/core/ui/compose/contactcard/ContactCardViewModel.kt:115

  • Deleting also writes the whole User snapshot from the preview state through Room @Update. Any profile or preference changes persisted after this snapshot was loaded can therefore be reverted when only the card should change. Delete the card through an atomic card-column update rather than replacing the complete row.
            val updatedUser = current.user.copy(card = null)
            accountUtils.updateUser(updatedUser)

@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from 64dc46e to 823feb5 Compare August 3, 2026 15:05
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from 823feb5 to 6e61152 Compare August 11, 2026 10:38
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from 6e61152 to 8632764 Compare August 12, 2026 12:32
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from 8632764 to 6673f3a Compare August 13, 2026 06:54
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from 6673f3a to a47131d Compare August 13, 2026 06:57
@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from a47131d to eb8d274 Compare August 13, 2026 07:26

@DrawableRes
private fun CardLinkType.iconRes(): Int = when (this) {
CardLinkType.LinkedIn -> R.drawable.ic_linkedin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be great to directly have this icon in CardLinkType.

Comment on lines +123 to +141
Surface(
shape = CircleShape,
color = MaterialTheme.colorScheme.surface,
modifier = Modifier
.size(qrSize * 0.24f)
.clip(CircleShape),
) {
Box(
modifier = Modifier.padding(3.dp),
contentAlignment = Alignment.Center,
) {
Avatar(
avatarType = AvatarType.fromUser(user),
modifier = Modifier
.fillMaxSize()
.clip(CircleShape),
)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Surface(
shape = CircleShape,
color = MaterialTheme.colorScheme.surface,
modifier = Modifier
.size(qrSize * 0.24f)
.clip(CircleShape),
) {
Box(
modifier = Modifier.padding(3.dp),
contentAlignment = Alignment.Center,
) {
Avatar(
avatarType = AvatarType.fromUser(user),
modifier = Modifier
.fillMaxSize()
.clip(CircleShape),
)
}
}
Surface(
shape = CircleShape,
color = MaterialTheme.colorScheme.surface,
modifier = Modifier
.size(qrSize * 0.24f)
.clip(CircleShape),
) {
Avatar(
avatarType = AvatarType.fromUser(user),
modifier = Modifier
.padding(3.dp)
.fillMaxSize()
.clip(CircleShape),
)
}

loadUser()
}

fun loadUser() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is public ? It seems you only use if in the init { ... }.

private val _uiState = MutableStateFlow<ContactCardUiState>(ContactCardUiState.Loading)
val uiState: StateFlow<ContactCardUiState> = _uiState.asStateFlow()

private var currentUser: User? = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having a var and checking everywhere if user is null to do an early return, it would be great to just quit the VCard screen. It makes no sense to be on that screen without a user.

}

companion object {
const val USER_ID_KEY = "userId"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this to be public.

@Elouan1411
Elouan1411 force-pushed the vcard-4-viewmodel-headers branch from eb8d274 to a47131d Compare August 13, 2026 16:09
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants