Skip to content

Commit

Permalink
Merge pull request #196 from YAPP-Github/feature/issue-191-respondent…
Browse files Browse the repository at this point in the history
…-bottom-sheet

[ISSUE-191] 응답자 바텀 시트 추가
  • Loading branch information
jihee-dev authored Aug 2, 2022
2 parents 548e46c + b099596 commit 12c2732
Show file tree
Hide file tree
Showing 17 changed files with 495 additions and 324 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.yapp.growth.presentation.component

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
Expand All @@ -18,12 +16,9 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.valentinilk.shimmer.ShimmerBounds
import com.valentinilk.shimmer.rememberShimmer
import com.valentinilk.shimmer.shimmer
import com.yapp.growth.presentation.R
import com.yapp.growth.presentation.component.type.PlanzAppBarMenu
import com.yapp.growth.presentation.theme.*

@Composable
Expand Down Expand Up @@ -113,7 +108,7 @@ private fun PlanzAppBar(
maxLines = 1,
)

if(back != null) {
if (back != null) {
Icon(
imageVector = ImageVector.vectorResource(id = back.icon),
tint = Color.Unspecified,
Expand All @@ -125,7 +120,7 @@ private fun PlanzAppBar(
.align(Alignment.CenterStart),
)
}
if(menu != null) {
if (menu != null) {
Icon(
imageVector = ImageVector.vectorResource(id = menu.icon),
tint = Color.Unspecified,
Expand Down Expand Up @@ -196,34 +191,6 @@ private fun PlanzColorTextAppBar(
}
}

enum class PlanzAppBarMenu(
val horizontalPadding: Dp,
@DrawableRes val icon: Int,
@StringRes val contentDescription: Int,
) {
CREATE(
horizontalPadding = 16.dp,
icon = R.drawable.ic_create,
contentDescription = R.string.icon_create_content_description
),
EXIT(
horizontalPadding = 20.dp,
icon = R.drawable.ic_exit,
contentDescription = R.string.icon_exit_content_description
),
SHARE(
horizontalPadding = 20.dp,
icon = R.drawable.ic_share_box_24,
contentDescription = R.string.icon_share_content_description
),

BACK(
horizontalPadding = 20.dp,
icon = R.drawable.ic_arrow_left_20,
contentDescription = R.string.icon_arrow_left_content_description
),
}

@Preview(showBackground = true)
@Composable
fun PlanzCreateAppBarPreview() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.yapp.growth.presentation.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.yapp.growth.domain.entity.User
import com.yapp.growth.presentation.R
import com.yapp.growth.presentation.theme.Gray700
import com.yapp.growth.presentation.theme.Gray800
import com.yapp.growth.presentation.theme.PlanzTypography

@Composable
fun PlanzRespondentBottomSheetContent(
respondents: List<User>,
) {
val respondentText = StringBuilder()
respondents.forEachIndexed { index, user ->
when (index) {
0, 3, 7 -> respondentText.append(user.userName)
2, 6 -> respondentText.append(", ${user.userName.plus("\n")}")
else -> respondentText.append(", ${user.userName}")
}
}

Column(
modifier = Modifier
.fillMaxWidth()
.background(Color.White)
.padding(horizontal = 20.dp)
.padding(top = 4.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Text(
text = stringResource(id = R.string.planz_component_respondent_bottom_sheet_content_title),
style = PlanzTypography.subtitle2,
color = Gray700
)
Text(
text = respondentText.toString(),
style = PlanzTypography.caption,
color = Gray800
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,21 @@
package com.yapp.growth.presentation.component

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.BottomSheetScaffold
import androidx.compose.material.BottomSheetScaffoldState
import androidx.compose.material.ExperimentalMaterialApi
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.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.yapp.growth.domain.entity.TimeTable
import com.yapp.growth.domain.entity.User
import com.yapp.growth.presentation.R
import com.yapp.growth.presentation.theme.*
import com.yapp.growth.presentation.util.getCurrentBlockDate
import com.yapp.growth.presentation.util.toHour
import com.yapp.growth.presentation.util.toPlanDate

@Composable
fun PlanzBottomSheetScaffoldLayout(
sheetContent: @Composable () -> Unit,
scaffoldState: BottomSheetScaffoldState,
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
BottomSheetScaffold(
scaffoldState = scaffoldState,
Expand All @@ -51,10 +41,9 @@ fun PlanzBottomSheetScaffoldLayout(

}


@Composable
fun PlanzBottomSheetScaffold(
sheetContent: @Composable () -> Unit
sheetContent: @Composable () -> Unit,
) {
Spacer(
modifier = Modifier
Expand All @@ -72,126 +61,3 @@ fun PlanzBottomSheetScaffold(
.background(color = Color.White)
)
}

@Composable
fun FixPlanBottomSheetContent(timeTable: TimeTable, currentClickTimeIndex: Pair<Int,Int>, currentClickUserData: List<User>, onClickSelectPlan: (String) -> Unit) {
if (currentClickTimeIndex.first < 0 || currentClickTimeIndex.second < 0 ) return

val day = timeTable.availableDates[currentClickTimeIndex.first].split('T').first()
val hour = timeTable.minTime.toHour()
val time = "${day}T${hour}:00"

val respondUserText = StringBuilder()
currentClickUserData.forEachIndexed { index, user ->
when (index) {
0, 3, 7 -> respondUserText.append(user.userName)
2, 6 -> respondUserText.append(", ${user.userName.plus("\n")}")
else -> respondUserText.append(", ${user.userName}")
}
}

Column(
modifier = Modifier
.background(Color.White)
.padding(start = 20.dp, end = 20.dp)) {
Row(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(
text = "약속 날짜",
style = PlanzTypography.subtitle2,
color = Gray700
)

Text(
text = time.getCurrentBlockDate(currentClickTimeIndex.second).toPlanDate(),
style = PlanzTypography.subtitle2,
color = MainPurple900
)
}

if (respondUserText.isNotEmpty()) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 12.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = "응답자",
style = PlanzTypography.subtitle2,
color = Gray700
)

Text(
text = respondUserText.toString(),
style = PlanzTypography.caption,
color = Gray800,
textAlign = TextAlign.End
)
}
}

PlanzBasicBottomButton(modifier = Modifier
.fillMaxWidth()
.padding(top = 20.dp), text = stringResource(id = R.string.fix_plan_fix_button_title), onClick = {
onClickSelectPlan(time.getCurrentBlockDate(currentClickTimeIndex.second))
})
}
}

@Composable
fun MonitorPlanBottomSheetContent(timeTable: TimeTable, currentClickUserData: List<User>, onClickExitIcon: () -> Unit) {

val respondUserText = StringBuilder()
currentClickUserData.forEachIndexed { index, user ->
when (index) {
0, 3, 7 -> respondUserText.append(user.userName)
2, 6 -> respondUserText.append(", ${user.userName.plus("\n")}")
else -> respondUserText.append(", ${user.userName}")
}
}

Column(
modifier = Modifier
.fillMaxWidth()
.background(Color.White)
.padding(start = 20.dp, end = 20.dp)) {

Icon(
modifier = Modifier
.align(Alignment.End)
.clickable {
onClickExitIcon()
},
painter = painterResource(R.drawable.ic_exit),
tint = Color.Unspecified,
contentDescription = stringResource(R.string.icon_exit_content_description),
)

Row {
Text(
text = timeTable.promisingName,
style = PlanzTypography.subtitle1,
color = MainPurple900,
)

Text(
text = stringResource(id = R.string.monitor_plan_join_title_text),
style = PlanzTypography.subtitle1,
color = Gray900,
)
}

if (respondUserText.isNotEmpty()) {
Text(
modifier = Modifier.padding(top = 12.dp),
text = respondUserText.toString(),
style = PlanzTypography.caption,
color = Gray800,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.yapp.growth.presentation.R
import com.yapp.growth.presentation.theme.Gray500
import com.yapp.growth.presentation.component.type.PlanzAppBarMenu
import com.yapp.growth.presentation.theme.Gray900
import com.yapp.growth.presentation.theme.MainPurple900
import com.yapp.growth.presentation.theme.PlanzTypography
Expand Down
Loading

0 comments on commit 12c2732

Please sign in to comment.