Skip to content
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
@@ -0,0 +1,159 @@
package com.paw.key.presentation.ui.home

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
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.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.paw.key.R
import com.paw.key.core.designsystem.component.PawkeyButton
import com.paw.key.core.designsystem.theme.PawKeyTheme
import com.paw.key.core.util.noRippleClickable
import com.paw.key.presentation.ui.home.viewmodel.HomeViewModel
import com.paw.key.presentation.ui.signup.component.FormField
import com.paw.key.presentation.ui.signup.component.LocationButton
import com.paw.key.presentation.ui.signup.component.LocationList

@Preview(showBackground = true)
@Composable
private fun PreviewHomeLocationSettingScreen() {
PawKeyTheme {
HomeLocationSettingScreen(
paddingValues = PaddingValues(),
navigateUp = {},
navigateNext = {},
navigateHomeLocationSetting = {}
)
}
}

@Composable
fun HomeLocationSettingRoute(
paddingValues: PaddingValues,
navigateUp: () -> Unit,
navigateNext: () -> Unit,
navigateHomeLocationSetting: () -> Unit,
modifier: Modifier = Modifier,
viewModel: HomeViewModel = hiltViewModel(),
) {

HomeLocationSettingScreen(
paddingValues = paddingValues,
navigateUp = navigateUp,
navigateNext = navigateNext,
navigateHomeLocationSetting = navigateHomeLocationSetting,
modifier = modifier,
viewModel = viewModel
)
}

@Composable
fun HomeLocationSettingScreen(
paddingValues: PaddingValues,
navigateUp: () -> Unit,
navigateNext: () -> Unit,
navigateHomeLocationSetting: () -> Unit,
modifier: Modifier = Modifier,
viewModel: HomeViewModel = hiltViewModel(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

뷰모델을 파라미터로 넘길 경우 재사용성과 생명주기의 문제와 의존성 주입 원칙에 위배되기 때문에 state.~로 관찰한 값을 넘겨주세요

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

엇...어엇.. 공부하겠습니다

) {
val state by viewModel.state.collectAsState()

Column(
modifier = modifier
.fillMaxSize()
.padding(horizontal = 16.dp)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.height(60.dp)
.padding(vertical = 16.dp),
verticalAlignment = Alignment.CenterVertically
)
{
Icon(
imageVector = ImageVector.vectorResource(R.drawable.ic_arrow_left_black),
contentDescription = "뒤로가기",
modifier = Modifier
.noRippleClickable { navigateUp() }
)
Box(
modifier = Modifier.weight(1f),
contentAlignment = Alignment.Center
) {
Text(
text = "저장한 산책 루트",
style = PawKeyTheme.typography.body16Sb
)
}
Spacer(modifier = Modifier.width(24.dp))
}

Spacer(modifier = Modifier.height(24.dp))

FormField(
label = stringResource(id = R.string.ic_onboarding_signup_main_location),
content = {
LocationButton(
isEnable = true,
location = "강남구",
onClick = { viewModel.toggleLocationMenu() }
)
}
)

Spacer(modifier = Modifier.height(46.dp))

FormField(
label = stringResource(id = R.string.ic_onboarding_signup_sub_location),
content = {
if (state.isLocationMenuVisible) {
LocationList(
selected = state.selectedLocation,
locations = listOf("개포동", "논현동", "뭔동", "동동동", "스꾸삐", "4글자유"),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

스꾸삐 먼가요

onLocationSelected = { location ->
viewModel.selectLocation(location)
}
)
}
}
)

Spacer(modifier = Modifier.weight(1f))

val isFormValid = state.selectedLocation.isNotEmpty()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이것도 상태에 관련된 내용이라 뷰모델에서 ㅎㅎ


PawkeyButton(
text = stringResource(id = R.string.ic_onboarding_signup_button),
enabled = isFormValid,
onClick = {
if (isFormValid) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

? 무슨 용도죵

}
}
)

Spacer(modifier = Modifier.height(46.dp))

}

}


50 changes: 37 additions & 13 deletions app/src/main/java/com/paw/key/presentation/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("DEPRECATION")

package com.paw.key.presentation.ui.home

import android.app.Activity
Expand All @@ -13,9 +11,10 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
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.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.collectAsState
Expand All @@ -26,43 +25,52 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.view.ViewCompat
import androidx.hilt.navigation.compose.hiltViewModel
import com.paw.key.R
import com.paw.key.core.designsystem.theme.PawKeyTheme
import com.paw.key.core.util.noRippleClickable
import com.paw.key.presentation.ui.home.component.DaytimeCard
import com.paw.key.presentation.ui.home.component.HistoryCard
import com.paw.key.presentation.ui.home.component.RowCalendar
import com.paw.key.presentation.ui.home.component.SettingButton
import com.paw.key.presentation.ui.home.component.TopBar
import com.paw.key.presentation.ui.home.component.TrackingCard
import com.paw.key.presentation.ui.home.component.WeatherCard
import com.paw.key.presentation.ui.home.viewmodel.HomeViewModel


