-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProfileTopAppBar.kt
55 lines (52 loc) · 1.89 KB
/
ProfileTopAppBar.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.dluvian.voyage.ui.views.nonMain.profile
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import com.dluvian.voyage.R
import com.dluvian.voyage.core.ClickEditProfile
import com.dluvian.voyage.core.FollowProfile
import com.dluvian.voyage.core.OnUpdate
import com.dluvian.voyage.core.UnfollowProfile
import com.dluvian.voyage.core.getSignerLauncher
import com.dluvian.voyage.data.model.FullProfileUI
import com.dluvian.voyage.ui.components.bar.GoBackTopAppBar
import com.dluvian.voyage.ui.components.button.FollowButton
@Composable
fun ProfileTopAppBar(profile: FullProfileUI, onUpdate: OnUpdate) {
val signerLauncher = getSignerLauncher(onUpdate = onUpdate)
GoBackTopAppBar(
title = {
Text(
text = profile.inner.name,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
},
actions = {
if (!profile.inner.isMe) FollowButton(
isFollowed = profile.inner.isFriend,
onFollow = {
onUpdate(
FollowProfile(
pubkey = profile.inner.pubkey,
signerLauncher = signerLauncher
)
)
},
onUnfollow = {
onUpdate(
UnfollowProfile(
pubkey = profile.inner.pubkey,
signerLauncher = signerLauncher
)
)
})
else Button(onClick = { onUpdate(ClickEditProfile) }) {
Text(text = stringResource(id = R.string.edit))
}
},
onUpdate = onUpdate
)
}