Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#267] 탐색 뷰 / 2차 QA 반영 #269

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -38,18 +40,16 @@ fun InternTitle(
.background(
color = TerningSub3,
shape = RoundedCornerShape(size = 5.dp)
),
)
.width(70.dp)
.height(25.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = dDay,
style = TerningTheme.typography.title3,
color = TerningMain,
modifier = Modifier.padding(
horizontal = 19.5.dp,
vertical = 1.5.dp
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,34 @@ fun ImageSlider(
images: List<Int>,
onAdvertisementClick: () -> Unit,
) {
val pagerState = rememberPagerState(pageCount = { images.size })
val infiniteImages = remember { images + images + images }
Copy link
Member

Choose a reason for hiding this comment

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

왜 동일한 리스트가 3번 더해진건가요?
배너에 이미지가 무조건 3개 이상 있도록 하려고 이렇게 구현하신건가요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 저렇게 해야 좌우로 이동할 때 부드럽게 이동되더라구요..!

val pagerState = rememberPagerState(
initialPage = images.size,
initialPageOffsetFraction = 0f,
pageCount = { infiniteImages.size }
)
val autoScroll = remember { mutableStateOf(true) }

LaunchedEffect(autoScroll.value) {
if (autoScroll.value) {
while (true) {
delay(2000)
if (!pagerState.isScrollInProgress) {
val nextPage = (pagerState.currentPage + 1) % pagerState.pageCount
val nextPage = pagerState.currentPage + 1
pagerState.animateScrollToPage(nextPage)
}
}
}
}

LaunchedEffect(pagerState.currentPage) {
if (pagerState.currentPage < images.size) {
pagerState.scrollToPage(pagerState.currentPage + images.size)
} else if (pagerState.currentPage >= 2 * images.size) {
pagerState.scrollToPage(pagerState.currentPage - images.size)
}
}

Column(
modifier
.fillMaxWidth()
Expand All @@ -54,10 +67,11 @@ fun ImageSlider(
) {
HorizontalPager(
state = pagerState,
modifier = modifier
modifier = modifier,
beyondViewportPageCount = infiniteImages.size
) { currentPage ->
Image(
painter = painterResource(id = images[currentPage]),
painter = painterResource(id = infiniteImages[currentPage % images.size]),
contentDescription = null,
modifier = modifier
.fillMaxWidth()
Expand All @@ -68,8 +82,8 @@ fun ImageSlider(
}
DotsIndicator(
pageCount = images.size,
currentPage = pagerState.currentPage
currentPage = pagerState.currentPage % images.size
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fun SearchIntern(
.crossfade(true)
.build(),
contentDescription = stringResource(id = R.string.search_image),
contentScale = ContentScale.Crop,
contentScale = ContentScale.FillWidth,
modifier = Modifier
.height(76.dp)
.wrapContentSize()
Expand Down
2 changes: 1 addition & 1 deletion feature/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<!--Intern-->
<string name="intern_share_icon">공유 아이콘</string>
<string name="intern_move_to_site">지원 사이트로 이동하기</string>
<string name="intern_top_app_bar_title">공고 정보</string>
<string name="intern_top_app_bar_title">공고 상세 정보</string>
<string name="intern_view_count_detail">%s회</string>
<string name="intern_info_d_day">서류 마감</string>
<string name="intern_info_working">근무 기간</string>
Expand Down
Loading