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
data class State( | |
val timePassedInMillis: Long, | |
val isRunning: Boolean | |
) |
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
class StopwatchRenderView(root: ViewGroup): RenderView<StopwatchRenderModel> { | |
private val timePassed: TextView = root.findViewById(R.id.time_passed_text_view) | |
private val startStopButton: Button = root.findViewById(R.id.start_stop_button) | |
private val resetButton: Button = root.findViewById(R.id.reset_button) | |
override val renderer: Renderer<StopwatchRenderModel> = Renderer.create { model -> | |
timePassed.text = model.timePassed | |
startStopButton.text = model.startStopButton.text | |
startStopButton.setOnClickListener { |
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
class StopwatchFormula : Formula<Unit, StopwatchFormula.State, StopwatchRenderModel> { | |
... | |
override fun evaluate( | |
input: Unit, | |
state: State, | |
context: FormulaContext<State> | |
): Evaluation<StopwatchRenderModel> { | |
return Evaluation( |
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
class StopwatchFormula : Formula<Unit, StopwatchState, StopwatchRenderModel> { | |
override fun initialState(input: Unit) = StopwatchState( | |
timePassedInMillis = 0, | |
isRunning = false | |
) | |
override fun evaluate( | |
input: Unit, | |
state: StopwatchState, |
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
data class StopwatchState( | |
val timePassedInMillis: Long, | |
val isRunning: Boolean | |
) |
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
data class StopwatchRenderModel( | |
val timePassed: String, | |
val startStopButton: ButtonRenderModel, | |
val resetButton: ButtonRenderModel | |
) | |
data class ButtonRenderModel( | |
val text: String, | |
val onSelected: () -> Unit | |
) |
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
package com.laimiux.dayahead.ui.util; | |
import android.content.Context; | |
import android.os.Bundle; | |
import android.os.Parcelable; | |
import android.support.v4.view.PagerAdapter; | |
import android.util.Log; | |
import android.util.SparseArray; | |
import android.view.LayoutInflater; | |
import android.view.View; |
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
fun reduce(event: TextChangedEvent): Reducer<CommentFormData> { | |
// implementation | |
} | |
fun reduce(event: Lce<Comment>): Reducer<CommentFormData> { | |
// implementation | |
} | |
fun formState( |
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
fun reduce(event: TextChangedEvent): (CommentFormData) -> CommentFormData { | |
// implementation | |
return { state -> | |
// Let's check comment validity | |
val isValid = event.enteredText.length > 5 | |
// Update the current state with the changes | |
return state.copy(comment = event.enteredText, isCommentValid = isValid) | |
} | |
} |