Skip to content

Commit

Permalink
DEP-198 마이페이지 ui 적용 (#73)
Browse files Browse the repository at this point in the history
* feat: nickname 수정 dialog 추가

* refactor

* ui: 습관 보관함 레이아웃 추가

* refactor: 사용하지 않는 파일 제외

* ui: 버전 정보 추가

* refactor: strings 로 상수 이동

* refactor: layout_hegiht wrap_content 사용하도록 개선

* refactor: string 변수로 추출

* refactor: 접근제어자 추가

* refactor: layoutParams lint error 해결

* docs: semantic versioning 방식으로 변경

* refactor: 안전한 방식으로 랜던값 생성 (kotlin:S2245)
  • Loading branch information
junhaesung authored Dec 15, 2022
1 parent b40555e commit 5ef34e4
Show file tree
Hide file tree
Showing 51 changed files with 1,184 additions and 53 deletions.
9 changes: 0 additions & 9 deletions .idea/compiler.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .idea/misc.xml

This file was deleted.

7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ android {
compileSdk 33

defaultConfig {
applicationId "com.depromeet.threedays"
applicationId rootProject.ext.threeDaysApplicationId
minSdk 26
targetSdk 33
versionCode 2
versionName "1.0"
versionCode rootProject.ext.threeDaysAppVersionCode
versionName rootProject.ext.threeDaysAppVersionName

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -49,6 +49,7 @@ dependencies {
implementation(project(":presentation:notification"))
implementation(project(":presentation:mate"))
implementation(project(":presentation:onboarding"))
implementation(project(":presentation:mypage"))

implementation(jetpackDeps)
implementation(coroutines)
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<activity
android:name="com.depromeet.threedays.onboarding.OnboardingActivity"
android:exported="false"/>

<activity
android:name="com.depromeet.threedays.mypage.archived_habit.ArchivedHabitActivity"
android:exported="false"/>

</application>

</manifest>
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ buildscript {
//classpath 'com.google.gms:google-services:4.3.13'
//classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1'
}

ext {
threeDaysApplicationId = "com.depromeet.threedays"
threeDaysAppVersionCode = 2
threeDaysAppVersionName = "0.0.1"
}
}

plugins {
Expand Down
1 change: 1 addition & 0 deletions core-design-system/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

android {
namespace 'com.depromeet.threedays.core_design_system'
compileSdk 33

defaultConfig {
Expand Down
5 changes: 5 additions & 0 deletions core-design-system/src/main/res/drawable/bg_oval_gray200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/gray_200" />
</shape>
8 changes: 8 additions & 0 deletions core-design-system/src/main/res/drawable/bg_rect_main_r10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/main" />
<corners android:radius="10dp" />

</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/white" />
<corners android:radius="10dp" />
<stroke
android:width="1dp"
android:color="@color/gray_450" />

</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/white" />
<corners android:radius="20dp" />

</shape>
13 changes: 13 additions & 0 deletions core-design-system/src/main/res/drawable/ic_close_white.xml
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="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M18,6L6,18M6,6L18,18"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#FFFFFF"
android:strokeLineCap="round"/>
</vector>
9 changes: 9 additions & 0 deletions core-design-system/src/main/res/drawable/ic_edit_gray450.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M19.063,19.195H5.941C5.693,19.195 5.454,19.29 5.278,19.459C5.103,19.628 5.004,19.858 5.004,20.097C5.004,20.337 5.103,20.566 5.278,20.736C5.454,20.905 5.693,21 5.941,21H19.063C19.311,21 19.55,20.905 19.726,20.736C19.901,20.566 20,20.337 20,20.097C20,19.858 19.901,19.628 19.726,19.459C19.55,19.29 19.311,19.195 19.063,19.195ZM5.941,17.39H6.026L9.934,17.047C10.362,17.006 10.762,16.824 11.068,16.532L19.503,8.409C19.831,8.076 20.008,7.631 19.995,7.173C19.983,6.714 19.782,6.279 19.438,5.963L16.87,3.489C16.534,3.186 16.095,3.012 15.635,3.001C15.176,2.989 14.728,3.14 14.377,3.426L5.941,11.55C5.638,11.844 5.45,12.23 5.407,12.642L5.004,16.406C4.991,16.538 5.009,16.671 5.056,16.796C5.103,16.921 5.178,17.034 5.276,17.128C5.363,17.212 5.467,17.278 5.581,17.323C5.696,17.368 5.818,17.39 5.941,17.39ZM15.567,4.753L18.125,7.217L16.251,8.977L13.739,6.558L15.567,4.753Z"
android:fillColor="#A5ADBD"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_switch_track_off" android:state_checked="false" />
<item android:drawable="@drawable/shape_switch_track_on" android:state_checked="true" />
</selector>
15 changes: 15 additions & 0 deletions core-design-system/src/main/res/drawable/shape_switch_thumb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp">
<shape android:shape="oval">
<size
android:width="24dp"
android:height="24dp" />
<solid android:color="@color/white" />
</shape>
</item>
</layer-list>
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="rectangle">
<size
android:height="28dp"
android:width="46dp" />
<solid android:color="@color/gray_500" />
<corners android:radius="20dp" />
</shape>
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="rectangle">
<size
android:height="28dp"
android:width="46dp"/>
<solid android:color="#33C95A" />
<corners android:radius="30dp" />
</shape>
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
}

android {
namespace 'com.depromeet.threedays.core'
compileSdk 33

defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ interface HabitService {

): List<HabitEntity>

@GET("/api/v1/habits?status=ARCHIVED")
suspend fun getArchivedHabits(): List<HabitEntity>

// @GET("/api/v1/habits/{habitId}")
// suspend fun getHabit(
// @Body request: PostProductsRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.depromeet.threedays.data.entity.HabitEntity
interface HabitRemoteDataSource {
suspend fun postHabit(habitEntity: HabitEntity)
suspend fun getHabits(): List<HabitEntity>
suspend fun getArchivedHabits(): List<HabitEntity>
//fun getHabit(habitId: Long): HabitEntity
suspend fun updateHabit(habitId: Long)
suspend fun deleteHabit(habitId: Long)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package com.depromeet.threedays.data.datasource.habit

import com.depromeet.threedays.data.api.HabitService
import com.depromeet.threedays.data.entity.HabitEntity
import java.security.SecureRandom
import java.time.DayOfWeek
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import javax.inject.Inject

class HabitRemoteDataSourceImpl @Inject constructor(
Expand All @@ -15,6 +19,40 @@ class HabitRemoteDataSourceImpl @Inject constructor(
return habitService.getHabits()
}

override suspend fun getArchivedHabits(): List<HabitEntity> {
return listOf(
HabitEntity(
1,
memberId = 1,
title = "물 마시기",
imojiPath = "",
dayOfWeeks = listOf(
"MONDAY","TUESDAY","WEDNESDAY"
),
reward = SecureRandom().nextInt(10),
color = "pink",
mate = null,
todayHabitAchievementId = null,
sequence = 1,
createAt = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME),
),
HabitEntity(
2,
memberId = 1,
title = "영어 공부 1시간 하기",
imojiPath = "",
dayOfWeeks = DayOfWeek.values().map { it.name }.toList(),
reward = SecureRandom().nextInt(10),
color = "blue",
mate = null,
todayHabitAchievementId = null,
sequence = 1,
createAt = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME),
),
)
// return habitService.getArchivedHabits()
}

// override fun getHabit(habitId: Long): HabitEntity {
//
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class HabitEntity (
val memberId: Int,
val title: String,
val imojiPath: String,
val dayOfWeeks: ArrayList<String>,
val dayOfWeeks: List<String>,
val reward: Int,
val color: String,
val mate: Mate,
val mate: Mate?,
val todayHabitAchievementId: Int?, // null이면 오늘 체크를 하지 않은 것
val sequence: Int,
val createAt: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ class HabitRepositoryImpl @Inject constructor(
}
}

override suspend fun getArchivedHabits(): Flow<DataState<List<Habit>>> {
return flow {
emit(DataState.loading())
val response = habitRemoteDataSource.getArchivedHabits()

if(response.isNotEmpty()) {
emit(DataState.success(data = response.map { it.toHabit() }))
} else {
emit(DataState.error(msg = "response has error"))
}.runCatching {
emit(DataState.fail("response is fail"))
}
}
}

// override suspend fun getHabit(habitId: Long): Habit {
//
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ data class Habit(
val memberId: Int,
val title: String,
val imojiPath: String,
val dayOfWeeks: ArrayList<String>,
val dayOfWeeks: List<String>,
val reward: Int,
val color: Color,
val mate: Mate,
val mate: Mate?,
val todayHabitAchievementId: Int?, // null이면 오늘 체크를 하지 않은 것
val sequence: Int,
val createAt: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlinx.coroutines.flow.Flow
interface HabitRepository {
suspend fun createHabit(habit: Habit)
suspend fun getHabits(): Flow<DataState<List<Habit>>>
suspend fun getArchivedHabits(): Flow<DataState<List<Habit>>>
//suspend fun getHabit(habitId: Long): Habit
suspend fun updateHabit(habitId: Long)
suspend fun deleteHabit(habitId: Long)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.depromeet.threedays.domain.usecase

import com.depromeet.threedays.domain.entity.DataState
import com.depromeet.threedays.domain.entity.habit.Habit
import com.depromeet.threedays.domain.repository.HabitRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetArchivedHabitsUseCase @Inject constructor(
private val habitRepository: HabitRepository,
) {
suspend operator fun invoke(): Flow<DataState<List<Habit>>> {
return habitRepository.getArchivedHabits()
}
}
1 change: 1 addition & 0 deletions navigator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

android {
namespace 'com.depromeet.threedays.navigator'
compileSdk 33

defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.depromeet.threedays.navigator

interface ArchivedHabitNavigator : Navigator
1 change: 1 addition & 0 deletions presentation/history/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
}

android {
namespace 'com.depromeet.threedays.history'
compileSdk 33

defaultConfig {
Expand Down
1 change: 1 addition & 0 deletions presentation/home/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
}

android {
namespace 'com.depromeet.threedays.home'
compileSdk 33

defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class HabitViewHolder(private val view: ItemHabitBinding) : RecyclerView.ViewHol
}
}

private fun convertDayListToString(dayOfWeeks: ArrayList<String>): String {
private fun convertDayListToString(dayOfWeeks: List<String>): String {
return if (dayOfWeeks.size == 7) {
"매일"
} else if (dayOfWeeks.size == 5
Expand Down
Loading

0 comments on commit 5ef34e4

Please sign in to comment.