Skip to content

Commit

Permalink
[CFRS-274] Implement friend action button in UserProfileDialog (#10)
Browse files Browse the repository at this point in the history
* Implement friend action button in UserProfileDIalog

* Add label size animation in Button

* Add result messages

* Replace to string resource
  • Loading branch information
jja08111 committed May 13, 2023
1 parent 51e9508 commit 6147cd2
Show file tree
Hide file tree
Showing 11 changed files with 403 additions and 129 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
package io.foundy.core.designsystem.component

import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.foundy.core.designsystem.icon.CamstudyIcon
import io.foundy.core.designsystem.theme.CamstudyTheme

@Composable
internal fun RawButton(
modifier: Modifier = Modifier,
label: String,
enableLabelSizeAnimation: Boolean = false,
leadingIcon: CamstudyIcon? = null,
shape: Shape = RoundedCornerShape(8.dp),
colors: ButtonColors = ButtonDefaults.buttonColors(
containerColor = CamstudyTheme.colorScheme.primary,
Expand All @@ -43,19 +52,36 @@ internal fun RawButton(
vertical = 8.dp
)
) {
Text(
text = label,
style = CamstudyTheme.typography.titleMedium.copy(
fontWeight = FontWeight.Medium
Row(verticalAlignment = Alignment.CenterVertically) {
if (leadingIcon != null) {
CamstudyIcon(
modifier = Modifier.size(20.dp),
icon = leadingIcon,
contentDescription = null,
)
Spacer(modifier = Modifier.width(10.dp))
}
Text(
modifier = if (enableLabelSizeAnimation) {
Modifier.animateContentSize()
} else {
Modifier
},
text = label,
style = CamstudyTheme.typography.titleMedium.copy(
fontWeight = FontWeight.Medium
)
)
)
}
}
}

@Composable
fun CamstudyOutlinedButton(
modifier: Modifier = Modifier,
label: String,
leadingIcon: CamstudyIcon? = null,
enableLabelSizeAnimation: Boolean = false,
shape: Shape = RoundedCornerShape(8.dp),
enabled: Boolean = true,
onClick: () -> Unit
Expand All @@ -67,6 +93,8 @@ fun CamstudyOutlinedButton(
label = label,
shape = shape,
enabled = enabled,
enableLabelSizeAnimation = enableLabelSizeAnimation,
leadingIcon = leadingIcon,
border = BorderStroke(
width = 1.dp,
color = if (enabled) colorScheme.primary else colorScheme.systemUi03
Expand All @@ -84,6 +112,8 @@ fun CamstudyOutlinedButton(
fun CamstudyContainedButton(
modifier: Modifier = Modifier,
label: String,
leadingIcon: CamstudyIcon? = null,
enableLabelSizeAnimation: Boolean = false,
shape: Shape = RoundedCornerShape(8.dp),
enabled: Boolean = true,
onClick: () -> Unit
Expand All @@ -94,6 +124,8 @@ fun CamstudyContainedButton(
onClick = onClick,
label = label,
shape = shape,
enableLabelSizeAnimation = enableLabelSizeAnimation,
leadingIcon = leadingIcon,
enabled = enabled,
colors = ButtonDefaults.buttonColors(
containerColor = colorScheme.primary,
Expand All @@ -108,6 +140,7 @@ fun CamstudyContainedButton(
fun CamstudyTextButton(
modifier: Modifier = Modifier,
label: String,
leadingIcon: CamstudyIcon? = null,
shape: Shape = RoundedCornerShape(8.dp),
enabled: Boolean = true,
onClick: () -> Unit
Expand All @@ -118,6 +151,7 @@ fun CamstudyTextButton(
onClick = onClick,
label = label,
shape = shape,
leadingIcon = leadingIcon,
enabled = enabled,
colors = ButtonDefaults.buttonColors(
containerColor = Color.Transparent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import androidx.compose.material.icons.filled.AccessTimeFilled
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowForwardIos
import androidx.compose.material.icons.filled.CancelScheduleSend
import androidx.compose.material.icons.filled.Chat
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.Error
import androidx.compose.material.icons.filled.FlipCameraAndroid
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material.icons.filled.KeyboardArrowUp
Expand Down Expand Up @@ -59,9 +61,11 @@ object CamstudyIcons {
val Send = Icons.Default.Send.asCamstudyIcon()
val Add = Icons.Default.Add.asCamstudyIcon()
val Delete = Icons.Default.Delete.asCamstudyIcon()
val Error = Icons.Default.Error.asCamstudyIcon()
val Person = Icons.Default.Person.asCamstudyIcon()
val PersonAdd = Icons.Default.PersonAdd.asCamstudyIcon()
val PersonRemove = Icons.Default.PersonRemove.asCamstudyIcon()
val CancelScheduleSend = Icons.Default.CancelScheduleSend.asCamstudyIcon()
val PersonOff = Icons.Default.PersonOff.asCamstudyIcon()
val People = Icons.Default.People.asCamstudyIcon()
val Timer = Icons.Outlined.Timer.asCamstudyIcon()
Expand Down
4 changes: 3 additions & 1 deletion core/model/src/main/java/io/foundy/core/model/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ data class User(
val growingCrop: GrowingCrop?,
val harvestedCrops: List<HarvestedCrop>,
val organizations: List<String>,
val tags: List<String>
val tags: List<String>,
val friendStatus: FriendStatus,
val isMe: Boolean
)
6 changes: 5 additions & 1 deletion user/data/src/main/java/io/foundy/user/data/model/UserDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.foundy.user.data.model

import com.google.gson.annotations.SerializedName
import io.foundy.core.data.model.FriendStatusDto
import io.foundy.core.data.model.toEntity
import io.foundy.core.model.GrowingCrop
import io.foundy.core.model.HarvestedCrop
import io.foundy.core.model.User
Expand All @@ -18,6 +19,7 @@ data class UserDto(
)

fun UserDto.toEntity(
isMe: Boolean,
weeklyRanking: Int,
totalRanking: Int,
weeklyStudyTimeSec: Int,
Expand All @@ -26,6 +28,7 @@ fun UserDto.toEntity(
harvestedCrops: List<HarvestedCrop>,
): User = User(
id = id,
isMe = isMe,
name = name,
introduce = introduce,
profileImage = profileImage,
Expand All @@ -37,5 +40,6 @@ fun UserDto.toEntity(
growingCrop = growingCrop,
harvestedCrops = harvestedCrops,
organizations = organizations,
tags = tags
tags = tags,
friendStatus = friendStatus.toEntity()
)
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class NetworkUserRepository @Inject constructor(

return@coroutineScope userDeferred.await()
.toEntity(
isMe = currentUserId == id,
weeklyRanking = weeklyRanking.user.ranking,
totalRanking = totalRanking.user.ranking,
weeklyStudyTimeSec = weeklyRanking.user.studyTimeSec,
Expand Down
1 change: 1 addition & 0 deletions user/ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {
implementation project(path: ':core:ui')
implementation project(path: ':core:common')
implementation project(path: ':user:domain')
implementation project(path: ':friend:data')

// hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
Expand Down
Loading

0 comments on commit 6147cd2

Please sign in to comment.