|
|
@ -15,6 +15,7 @@ import androidx.compose.material.* |
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
import androidx.compose.runtime.getValue |
|
|
|
import androidx.compose.runtime.getValue |
|
|
|
import androidx.compose.runtime.livedata.observeAsState |
|
|
|
import androidx.compose.runtime.livedata.observeAsState |
|
|
|
|
|
|
|
import androidx.compose.runtime.rememberCoroutineScope |
|
|
|
import androidx.compose.ui.Alignment |
|
|
|
import androidx.compose.ui.Alignment |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.draw.rotate |
|
|
|
import androidx.compose.ui.draw.rotate |
|
|
@ -37,6 +38,8 @@ import com.gyf.csams.ui.model.CommunityDto |
|
|
|
import com.gyf.csams.ui.model.ListViewModel |
|
|
|
import com.gyf.csams.ui.model.ListViewModel |
|
|
|
import com.gyf.csams.ui.model.MarqueeViewModel |
|
|
|
import com.gyf.csams.ui.model.MarqueeViewModel |
|
|
|
import com.gyf.csams.ui.theme.CSAMSTheme |
|
|
|
import com.gyf.csams.ui.theme.CSAMSTheme |
|
|
|
|
|
|
|
import com.orhanobut.logger.Logger |
|
|
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -68,6 +71,23 @@ fun Body() { |
|
|
|
} |
|
|
|
} |
|
|
|
composable(MainMenu.List.name) { |
|
|
|
composable(MainMenu.List.name) { |
|
|
|
CommunityList(navController = navController) |
|
|
|
CommunityList(navController = navController) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val model:ListViewModel= viewModel() |
|
|
|
|
|
|
|
val snackBarMsg:String by model.snackBarMsg.observeAsState("") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(snackBarMsg!=""){ |
|
|
|
|
|
|
|
val scope= rememberCoroutineScope() |
|
|
|
|
|
|
|
scope.launch { |
|
|
|
|
|
|
|
val result=scaffoldState.snackbarHostState.showSnackbar( |
|
|
|
|
|
|
|
message = snackBarMsg |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
model.reset() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// scope.launch { |
|
|
|
|
|
|
|
// delay(1000) |
|
|
|
|
|
|
|
// scaffoldState.snackbarHostState.currentSnackbarData?.dismiss() |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
composable(MainMenu.Center.name) { |
|
|
|
composable(MainMenu.Center.name) { |
|
|
|
Box(modifier = Modifier.fillMaxSize()) { |
|
|
|
Box(modifier = Modifier.fillMaxSize()) { |
|
|
@ -187,6 +207,8 @@ fun CommunityListBody(model: ListViewModel = viewModel()) { |
|
|
|
val communityList: MutableList<CommunityDto>? by model.communityDto.observeAsState() |
|
|
|
val communityList: MutableList<CommunityDto>? by model.communityDto.observeAsState() |
|
|
|
val listState = rememberLazyListState() |
|
|
|
val listState = rememberLazyListState() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Text(text ="communityList.size=${communityList?.size}") |
|
|
|
|
|
|
|
|
|
|
|
LazyColumn(state = listState) { |
|
|
|
LazyColumn(state = listState) { |
|
|
|
communityList?.chunked(2)?.forEach { |
|
|
|
communityList?.chunked(2)?.forEach { |
|
|
|
item{ |
|
|
|
item{ |
|
|
@ -212,9 +234,15 @@ fun CommunityListBody(model: ListViewModel = viewModel()) { |
|
|
|
.height(10.dp)) |
|
|
|
.height(10.dp)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if(listState.firstVisibleItemIndex>0){ |
|
|
|
Logger.i("totalItemsCount=${listState.layoutInfo.totalItemsCount}" + |
|
|
|
|
|
|
|
",firstVisibleItemIndex=${listState.firstVisibleItemIndex}," + |
|
|
|
|
|
|
|
"firstVisibleItemScrollOffset=${listState.firstVisibleItemScrollOffset}," + |
|
|
|
|
|
|
|
"viewportStartOffset=${listState.layoutInfo.viewportStartOffset}" + |
|
|
|
|
|
|
|
"viewportEndOffset=${listState.layoutInfo.viewportEndOffset}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(listState.layoutInfo.totalItemsCount-listState.firstVisibleItemIndex==4){ |
|
|
|
model.addMore() |
|
|
|
model.addMore() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|