Skip to content

Commit

Permalink
fix code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Feb 20, 2024
1 parent 3fc0921 commit 045690c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ class TeiDataRepositoryImpl(

val canAddEventToEnrollment = enrollmentUid?.let {
programStage.access()?.data()?.write() == true &&
d2.eventModule().eventService().blockingCanAddEventToEnrollment(
it,
programStage.uid(),
)
d2.eventModule().eventService().blockingCanAddEventToEnrollment(
it,
programStage.uid(),
)
} ?: false

eventViewModels.add(
Expand All @@ -186,7 +186,7 @@ class TeiDataRepositoryImpl(
),
)
checkEventStatus(eventList).take(
if (selectedStage.showAllEvents) eventList.size else maxEventToShow
if (selectedStage.showAllEvents) eventList.size else maxEventToShow,
).forEachIndexed { index, event ->
val showTopShadow = index == 0
val showBottomShadow = index == eventList.size - 1
Expand Down Expand Up @@ -238,7 +238,7 @@ class TeiDataRepositoryImpl(
displayDate = null,
nameCategoryOptionCombo = null,
showAllEvents = selectedStage.showAllEvents,
maxEventsToShow = maxEventToShow
maxEventsToShow = maxEventToShow,
),
)
}
Expand All @@ -249,7 +249,7 @@ class TeiDataRepositoryImpl(

private fun getTimelineEvents(
eventRepository: EventCollectionRepository,
showAllEvents: Boolean
showAllEvents: Boolean,
): Single<List<EventViewModel>> {
val eventViewModels = mutableListOf<EventViewModel>()
val maxEventToShow = 5
Expand All @@ -260,7 +260,7 @@ class TeiDataRepositoryImpl(
.get()
.map { eventList ->
checkEventStatus(eventList).take(
if (showAllEvents) eventList.size else maxEventToShow
if (showAllEvents) eventList.size else maxEventToShow,
).forEachIndexed { _, event ->
val programStage = d2.programModule().programStages()
.uid(event.programStage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class EventAdapter(
oldItem.event!!.uid()
} else {
oldItem.stage!!.uid()

}
val newItemId = if (newItem.type == EVENT) {
newItem.event!!.uid()
Expand Down Expand Up @@ -100,7 +99,7 @@ class EventAdapter(
TOGGLE_BUTTON -> {
ToggleStageEventsButtonHolder(
ComposeView(parent.context),
stageSelector
stageSelector,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ internal class StageViewHolder(
StageSection(
stageUid = stage.uid(),
showOptions = true,
showAllEvents = false
)
showAllEvents = false,
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ToggleStageEventsButtonHolder(
private val stageSelector: FlowableProcessor<StageSection>,
) : RecyclerView.ViewHolder(composeView) {
fun bind(
eventViewModel: EventViewModel
eventViewModel: EventViewModel,
) {
composeView.setContent {
MdcTheme {
Expand All @@ -27,16 +27,20 @@ class ToggleStageEventsButtonHolder(
StageSection(
stageUid = eventViewModel.stage?.uid() ?: "",
showOptions = false,
showAllEvents = !eventViewModel.showAllEvents
)
showAllEvents = !eventViewModel.showAllEvents,
),
)
},
text = if (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())
} else {
composeView.context.getString(
R.string.show_more_events,
(eventViewModel.eventCount - eventViewModel.maxEventsToShow).toString(),
)
},
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ data class EventViewModel(

fun isAfterToday(today: Date): Boolean {
return type == EventViewModelType.EVENT && event?.eventDate() != null &&
event.eventDate()?.after(today) == true
event.eventDate()?.after(today) == true
}

fun applyHideStage(hidden: Boolean): EventViewModel? {
Expand Down

0 comments on commit 045690c

Please sign in to comment.