Skip to content

Commit 5e00c30

Browse files
committed
Fix: Accept the feedback for the code style.
* A one-liner arrow for a multiline if seems weird, using blocks instead * #16 (comment) * Add a whitespace * #16 (comment) * Change back DragRefreshSample.kt code to match with README.md
1 parent 654a7ce commit 5e00c30

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

demo/src/main/java/dev/materii/pullrefresh/demo/MainActivity.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ class MainActivity : ComponentActivity() {
135135
1 -> DragRefreshSample(
136136
flipped = flipped,
137137
pullRefreshState = pullRefreshState,
138-
modifier = Modifier.fillMaxSize(),
139-
isRefreshing = isRefreshing
138+
modifier = Modifier.fillMaxSize()
140139
)
141140
}
142141
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package dev.materii.pullrefresh.demo.sample
22

3-
import androidx.compose.foundation.background
3+
import androidx.compose.foundation.layout.Box
44
import androidx.compose.foundation.layout.fillMaxSize
5-
import androidx.compose.foundation.layout.fillMaxWidth
6-
import androidx.compose.foundation.layout.padding
7-
import androidx.compose.foundation.lazy.LazyColumn
8-
import androidx.compose.foundation.shape.RoundedCornerShape
5+
import androidx.compose.foundation.rememberScrollState
6+
import androidx.compose.foundation.verticalScroll
97
import androidx.compose.material3.MaterialTheme
108
import androidx.compose.material3.Text
119
import androidx.compose.runtime.Composable
10+
import androidx.compose.ui.Alignment
1211
import androidx.compose.ui.Modifier
13-
import androidx.compose.ui.unit.dp
1412
import dev.materii.pullrefresh.DragRefreshIndicator
1513
import dev.materii.pullrefresh.DragRefreshLayout
1614
import dev.materii.pullrefresh.PullRefreshState
@@ -19,8 +17,7 @@ import dev.materii.pullrefresh.PullRefreshState
1917
fun DragRefreshSample(
2018
flipped: Boolean,
2119
pullRefreshState: PullRefreshState,
22-
modifier: Modifier = Modifier,
23-
isRefreshing: Boolean
20+
modifier: Modifier = Modifier
2421
) {
2522
DragRefreshLayout(
2623
modifier = modifier,
@@ -34,22 +31,13 @@ fun DragRefreshSample(
3431
)
3532
}
3633
) {
37-
LazyColumn(
38-
Modifier.fillMaxSize(),
39-
userScrollEnabled = !isRefreshing
34+
Box(
35+
modifier = Modifier
36+
.fillMaxSize()
37+
.verticalScroll(rememberScrollState()),
38+
contentAlignment = Alignment.Center
4039
) {
41-
items(100) {
42-
Text(
43-
modifier = Modifier
44-
.fillMaxWidth()
45-
.padding(5.dp)
46-
.background(
47-
color = MaterialTheme.colorScheme.outline,
48-
shape = RoundedCornerShape(10.dp)
49-
)
50-
.padding(10.dp), text = "No. $it"
51-
)
52-
}
40+
Text(text = "Pull ${if (flipped) "up" else "down"} to refresh")
5341
}
5442
}
5543
}

pullrefresh/src/commonMain/kotlin/dev/materii/pullrefresh/PullRefreshState.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,15 @@ class PullRefreshState internal constructor(
134134
// We are flinging without having dragged the pull refresh (for example a fling inside
135135
// a list) - don't consume
136136
distancePulled == 0f -> 0f
137-
velocity < 0f -> if (isRefreshTiming) {
138-
// We need to prevent the fling upward when the refresh starts.
139-
velocity
140-
}else {
141-
// If the velocity is negative, the fling is upwards, and we don't want to prevent
142-
// the list from scrolling
143-
0f
137+
velocity < 0f -> {
138+
if (isRefreshTiming) {
139+
// We need to prevent the fling upward when the refresh starts.
140+
velocity
141+
} else {
142+
// If the velocity is negative, the fling is upwards, and we don't want to prevent
143+
// the list from scrolling
144+
0f
145+
}
144146
}
145147
// We are showing the indicator, and the fling is downwards - consume everything
146148
else -> velocity

0 commit comments

Comments
 (0)