@Preview
@Composable
private fun HomeScreenPreview() {
PawKeyTheme {
HomeScreen(
paddingValues = PaddingValues(),
navigateNext = {},)
navigateUp = {},
navigateNext = {},
navigateHomeLocationSetting = {}
)
}

}

@Composable
fun HomeRoute(
paddingValues: PaddingValues,
navigateUp: () -> Unit,
navigateNext: () -> Unit,
navigateHomeLocationSetting: () -> Unit,
modifier: Modifier = Modifier,
viewModel: HomeViewModel = hiltViewModel(),
) {

HomeScreen(
paddingValues = paddingValues,
navigateUp = navigateUp,
navigateNext = navigateNext,
navigateHomeLocationSetting = navigateHomeLocationSetting,
modifier = modifier,
viewModel = viewModel
)
Expand All @@ -71,7 +79,9 @@ fun HomeRoute(
@Composable
fun HomeScreen(
paddingValues: PaddingValues,
navigateUp: () -> Unit,
navigateNext: () -> Unit,
navigateHomeLocationSetting: () -> Unit,
modifier: Modifier = Modifier,
viewModel: HomeViewModel = hiltViewModel(),
) {
Expand All @@ -91,15 +101,16 @@ fun HomeScreen(
Column(
modifier = modifier
.padding(paddingValues)
.background(color = PawKeyTheme.colors.white2)
.fillMaxSize()
.background(color = PawKeyTheme.colors.white1)
) {
TopBar(location = "강남구 역삼동", onLocationClick = { viewModel.toggleLocationMenu() })

Column(
verticalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier
.padding(horizontal = 16.dp),
.padding(horizontal = 16.dp)
.background(color = PawKeyTheme.colors.white2),
) {
Spacer(modifier = Modifier.height(13.dp))

Expand All @@ -112,15 +123,15 @@ fun HomeScreen(
)

Row(
horizontalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier.padding(horizontal = 16.dp),
modifier = Modifier
.fillMaxWidth()
) {
DaytimeCard(
daytime = "05:06",
daystate = "일출",
)

Spacer(modifier = Modifier.width(12.dp))
Spacer(modifier = Modifier.weight(1F))

TrackingCard(onClick = { navigateNext() })
}
Expand All @@ -129,7 +140,14 @@ fun HomeScreen(

RowCalendar(date = "7월")

HistoryCard()
// Todo : 이거 공통 컴포넌트로 변경
// HistoryCard()
Spacer(modifier = Modifier.height(17.dp))
Text(
text = stringResource(R.string.ic_home_current_word),
color = PawKeyTheme.colors.black,
style = PawKeyTheme.typography.head18Sb,
)
}

}
Expand All @@ -142,7 +160,7 @@ fun HomeScreen(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) {
viewModel.hideLocationMenu()
viewModel.toggleLocationMenu()
}
)

Expand All @@ -151,7 +169,13 @@ fun HomeScreen(
modifier = Modifier
.padding(top = 97.dp, start = 250.dp),
) {
SettingButton()
SettingButton(
modifier = Modifier
.noRippleClickable {
viewModel.toggleLocationMenu()
navigateHomeLocationSetting()
},
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
package com.paw.key.presentation.ui.home.component

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
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.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import com.paw.key.R
import com.paw.key.core.designsystem.theme.PawKeyTheme

@Preview(showBackground = true)
Expand All @@ -33,18 +41,23 @@ fun DaytimeCard(
modifier: Modifier = Modifier,
) {
Box(
contentAlignment = Alignment.BottomCenter,
modifier = modifier
.width(81.dp)
.height(110.dp)
.background(color = PawKeyTheme.colors.white1)
.background(
color = PawKeyTheme.colors.white1,
shape = RoundedCornerShape(15.dp),)
.clip(RoundedCornerShape(15.dp)),
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(31.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 11.dp, vertical = 12.dp),
.padding(horizontal = 11.dp)
.padding(bottom = 14.dp)
.zIndex(1F),
) {
Text(
text = daytime,
Expand All @@ -58,5 +71,11 @@ fun DaytimeCard(
style = PawKeyTheme.typography.body16Sb,
)
}
Icon(
imageVector = ImageVector.vectorResource(R.drawable.img_home_sunset),
contentDescription = "daytime",
tint = Color.Unspecified,
)

}
}
Loading