Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…droid into feature/#68
  • Loading branch information
kimyuchan-k1 committed Feb 17, 2025
2 parents 864c25d + 3ca3e8b commit a9ddaf2
Show file tree
Hide file tree
Showing 73 changed files with 3,488 additions and 1,328 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

11 changes: 0 additions & 11 deletions .idea/deploymentTargetSelector.xml

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

3 changes: 2 additions & 1 deletion .idea/misc.xml

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

450 changes: 450 additions & 0 deletions .idea/other.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.example.yeongkkuel.presentation.home.store.StoreApiService
import com.example.yeongkkuel.network.service.MyPageService
import com.example.yeongkkuel.network.service.NotificationService
import com.example.yeongkkuel.network.service.StatService
import com.example.yeongkkuel.presentation.home.entry.data.ExpenseApiService

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
Expand Down Expand Up @@ -91,4 +92,8 @@ object RetrofitClient {
authRetrofit!!.create(NotificationService::class.java)
}

val expenseApiService: ExpenseApiService by lazy {
authRetrofit!!.create(ExpenseApiService::class.java)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.example.yeongkkuel.network

import com.example.yeongkkuel.network.request.expenditure.ExpenditureTargetRequest
import com.example.yeongkkuel.network.response.Response
import com.example.yeongkkuel.network.response.expenditure.DayExpenditureResponse
import com.example.yeongkkuel.network.response.expenditure.MonthExpendituresCalendar
import com.example.yeongkkuel.network.response.expenditure.MonthExpendituresCategory
import com.example.yeongkkuel.network.response.expenditure.MonthlyAverageExpenditureResponse
import com.example.yeongkkuel.network.response.expenditure.WeekExpenditureExpensesResponse
import com.example.yeongkkuel.network.response.expenditure.WeekExpendituresAverage
import com.example.yeongkkuel.presentation.home.category.data.CategoryRequest
import com.example.yeongkkuel.presentation.home.category.data.CategoryResponse

import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path

interface YeongkkuelService {

//stat
@GET("/api/expenditures/day")
suspend fun getExpendituresDay(
): retrofit2.Response<Response<DayExpenditureResponse>>

@GET("/api/expenditures/week/expenses")
suspend fun getExpendituresWeekExpenses(
): Response<WeekExpenditureExpensesResponse>

@GET("/api/expenditures/week/average")
suspend fun getExpendituresWeekAverage(
): Response<WeekExpendituresAverage>

@GET("/api/expenditures/month/{year}/{month}")
suspend fun getExpendituresMonthCalendar(
@Path("year") year: Int,
@Path("month") month: Int
): Response<MonthExpendituresCalendar>

@GET("/api/expenditures/{year}/{month}/{day}")
suspend fun getExpendituresMonthCategory(
@Path("year") year: Int,
@Path("month") month: Int,
@Path("day") day: Int,
): Response<MonthExpendituresCategory>

@POST("/api/expenditures/target")
suspend fun postExpendituresTarget(
@Body request: ExpenditureTargetRequest
)

@GET("/api/expenditures/target/recommendation")
suspend fun getExpenditureAverageMonthly(
): Response<MonthlyAverageExpenditureResponse>


// Category
@GET("/api/category/categories")
suspend fun getCategories(): Response<List<CategoryResponse>>

@GET("/api/category/{category_id}")
suspend fun getCategoryDetail(
@Path("category_id") categoryId: Int
): Response<CategoryResponse>

@POST("/api/category")
suspend fun addCategory(
@Body request: CategoryRequest
): Response<Unit>

@PATCH("/api/category/{category_id}")
suspend fun updateCategory(
@Path("category_id") categoryId: Int,
@Body request: CategoryRequest
): Response<Unit>

@DELETE("/api/category/{category_id}")
suspend fun deleteCategory(
@Path("category_id") categoryId: Int
): Response<Unit>

}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.example.yeongkkuel.network.response.expenditure
import com.google.gson.annotations.SerializedName

data class WeekExpendituresAverage(
@SerializedName("age") val age: String,
@SerializedName("job") val job: String,
@SerializedName("topPercent") val topPercent: Int,
@SerializedName("averageExpenditure") val averageExpenditure: Int,
@SerializedName("age") val age: String?,
@SerializedName("job") val job: String?,
@SerializedName("topPercent") val topPercent: Int?,
@SerializedName("averageExpenditure") val averageExpenditure: Int?,
@SerializedName("myAverageExpenditure") val myAverageExpenditure: Int,
@SerializedName("lastWeekExpenditure") val lastWeekExpenditure: Int,
@SerializedName("lastWeekExpenditure") val lastWeekExpenditure: Int?,
@SerializedName("thisWeekExpenditure") val thisWeekExpenditure: Int,
@SerializedName("categories") val categories: List<Category>
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ import retrofit2.http.POST
import retrofit2.http.Path

interface StatService {
@GET("/api/expenditures/day")
@GET("/api/expense/day")
suspend fun getExpendituresDay(
): retrofit2.Response<Response<DayExpenditureResponse>>

@GET("/api/expenditures/week/expenses")
@GET("/api/expense/week/expenses")
suspend fun getExpendituresWeekExpenses(
): Response<WeekExpenditureExpensesResponse>

@GET("/api/expenditures/week/average")
@GET("/api/expense/week/average")
suspend fun getExpendituresWeekAverage(
): Response<WeekExpendituresAverage>

@GET("/api/expenditures/month/{year}/{month}")
@GET("/api/expense/month/{year}/{month}")
suspend fun getExpendituresMonthCalendar(
@Path("year") year: Int,
@Path("month") month: Int
): Response<MonthExpendituresCalendar>

@GET("/api/expenditures/{year}/{month}/{day}")
@GET("/api/expense/{year}/{month}/{day}")
suspend fun getExpendituresMonthCategory(
@Path("year") year: Int,
@Path("month") month: Int,
@Path("day") day: Int,
): Response<MonthExpendituresCategory>

@POST("/api/expenditures/target")
@POST("/api/expense/target")
suspend fun postExpendituresTarget(
@Body request: ExpenditureTargetRequest
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class MainActivity : AppCompatActivity(), BotSheetListener {
private var rvBottomSheetCollapseStateHeight: Int = 0

override fun onCreate(savedInstanceState: Bundle?) {


// 스플래시 화면 설정
val splashScreen = this.installSplashScreen()

Expand All @@ -71,12 +69,16 @@ class MainActivity : AppCompatActivity(), BotSheetListener {
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

// 스플래시 화면 종료 조건 설정 (예: 데이터 초기화 완료)
splashScreen.setKeepOnScreenCondition {
// 앱 초기화 작업이 완료될 때까지 유지
checkInitialization()
// 앱 초기화 작업 중 미리 API 호출하여 데이터를 프리로드
lifecycleScope.launch {
botSheetViewModel.getSpendingList()
}

// 스플래시 화면 종료 조건: 데이터가 로드되지 않았다면 계속 유지
// splashScreen.setKeepOnScreenCondition {
// !isDataLoaded() // 데이터가 아직 로드되지 않았다면 true를 반환해서 스플래시 유지
// }

setupHamburgerClickListener() // 카테고리 더보기 기능 추가

val navHostFragment =
Expand All @@ -96,6 +98,10 @@ class MainActivity : AppCompatActivity(), BotSheetListener {
setupAddCategoryClickListener(navHostFragment.navController)
}

private fun isDataLoaded(): Boolean {
return botSheetViewModel.uiState.value.spendingList.isNotEmpty()
}

private fun setupAddCategoryClickListener(navController: NavController) {
binding.tvAddCategory.setOnClickListener {
navController.navigate(R.id.categoryAddFragment, null, NavOptions.Builder()
Expand All @@ -106,6 +112,11 @@ class MainActivity : AppCompatActivity(), BotSheetListener {
}
}

fun resetBottomSheetState() {
val bottomSheetBehavior = BottomSheetBehavior.from(binding.clItemBotSheet)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
}

private fun initView() = with(binding) {
fun initBottomSheet() {
val bottomSheet = binding.clItemBotSheet
Expand Down Expand Up @@ -233,7 +244,7 @@ class MainActivity : AppCompatActivity(), BotSheetListener {
when (destination.id) {
R.id.navigation_home,
R.id.navigation_stat,
-> setBotSheetVisible()
-> setBotSheetVisible()


else -> setBotSheetGone()
Expand Down Expand Up @@ -321,7 +332,7 @@ class MainActivity : AppCompatActivity(), BotSheetListener {
lifecycleScope.launch {
uiState.flowWithLifecycle(lifecycle)
.collectLatest { uiState ->
onBind(uiState) // UI 데이터 바인딩
onBind(uiState) // UI 데이터 바인딩
}
}
}
Expand Down Expand Up @@ -350,14 +361,15 @@ class MainActivity : AppCompatActivity(), BotSheetListener {

// iv_hamberger 클릭 리스너 추가
binding.ivHamberger.setOnClickListener {
categoryViewModel.updateCategoryOrderLocally(botSheetViewModel.getCategoryList()) // 현재 카테고리 목록을 ViewModel에 업데이트
navController.navigate(R.id.categoryManageFragment)
val bottomSheetBehavior = BottomSheetBehavior.from(binding.clItemBotSheet)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED // BottomSheet 닫기
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
}
}

private fun onBind(uiState: BotSheetUiState) = with(binding) {

Log.e("histories1", uiState.spendingList.map { it.history }.toString())
botSheetCategoryListAdapter.submitList(uiState.spendingList)

val isEmpty = uiState.spendingList.isEmpty()
Expand Down Expand Up @@ -414,23 +426,31 @@ class MainActivity : AppCompatActivity(), BotSheetListener {
navController.navigate(R.id.expenseEntryFragment, bundle)
}

override fun navigateToExpenseView(expenseName: String, expensePrice: Int, categoryColor: Int) {
Log.d("MainActivity", "📌 navigateToExpenseView() 호출됨")
Log.d("MainActivity", "📌 전달된 데이터 - name: $expenseName, price: $expensePrice, categoryColor: $categoryColor")
override fun navigateToExpenseView(
expenseId: Int,
expenseName: String,
expensePrice: Int,
categoryColor: Int,
categoryName: String
) {
Log.d("MainActivity", "navigateToExpenseView() 호출됨 - id=$expenseId, name=$expenseName, price=$expensePrice, color=$categoryColor")

val navHostFragment =
supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment
val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment
val navController = navHostFragment.navController

// 🔹 번들에 데이터 추가하여 ExpenseViewFragment로 전달
val bundle = Bundle().apply {
putInt("expenseId", expenseId)
putString("expenseName", expenseName)
putInt("expensePrice", expensePrice)
putInt("categoryColor", categoryColor) // ✅ categoryColor를 Int로 전달
putInt("categoryColor", categoryColor)
putString("categoryName", categoryName)
}

navController.navigate(R.id.navigation_expense_view, bundle)
}



override fun onNoExpenseChanged(isNoExpense: Boolean) {
}

Expand Down
Loading

0 comments on commit a9ddaf2

Please sign in to comment.