Skip to content

Commit

Permalink
feat: integrating dialects service to dialects ui. (#37)
Browse files Browse the repository at this point in the history
* feat: integrating dialects service to dialects ui.

* fix: try again button color.
  • Loading branch information
SamilaRuane authored and adrielcafe committed Oct 26, 2019
1 parent b41a364 commit 74a4ada
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ val presentationModule = Kodein.Module(name = "presentation") {
)

DialectsViewModel(
machine = stateMachine
machine = stateMachine,
service = instance()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class DialectsActivity : AppCompatActivity(), KodeinAware {
private fun setupRetry() {
errorStateView.let {
tryAgainBtn.setOnClickListener {
viewModel.handle(UserInteraction.RequestedFreshContent)
viewModel.handle(ShowDialects(region))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jcaique.presentation.dialects

import com.jcaique.domain.dialects.DialectsService
import com.jcaique.domain.models.Dialect
import com.jcaique.utils.dataflow.StateMachine
import com.jcaique.utils.dataflow.StateTransition
Expand All @@ -8,33 +9,11 @@ import com.jcaique.utils.dataflow.UserInteraction
import kotlinx.coroutines.coroutineScope

internal class DialectsViewModel(
private val machine: StateMachine<DialectsPresentation>
// TODO inject dialects service
private val machine: StateMachine<DialectsPresentation>,
private val service: DialectsService
) {

// TODO mocked result
private val dialects by lazy {
listOf(
Dialect(
slug = "lasquei-em-banda",
dialect = "Lasquei em banda",
meanings = listOf("Sem pena", "Abrupto"),
examples = listOf("Oxe man, lasquei foi em banda mermo, quis nem saber.")
),
Dialect(
slug = "lasquei-em-banda",
dialect = "Lasquei em banda",
meanings = listOf("Sem pena", "Abrupto"),
examples = listOf("Oxe man, lasquei foi em banda mermo, quis nem saber.")
),
Dialect(
slug = "lasquei-em-banda",
dialect = "Lasquei em banda",
meanings = listOf("Sem pena", "Abrupto"),
examples = listOf("Oxe man, lasquei foi em banda mermo, quis nem saber.")
)
)
}
private var dialects = emptyList<Dialect>()

fun bind() = machine.states()

Expand All @@ -55,7 +34,9 @@ internal class DialectsViewModel(
parameters: StateTransition.Parameters
): DialectsPresentation = coroutineScope {
val interaction = parameters as ShowDialects


dialects = service.getDialectsBy(interaction.region.name.toLowerCase())

dialects
.let(::DialectsPresentation)
}
Expand Down
8 changes: 4 additions & 4 deletions presentation/src/main/res/layout/error_state_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

<com.google.android.material.button.MaterialButton
android:id="@+id/tryAgainBtn"
android:theme="@style/AppTheme.Inverted"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_margin="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:backgroundTint="@color/blue"
android:text="@string/text_button_try_again"
android:textAllCaps="false"
android:visibility="visible"
/>
android:theme="@style/AppTheme.Inverted"
android:visibility="visible" />
</LinearLayout>
1 change: 1 addition & 0 deletions presentation/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<color name="lightGray2">#DCE0E9</color>
<color name="darkGray1">#2D3844</color>
<color name="darkGray2">#5a6872</color>
<color name="blue">#2144F3</color>
</resources>

0 comments on commit 74a4ada

Please sign in to comment.