Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-43] 홈 화면 UI 구현 #73

Merged
merged 35 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4b72c85
chore - 안드로이드X 사용 명시
hoyahozz Jun 29, 2022
a82478c
design - Home 화면에 사용되는 아이콘 추가
hoyahozz Jun 29, 2022
f48e672
chore - Compose ConstraintLayout 의존성 추가
hoyahozz Jun 29, 2022
8345119
chore - Material CalendarView 써드파티 의존성 추가
hoyahozz Jun 29, 2022
7562e0f
feat - BottomNavigation이 화면을 가리지 않도록 설정
hoyahozz Jun 29, 2022
d6b19f4
feat - HomeContract, HomeViewModel 생성
hoyahozz Jun 29, 2022
244e3ab
feat - Home 화면 이벤트, 사이드 이펙트 로직 추가
hoyahozz Jun 29, 2022
18b332d
feat - Home 화면 앱바 추가
hoyahozz Jun 29, 2022
3aa4b4d
feat - 로그인 상태에 따라 상단 박스가 다르게 보이도록 설정
hoyahozz Jun 29, 2022
06ac039
feat - 로그인 상태일 때 보여줄 박스 추가
hoyahozz Jun 29, 2022
8847a1a
feat - 비로그인 상태일 때 보여줄 박스 추가
hoyahozz Jun 29, 2022
317f891
feat - 약속 목록 UI 구현
hoyahozz Jun 29, 2022
3b2a800
feat - 홈 화면 바텀 박스 추가
hoyahozz Jun 29, 2022
92b0f31
feat - 텍스트 약속 목록 UI 구현
hoyahozz Jun 29, 2022
228d992
feat - 캘린더 추가
hoyahozz Jun 29, 2022
46ba6ba
design - 캘린더 데코레이팅을 위한 XML 추가
hoyahozz Jun 29, 2022
10e4036
feat - 캘린더 데코레이팅을 위한 데코레이터 클래스 추가
hoyahozz Jun 29, 2022
b629568
feat - 캘린더 데코레이팅 설정
hoyahozz Jun 29, 2022
806a138
fix - 캘린더 사용 주석 해제
hoyahozz Jun 29, 2022
0bb04d1
Merge branch 'develop' into feature/issue-043-home-ui
hoyahozz Jun 29, 2022
34e1dd6
refactor - 컴포저블 함수 네이밍 변경
hoyahozz Jun 30, 2022
ffb80b0
feat - 홈 화면 스트링 리소스 추가 및 적용
hoyahozz Jun 30, 2022
f797009
refactor - 캘린더 데코레이터 클래스의 가독성 개선
hoyahozz Jun 30, 2022
60e6365
fix - 소수점 단위로 설정한 UI 크기 변경
hoyahozz Jun 30, 2022
0685090
refactor - 컴포저블 함수 분리
hoyahozz Jun 30, 2022
84c4547
refactor - 아이콘의 네이밍 변경
hoyahozz Jun 30, 2022
b716865
refactor - 홈 유저 프로필의 레이아웃 구성 변경
hoyahozz Jun 30, 2022
133131e
Merge branch 'develop' into feature/issue-043-home-ui
jihee-dev Jul 1, 2022
245067b
fix - 중복 선언된 버전 정보 삭제
jihee-dev Jul 1, 2022
083972f
refactor - Spacer 를 지정할 때 height, width 를 사용하도록 변경
hoyahozz Jul 3, 2022
b6e5fcb
fix - EOF 개행 추가
hoyahozz Jul 3, 2022
5a33f35
fix - 월 표현 방식을 (5월 -> 05월) 형식으로 변경
hoyahozz Jul 4, 2022
2eec2a2
fix - 어떤 요소의 사이즈가 변경되더라도 다른 요소의 배치에는 영향을 미치지 않도록 수정
hoyahozz Jul 5, 2022
1e8cdf5
feat - 커스텀 Modifier Shadow Extension 추가
hoyahozz Jul 5, 2022
9dc0ba4
refactor - 박스 화살표 아이콘 네이밍 변경
hoyahozz Jul 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ object Versions {
const val COMPOSE = "1.1.1"
const val COMPOSE_ACTIVITY = "1.4.0"
const val COMPOSE_CONSTRAINT_LAYOUT = "1.1.0-alpha02"
const val COMPOSE_NAVIGATION = "2.4.2"
const val CONSTRAINT_LAYOUT = "2.1.3"
const val COMPOSE_NAVIGATION = "2.4.2"
const val FIREBASE_BOM = "29.1.0"
const val FIREBASE_CRASHLYTICS = "2.9.0"
const val GOOGLE_SERVICE = "4.3.10"
Expand All @@ -18,6 +18,7 @@ object Versions {
const val KAKAO_SDK = "2.10.0"
const val KOTLIN = "1.6.10"
const val KOTLIN_COROUTINES = "1.5.1"
const val MATERIAL_CALENDAR = "1.4.3"
const val LIFECYCLE = "2.4.1"
const val OKHTTP = "4.3.1"
const val RETROFIT = "2.7.1"
Expand Down
9 changes: 9 additions & 0 deletions buildSrc/src/main/java/app/ModuleDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ object ModuleDependencies {
Versions.COMPOSE_ACTIVITY,
Method.IMPLEMENTATION
),
DependencyInfo(
"androidx.constraintlayout:constraintlayout-compose",
Versions.COMPOSE_CONSTRAINT_LAYOUT,
Method.IMPLEMENTATION
),
DependencyInfo("io.coil-kt:coil-compose", Versions.COIL, Method.IMPLEMENTATION),
DependencyInfo(
"androidx.navigation:navigation-compose",
Expand Down Expand Up @@ -144,6 +149,10 @@ object ModuleDependencies {
DependencyInfo("javax.inject:javax.inject", Versions.INJECT, Method.IMPLEMENTATION)
)

val materialCalendarView = arrayOf(
DependencyInfo("com.prolificinteractive:material-calendarview", Versions.MATERIAL_CALENDAR, Method.IMPLEMENTATION)
)

val kakaoSdk = arrayOf(
DependencyInfo("com.kakao.sdk:v2-user", Versions.KAKAO_SDK, Method.IMPLEMENTATION)
)
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.enableJetifier=true
1 change: 1 addition & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
app.ModuleDependencies.hilt.implement(this)
app.ModuleDependencies.hiltAndroid.implement(this)
app.ModuleDependencies.timber.implement(this)
app.ModuleDependencies.materialCalendarView.implement(this)

implementation(platform(app.ModuleDependencies.FIREBASE_BOM))
implementation(app.ModuleDependencies.FIREBASE_ANALYTICS)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package com.yapp.growth.presentation.ui.main.home

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Typeface
import android.text.style.ForegroundColorSpan
import android.text.style.LineBackgroundSpan
import android.text.style.StyleSpan
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.core.content.ContextCompat
import com.prolificinteractive.materialcalendarview.CalendarDay
import com.prolificinteractive.materialcalendarview.DayViewDecorator
import com.prolificinteractive.materialcalendarview.DayViewFacade
import com.prolificinteractive.materialcalendarview.MaterialCalendarView
import com.prolificinteractive.materialcalendarview.spans.DotSpan.DEFAULT_RADIUS
import com.yapp.growth.presentation.R
import com.yapp.growth.presentation.theme.*
import java.util.*


class CalendarDecorator {
class TodayDecorator(context: Context) : DayViewDecorator {
private var date = CalendarDay.today()
private val boldSpan = StyleSpan(Typeface.BOLD)

@SuppressLint("UseCompatLoadingForDrawables")
val drawable = ContextCompat.getDrawable(context, R.drawable.bg_calendar_today)
override fun shouldDecorate(day: CalendarDay): Boolean {
return day == date
}

override fun decorate(view: DayViewFacade) {
if (drawable != null) {
view.apply {
this.addSpan(object : ForegroundColorSpan(Color.White.toArgb()) {})
this.setSelectionDrawable(drawable)
this.addSpan(boldSpan)
}
}
}
}

class SelectDecorator(context: Context, mCalendar: MaterialCalendarView) : DayViewDecorator {
@SuppressLint("UseCompatLoadingForDrawables")
private val mCalendar = mCalendar.currentDate.calendar
private val drawable = ContextCompat.getDrawable(context, R.drawable.bg_calendar_selection)

override fun shouldDecorate(day: CalendarDay): Boolean {
val calendar = day.calendar

return calendar.get(Calendar.ERA) == mCalendar.get(Calendar.ERA)
&& calendar.get(Calendar.YEAR) == mCalendar.get(Calendar.YEAR)
&& calendar.get(Calendar.MONTH) == mCalendar.get(Calendar.MONTH)
}

override fun decorate(view: DayViewFacade) {
if (drawable != null) {
view.apply {
this.addSpan(object : ForegroundColorSpan(Gray900.toArgb()) {})
this.setSelectionDrawable(drawable)
}
}
}
}

class OtherDayDecorator(context: Context, mCalendar: MaterialCalendarView) : DayViewDecorator {
@SuppressLint("UseCompatLoadingForDrawables")
private val mCalendar = mCalendar.currentDate.calendar
private val drawable = ContextCompat.getDrawable(context, R.drawable.bg_calendar_selection)
override fun shouldDecorate(day: CalendarDay): Boolean {
val calendar = day.calendar

return calendar.get(Calendar.ERA) == mCalendar.get(Calendar.ERA)
&& calendar.get(Calendar.YEAR) == mCalendar.get(Calendar.YEAR)
&& calendar.get(Calendar.MONTH) != mCalendar.get(Calendar.MONTH)
}

override fun decorate(view: DayViewFacade) {
if (drawable != null) {
view.apply {
this.addSpan(object : ForegroundColorSpan(Gray300.toArgb()) {})
this.setSelectionDrawable(drawable)
}
}
}
}

class SundayDecorator : DayViewDecorator {
private val calendar = Calendar.getInstance()
override fun shouldDecorate(day: CalendarDay): Boolean {
day.copyTo(calendar)
val weekDay = calendar.get(Calendar.DAY_OF_WEEK)
return (weekDay == Calendar.SUNDAY)
}

override fun decorate(view: DayViewFacade) {
view.addSpan(object : ForegroundColorSpan(SubCoral.toArgb()) {})
}
}

// TODO : 일정이 있는 날만 점 데코레이터 찍기
class DotDecorator : DayViewDecorator {
private var date = CalendarDay.from(2022, 5, 21)

override fun shouldDecorate(day: CalendarDay): Boolean {
return day == date
}

override fun decorate(view: DayViewFacade) {
view.addSpan(CustomMultipleDotSpan(4F, color = intArrayOf(SubCoral.toArgb(), SubYellow.toArgb(), MainPurple900.toArgb())))
}
}

class CustomMultipleDotSpan : LineBackgroundSpan {
private val radius: Float
private var color = IntArray(0)

constructor() {
radius = DEFAULT_RADIUS
color[0] = 0
}

constructor(color: Int) {
radius = DEFAULT_RADIUS
this.color[0] = 0
}

constructor(radius: Float) {
this.radius = radius
color[0] = 0
}

constructor(radius: Float, color: IntArray) {
this.radius = radius
this.color = color
}

override fun drawBackground(
canvas: Canvas,
paint: Paint,
left: Int,
right: Int,
top: Int,
baseline: Int,
bottom: Int,
charSequence: CharSequence,
start: Int,
end: Int,
lineNum: Int
) {
val total = if (color.size > 5) 5 else color.size
var leftMost = (total - 1) * - 10

for (i in 0 until total) {
val oldColor: Int = paint.color
if (color[i] != 0) {
paint.color = color[i]
}
canvas.drawCircle(((left + right) / 2 - leftMost).toFloat(), bottom + 10F , radius, paint)
paint.color = oldColor
leftMost += 20
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.yapp.growth.presentation.ui.main.home

import com.yapp.growth.base.ViewEvent
import com.yapp.growth.base.ViewSideEffect
import com.yapp.growth.base.ViewState

class HomeContract {
data class HomeViewState(
val loginState: LoginState = LoginState.LOGIN
) : ViewState

// TODO : 유저 아이콘 클릭 시 내 정보 창으로 이동 (정호)
sealed class HomeSideEffect : ViewSideEffect {
object NavigateToInfoScreen : HomeSideEffect()
object NavigateDetailPlanScreen : HomeSideEffect()
object OpenBottomSheet : HomeSideEffect()
}

sealed class HomeEvent : ViewEvent {
object OnUserImageButtonClicked : HomeEvent()
object OnPlanClicked : HomeEvent()
object OnCalendarDayClicked : HomeEvent()
}

enum class LoginState {
NONE, LOGIN
}
}
Loading