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

[UI/#11] 탐색 뷰 / 탐색 기본 화면 구현 #30

Merged
merged 24 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8dd453c
[ADD/#11] TerningTextField 추가
arinming Jul 6, 2024
2c4c070
Merge remote-tracking branch 'origin/develop' into ui/#11-search-view-ui
arinming Jul 9, 2024
9819c4e
[ADD/#11] TerningTextField 추가
arinming Jul 6, 2024
78c8b3a
Merge remote-tracking branch 'origin/ui/#11-search-view-ui' into ui/#…
arinming Jul 9, 2024
e7cf63f
[FIX/#23] 경로 수정
arinming Jul 9, 2024
7340cdd
Merge branch 'refs/heads/ui/#23-text-field-color' into ui/#11-search-…
arinming Jul 9, 2024
ed2c94b
Merge branch 'refs/heads/develop' into ui/#11-search-view-ui
arinming Jul 9, 2024
42819ec
[ADD/#11] TerningTextField 추가
arinming Jul 6, 2024
7c3dee4
Merge remote-tracking branch 'origin/ui/#11-search-view-ui' into ui/#…
arinming Jul 9, 2024
9d393a4
[ADD/#11] TerningTextField 추가
arinming Jul 6, 2024
7d0e855
Merge remote-tracking branch 'origin/ui/#11-search-view-ui' into ui/#…
arinming Jul 9, 2024
eed08f5
[FEAT/#11] ImageSlider 구현
arinming Jul 9, 2024
6846986
[FEAT/#11] 광고 컴포넌트 구현
arinming Jul 9, 2024
8f2970c
[FEAT/#11] 요즘 대학생들에게 인기 있는 공고 텍스트
arinming Jul 9, 2024
314d592
[FEAT/#11] 공고 리스트 텍스트
arinming Jul 9, 2024
7641fd4
[FEAT/#11] 공고 리스트 컴포넌트 구현
arinming Jul 9, 2024
628c9a6
[FIX/#11] 탐색 텍스트 필드 색상 수정
arinming Jul 9, 2024
4d5a569
[DELETE/#11] 안쓰는 코드 삭제
arinming Jul 9, 2024
cb73920
[FIX/#11] 경로 변경
arinming Jul 9, 2024
3b353e6
[REFACTOR/#11] padding 값 수정
arinming Jul 10, 2024
8321ae2
[ADD/#11] InternListType Enum class 생성
arinming Jul 10, 2024
3066940
Merge remote-tracking branch 'origin/develop' into ui/#11-search-view-ui
arinming Jul 10, 2024
cf2c328
[FIX/#11] 경로 수정
arinming Jul 10, 2024
872c4a9
Merge remote-tracking branch 'origin/develop' into ui/#11-search-view-ui
arinming Jul 10, 2024
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 @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.SolidColor
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTheme

@Composable
Expand All @@ -12,18 +13,20 @@ fun SearchTextField(
onValueChange: (String) -> Unit,
hint: String,
leftIcon: Int,
readOnly: Boolean = false,
) {
TerningBasicTextField(
value = text,
onValueChange = onValueChange,
textStyle = TerningTheme.typography.button3,
textColor = Grey400,
cursorBrush = SolidColor(Grey300),
drawLineColor = Grey300,
drawLineColor = TerningMain,
strokeWidth = 2f,
hint = hint,
hintColor = Grey300,
leftIcon = leftIcon,
leftIconColor = Grey400,
leftIconColor = TerningMain,
readOnly = readOnly,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import com.terning.core.designsystem.theme.White
fun TerningBasicTextField(
value: String,
onValueChange: (String) -> Unit,
readOnly: Boolean = false,
textStyle: TextStyle,
textColor: Color,
hintColor: Color,
Expand All @@ -52,6 +51,7 @@ fun TerningBasicTextField(
helperMessage: String = "",
helperIcon: Int? = null,
helperColor: Color = TerningMain,
readOnly: Boolean = false,
) {
val keyboardController = LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current
Expand All @@ -62,7 +62,6 @@ fun TerningBasicTextField(
onValueChange = onValueChange,
singleLine = true,
maxLines = 1,
readOnly = readOnly,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(
onDone = {
Expand Down Expand Up @@ -124,7 +123,9 @@ fun TerningBasicTextField(
)
}
}
})
},
readOnly = readOnly,
)

Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.terning.core.designsystem.component.topappbar

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
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.terning.core.R
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.designsystem.theme.White
Expand Down Expand Up @@ -51,6 +54,7 @@ fun TerningBasicTopAppBar(
action()
}
},
colors = TopAppBarDefaults.topAppBarColors(White)
colors = TopAppBarDefaults.topAppBarColors(White),
modifier = Modifier.padding(horizontal = 16.dp)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.terning.feature.calendar.navigation.navigateCalendar
import com.terning.feature.home.navigation.navigateHome
import com.terning.feature.mypage.navigation.navigateMyPage
import com.terning.feature.onboarding.signin.navigation.SignIn
import com.terning.feature.search.navigation.Search
import com.terning.feature.search.navigation.navigateSearch

class MainNavigator(
Expand Down
104 changes: 52 additions & 52 deletions feature/src/main/java/com/terning/feature/search/SearchRoute.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.terning.feature.search

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -11,12 +15,14 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.component.textfield.NameTextField
import com.terning.core.designsystem.component.textfield.SearchTextField
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.WarningRed
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey100
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.feature.R
import com.terning.feature.search.component.ImageSlider
import com.terning.feature.search.component.InternListType
import com.terning.feature.search.component.SearchInternList

@Composable
fun SearchRoute() {
Expand All @@ -26,61 +32,55 @@ fun SearchRoute() {
@Composable
fun SearchScreen() {
var text by remember { mutableStateOf("") }

// TODO 프로필 스크린 TextField로, 삭제될 코드입니다
var helperMessage by remember { mutableStateOf(R.string.profile_text_field_helper) }
var helperIcon by remember { mutableStateOf<Int?>(null) }
var helperColor by remember { mutableStateOf(Grey400) }
val specialCharacterPattern = Regex("[!@#\$%^&*(),.?\":{}|<>\\[\\]\\\\/]")

// TODO 프로필 스크린 TextField로, 삭제될 코드입니다
fun updateHelper(text: String) {
helperMessage = when {
text.isEmpty() -> R.string.profile_text_field_helper
specialCharacterPattern.containsMatchIn(text) -> R.string.profile_text_field_warning
text.length <= 12 -> R.string.profile_text_field_check
else -> R.string.profile_text_field_helper
}
helperIcon = when {
text.isEmpty() -> null
specialCharacterPattern.containsMatchIn(text) -> R.drawable.ic_warning
text.length <= 12 -> R.drawable.ic_check
else -> null
}
helperColor = when {
text.isEmpty() -> Grey400
specialCharacterPattern.containsMatchIn(text) -> WarningRed
text.length <= 12 -> TerningMain
else -> Grey400
}
}
val images = listOf(
R.drawable.ic_nav_search,
R.drawable.ic_check,
R.drawable.ic_nav_my_page,
)

Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
) {
Box(
modifier = Modifier.padding(
horizontal = 24.dp,
vertical = 16.dp
)
) {
SearchTextField(
text = text,
onValueChange = { newText ->
text = newText
},
hint = stringResource(R.string.search_text_field_hint),
leftIcon = R.drawable.ic_nav_search,
readOnly = true,
)
}

SearchTextField(
text = text,
onValueChange = { newText ->
text = newText
},
hint = stringResource(R.string.search_text_field_hint),
leftIcon = R.drawable.ic_nav_search
ImageSlider(
images = images
)

// TODO 프로필 스크린 TextField로, 삭제될 코드입니다
NameTextField(
text = text,
onValueChange = { newText ->
text = newText
updateHelper(newText)
},
hint = stringResource(R.string.profile_text_field_hint),
helperMessage = stringResource(helperMessage),
helperIcon = helperIcon,
helperColor = helperColor
Spacer(modifier = Modifier.padding(8.dp))

Text(
text = stringResource(id = R.string.search_today_popular),
modifier = Modifier.padding(
horizontal = 24.dp,
vertical = 4.dp
),
style = TerningTheme.typography.title1,
color = Black
)

SearchInternList(type = InternListType.VIEW)
HorizontalDivider(
thickness = 4.dp,
modifier = Modifier.padding(vertical = 8.dp),
color = Grey100,
)
SearchInternList(type = InternListType.SCRAP)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.terning.feature.search.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun DotsIndicator(
modifier: Modifier = Modifier,
pageCount: Int,
currentPage: Int,
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(8.dp)
) {
repeat(pageCount) { index ->
IndicatorDots(
isSelected = index == currentPage,
modifier = modifier
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.terning.feature.search.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.Card
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.Grey200
import kotlinx.coroutines.delay

@Composable
fun ImageSlider(
modifier: Modifier = Modifier,
images: List<Int>,
) {
val pagerState = rememberPagerState(pageCount = { images.size })

LaunchedEffect(Unit) {
while (true) {
delay(3000)
val nextPage = (pagerState.currentPage + 1) % pagerState.pageCount
pagerState.scrollToPage(nextPage)
}
}
Comment on lines +30 to +36
Copy link
Member

Choose a reason for hiding this comment

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

이건 자동 스크롤 로직인가요??

Copy link
Member

Choose a reason for hiding this comment

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

우왕 자동 스크롤까지 구현하다니!!! 진짜 최고최고

Copy link
Contributor Author

Choose a reason for hiding this comment

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

기디에서 3초마다 넘어가게 해달라고 하셔서 반영했습니당....... 🫶🏻

Column(
modifier
.fillMaxWidth()
.background(Grey200),
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = modifier
.wrapContentSize(),
contentAlignment = Alignment.BottomCenter
) {
HorizontalPager(
state = pagerState,
modifier = modifier.wrapContentSize()
) { currentPage ->
Card(
modifier
.wrapContentSize()
) {
Image(
painter = painterResource(id = images[currentPage]),
contentDescription = null,
modifier = modifier
.fillMaxWidth()
.height(112.dp)
.padding(16.dp)
)
Comment on lines +58 to +63
Copy link
Member

Choose a reason for hiding this comment

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

나중에 실제 광고 화면 들어가면 요거 고정 디피는 지양하면 좋을 것 가타요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 !!!

}
}
DotsIndicator(
pageCount = images.size,
currentPage = pagerState.currentPage
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.terning.feature.search.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.White

@Composable
fun IndicatorDots(
isSelected: Boolean, modifier: Modifier,
) {
Box(
modifier = modifier
.padding(2.dp)
.clip(CircleShape)
.size(6.dp)
.background(if (isSelected) TerningMain else White)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.terning.feature.search.component

enum class InternListType(val type: String) {
VIEW("view"),
SCRAP("scrap");
}
Loading
Loading