@@ -69,8 +69,7 @@ fun WeatherViewPager(
6969@ExperimentalPermissionsApi
7070@Composable
7171private fun Weather (
72- cityInfoList : List <CityInfo >,
73- pagerState : PagerState
72+ cityInfoList : List <CityInfo >, pagerState : PagerState
7473) {
7574 val value = defaultCityState.value ? : return
7675 var indexOf = - 1
@@ -97,10 +96,7 @@ private fun NoCityContent(
9796 val isLand = config.orientation == Configuration .ORIENTATION_LANDSCAPE
9897 Column (modifier = Modifier .fillMaxSize()) {
9998 Row (
100- modifier = Modifier
101- .fillMaxWidth()
102- .statusBarsPadding()
103- .navigationBarsPadding(),
99+ modifier = Modifier .fillMaxWidth().statusBarsPadding().navigationBarsPadding(),
104100 horizontalArrangement = Arrangement .End ,
105101 verticalAlignment = Alignment .CenterVertically ,
106102 ) {
@@ -140,14 +136,13 @@ fun WeatherViewPager(
140136 }, pageContent = { page ->
141137 val isRefreshing by weatherViewModel.isRefreshing.collectAsState()
142138 val cityInfo = cityInfoList[page]
143- val pullRefreshState = rememberPullRefreshState(isRefreshing,
144- {
145- if (cityInfo.isLocation > 0 || ! cityInfoList.hasLocationCityInfo()) {
146- // 刷新当前位置
147- weatherViewModel.refreshLocation()
148- }
149- weatherViewModel.refresh(cityInfo)
150- })
139+ val pullRefreshState = rememberPullRefreshState(isRefreshing, {
140+ if (cityInfo.isLocation > 0 || ! cityInfoList.hasLocationCityInfo()) {
141+ // 刷新当前位置
142+ weatherViewModel.refreshLocation()
143+ }
144+ weatherViewModel.refresh(cityInfo)
145+ })
151146
152147 Box (Modifier .pullRefresh(pullRefreshState)) {
153148 WeatherPage (
@@ -161,12 +156,12 @@ fun WeatherViewPager(
161156 )
162157 }
163158 })
164- HorizontalPagerIndicator (
165- pagerState = pagerState,
166- pageCount = cityInfoList.size ,
167- modifier = Modifier
168- .align(Alignment .BottomCenter )
169- .padding(bottom = 25 .dp),
170- )
159+ if (cityInfoList.size > 1 ) {
160+ HorizontalPagerIndicator (
161+ pagerState = pagerState ,
162+ pageCount = cityInfoList.size,
163+ modifier = Modifier .align(Alignment .BottomCenter ).padding(bottom = 25 .dp),
164+ )
165+ }
171166 }
172167}
0 commit comments