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

[FEATURE] Modified Player Search Screen (1) #101

Merged
merged 6 commits into from
Jul 13, 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 @@ -11,6 +11,7 @@ import com.eshc.goonersapp.core.database.model.onFailure
import com.eshc.goonersapp.core.database.model.onSuccess
import com.eshc.goonersapp.core.domain.model.DataResult
import com.eshc.goonersapp.core.domain.model.player.Player
import com.eshc.goonersapp.core.domain.model.player.PlayerFilter
import com.eshc.goonersapp.core.domain.model.player.PlayerList
import com.eshc.goonersapp.core.domain.repository.PlayerRepository
import com.eshc.goonersapp.core.network.PlayerNetworkDataSource
Expand All @@ -24,9 +25,18 @@ class PlayerRepositoryImpl @Inject constructor(
private val playerNetworkDataSource: PlayerNetworkDataSource,
private val playerLocalDataSource: PlayerLocalDataSource
) : PlayerRepository {
override fun getPlayers(): Flow<DataResult<PlayerList>> = flow {
override fun getPlayers(
playerFilter : PlayerFilter
): Flow<DataResult<PlayerList>> = flow {
emit(
playerNetworkDataSource.getPlayerList().toDataResult {
playerNetworkDataSource.getPlayerList(
teamId = playerFilter.teamId,
seasonId = playerFilter.seasonId,
positionId = playerFilter.positionId,
keyword = playerFilter.keyword,
page = playerFilter.page,
size = playerFilter.size
).toDataResult {
it.toModel()
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.eshc.goonersapp.core.designsystem.component

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
Expand All @@ -11,36 +13,42 @@ 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.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.dp
import com.eshc.goonersapp.core.designsystem.theme.pretendard
import com.eshc.goonersapp.core.designsystem.theme.ColorFFDCDCDC
import com.eshc.goonersapp.core.designsystem.theme.ColorFFFFFFFF

@Composable
fun GnrTextFiled(
modifier: Modifier = Modifier,
message : String,
text : String,
onValueChange : (String) -> Unit,
modifier: Modifier = Modifier,
placeholder : String = "",
backgroundColor : Color = ColorFFFFFFFF,
shape : Shape = CircleShape,
borderStroke: BorderStroke = BorderStroke(1.dp, ColorFFDCDCDC),
enabled : Boolean = true
) {
BasicTextField(
modifier = modifier,
value = message,
value = text,
maxLines = 1,
enabled = enabled,
textStyle = MaterialTheme.typography.bodyMedium.copy(
color = if(enabled) Color.Black else Color.Gray
),
onValueChange = onValueChange,
onValueChange = {
onValueChange(it)
},
decorationBox = { innerTextField ->
Box(
modifier = Modifier
.background(Color(0xFFF1F1F1), CircleShape)
.border(borderStroke, shape)
.background(backgroundColor)
.padding(horizontal = 16.dp),
contentAlignment = Alignment.CenterStart
) {
if(message.isBlank()){
if(text.isBlank()){
Text(
text = placeholder,
style = MaterialTheme.typography.bodyMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -20,16 +21,19 @@ import com.eshc.goonersapp.core.designsystem.theme.GnrTypography

@Composable
fun GnrTopLevelTopBar(
title : String,
title: String,
modifier: Modifier = Modifier,
content : @Composable () -> Unit
){
content: @Composable () -> Unit
) {
Row(
modifier = modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Text(
modifier = Modifier.padding(vertical = 8.dp).wrapContentHeight().weight(1f),
modifier = Modifier
.padding(vertical = 8.dp)
.wrapContentHeight()
.weight(1f),
text = title,
style = GnrTypography.heading2SemiBold,
color = Color.Black,
Expand All @@ -40,27 +44,33 @@ fun GnrTopLevelTopBar(

@Composable
fun GnrTopBar(
title : String,
title: String,
onBackIconClick: () -> Unit,
modifier: Modifier = Modifier,
content : @Composable () -> Unit = {}
){
content: @Composable () -> Unit = {}
) {
Row(
modifier = modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = IconPack.IcIosArrowBack,
contentDescription = null,
modifier= Modifier
.padding(start = 8.dp,end = 8.dp)
.size(24.dp)
.clickable(onClick = onBackIconClick)
)
IconButton(
onClick = onBackIconClick
) {
Icon(
imageVector = IconPack.IcIosArrowBack,
contentDescription = null,
modifier = Modifier
.size(18.dp)
)
}

Text(
modifier = Modifier.padding(vertical = 8.dp).wrapContentHeight().weight(1f),
modifier = Modifier
.padding(vertical = 8.dp)
.wrapContentHeight()
.weight(1f),
text = title,
style = MaterialTheme.typography.headlineLarge,
style = GnrTypography.heading2SemiBold,
color = Color.Black,
)
content()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.eshc.goonersapp.core.domain.model.player

data class PlayerFilter(
val teamId : Int = 19,
val seasonId : Int = 21646,
val positionId : Int? = null,
val keyword : String? = null,
val page : Int? = null,
val size : Int? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package com.eshc.goonersapp.core.domain.repository

import com.eshc.goonersapp.core.domain.model.DataResult
import com.eshc.goonersapp.core.domain.model.player.Player
import com.eshc.goonersapp.core.domain.model.player.PlayerFilter
import com.eshc.goonersapp.core.domain.model.player.PlayerList
import kotlinx.coroutines.flow.Flow

interface PlayerRepository {

fun getPlayers() : Flow<DataResult<PlayerList>>
fun getPlayers(
playerFilter : PlayerFilter
) : Flow<DataResult<PlayerList>>

fun getPlayerDetail(playerId: Int) : Flow<Player>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.eshc.goonersapp.core.domain.usecase.player

import com.eshc.goonersapp.core.domain.model.DataResult
import com.eshc.goonersapp.core.domain.model.player.Player
import com.eshc.goonersapp.core.domain.model.player.PlayerFilter
import com.eshc.goonersapp.core.domain.model.player.PlayerList
import com.eshc.goonersapp.core.domain.repository.PlayerRepository
import kotlinx.coroutines.flow.Flow
Expand All @@ -11,6 +12,8 @@ class GetPlayersUseCase @Inject constructor(
private val playerRepository: PlayerRepository
) {

operator fun invoke(): Flow<DataResult<PlayerList>> =
playerRepository.getPlayers()
operator fun invoke(
playerFilter : PlayerFilter = PlayerFilter()
): Flow<DataResult<PlayerList>> =
playerRepository.getPlayers(playerFilter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import com.eshc.goonersapp.core.network.model.player.RemotePlayerList

interface PlayerNetworkDataSource {

suspend fun getPlayerList() : NetworkResult<RemotePlayerList>
suspend fun getPlayerList(
teamId : Int = 19,
seasonId : Int = 21646,
positionId : Int? = null,
keyword : String? = null,
page : Int? = null,
size : Int? = null
) : NetworkResult<RemotePlayerList>

suspend fun getPlayerDetail(playerId : Int) : NetworkResult<RemotePlayer>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ class FakePlayerNetworkDataSource : PlayerNetworkDataSource {
this.responseForPlayerDetail = response
}

override suspend fun getPlayerList(): NetworkResult<RemotePlayerList> {
override suspend fun getPlayerList(
teamId : Int,
seasonId : Int,
positionId : Int?,
keyword : String?,
page : Int?,
size : Int?
): NetworkResult<RemotePlayerList> {
val response = responseForPlayerList?.invoke()
return if (response != null) {
NetworkResult.Success(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,23 @@ class PlayerNetworkDataSourceImpl @Inject constructor(
private val playerNetworkService: PlayerNetworkService
) : PlayerNetworkDataSource {

override suspend fun getPlayerList(): NetworkResult<RemotePlayerList> {
override suspend fun getPlayerList(
teamId : Int,
seasonId : Int,
positionId : Int?,
keyword : String?,
page : Int?,
size : Int?
): NetworkResult<RemotePlayerList> {
return handleApi {
playerNetworkService.getPlayers()
playerNetworkService.getPlayers(
teamId = teamId,
seasonId = seasonId,
positionId = positionId,
keyword = keyword,
page = page,
size = size
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun LoginScreen(
.fillMaxWidth()
.padding(top = 16.dp, bottom = 16.dp, start = 16.dp, end = 16.dp)
.height(40.dp),
message = "",
text = "",
onValueChange = {

},
Expand All @@ -63,7 +63,7 @@ fun LoginScreen(
.fillMaxWidth()
.padding(bottom = 16.dp, start = 16.dp, end = 16.dp)
.height(40.dp),
message = "",
text = "",
onValueChange = {

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun SignUpScreen(
.padding(top = 16.dp, bottom = 16.dp, start = 16.dp, end = 16.dp)
.height(40.dp),
enabled = viewModel.isCurrentType(type),
message = when (type) {
text = when (type) {
SignUpInputType.Email -> {
email
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.eshc.goonersapp.feature.team.model

import com.eshc.goonersapp.core.domain.model.player.Player

data class TeamSearchUiModel(
val players : List<Player> = emptyList(),
val page : Int = 1,
val isEnded : Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.navigation.navArgument
import com.eshc.goonersapp.feature.team.TeamRootScreen
import com.eshc.goonersapp.feature.team.club.ClubDetailRoute
import com.eshc.goonersapp.feature.team.detail.PlayerDetailRootScreen
import com.eshc.goonersapp.feature.team.history.TeamSearchRootScreen
import com.eshc.goonersapp.feature.team.search.TeamSearchRootScreen

const val teamNavigationRoute = "team_route"
const val playerDetailNavigationRoute = "player_route"
Expand Down
Loading
Loading