Skip to content

Commit

Permalink
[feat] 성동 발자국 지도 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
reezung committed Feb 26, 2024
1 parent c0bbe8b commit 814cf4c
Show file tree
Hide file tree
Showing 17 changed files with 459 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.sungdongwalk.components.navigator_bottom.BottomNav
import com.example.sungdongwalk.screens.BadgeScreen
import com.example.sungdongwalk.screens.FootprintScreen
import com.example.sungdongwalk.screens.MypageScreen
import com.example.sungdongwalk.screens.WalkScreen
import com.example.sungdongwalk.viewmodels.WalkViewModel
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -35,6 +38,15 @@ fun Nav(){
composable(route = Screens.WalkScreen.name) {
WalkScreen(navController)
}
composable(route = Screens.MypageScreen.name) {
MypageScreen(navController)
}
composable(route = Screens.BadgeScreen.name) {
BadgeScreen(navController)
}
composable(route = Screens.FootprintScreen.name) {
FootprintScreen(navController)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ package com.example.sungdongwalk.activities.navigation
enum class Screens {
MainScreen,
WalkScreen,
MypageScreen,
BadgeScreen,
FootprintScreen
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ class RetrofitManager {
Log.d(TAG, e.toString())
}
}
fun getUserPlaces() = CoroutineScope(IO).launch {
try{
val request = CoroutineScope(IO).async { iRetrofit?.getUserPlaces(LoginViewModel.instance.id.value)}
val response = request.await()
when(response?.code()){
200 -> {
val userPlaces = response.body()?.places ?: listOf()
PlaceViewModel.instance.updateUserPlace(userPlaces)
}
else -> {}
}
}catch(e: Exception){
Log.d(TAG, e.toString())
}
}
fun getPlaces(
xCoordinate: String,
yCoordinate: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.example.sungdongwalk.R
import com.example.sungdongwalk.activities.navigation.Screens
import com.example.sungdongwalk.ui.theme.Gray500
import com.example.sungdongwalk.ui.theme.SDwhite
import com.example.sungdongwalk.ui.theme.Typography
Expand All @@ -27,7 +29,11 @@ enum class NavigatorTopType {
LOGO, EVENT, MYPAGE
}
@Composable
fun NavigatorTop(type: NavigatorTopType){
fun NavigatorTop(
type: NavigatorTopType,
navController: NavController,
navText: String? = null
){
Row(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -54,24 +60,26 @@ fun NavigatorTop(type: NavigatorTopType){
Icon(
modifier = Modifier
.size(20.dp)
.clickable { },
.clickable { navController.navigateUp() },
painter = painterResource(id = R.drawable.ic_back),
contentDescription = "back",
)
Spacer(Modifier.width(15.dp))
Spacer(Modifier.width(10.dp))
Text(
text = "내 정보",
text = navText!!,
style = Typography.headlineLarge,
)
}

}
}
Icon(
modifier = Modifier.clickable { },
painter = painterResource(id = R.drawable.ic_profile),
contentDescription = "profile",
tint = Gray500,
)
if(type != NavigatorTopType.MYPAGE ){
Icon(
modifier = Modifier.clickable { navController.navigate(Screens.MypageScreen.name)},
painter = painterResource(id = R.drawable.ic_profile),
contentDescription = "profile",
tint = Gray500,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.example.sungdongwalk.components

import androidx.compose.foundation.background
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.shape.CircleShape
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.example.sungdongwalk.ui.theme.Gray100
import com.example.sungdongwalk.ui.theme.SDblack
import com.example.sungdongwalk.ui.theme.SDblue
import com.example.sungdongwalk.ui.theme.SDwhite
import com.example.sungdongwalk.ui.theme.Typography

@Composable
fun PercentSlider(
title : String,
percent : Int,
){
Column(
modifier = Modifier
.fillMaxWidth()
.padding(30.dp)
.background(SDwhite)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 10.dp, start = 7.dp, end = 7.dp),
horizontalArrangement = Arrangement.SpaceBetween
){
Text(text = title, color = SDblue, style = Typography.bodyLarge)
Text(text = "$percent%", color = SDblack, style = Typography.bodyLarge)
}
LinearProgressIndicator(
progress = percent*0.01f,
modifier = Modifier
.fillMaxWidth()
.height(15.dp)
.clip(CircleShape),
trackColor = Gray100,
color = SDblue,
)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun EventContainer(
modifier = Modifier
.fillMaxWidth()
.background(Lightblue100)
.padding(top = 10.dp, bottom = 22.dp),
.padding(top = 10.dp, bottom = 22.dp, start=10.dp, end=10.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
maxItemsInEachRow = 4
){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ fun BottomNav(navController: NavController){
.padding(paddingValue)
){
composable(route = BottomNavScreens.HomeScreen.name){
HomeScreen(setIsLoading)
HomeScreen(navController,setIsLoading)
}
composable(route = BottomNavScreens.MapScreen.name){
MapScreen(setIsLoading)
}
composable(route = BottomNavScreens.EventScreen.name){
EventScreen(setIsLoading)
EventScreen(navController, setIsLoading)
}
}
if(isLoading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
import com.example.sungdongwalk.components.NavigatorTop
import com.example.sungdongwalk.components.NavigatorTopType
import com.example.sungdongwalk.components.event.EventContainer
Expand All @@ -18,14 +19,15 @@ enum class EventCategory{
@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun EventScreen(
navController: NavController,
setIsLoading: (Boolean) -> Unit
) {
Column(
modifier = Modifier
.fillMaxSize()
.background(SDwhite)
){
NavigatorTop(NavigatorTopType.EVENT)
NavigatorTop(NavigatorTopType.EVENT, navController)
EventContainer(setIsLoading)
}
}
101 changes: 101 additions & 0 deletions app/src/main/java/com/example/sungdongwalk/screens/FootprintScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.example.sungdongwalk.screens

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Text
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.Center
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.example.sungdongwalk.R
import com.example.sungdongwalk.components.NavigatorTop
import com.example.sungdongwalk.components.NavigatorTopType
import com.example.sungdongwalk.components.PercentSlider
import com.example.sungdongwalk.ui.theme.Gray300
import com.example.sungdongwalk.ui.theme.Gray500
import com.example.sungdongwalk.ui.theme.Lightblue100
import com.example.sungdongwalk.ui.theme.SDblack
import com.example.sungdongwalk.ui.theme.SDblue
import com.example.sungdongwalk.ui.theme.SDwhite
import com.example.sungdongwalk.ui.theme.Typography
import com.example.sungdongwalk.viewmodels.PlaceViewModel

@OptIn(ExperimentalLayoutApi::class)
@Composable
fun FootprintScreen(
navController: NavController
){
Column(
modifier = Modifier
.fillMaxWidth()
.background(SDwhite),
horizontalAlignment = Alignment.CenterHorizontally
){
NavigatorTop(type = NavigatorTopType.MYPAGE, navController = navController, "성동 발자국 지도")
PercentSlider("지도달성률", PlaceViewModel.instance.userPlaceAchievementRate.value)
FlowRow(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 15.dp, vertical = 20.dp)
.verticalScroll(rememberScrollState()),
maxItemsInEachRow = 3,
horizontalArrangement = Arrangement.SpaceEvenly,
verticalArrangement = Arrangement.spacedBy(15.dp)
) {
PlaceViewModel.instance.userPlace.value.forEachIndexed { index, it ->
Card(
shape = CircleShape,
colors = CardDefaults.cardColors(
containerColor = if(it.isVisited) Lightblue100 else Gray300
),
modifier = Modifier
.size(100.dp)
.align(CenterVertically)
) {
Box(
modifier = Modifier
.fillMaxSize()
){
if (it.isVisited)
Icon(
painter = painterResource(id = R.drawable.ic_footprint),
contentDescription = null,
tint = SDblue,
modifier = Modifier
.padding(12.dp)
.align(Center)
)
Text(
text = it.name,
color = if (it.isVisited) SDblack else Gray500,
textAlign = TextAlign.Center,
style = Typography.labelLarge,
modifier = Modifier
.padding(10.dp)
.align(Center)
)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.example.sungdongwalk.R
import com.example.sungdongwalk.api.Dto
import com.example.sungdongwalk.components.CardLarge
Expand All @@ -40,7 +41,10 @@ import kotlinx.coroutines.launch
@SuppressLint("StateFlowValueCalledInComposition")
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun HomeScreen(setIsLoading: (Boolean)->Unit) {
fun HomeScreen(
navController: NavController,
setIsLoading: (Boolean)->Unit
) {
val (places, setPlaces) = remember{
mutableStateOf(listOf<Dto.SimplePlaceVo>())
}
Expand All @@ -56,7 +60,7 @@ fun HomeScreen(setIsLoading: (Boolean)->Unit) {
.fillMaxSize()
.background(SDwhite)
) {
NavigatorTop(type = NavigatorTopType.LOGO)
NavigatorTop(type = NavigatorTopType.LOGO, navController)
Row(
modifier = Modifier
.padding(vertical = 20.dp, horizontal = 30.dp)
Expand Down
Loading

0 comments on commit 814cf4c

Please sign in to comment.