-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
469 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.kkkk.presentation.main.report | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.github.mikephil.charting.data.Entry | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class ReportViewModel | ||
@Inject | ||
constructor( | ||
// private val authRepository: AuthRepository, | ||
) : ViewModel() { | ||
|
||
val isChangingMonth = MutableLiveData<Boolean>(false) | ||
val reportMonth = MutableLiveData<Int>(3) | ||
|
||
val mockList = listOf( | ||
Pair(10f, "2024-02-28"), | ||
Pair(20f, "2024-03-28"), | ||
Pair(20f, "2024-04-02"), | ||
Pair(30f, "2024-04-29"), | ||
Pair(10f, "2024-05-08"), | ||
Pair(20f, "2024-05-18"), | ||
Pair(20f, "2024-05-22"), | ||
Pair(30f, "2024-06-09"), | ||
Pair(100f, "2024-06-13"), | ||
Pair(90f, "2024-06-23") | ||
) | ||
var nowList = listOf<Pair<Float, String>>() | ||
|
||
private val _chartEntry = MutableStateFlow<MutableList<Entry>>(mutableListOf()) | ||
val chartEntry: StateFlow<MutableList<Entry>> = _chartEntry | ||
|
||
init { | ||
setGraphValue() | ||
} | ||
|
||
fun setIsChangingMonth() { | ||
isChangingMonth.value = isChangingMonth.value?.not() ?: false | ||
} | ||
|
||
fun setReportMonth(month: Int) { | ||
reportMonth.value = month | ||
isChangingMonth.value = false | ||
} | ||
|
||
fun setGraphValue() { | ||
// TODO 서버 붙이고 수정 | ||
nowList = when (reportMonth.value) { | ||
1 -> mockList.subList(5, 10) | ||
3 -> mockList.subList(2, 10) | ||
6 -> mockList.subList(0, 10) | ||
else -> return | ||
} | ||
val tempList = arrayListOf<Entry>() | ||
nowList.forEachIndexed { index, (value, _) -> | ||
tempList.add(Entry(index.toFloat(), value)) | ||
} | ||
_chartEntry.value = tempList | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="44dp" | ||
android:height="44dp" | ||
android:viewportWidth="44" | ||
android:viewportHeight="44"> | ||
<path | ||
android:pathData="M22,22m-13,0a13,13 0,1 1,26 0a13,13 0,1 1,-26 0" | ||
android:fillColor="#784DF0"/> | ||
<path | ||
android:pathData="M17,20L22,25L27,20" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="2" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#FDFDFD" | ||
android:strokeLineCap="round"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="44dp" | ||
android:height="44dp" | ||
android:viewportWidth="44" | ||
android:viewportHeight="44"> | ||
<path | ||
android:pathData="M22,22m-13,0a13,13 0,1 1,26 0a13,13 0,1 1,-26 0" | ||
android:fillColor="#784DF0"/> | ||
<path | ||
android:pathData="M27,24L22,19L17,24" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="2" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#FDFDFD" | ||
android:strokeLineCap="round"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="10dp" | ||
android:height="16dp" | ||
android:viewportWidth="10" | ||
android:viewportHeight="16"> | ||
<path | ||
android:pathData="M3,13L8,8L3,3" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="1.5" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#784DF0" | ||
android:strokeLineCap="round"/> | ||
</vector> |
6 changes: 6 additions & 0 deletions
6
presentation/src/main/res/drawable/shape_gray100_fill_8_rect.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/gray_100" /> | ||
<corners | ||
android:radius="8dp" /> | ||
</shape> |
9 changes: 9 additions & 0 deletions
9
presentation/src/main/res/drawable/shape_gray300_dash_line.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="line"> | ||
<stroke | ||
android:width="1dp" | ||
android:color="@color/gray_300" | ||
android:dashWidth="6dp" | ||
android:dashGap="6dp"/> | ||
</shape> |
Oops, something went wrong.