Skip to content

Commit

Permalink
add loading in "search on this area" button
Browse files Browse the repository at this point in the history
  • Loading branch information
Balcan committed Dec 18, 2024
1 parent 115ce42 commit 3ee8233
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -77,10 +78,13 @@ import org.hisp.dhis.mobile.ui.designsystem.component.LocationBar
import org.hisp.dhis.mobile.ui.designsystem.component.LocationItem
import org.hisp.dhis.mobile.ui.designsystem.component.LocationItemIcon
import org.hisp.dhis.mobile.ui.designsystem.component.OnSearchAction
import org.hisp.dhis.mobile.ui.designsystem.component.ProgressIndicator
import org.hisp.dhis.mobile.ui.designsystem.component.ProgressIndicatorType
import org.hisp.dhis.mobile.ui.designsystem.component.SearchBarMode
import org.hisp.dhis.mobile.ui.designsystem.component.TopBar
import org.hisp.dhis.mobile.ui.designsystem.component.model.LocationItemModel
import org.hisp.dhis.mobile.ui.designsystem.theme.Shape
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

Expand Down Expand Up @@ -148,6 +152,7 @@ fun SinglePaneMapSelector(
captureMode = screenState.captureMode,
selectedLocation = screenState.selectedLocation,
searchOnThisAreaVisible = screenState.searchOnAreaVisible,
searching = screenState.searching,
locationState = screenState.locationState,
isManualCaptureEnabled = screenState.isManualCaptureEnabled,
isPolygonMode = screenState.displayPolygonInfo,
Expand Down Expand Up @@ -239,6 +244,7 @@ private fun TwoPaneMapSelector(
captureMode = screenState.captureMode,
selectedLocation = screenState.selectedLocation,
searchOnThisAreaVisible = screenState.searchOnAreaVisible,
searching = screenState.searching,
locationState = screenState.locationState,
isManualCaptureEnabled = screenState.isManualCaptureEnabled,
isPolygonMode = screenState.displayPolygonInfo,
Expand Down Expand Up @@ -442,6 +448,7 @@ private fun Map(
captureMode: MapSelectorViewModel.CaptureMode,
selectedLocation: SelectedLocation,
searchOnThisAreaVisible: Boolean,
searching: Boolean,
locationState: LocationState,
isManualCaptureEnabled: Boolean,
isPolygonMode: Boolean,
Expand Down Expand Up @@ -487,7 +494,7 @@ private fun Map(
modifier = Modifier
.align(Alignment.TopCenter)
.offset(y = 60.dp),
visible = searchOnThisAreaVisible,
visible = searchOnThisAreaVisible or searching,
enter = scaleIn(
animationSpec = spring(
dampingRatio = Spring.DampingRatioLowBouncy,
Expand All @@ -502,6 +509,7 @@ private fun Map(
),
) {
SearchInAreaButton(
searching = searching,
onClick = onSearchOnAreaClick,
)
}
Expand Down Expand Up @@ -548,11 +556,23 @@ private fun SwipeToChangeLocationInfo(

@Composable
private fun SearchInAreaButton(
searching: Boolean,
onClick: () -> Unit = {},
) {
Button(
style = ButtonStyle.TONAL,
text = stringResource(R.string.search_on_this_area),
text = if (searching) "" else stringResource(R.string.search_on_this_area),
icon = if (searching) {
{ ProgressIndicator(type = ProgressIndicatorType.CIRCULAR_SMALL) }
} else {
null
},
paddingValues = PaddingValues(
Spacing.Spacing24,
Spacing.Spacing10,
Spacing.Spacing24 - Spacing.Spacing8,
Spacing.Spacing10,
),
onClick = onClick,
)
}
Expand Down Expand Up @@ -669,6 +689,7 @@ private class ScreenStateParamProvider : PreviewParameterProvider<MapSelectorScr
get() = sequenceOf(
searchScreenState,
gpsScreenState,
gpsScreenState.copy(searching = true),
)
}

Expand Down

0 comments on commit 3ee8233

Please sign in to comment.