Skip to content

Commit

Permalink
update toggle button design
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Feb 20, 2024
1 parent c70b2f4 commit 2007139
Showing 1 changed file with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package org.dhis2.usescases.teiDashboard.dashboardfragments.teidata.teievents

import androidx.compose.foundation.clickable
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.composethemeadapter.MdcTheme
import io.reactivex.processors.FlowableProcessor
import org.dhis2.R
import org.dhis2.commons.data.EventViewModel
import org.dhis2.commons.data.StageSection
import org.hisp.dhis.mobile.ui.designsystem.component.Button
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle

class ToggleStageEventsButtonHolder(
val composeView: ComposeView,
Expand All @@ -19,26 +17,23 @@ class ToggleStageEventsButtonHolder(
eventViewModel: EventViewModel,
) {
composeView.setContent {
MdcTheme {
Text(
modifier = Modifier
.clickable {
stageSelector.onNext(
StageSection(
stageUid = eventViewModel.stage?.uid() ?: "",
showOptions = false,
showAllEvents = !eventViewModel.showAllEvents,
),
)
},
text = if (eventViewModel.showAllEvents) {
composeView.context.getString(R.string.show_less_events)
} else {
composeView.context.getString(
R.string.show_more_events,
(eventViewModel.eventCount - eventViewModel.maxEventsToShow).toString(),
)
},
Button(
style = ButtonStyle.TEXT,
text = if (eventViewModel.showAllEvents) {
composeView.context.getString(R.string.show_less_events)
} else {
composeView.context.getString(
R.string.show_more_events,
(eventViewModel.eventCount - eventViewModel.maxEventsToShow).toString(),
)
},
) {
stageSelector.onNext(
StageSection(
stageUid = eventViewModel.stage?.uid() ?: "",
showOptions = false,
showAllEvents = !eventViewModel.showAllEvents,
),
)
}
}
Expand Down

0 comments on commit 2007139

Please sign in to comment.