-
Notifications
You must be signed in to change notification settings - Fork 1
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 #79 from YAPP-Github/feature/MZ-182-ledger-add
Feature/mz 182 ledger add
- Loading branch information
Showing
33 changed files
with
860 additions
and
210 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
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 |
---|---|---|
@@ -1,12 +1,22 @@ | ||
package com.susu.core.ui.util | ||
|
||
import android.util.Log | ||
import java.time.DateTimeException | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
val currentDate = LocalDateTime.now() | ||
val currentDate: LocalDateTime = LocalDateTime.now() | ||
val minDate: LocalDateTime = LocalDateTime.of(1930, 1, 1, 0, 0) | ||
|
||
@Suppress("detekt:FunctionNaming") | ||
fun LocalDateTime.to_yyyy_dot_MM_dot_dd(): String { | ||
val formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd") | ||
return this.format(formatter) | ||
} | ||
|
||
fun getSafeLocalDateTime(year: Int, month: Int, day: Int): LocalDateTime = try { | ||
LocalDateTime.of(year, month, day, 0, 0) | ||
} catch (e: DateTimeException) { | ||
Log.e("DateTimeError", "Invalid date provided: $year-$month-$day", e) | ||
LocalDateTime.of(year, month, 1, 0, 0) | ||
} |
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
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/susu/domain/usecase/ledger/CreateLedgerUseCase.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,14 @@ | ||
package com.susu.domain.usecase.ledger | ||
|
||
import com.susu.core.common.runCatchingIgnoreCancelled | ||
import com.susu.core.model.Ledger | ||
import com.susu.domain.repository.LedgerRepository | ||
import javax.inject.Inject | ||
|
||
class CreateLedgerUseCase @Inject constructor( | ||
private val ledgerRepository: LedgerRepository, | ||
) { | ||
suspend operator fun invoke(ledger: Ledger) = runCatchingIgnoreCancelled { | ||
ledgerRepository.createLedger(ledger) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
feature/received/src/main/java/com/susu/feature/received/ledgeradd/LedgerAddContract.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,22 @@ | ||
package com.susu.feature.received.ledgeradd | ||
|
||
import com.susu.core.ui.base.SideEffect | ||
import com.susu.core.ui.base.UiState | ||
|
||
data class LedgerAddState( | ||
val currentStep: LedgerAddStep = LedgerAddStep.CATEGORY, | ||
val buttonEnabled: Boolean = false, | ||
val isLoading: Boolean = false, | ||
) : UiState | ||
|
||
enum class LedgerAddStep { | ||
CATEGORY, | ||
NAME, | ||
DATE, | ||
} | ||
|
||
sealed interface LedgerAddSideEffect : SideEffect { | ||
data object PopBackStack : LedgerAddSideEffect | ||
data class PopBackStackWithLedger(val ledger: String) : LedgerAddSideEffect | ||
data class HandleException(val throwable: Throwable, val retry: () -> Unit) : LedgerAddSideEffect | ||
} |
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.