-
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 branch 'ddddddd' into feature/#310-representation-rule-ui-prese…
…ntation
- Loading branch information
Showing
53 changed files
with
1,232 additions
and
582 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
51 changes: 51 additions & 0 deletions
51
app/src/main/java/hous/release/android/presentation/our_rules/event/UpdateRuleReducer.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,51 @@ | ||
package hous.release.android.presentation.our_rules.event | ||
|
||
import hous.release.android.presentation.our_rules.model.PhotoUiModel | ||
import hous.release.android.presentation.our_rules.viewmodel.UpdateRuleEvent | ||
import hous.release.android.presentation.our_rules.viewmodel.UpdateRuleState | ||
import hous.release.android.util.event.Reducer | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
class UpdateRuleReducer @Inject constructor() : Reducer<UpdateRuleState, UpdateRuleEvent> { | ||
override fun dispatch(state: UpdateRuleState, event: UpdateRuleEvent): UpdateRuleState { | ||
return when (event) { | ||
is UpdateRuleEvent.InitRule -> { | ||
state.copy( | ||
id = event.id, | ||
name = event.name, | ||
description = event.description, | ||
photos = event.photos | ||
) | ||
} | ||
|
||
is UpdateRuleEvent.ChangeDescription -> { | ||
state.copy(description = event.description) | ||
} | ||
|
||
is UpdateRuleEvent.ChangeName -> { | ||
state.copy(name = event.name) | ||
} | ||
|
||
is UpdateRuleEvent.LoadImage -> { | ||
val newPhotos = event.photos.map { photo -> | ||
PhotoUiModel.from(photo) | ||
} | ||
val updatedPhotos = state.photos + newPhotos | ||
Timber.e("LoadImage: updatedPhotos: $updatedPhotos") | ||
state.copy( | ||
photos = updatedPhotos | ||
) | ||
} | ||
|
||
is UpdateRuleEvent.DeleteImage -> { | ||
val filteredPhotos = state.photos.filter { photo -> | ||
photo != event.photo | ||
} | ||
state.copy( | ||
photos = filteredPhotos | ||
) | ||
} | ||
} | ||
} | ||
} |
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.