-
Notifications
You must be signed in to change notification settings - Fork 80
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 #26 from bn-tw2020/featrue/layout-25
[feat] 레이아웃 전체 구성 및 달력 구현(20, 25)
- Loading branch information
Showing
28 changed files
with
1,047 additions
and
82 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
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/example/todo/airbnb/data/datasource/DateLocalDataSource.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,61 @@ | ||
package com.example.todo.airbnb.data.datasource | ||
|
||
import android.annotation.SuppressLint | ||
import android.os.Build | ||
import androidx.annotation.RequiresApi | ||
import com.example.todo.airbnb.presentation.search.date.components.CalendarMonth | ||
import com.example.todo.airbnb.presentation.search.date.components.DatesSelectedState | ||
import com.example.todo.airbnb.presentation.search.date.components.DayOfWeek | ||
import com.example.todo.airbnb.presentation.search.date.components.DaySelected | ||
import java.time.LocalDate | ||
import java.time.temporal.TemporalAdjusters | ||
|
||
typealias CalendarYear = List<CalendarMonth> | ||
|
||
@RequiresApi(Build.VERSION_CODES.O) | ||
class DatesLocalDataSource { | ||
|
||
private val dayOfWeek = listOf( | ||
"January", | ||
"February", | ||
"March", | ||
"April", | ||
"May", | ||
"June", | ||
"July", | ||
"August", | ||
"September", | ||
"October", | ||
"November", | ||
"December" | ||
) | ||
|
||
val calendarYear = getDayList() | ||
val datesSelected = DatesSelectedState(calendarYear) | ||
|
||
fun onDaySelected(daySelected: DaySelected) { | ||
datesSelected.daySelected(daySelected) | ||
} | ||
|
||
private fun getDayList(): List<CalendarMonth> { | ||
val list = mutableListOf<CalendarMonth>() | ||
for (month in 1..12) { | ||
val date = LocalDate.of(2021, month, 1) | ||
list.add( | ||
CalendarMonth( | ||
name = dayOfWeek[month - 1], | ||
year = date.year.toString(), | ||
numDays = date.with(TemporalAdjusters.lastDayOfMonth()).dayOfMonth, | ||
monthNumber = month, | ||
startDayOfWeek = DayOfWeek.values(date.dayOfWeek.toString()) ?: DayOfWeek.Sunday | ||
) | ||
) | ||
} | ||
return list | ||
} | ||
|
||
@SuppressLint("VisibleForTests") | ||
fun onClear() { | ||
datesSelected.clearDates() | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/example/todo/airbnb/data/repository/DateeRepositoryImpl.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,37 @@ | ||
package com.example.todo.airbnb.data.repository | ||
|
||
import android.os.Build | ||
import androidx.annotation.RequiresApi | ||
import com.example.todo.airbnb.data.datasource.CalendarYear | ||
import com.example.todo.airbnb.data.datasource.DatesLocalDataSource | ||
import com.example.todo.airbnb.domain.repository.DateRepository | ||
import com.example.todo.airbnb.presentation.search.date.components.DatesSelectedState | ||
import com.example.todo.airbnb.presentation.search.date.components.DaySelected | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
|
||
@RequiresApi(Build.VERSION_CODES.O) | ||
class DateRepositoryImpl( | ||
private val datesLocalDataSource: DatesLocalDataSource, | ||
) : DateRepository { | ||
|
||
override fun getDate(): CalendarYear { | ||
return datesLocalDataSource.calendarYear | ||
} | ||
|
||
override fun getDatesSelected(): DatesSelectedState { | ||
return datesLocalDataSource.datesSelected | ||
} | ||
|
||
override suspend fun onDaySelected(daySelected: DaySelected) { | ||
withContext(Dispatchers.IO) { | ||
datesLocalDataSource.onDaySelected(daySelected) | ||
} | ||
} | ||
|
||
override suspend fun onClear() { | ||
withContext(Dispatchers.IO) { | ||
datesLocalDataSource.onClear() | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/example/todo/airbnb/domain/repository/DateRepository.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,15 @@ | ||
package com.example.todo.airbnb.domain.repository | ||
|
||
import com.example.todo.airbnb.data.datasource.CalendarYear | ||
import com.example.todo.airbnb.presentation.search.date.components.DatesSelectedState | ||
import com.example.todo.airbnb.presentation.search.date.components.DaySelected | ||
|
||
interface DateRepository { | ||
fun getDate(): CalendarYear | ||
|
||
fun getDatesSelected(): DatesSelectedState | ||
|
||
suspend fun onDaySelected(daySelected: DaySelected) | ||
|
||
suspend fun onClear() | ||
} |
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
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
Oops, something went wrong.