File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
ptr-compose/src/main/java/wtf/s1/ui/nsptr/compose
ptr-demo/src/main/java/wtf/s1/android/ptr/demo Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ class NSPtrState(
3636 val contentRefreshPosition : Dp = 54 .dp,
3737 val pullFriction : Float = 0.56f ,
3838 coroutineScope : CoroutineScope ,
39- onRefresh : (suspend ( NSPtrState ) -> Unit ) ? = null ,
39+ onRefresh : (NSPtrState ) -> Unit ,
4040) {
4141
4242 var contentPositionPx: Float by mutableStateOf(0f )
@@ -64,7 +64,7 @@ class NSPtrState(
6464 }
6565 is SideEffect .OnRefreshing -> {
6666 animateContentTo(contentRefreshPositionPx)
67- onRefresh? .invoke(this @NSPtrState)
67+ onRefresh.invoke(this @NSPtrState)
6868 }
6969 else -> {
7070
@@ -147,7 +147,7 @@ private class NSPtrNestedScrollConnection(val ptrState: NSPtrState) : NestedScro
147147
148148@Composable
149149fun NSPtrLayout (
150- nsPtrState : NSPtrState = NSPtrState (coroutineScope = rememberCoroutineScope()) ,
150+ nsPtrState : NSPtrState ,
151151 modifier : Modifier ,
152152 content : @Composable NSPtrScope .() -> Unit
153153) {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier
1212import androidx.compose.ui.platform.AbstractComposeView
1313import androidx.compose.ui.unit.dp
1414import kotlinx.coroutines.delay
15+ import kotlinx.coroutines.launch
1516import wtf.s1.ui.nsptr.Event
1617import wtf.s1.ui.nsptr.compose.NSPtrEZHeader
1718import wtf.s1.ui.nsptr.compose.NSPtrLayout
@@ -41,8 +42,10 @@ fun Ins() {
4142 contentInitPosition = 0 .dp,
4243 contentRefreshPosition = 60 .dp
4344 ) {
44- delay(3000 )
45- it.dispatchPtrEvent(Event .RefreshComplete )
45+ coroutine.launch {
46+ delay(3000 )
47+ it.dispatchPtrEvent(Event .RefreshComplete )
48+ }
4649 }
4750 }
4851 NSPtrLayout (
You can’t perform that action at this time.
0 commit comments