-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from YAPP-Github/feature/issue-043-home-ui
[ISSUE-43] 홈 화면 UI 구현
- Loading branch information
Showing
29 changed files
with
1,153 additions
and
103 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
168 changes: 168 additions & 0 deletions
168
presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/CalendarDecorator.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,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 | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeContract.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,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 | ||
} | ||
} |
Oops, something went wrong.