|
|
@ -4,6 +4,7 @@ import android.os.Bundle |
|
|
|
import androidx.activity.ComponentActivity |
|
|
|
import androidx.activity.ComponentActivity |
|
|
|
import androidx.activity.compose.setContent |
|
|
|
import androidx.activity.compose.setContent |
|
|
|
import androidx.compose.foundation.Image |
|
|
|
import androidx.compose.foundation.Image |
|
|
|
|
|
|
|
import androidx.compose.foundation.border |
|
|
|
import androidx.compose.foundation.layout.* |
|
|
|
import androidx.compose.foundation.layout.* |
|
|
|
import androidx.compose.foundation.lazy.LazyColumn |
|
|
|
import androidx.compose.foundation.lazy.LazyColumn |
|
|
|
import androidx.compose.foundation.lazy.rememberLazyListState |
|
|
|
import androidx.compose.foundation.lazy.rememberLazyListState |
|
|
@ -22,9 +23,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel |
|
|
|
import androidx.navigation.compose.NavHost |
|
|
|
import androidx.navigation.compose.NavHost |
|
|
|
import androidx.navigation.compose.composable |
|
|
|
import androidx.navigation.compose.composable |
|
|
|
import com.gyf.csams.R |
|
|
|
import com.gyf.csams.R |
|
|
|
import com.gyf.csams.association.model.AssociationViewModel |
|
|
|
import com.gyf.csams.association.model.* |
|
|
|
import com.gyf.csams.association.model.MemberViewModel |
|
|
|
|
|
|
|
import com.gyf.csams.association.model.MemberVo |
|
|
|
|
|
|
|
import com.gyf.csams.uikit.* |
|
|
|
import com.gyf.csams.uikit.* |
|
|
|
import com.gyf.csams.uikit.theme.CSAMSTheme |
|
|
|
import com.gyf.csams.uikit.theme.CSAMSTheme |
|
|
|
|
|
|
|
|
|
|
@ -46,7 +45,7 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
|
|
|
|
|
|
|
Column { |
|
|
|
Column { |
|
|
|
AssociationAppBar(menu = menu,nav = nav,back = { context.onBackPressed() }){ |
|
|
|
AssociationAppBar(menu = menu,nav = nav,back = { context.onBackPressed() }){ |
|
|
|
|
|
|
|
//TODO 显示下拉菜单 |
|
|
|
} |
|
|
|
} |
|
|
|
NavHost(navController = nav, startDestination = startMenu.name) { |
|
|
|
NavHost(navController = nav, startDestination = startMenu.name) { |
|
|
|
composable(AssociationMenu.member.name){ |
|
|
|
composable(AssociationMenu.member.name){ |
|
|
@ -122,8 +121,8 @@ private fun Search(modifier:Modifier=Modifier, model: MemberViewModel= viewModel |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun MemberList(modifier: Modifier=Modifier,viewModel: MemberViewModel=viewModel()){ |
|
|
|
private fun MemberList(modifier: Modifier=Modifier, model: MemberViewModel=viewModel(), scaffoldModel: ScaffoldModel= viewModel()){ |
|
|
|
val list:MutableList<MemberVo>? by viewModel.memberList.observeAsState() |
|
|
|
val list:MutableList<MemberVo>? by model.memberList.observeAsState() |
|
|
|
val listState= rememberLazyListState() |
|
|
|
val listState= rememberLazyListState() |
|
|
|
LazyColumn(state = listState,modifier = modifier) { |
|
|
|
LazyColumn(state = listState,modifier = modifier) { |
|
|
|
list?.forEach { |
|
|
|
list?.forEach { |
|
|
@ -148,7 +147,9 @@ private fun MemberList(modifier: Modifier=Modifier,viewModel: MemberViewModel=vi |
|
|
|
} |
|
|
|
} |
|
|
|
item { |
|
|
|
item { |
|
|
|
Row(horizontalArrangement = Arrangement.Center,modifier = Modifier.fillMaxWidth()) { |
|
|
|
Row(horizontalArrangement = Arrangement.Center,modifier = Modifier.fillMaxWidth()) { |
|
|
|
IconButton(onClick = { viewModel.loadMore() }) { |
|
|
|
IconButton(onClick = { model.loadMore{ |
|
|
|
|
|
|
|
scaffoldModel.update(it) |
|
|
|
|
|
|
|
} }) { |
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_arrow_down), contentDescription = null) |
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_arrow_down), contentDescription = null) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -250,7 +251,77 @@ private fun Showcase(modifier: Modifier){ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun AssociationList(){ |
|
|
|
private fun AssociationList(){ |
|
|
|
MainFrame(background = { Background(image = BackgroundImage.association_main,alpha = 07F) }) { |
|
|
|
MainFrame(background = { Background(image = BackgroundImage.association_main,alpha = 07F) }) { |
|
|
|
Text(text = "活动列表") |
|
|
|
val onGoWeight=0.3F |
|
|
|
|
|
|
|
OngoingActivity(modifier = Modifier |
|
|
|
|
|
|
|
.weight(onGoWeight) |
|
|
|
|
|
|
|
.fillMaxWidth()) |
|
|
|
|
|
|
|
HistoryActivityList(modifier = Modifier |
|
|
|
|
|
|
|
.fillMaxWidth() |
|
|
|
|
|
|
|
.weight(1 - onGoWeight) |
|
|
|
|
|
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 进行中的活动 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
private fun OngoingActivity(modifier: Modifier=Modifier){ |
|
|
|
|
|
|
|
Row(modifier = modifier,horizontalArrangement = Arrangement.Center) { |
|
|
|
|
|
|
|
val weight=0.5F |
|
|
|
|
|
|
|
val spaceWeight=(1-0.5F)/2 |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.weight(spaceWeight)) |
|
|
|
|
|
|
|
Poster(id = R.drawable.ic_launcher_foreground,modifier = Modifier.weight(weight)) |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.weight(spaceWeight)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 历史活动列表 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param modifier |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
private fun HistoryActivityList(modifier: Modifier,model:HistoryActViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()){ |
|
|
|
|
|
|
|
val listState= rememberLazyListState() |
|
|
|
|
|
|
|
val list by model.data.observeAsState() |
|
|
|
|
|
|
|
LazyColumn(state = listState,modifier = modifier) { |
|
|
|
|
|
|
|
list?.chunked(2)?.forEach { |
|
|
|
|
|
|
|
item { |
|
|
|
|
|
|
|
Row(modifier=Modifier.fillMaxWidth()) { |
|
|
|
|
|
|
|
HistoryActivity(modifier = Modifier.weight(0.4F),it[0]) |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.weight(0.2F)) |
|
|
|
|
|
|
|
if (it.size==2) HistoryActivity(modifier = Modifier.weight(0.4F),it[1]) |
|
|
|
|
|
|
|
else Box(modifier = Modifier.weight(0.4F)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.height(10.dp)) |
|
|
|
|
|
|
|
Divider(color = MaterialTheme.colors.background) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(listState.layoutInfo.totalItemsCount-listState.firstVisibleItemIndex==model.initSize/2-1){ |
|
|
|
|
|
|
|
model.loadMore { scaffoldModel.update(it) } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 历史活动 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param modifier |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
private fun HistoryActivity(modifier: Modifier,historyActVo: HistoryActVo){ |
|
|
|
|
|
|
|
Box(modifier=modifier,contentAlignment = Alignment.Center){ |
|
|
|
|
|
|
|
Image(painter = painterResource(id = R.drawable.history_activity_border), |
|
|
|
|
|
|
|
contentDescription = null, |
|
|
|
|
|
|
|
modifier = Modifier.fillMaxSize()) |
|
|
|
|
|
|
|
Image(painter = painterResource(id = R.drawable.ic_launcher_foreground), |
|
|
|
|
|
|
|
contentDescription = null, |
|
|
|
|
|
|
|
modifier = Modifier.fillMaxSize()) |
|
|
|
|
|
|
|
Text(text = historyActVo.name) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|