From 6e5e5a70199f3053915beffb677a0703466289ef Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 00:54:05 +0900 Subject: [PATCH 01/11] =?UTF-8?q?[ADD/#9]=20MpChart=20implementation=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/Dependencies.kt | 34 +++++++++++++++++------- buildSrc/src/main/kotlin/Versions.kt | 2 ++ presentation/build.gradle.kts | 4 +++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 11f1c65..82284de 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,7 +1,9 @@ object KotlinDependencies { const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlinVersion}" - const val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutinesAndroidVersion}" - const val jsonSerialization = "org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.kotlinSerializationJsonVersion}" + const val coroutines = + "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutinesAndroidVersion}" + const val jsonSerialization = + "org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.kotlinSerializationJsonVersion}" const val dateTime = "org.jetbrains.kotlinx:kotlinx-datetime:${Versions.kotlinDateTimeVersion}" } @@ -10,22 +12,26 @@ object AndroidXDependencies { const val splashScreen = "androidx.core:core-splashscreen:${Versions.splashVersion}" const val appCompat = "androidx.appcompat:appcompat:${Versions.appCompatVersion}" - const val constraintLayout = "androidx.constraintlayout:constraintlayout:${Versions.constraintLayoutVersion}" + const val constraintLayout = + "androidx.constraintlayout:constraintlayout:${Versions.constraintLayoutVersion}" const val startup = "androidx.startup:startup-runtime:${Versions.appStartUpVersion}" const val fragment = "androidx.fragment:fragment-ktx:${Versions.fragmentKtxVersion}" const val legacy = "androidx.legacy:legacy-support-v4:${Versions.legacySupportVersion}" const val security = "androidx.security:security-crypto:${Versions.securityVersion}" - const val navigationFragment = "androidx.navigation:navigation-fragment-ktx:${Versions.navigationVersion}" + const val navigationFragment = + "androidx.navigation:navigation-fragment-ktx:${Versions.navigationVersion}" const val navigationUi = "androidx.navigation:navigation-ui-ktx:${Versions.navigationVersion}" const val lifeCycleKtx = "androidx.lifecycle:lifecycle-runtime-ktx:${Versions.lifecycleVersion}" - const val lifecycleJava8 = "androidx.lifecycle:lifecycle-common-java8:${Versions.lifecycleVersion}" + const val lifecycleJava8 = + "androidx.lifecycle:lifecycle-common-java8:${Versions.lifecycleVersion}" const val workManager = "androidx.work:work-runtime-ktx:${Versions.workManagerVersion}" const val hiltWorkManager = "androidx.hilt:hilt-work:1.0.0" const val hilt = "com.google.dagger:hilt-android:${Versions.hiltVersion}" - const val ossLicense = "com.google.android.gms:play-services-oss-licenses:${Versions.ossVersion}" + const val ossLicense = + "com.google.android.gms:play-services-oss-licenses:${Versions.ossVersion}" } object TestDependencies { @@ -35,7 +41,8 @@ object TestDependencies { } object MaterialDesignDependencies { - const val materialDesign = "com.google.android.material:material:${Versions.materialDesignVersion}" + const val materialDesign = + "com.google.android.material:material:${Versions.materialDesignVersion}" } object KaptDependencies { @@ -48,23 +55,30 @@ object ThirdPartyDependencies { const val coil = "io.coil-kt:coil:${Versions.coilVersion}" const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofitVersion}" - const val retrofitJsonConverter = "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:${Versions.kotlinSerializationConverterVersion}" + const val retrofitJsonConverter = + "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:${Versions.kotlinSerializationConverterVersion}" const val okHttpBom = "com.squareup.okhttp3:okhttp-bom:${Versions.okHttpVersion}" const val okHttp = "com.squareup.okhttp3:okhttp" const val okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor" const val timber = "com.jakewharton.timber:timber:${Versions.timberVersion}" - const val ossLicense = "com.google.android.gms:play-services-oss-licenses:${Versions.ossVersion}" + const val ossLicense = + "com.google.android.gms:play-services-oss-licenses:${Versions.ossVersion}" const val progressView = "com.github.skydoves:progressview:${Versions.progressViewVersion}" const val balloon = "com.github.skydoves:balloon:${Versions.balloonVersion}" const val lottie = "com.airbnb.android:lottie:${Versions.lottieVersion}" - const val circularProgressBar = "com.mikhaellopez:circularprogressbar:${Versions.circularProgressBar}" + const val circularProgressBar = + "com.mikhaellopez:circularprogressbar:${Versions.circularProgressBar}" const val circleIndicator = "me.relex:circleindicator:${Versions.circleIndicatorVersion}" const val shimmer = "com.facebook.shimmer:shimmer:${Versions.shimmerVersion}" } +object JitPackDependencies { + const val mpChart = "com.github.PhilJay:MPAndroidChart:${Versions.mpChartVersion}" +} + object ClassPathPlugins { const val gradle = "com.android.tools.build:gradle:${Versions.gradleVersion}" const val kotlinGradle = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlinVersion}" diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index f64faaf..66e803d 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -34,6 +34,8 @@ object Versions { const val circleIndicatorVersion = "2.1.6" const val shimmerVersion = "0.5.0" + const val mpChartVersion = "v3.1.0" + const val junitVersion = "4.13.2" const val espressoVersion = "3.5.1" const val androidTestVersion = "1.1.2" diff --git a/presentation/build.gradle.kts b/presentation/build.gradle.kts index 3698195..4d975c5 100644 --- a/presentation/build.gradle.kts +++ b/presentation/build.gradle.kts @@ -85,4 +85,8 @@ dependencies { implementation(circularProgressBar) implementation(circleIndicator) } + + JitPackDependencies.run { + implementation(mpChart) + } } From f13cfd2bdfb3c84a113387e7c9bc42865d8dfbcb Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 01:28:00 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[UI/#9]=20=EA=B8=B0=EB=A1=9D=EB=B7=B0=20U?= =?UTF-8?q?I=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/drawable/ic_next_purple.xml | 13 +++ .../drawable/shape_gray100_fill_8_rect.xml | 6 ++ .../src/main/res/layout/fragment_report.xml | 85 ++++++++++++++++++- presentation/src/main/res/values/strings.xml | 4 + 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 presentation/src/main/res/drawable/ic_next_purple.xml create mode 100644 presentation/src/main/res/drawable/shape_gray100_fill_8_rect.xml diff --git a/presentation/src/main/res/drawable/ic_next_purple.xml b/presentation/src/main/res/drawable/ic_next_purple.xml new file mode 100644 index 0000000..e7a67b4 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_next_purple.xml @@ -0,0 +1,13 @@ + + + diff --git a/presentation/src/main/res/drawable/shape_gray100_fill_8_rect.xml b/presentation/src/main/res/drawable/shape_gray100_fill_8_rect.xml new file mode 100644 index 0000000..35de093 --- /dev/null +++ b/presentation/src/main/res/drawable/shape_gray100_fill_8_rect.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_report.xml b/presentation/src/main/res/layout/fragment_report.xml index 71cbc96..619729d 100644 --- a/presentation/src/main/res/layout/fragment_report.xml +++ b/presentation/src/main/res/layout/fragment_report.xml @@ -11,14 +11,95 @@ android:layout_height="match_parent"> + + + + + + + app:layout_constraintTop_toBottomOf="@id/chart_report"> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index b8302a1..d89334a 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -20,4 +20,8 @@ 단계 변경하기 완료하기 + 동안의 성과에요! + 달성한 업적 + 전체보기 + \ No newline at end of file From 2b0e31e7d308e354d1cb6e67420e476c9e0f1380 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 02:23:39 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[ADD/#9]=20=EA=B8=B0=EB=A1=9D=EB=B7=B0=20?= =?UTF-8?q?=EA=B7=B8=EB=9E=98=ED=94=84=20=EC=B4=88=EA=B8=B0=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/report/ReportFragment.kt | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index 9fbf9d9..7db3d3d 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -2,7 +2,14 @@ package com.kkkk.presentation.main.report import android.os.Bundle import android.view.View +import com.github.mikephil.charting.components.XAxis +import com.github.mikephil.charting.data.Entry +import com.github.mikephil.charting.data.LineData +import com.github.mikephil.charting.data.LineDataSet +import com.github.mikephil.charting.formatter.IndexAxisValueFormatter import com.kkkk.core.base.BaseFragment +import com.kkkk.core.extension.colorOf +import com.kkkk.core.extension.dpToPx import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentReportBinding @@ -15,5 +22,47 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep ) { super.onViewCreated(view, savedInstanceState) + setGraphData() + setGraphSettings() + } + + private fun setGraphData() { + val chartEntry = arrayListOf() + val mockList = listOf(20, 30, 50, 90) + mockList.forEachIndexed { index, listItem -> + chartEntry.add(Entry(index.toFloat(), listItem.toFloat())) + } + + binding.chartReport.apply { + xAxis.valueFormatter = IndexAxisValueFormatter(listOf("1월", "2월", "3월", "4월")) + data = LineData(LineDataSet(chartEntry, "").apply { + color = colorOf(R.color.purple_50) + circleRadius = 8f + setCircleColor(colorOf(R.color.purple_50)) + setDrawFilled(true) + setDrawValues(false) + lineWidth = 3F + setDrawCircleHole(false) + fillColor = colorOf(R.color.purple_10) + mode = LineDataSet.Mode.LINEAR + }) + invalidate() + } + } + + private fun setGraphSettings() { + binding.chartReport.apply { + xAxis.apply { + position = XAxis.XAxisPosition.BOTTOM + setDrawGridLines(false) + setDrawAxisLine(false) + textColor = colorOf(R.color.dark) + setAvoidFirstLastClipping(true) + } + axisLeft.isEnabled = false + axisRight.isEnabled = false + legend.isEnabled = false + description.isEnabled = false + } } } \ No newline at end of file From 62f5605d6267ba1959f15c9e91cdb29a13cdc278 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 17:13:04 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[FIX/#9]=20=EA=B7=B8=EB=9E=98=ED=94=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=ED=84=B0=EC=B9=98=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=EB=84=88=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/report/ReportFragment.kt | 29 ++++++++++--------- .../src/main/res/layout/fragment_report.xml | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index 7db3d3d..80fcc41 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -2,20 +2,21 @@ package com.kkkk.presentation.main.report import android.os.Bundle import android.view.View -import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.data.Entry import com.github.mikephil.charting.data.LineData import com.github.mikephil.charting.data.LineDataSet -import com.github.mikephil.charting.formatter.IndexAxisValueFormatter import com.kkkk.core.base.BaseFragment import com.kkkk.core.extension.colorOf -import com.kkkk.core.extension.dpToPx import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentReportBinding @AndroidEntryPoint class ReportFragment : BaseFragment(R.layout.fragment_report) { + + val chartEntry = arrayListOf() + val mockList = listOf(10, 30, 50, 60, 90) + override fun onViewCreated( view: View, savedInstanceState: Bundle?, @@ -27,15 +28,12 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep } private fun setGraphData() { - val chartEntry = arrayListOf() - val mockList = listOf(20, 30, 50, 90) + chartEntry.add(Entry(-1f, mockList[0].toFloat())) mockList.forEachIndexed { index, listItem -> chartEntry.add(Entry(index.toFloat(), listItem.toFloat())) } - binding.chartReport.apply { - xAxis.valueFormatter = IndexAxisValueFormatter(listOf("1월", "2월", "3월", "4월")) - data = LineData(LineDataSet(chartEntry, "").apply { + data = LineData(LineDataSet(chartEntry, CHART_REPORT).apply { color = colorOf(R.color.purple_50) circleRadius = 8f setCircleColor(colorOf(R.color.purple_50)) @@ -44,6 +42,7 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep lineWidth = 3F setDrawCircleHole(false) fillColor = colorOf(R.color.purple_10) + isHighlightEnabled = false mode = LineDataSet.Mode.LINEAR }) invalidate() @@ -53,16 +52,20 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep private fun setGraphSettings() { binding.chartReport.apply { xAxis.apply { - position = XAxis.XAxisPosition.BOTTOM - setDrawGridLines(false) - setDrawAxisLine(false) - textColor = colorOf(R.color.dark) - setAvoidFirstLastClipping(true) + isEnabled = false + axisMinimum = 0.7f + axisMaximum = mockList.size - 0.8f } axisLeft.isEnabled = false axisRight.isEnabled = false legend.isEnabled = false description.isEnabled = false + setScaleEnabled(false) + setDragEnabled(false) } } + + companion object { + private const val CHART_REPORT = "CHART_REPORT" + } } \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_report.xml b/presentation/src/main/res/layout/fragment_report.xml index 619729d..5daa684 100644 --- a/presentation/src/main/res/layout/fragment_report.xml +++ b/presentation/src/main/res/layout/fragment_report.xml @@ -25,6 +25,7 @@ android:id="@+id/tv_report_title" style="@style/TextAppearance.Stempo.Head1" android:layout_width="wrap_content" + android:layout_marginTop="-5dp" android:layout_height="wrap_content" android:layout_marginStart="18dp" android:text="@string/report_tv_title" @@ -35,7 +36,6 @@ android:id="@+id/chart_report" android:layout_width="0dp" android:layout_height="300dp" - android:layout_marginHorizontal="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_report_title" /> From bf7fc408fd8b228179d9e235dcd3e9d716b0d0ac Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 18:45:52 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[FIX/#9]=20=EC=9D=B8=EB=8D=B1=EC=8A=A4=20?= =?UTF-8?q?=EB=B3=84=20=EB=82=A0=EC=A7=9C=20=ED=91=9C=EC=8B=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/report/ReportFragment.kt | 63 ++++++++++++++----- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index 80fcc41..f151022 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -2,20 +2,32 @@ package com.kkkk.presentation.main.report import android.os.Bundle import android.view.View +import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.data.Entry import com.github.mikephil.charting.data.LineData import com.github.mikephil.charting.data.LineDataSet +import com.github.mikephil.charting.formatter.ValueFormatter import com.kkkk.core.base.BaseFragment import com.kkkk.core.extension.colorOf import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentReportBinding +import java.text.SimpleDateFormat +import java.util.Locale @AndroidEntryPoint class ReportFragment : BaseFragment(R.layout.fragment_report) { val chartEntry = arrayListOf() - val mockList = listOf(10, 30, 50, 60, 90) + private val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) + private val displayDateFormat = SimpleDateFormat("MMdd", Locale.getDefault()) + private val mockList = listOf( + Pair(10f, "2024-02-28"), + Pair(20f, "2024-03-28"), + Pair(30f, "2024-04-29"), + Pair(50f, "2024-05-23"), + Pair(90f, "2024-06-13") + ) override fun onViewCreated( view: View, @@ -28,33 +40,50 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep } private fun setGraphData() { - chartEntry.add(Entry(-1f, mockList[0].toFloat())) - mockList.forEachIndexed { index, listItem -> - chartEntry.add(Entry(index.toFloat(), listItem.toFloat())) + mockList.forEachIndexed { index, (value, _) -> + chartEntry.add(Entry(index.toFloat(), value)) } binding.chartReport.apply { - data = LineData(LineDataSet(chartEntry, CHART_REPORT).apply { - color = colorOf(R.color.purple_50) - circleRadius = 8f - setCircleColor(colorOf(R.color.purple_50)) - setDrawFilled(true) - setDrawValues(false) - lineWidth = 3F - setDrawCircleHole(false) - fillColor = colorOf(R.color.purple_10) - isHighlightEnabled = false - mode = LineDataSet.Mode.LINEAR - }) + data = LineData(LineDataSet(chartEntry, CHART_REPORT).setDataSettings()) invalidate() } } + private fun LineDataSet.setDataSettings(): LineDataSet { + this.apply { + color = colorOf(R.color.purple_50) + circleRadius = 8f + setCircleColor(colorOf(R.color.purple_50)) + setDrawFilled(true) + setDrawValues(false) + lineWidth = 3F + setDrawCircleHole(false) + fillColor = colorOf(R.color.purple_10) + isHighlightEnabled = false + mode = LineDataSet.Mode.LINEAR + } + return this + } + private fun setGraphSettings() { binding.chartReport.apply { xAxis.apply { - isEnabled = false + valueFormatter = object : ValueFormatter() { + override fun getFormattedValue(value: Float): String { + val index = value.toInt() + return if (index in mockList.indices) { + displayDateFormat.format(dateFormat.parse(mockList[index].second)) + } else { + "" + } + } + } + position = XAxis.XAxisPosition.BOTTOM + granularity = 1f axisMinimum = 0.7f axisMaximum = mockList.size - 0.8f + setDrawGridLines(false) + setDrawAxisLine(false) } axisLeft.isEnabled = false axisRight.isEnabled = false From 61a31a887eace4dbdbef4629ec087e2360af1c40 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 18:55:52 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[FIX/#9]=20=EB=92=A4=20=EB=B0=B0=EA=B2=BD?= =?UTF-8?q?=20=EC=84=B8=EB=A1=9C=20=EC=A0=90=EC=84=A0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/report/ReportFragment.kt | 3 +- .../res/drawable/shape_gray300_dash_line.xml | 9 +++++ .../src/main/res/layout/fragment_report.xml | 33 ++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 presentation/src/main/res/drawable/shape_gray300_dash_line.xml diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index f151022..c87caba 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -56,9 +56,10 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep setCircleColor(colorOf(R.color.purple_50)) setDrawFilled(true) setDrawValues(false) - lineWidth = 3F + lineWidth = 4F setDrawCircleHole(false) fillColor = colorOf(R.color.purple_10) + fillAlpha = 255 isHighlightEnabled = false mode = LineDataSet.Mode.LINEAR } diff --git a/presentation/src/main/res/drawable/shape_gray300_dash_line.xml b/presentation/src/main/res/drawable/shape_gray300_dash_line.xml new file mode 100644 index 0000000..83fa19f --- /dev/null +++ b/presentation/src/main/res/drawable/shape_gray300_dash_line.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_report.xml b/presentation/src/main/res/layout/fragment_report.xml index 5daa684..e4d2791 100644 --- a/presentation/src/main/res/layout/fragment_report.xml +++ b/presentation/src/main/res/layout/fragment_report.xml @@ -25,17 +25,48 @@ android:id="@+id/tv_report_title" style="@style/TextAppearance.Stempo.Head1" android:layout_width="wrap_content" - android:layout_marginTop="-5dp" android:layout_height="wrap_content" android:layout_marginStart="18dp" + android:layout_marginTop="-5dp" android:text="@string/report_tv_title" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_report_month" /> + + + + + + From 643b9a56a38277330244aae498c5eacf9d7ae677 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 19:10:31 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[FIX/#9]=20x=EC=B6=95=20=ED=85=8D?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/kkkk/presentation/main/report/ReportFragment.kt | 6 +++++- presentation/src/main/res/layout/fragment_report.xml | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index c87caba..13bbb9d 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -9,6 +9,7 @@ import com.github.mikephil.charting.data.LineDataSet import com.github.mikephil.charting.formatter.ValueFormatter import com.kkkk.core.base.BaseFragment import com.kkkk.core.extension.colorOf +import com.kkkk.core.extension.dpToPx import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentReportBinding @@ -20,7 +21,7 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep val chartEntry = arrayListOf() private val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) - private val displayDateFormat = SimpleDateFormat("MMdd", Locale.getDefault()) + private val displayDateFormat = SimpleDateFormat("MM/dd", Locale.getDefault()) private val mockList = listOf( Pair(10f, "2024-02-28"), Pair(20f, "2024-03-28"), @@ -85,6 +86,8 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep axisMaximum = mockList.size - 0.8f setDrawGridLines(false) setDrawAxisLine(false) + textSize = 15f + textColor = colorOf(R.color.gray_600) } axisLeft.isEnabled = false axisRight.isEnabled = false @@ -92,6 +95,7 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep description.isEnabled = false setScaleEnabled(false) setDragEnabled(false) + setExtraOffsets(0f, 0f, 0f, 20f) } } diff --git a/presentation/src/main/res/layout/fragment_report.xml b/presentation/src/main/res/layout/fragment_report.xml index e4d2791..39fd759 100644 --- a/presentation/src/main/res/layout/fragment_report.xml +++ b/presentation/src/main/res/layout/fragment_report.xml @@ -45,7 +45,7 @@ android:layout_width="0dp" android:layout_height="2dp" android:layout_marginHorizontal="16dp" - android:layout_marginBottom="15dp" + android:layout_marginBottom="37dp" android:background="@drawable/shape_gray300_dash_line" app:layout_constraintBottom_toBottomOf="@id/chart_report" app:layout_constraintEnd_toEndOf="parent" @@ -56,11 +56,11 @@ android:layout_width="0dp" android:layout_height="2dp" android:layout_marginHorizontal="16dp" - android:layout_marginBottom="15dp" + android:layout_marginBottom="37dp" android:background="@drawable/shape_gray300_dash_line" app:layout_constraintBottom_toBottomOf="@id/chart_report" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent"/> + app:layout_constraintStart_toStartOf="parent" /> Date: Wed, 24 Jul 2024 20:57:38 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[FIX/#9]=20=EA=B7=B8=EB=9E=98=ED=94=84=20?= =?UTF-8?q?=EC=B5=9C=EB=8C=93=EA=B0=92=20=EB=B0=8F=20=EC=A0=90=EC=84=A0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/kkkk/presentation/main/report/ReportFragment.kt | 7 +++++-- presentation/src/main/res/layout/fragment_report.xml | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index 13bbb9d..886f13e 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -26,7 +26,7 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep Pair(10f, "2024-02-28"), Pair(20f, "2024-03-28"), Pair(30f, "2024-04-29"), - Pair(50f, "2024-05-23"), + Pair(100f, "2024-05-23"), Pair(90f, "2024-06-13") ) @@ -89,7 +89,10 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep textSize = 15f textColor = colorOf(R.color.gray_600) } - axisLeft.isEnabled = false + axisLeft.apply { + isEnabled = false + axisMaximum = 100f + } axisRight.isEnabled = false legend.isEnabled = false description.isEnabled = false diff --git a/presentation/src/main/res/layout/fragment_report.xml b/presentation/src/main/res/layout/fragment_report.xml index 39fd759..287a45e 100644 --- a/presentation/src/main/res/layout/fragment_report.xml +++ b/presentation/src/main/res/layout/fragment_report.xml @@ -33,26 +33,29 @@ app:layout_constraintTop_toBottomOf="@id/tv_report_month" /> + app:layout_constraintTop_toTopOf="@id/border_chart_top" /> Date: Wed, 24 Jul 2024 21:29:16 +0900 Subject: [PATCH 09/11] =?UTF-8?q?[ADD/#9]=20ReportViewModel=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/report/ReportFragment.kt | 81 ++++++++++--------- .../main/report/ReportViewModel.kt | 31 +++++++ 2 files changed, 74 insertions(+), 38 deletions(-) create mode 100644 presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index 886f13e..c7d8d51 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -2,14 +2,14 @@ package com.kkkk.presentation.main.report import android.os.Bundle import android.view.View +import androidx.fragment.app.activityViewModels +import com.github.mikephil.charting.charts.LineChart import com.github.mikephil.charting.components.XAxis -import com.github.mikephil.charting.data.Entry import com.github.mikephil.charting.data.LineData import com.github.mikephil.charting.data.LineDataSet import com.github.mikephil.charting.formatter.ValueFormatter import com.kkkk.core.base.BaseFragment import com.kkkk.core.extension.colorOf -import com.kkkk.core.extension.dpToPx import dagger.hilt.android.AndroidEntryPoint import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentReportBinding @@ -19,16 +19,7 @@ import java.util.Locale @AndroidEntryPoint class ReportFragment : BaseFragment(R.layout.fragment_report) { - val chartEntry = arrayListOf() - private val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) - private val displayDateFormat = SimpleDateFormat("MM/dd", Locale.getDefault()) - private val mockList = listOf( - Pair(10f, "2024-02-28"), - Pair(20f, "2024-03-28"), - Pair(30f, "2024-04-29"), - Pair(100f, "2024-05-23"), - Pair(90f, "2024-06-13") - ) + private val viewModel by activityViewModels() override fun onViewCreated( view: View, @@ -41,11 +32,9 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep } private fun setGraphData() { - mockList.forEachIndexed { index, (value, _) -> - chartEntry.add(Entry(index.toFloat(), value)) - } + viewModel.setGraphValue() binding.chartReport.apply { - data = LineData(LineDataSet(chartEntry, CHART_REPORT).setDataSettings()) + data = LineData(LineDataSet(viewModel.chartEntry, CHART_REPORT).setDataSettings()) invalidate() } } @@ -69,31 +58,45 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep private fun setGraphSettings() { binding.chartReport.apply { - xAxis.apply { - valueFormatter = object : ValueFormatter() { - override fun getFormattedValue(value: Float): String { - val index = value.toInt() - return if (index in mockList.indices) { - displayDateFormat.format(dateFormat.parse(mockList[index].second)) - } else { - "" - } + setXAxisSettings(this) + setYAxisSettings(this) + setCommonSettings(this) + } + } + + private fun setXAxisSettings(chart: LineChart) { + chart.xAxis.apply { + valueFormatter = object : ValueFormatter() { + override fun getFormattedValue(value: Float): String? { + return if (value.toInt() in viewModel.mockList.indices) { + DATE_FORMAT.parse(viewModel.mockList[value.toInt()].second) + ?.let { DISPLAY_DATE_FORMAT.format(it) } + } else { + "" } } - position = XAxis.XAxisPosition.BOTTOM - granularity = 1f - axisMinimum = 0.7f - axisMaximum = mockList.size - 0.8f - setDrawGridLines(false) - setDrawAxisLine(false) - textSize = 15f - textColor = colorOf(R.color.gray_600) - } - axisLeft.apply { - isEnabled = false - axisMaximum = 100f } - axisRight.isEnabled = false + position = XAxis.XAxisPosition.BOTTOM + granularity = 1f + axisMinimum = 0.7f + axisMaximum = viewModel.chartEntry.size - 0.8f + setDrawGridLines(false) + setDrawAxisLine(false) + textSize = 15f + textColor = colorOf(R.color.gray_600) + } + } + + private fun setYAxisSettings(chart: LineChart) { + chart.axisLeft.apply { + isEnabled = false + axisMaximum = 100f + } + chart.axisRight.isEnabled = false + } + + private fun setCommonSettings(chart: LineChart) { + chart.apply { legend.isEnabled = false description.isEnabled = false setScaleEnabled(false) @@ -104,5 +107,7 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep companion object { private const val CHART_REPORT = "CHART_REPORT" + val DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) + val DISPLAY_DATE_FORMAT = SimpleDateFormat("MM/dd", Locale.getDefault()) } } \ No newline at end of file diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt new file mode 100644 index 0000000..6ab28db --- /dev/null +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt @@ -0,0 +1,31 @@ +package com.kkkk.presentation.main.report + +import androidx.lifecycle.ViewModel +import com.github.mikephil.charting.data.Entry +import dagger.hilt.android.lifecycle.HiltViewModel +import timber.log.Timber +import javax.inject.Inject + +@HiltViewModel +class ReportViewModel +@Inject +constructor( + // private val authRepository: AuthRepository, +) : ViewModel() { + var chartEntry = arrayListOf() + val mockList = listOf( + Pair(10f, "2024-02-28"), + Pair(20f, "2024-03-28"), + Pair(20f, "2024-04-02"), + Pair(30f, "2024-04-29"), + Pair(100f, "2024-05-23"), + Pair(90f, "2024-06-13") + ) + + fun setGraphValue() { + chartEntry = arrayListOf() + mockList.forEachIndexed { index, (value, _) -> + chartEntry.add(Entry(index.toFloat(), value)) + } + } +} \ No newline at end of file From 82d1144e934f9bf97cb49316b8eac659c6104c3c Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 22:13:33 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[ADD/#9]=20=EA=B0=9C=EC=9B=94=20=ED=86=A0?= =?UTF-8?q?=EA=B8=80=20UI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/report/ReportFragment.kt | 1 + .../main/report/ReportViewModel.kt | 15 +++- .../src/main/res/drawable/ic_drop_down.xml | 16 ++++ .../src/main/res/drawable/ic_drop_up.xml | 16 ++++ .../src/main/res/layout/fragment_report.xml | 80 +++++++++++++++++-- 5 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 presentation/src/main/res/drawable/ic_drop_down.xml create mode 100644 presentation/src/main/res/drawable/ic_drop_up.xml diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index c7d8d51..955bf1c 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -27,6 +27,7 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep ) { super.onViewCreated(view, savedInstanceState) + binding.vm = viewModel setGraphData() setGraphSettings() } diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt index 6ab28db..bd4ba02 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt @@ -1,9 +1,9 @@ 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 timber.log.Timber import javax.inject.Inject @HiltViewModel @@ -12,6 +12,10 @@ class ReportViewModel constructor( // private val authRepository: AuthRepository, ) : ViewModel() { + + val isChangingMonth = MutableLiveData(false) + val reportMonth = MutableLiveData(1) + var chartEntry = arrayListOf() val mockList = listOf( Pair(10f, "2024-02-28"), @@ -22,6 +26,15 @@ constructor( Pair(90f, "2024-06-13") ) + fun setIsChangingMonth() { + isChangingMonth.value = isChangingMonth.value?.not() ?: false + } + + fun setReportMonth(month: Int) { + reportMonth.value = month + isChangingMonth.value = false + } + fun setGraphValue() { chartEntry = arrayListOf() mockList.forEachIndexed { index, (value, _) -> diff --git a/presentation/src/main/res/drawable/ic_drop_down.xml b/presentation/src/main/res/drawable/ic_drop_down.xml new file mode 100644 index 0000000..0703360 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_drop_down.xml @@ -0,0 +1,16 @@ + + + + diff --git a/presentation/src/main/res/drawable/ic_drop_up.xml b/presentation/src/main/res/drawable/ic_drop_up.xml new file mode 100644 index 0000000..949cb69 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_drop_up.xml @@ -0,0 +1,16 @@ + + + + diff --git a/presentation/src/main/res/layout/fragment_report.xml b/presentation/src/main/res/layout/fragment_report.xml index 287a45e..c88c53c 100644 --- a/presentation/src/main/res/layout/fragment_report.xml +++ b/presentation/src/main/res/layout/fragment_report.xml @@ -4,6 +4,12 @@ + + + + + + + + + + + + + + + + + app:layout_constraintEnd_toEndOf="@id/border_chart_top" + app:layout_constraintStart_toStartOf="@id/border_chart_top" /> From 31bc0ceb7483b5aa1b0fec9ba80722ea6b0fe8ad Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Wed, 24 Jul 2024 22:36:05 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[FEAT/#9]=20=EA=B0=9C=EC=9B=94=20?= =?UTF-8?q?=EB=B3=84=20=EA=B7=B8=EB=9E=98=ED=94=84=20=EB=B3=80=ED=99=98=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/report/ReportFragment.kt | 47 +++++++++++++++---- .../main/report/ReportViewModel.kt | 35 +++++++++++--- .../src/main/res/layout/fragment_report.xml | 13 ++--- presentation/src/main/res/values/strings.xml | 4 ++ 4 files changed, 76 insertions(+), 23 deletions(-) diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt index 955bf1c..ec06a87 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportFragment.kt @@ -3,6 +3,8 @@ package com.kkkk.presentation.main.report import android.os.Bundle import android.view.View import androidx.fragment.app.activityViewModels +import androidx.lifecycle.flowWithLifecycle +import androidx.lifecycle.lifecycleScope import com.github.mikephil.charting.charts.LineChart import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.data.LineData @@ -10,7 +12,11 @@ import com.github.mikephil.charting.data.LineDataSet import com.github.mikephil.charting.formatter.ValueFormatter import com.kkkk.core.base.BaseFragment import com.kkkk.core.extension.colorOf +import com.kkkk.core.extension.stringOf import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import kr.genti.presentation.R import kr.genti.presentation.databinding.FragmentReportBinding import java.text.SimpleDateFormat @@ -28,18 +34,39 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep super.onViewCreated(view, savedInstanceState) binding.vm = viewModel - setGraphData() - setGraphSettings() + observeReportMonth() + observeChartEntry() } - private fun setGraphData() { - viewModel.setGraphValue() - binding.chartReport.apply { - data = LineData(LineDataSet(viewModel.chartEntry, CHART_REPORT).setDataSettings()) - invalidate() + private fun observeReportMonth() { + viewModel.reportMonth.observe(viewLifecycleOwner) { month -> + binding.tvReportMonth.text = when (month) { + 1 -> stringOf(R.string.report_tv_month_1) + 3 -> stringOf(R.string.report_tv_month_3) + 6 -> stringOf(R.string.report_tv_month_6) + else -> return@observe + } + viewModel.setGraphValue() } } + private fun observeChartEntry() { + viewModel.chartEntry.flowWithLifecycle(lifecycle).distinctUntilChanged().onEach { + if (it.isNotEmpty()) { + binding.chartReport.apply { + data = LineData( + LineDataSet( + viewModel.chartEntry.value, + CHART_REPORT + ).setDataSettings() + ) + invalidate() + } + setGraphSettings() + } + }.launchIn(lifecycleScope) + } + private fun LineDataSet.setDataSettings(): LineDataSet { this.apply { color = colorOf(R.color.purple_50) @@ -69,8 +96,8 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep chart.xAxis.apply { valueFormatter = object : ValueFormatter() { override fun getFormattedValue(value: Float): String? { - return if (value.toInt() in viewModel.mockList.indices) { - DATE_FORMAT.parse(viewModel.mockList[value.toInt()].second) + return if (value.toInt() in viewModel.nowList.indices) { + DATE_FORMAT.parse(viewModel.nowList[value.toInt()].second) ?.let { DISPLAY_DATE_FORMAT.format(it) } } else { "" @@ -80,7 +107,7 @@ class ReportFragment : BaseFragment(R.layout.fragment_rep position = XAxis.XAxisPosition.BOTTOM granularity = 1f axisMinimum = 0.7f - axisMaximum = viewModel.chartEntry.size - 0.8f + axisMaximum = viewModel.chartEntry.value.size - 0.8f setDrawGridLines(false) setDrawAxisLine(false) textSize = 15f diff --git a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt index bd4ba02..b2491d1 100644 --- a/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt +++ b/presentation/src/main/java/com/kkkk/presentation/main/report/ReportViewModel.kt @@ -4,6 +4,8 @@ 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 @@ -14,17 +16,28 @@ constructor( ) : ViewModel() { val isChangingMonth = MutableLiveData(false) - val reportMonth = MutableLiveData(1) + val reportMonth = MutableLiveData(3) - var chartEntry = arrayListOf() val mockList = listOf( Pair(10f, "2024-02-28"), Pair(20f, "2024-03-28"), Pair(20f, "2024-04-02"), Pair(30f, "2024-04-29"), - Pair(100f, "2024-05-23"), - Pair(90f, "2024-06-13") + 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>() + + private val _chartEntry = MutableStateFlow>(mutableListOf()) + val chartEntry: StateFlow> = _chartEntry + + init { + setGraphValue() + } fun setIsChangingMonth() { isChangingMonth.value = isChangingMonth.value?.not() ?: false @@ -36,9 +49,17 @@ constructor( } fun setGraphValue() { - chartEntry = arrayListOf() - mockList.forEachIndexed { index, (value, _) -> - chartEntry.add(Entry(index.toFloat(), value)) + // 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() + nowList.forEachIndexed { index, (value, _) -> + tempList.add(Entry(index.toFloat(), value)) } + _chartEntry.value = tempList } } \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_report.xml b/presentation/src/main/res/layout/fragment_report.xml index c88c53c..2669a5e 100644 --- a/presentation/src/main/res/layout/fragment_report.xml +++ b/presentation/src/main/res/layout/fragment_report.xml @@ -1,6 +1,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> @@ -24,9 +25,9 @@ android:layout_marginStart="18dp" android:layout_marginTop="32dp" android:onClick="@{() -> vm.setIsChangingMonth()}" - android:text="3개월" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:text="3개월" /> diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index d89334a..3808361 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -24,4 +24,8 @@ 달성한 업적 전체보기 + 1개월 + 3개월 + 6개월 + \ No newline at end of file