Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Adds test modification check #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build_and_local_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Prevent changes in test/
uses: xalvarez/prevent-file-change-action@v1
if: github.event_name == 'pull_request'
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
pattern: ^app/src/test/
#trustedAuthors: JoseAlcerreca

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fun LocationScreenForecast(
onLocationChange: (String) -> Unit,
modifier: Modifier = Modifier
) {
val expandedDays = remember { mutableStateMapOf<String, Int>() }
val expandedDays = rememberSaveable(saver = indexSaver) { mutableStateMapOf<String, Int>() }
LocationScreenForecast(
forecast = locationForecast,
onLocationChange = onLocationChange,
Expand Down Expand Up @@ -154,11 +154,13 @@ fun LocationScreenForecast(
contentDescription = label
}) {
val index = 0
WeekForecastRow(
forecast.forecastWeek[index],
expanded = index == expandedDayIndex,
onClick = { onExpandedChanged(if (expandedDayIndex == index) -1 else index) }
)
forecast.forecastWeek.forEachIndexed { index, forecastDay ->
WeekForecastRow(
forecast.forecastWeek[index],
expanded = index == expandedDayIndex,
onClick = { onExpandedChanged(if (expandedDayIndex == index) -1 else index) }
)
}
}
}
}
Expand All @@ -175,19 +177,19 @@ fun TopAppBar(
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
IconButton(
onClick = { onLocationChange("Mountain View") }
onClick = { onLocationChange("Sunnyvale") }
) {
Icon(
Icons.Default.KeyboardArrowLeft,
stringResource(R.string.prev_location)
)
}
Text(
"//TODO",
locationName,
modifier = Modifier.padding(horizontal = 32.dp)
)
IconButton(
onClick = { onLocationChange("Sunnyvale") }
onClick = { onLocationChange("Mountain View") }
) {
Icon(
Icons.Default.KeyboardArrowRight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class LocationViewModel @Inject constructor(
val uiState = locationId.flatMapLatest { location ->
forecastRepository.getForecast(location)
.map<Forecast, LocationUiState> { Success(it) }
.catch { emit(Error(it)) }
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), Loading)

fun changeLocation(id: String) {
Expand Down