-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from 014967/feature/add_wrapper_from_text
๋งํ์ ์์ ํ ์คํธ ์ถ๊ฐ
- Loading branch information
Showing
11 changed files
with
255 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 80 additions & 19 deletions
99
...r/src/main/java/com/mashup/twotoo/presenter/home/ongoing/components/HomeFlowerLanguage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,110 @@ | ||
package com.mashup.twotoo.presenter.home.ongoing.components | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.platform.LocalConfiguration | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.constraintlayout.compose.ConstraintLayout | ||
import com.mashup.twotoo.presenter.R | ||
import com.mashup.twotoo.presenter.designsystem.component.TwoTooImageView | ||
import com.mashup.twotoo.presenter.designsystem.theme.TwoTooTheme | ||
import com.mashup.twotoo.presenter.home.model.Flower | ||
import com.mashup.twotoo.presenter.home.model.HomeFlowerUiModel | ||
import com.mashup.twotoo.presenter.model.Stage | ||
|
||
@Composable | ||
fun HomeFlowerLanguage( | ||
homeFlowerUiModel: HomeFlowerUiModel, | ||
modifier: Modifier = Modifier, | ||
onClickFlowerTextBubble: (HomeFlowerUiModel) -> Unit = {}, | ||
) { | ||
val context = LocalContext.current | ||
Column( | ||
modifier = modifier, | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
val growType = (homeFlowerUiModel.flowerType as Flower).growType | ||
val screenHeight = LocalConfiguration.current.screenHeightDp | ||
val screenWidth = LocalConfiguration.current.screenWidthDp | ||
val bubbleWidth = if (growType.isSuccess()) 92.dp else 118.dp * screenWidth / 375 | ||
val bubbleHeight = if (growType.isSuccess()) 48.dp else 63.dp * screenHeight / 812 | ||
val areaMargin = 10.dp * screenHeight / 812 | ||
val bottomMargin = 12.dp * screenHeight / 812 | ||
|
||
ConstraintLayout( | ||
modifier = modifier.clickable { | ||
onClickFlowerTextBubble(homeFlowerUiModel) | ||
}, | ||
) { | ||
Text( | ||
modifier = Modifier.padding(top = 16.dp, bottom = 8.dp), | ||
text = (homeFlowerUiModel.flowerType as Flower).getFlowerName(context = context), | ||
style = TwoTooTheme.typography.headLineNormal24, | ||
color = TwoTooTheme.color.mainBrown, | ||
) | ||
Text( | ||
text = homeFlowerUiModel.flowerType.getFlowerLanguage(context = context), | ||
style = TwoTooTheme.typography.bodyNormal14, | ||
color = TwoTooTheme.color.mainBrown, | ||
textAlign = TextAlign.Center, | ||
maxLines = 2, | ||
val (bubbleWrapper, textRow) = createRefs() | ||
TwoTooImageView( | ||
modifier = Modifier.width(bubbleWidth).height(bubbleHeight).constrainAs(bubbleWrapper) { | ||
start.linkTo(parent.start) | ||
end.linkTo(parent.end) | ||
top.linkTo(parent.top) | ||
bottom.linkTo(parent.bottom) | ||
}, | ||
model = if (growType.isSuccess()) R.drawable.ic_flower_text_bubble_wrapper else R.drawable.ic_cheer_bubble_wrapper, | ||
previewPlaceholder = if (growType.isSuccess()) R.drawable.ic_flower_text_bubble_wrapper else R.drawable.ic_cheer_bubble_wrapper, | ||
contentScale = ContentScale.Fit, | ||
) | ||
Row( | ||
modifier = Modifier.padding( | ||
start = areaMargin, | ||
end = areaMargin, | ||
top = areaMargin, | ||
bottom = areaMargin + bottomMargin, | ||
).constrainAs(textRow) { | ||
start.linkTo(parent.start) | ||
end.linkTo(parent.end) | ||
bottom.linkTo(parent.bottom) | ||
top.linkTo(parent.top) | ||
}, | ||
horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
if (growType.isSuccess()) { | ||
Text( | ||
text = stringResource(id = R.string.homeCompleteFlowerBubbleSuccessText), | ||
style = TwoTooTheme.typography.bodyNormal16, | ||
color = TwoTooTheme.color.mainBrown, | ||
) | ||
TwoTooImageView( | ||
modifier = Modifier.size(18.dp), | ||
model = R.drawable.ic_flower_text_bubble_textflower, | ||
previewPlaceholder = R.drawable.ic_flower_text_bubble_textflower, | ||
) | ||
} else { | ||
Text( | ||
text = stringResource(id = R.string.homeCompleteFlowerBubbleFaileText), | ||
style = TwoTooTheme.typography.bodyNormal16, | ||
color = TwoTooTheme.color.gray600, | ||
textAlign = TextAlign.Center, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Stage.isSuccess(): Boolean { | ||
return this >= Stage.Fourth | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewHomeFlowerLanguage() { | ||
TwoTooTheme { | ||
HomeFlowerLanguage(homeFlowerUiModel = HomeFlowerUiModel.default) | ||
HomeFlowerLanguage( | ||
modifier = Modifier.width(92.dp).height(48.dp), | ||
homeFlowerUiModel = HomeFlowerUiModel.default, | ||
) | ||
} | ||
} |
Oops, something went wrong.