|
|
|
@ -34,109 +34,139 @@ import com.gyf.csams.util.randomChinese |
|
|
|
|
import com.orhanobut.logger.Logger |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 社团界面 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
class AssociationActivity: ComponentActivity() { |
|
|
|
|
class AssociationActivity : ComponentActivity() { |
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
|
setContent { |
|
|
|
|
CSAMSTheme { |
|
|
|
|
Body { |
|
|
|
|
nav, scaffoldState -> |
|
|
|
|
val context= LocalContext.current as AssociationActivity |
|
|
|
|
val model:AssociationViewModel= viewModel() |
|
|
|
|
val currentMenuName:AssociationMenu by model.currentMenu.observeAsState(AssociationMenu.startMenu) |
|
|
|
|
val intent=Intent(context,ExamActivity::class.java) |
|
|
|
|
val expanded by model.expanded.observeAsState(false) |
|
|
|
|
Body { nav, scaffoldState -> |
|
|
|
|
val context = LocalContext.current as AssociationActivity |
|
|
|
|
val model: AssociationViewModel = viewModel() |
|
|
|
|
val currentMenuName: AssociationMenu by model.currentMenu.observeAsState( |
|
|
|
|
AssociationMenu.startMenu |
|
|
|
|
) |
|
|
|
|
val intent = Intent(context, ExamActivity::class.java) |
|
|
|
|
val expanded by model.expanded.observeAsState(false) |
|
|
|
|
|
|
|
|
|
Column { |
|
|
|
|
Logger.i("expanded=$expanded") |
|
|
|
|
TextTopAppBar(nav = nav, |
|
|
|
|
currentMenuName= currentMenuName.menuName, |
|
|
|
|
menuNames = AssociationMenu.values(), |
|
|
|
|
iconMenu = {model.switchType()}){ |
|
|
|
|
Row{ |
|
|
|
|
DropdownMenu(expanded = expanded, |
|
|
|
|
onDismissRequest = { /*TODO*/ }, |
|
|
|
|
Column { |
|
|
|
|
Logger.i("expanded=$expanded") |
|
|
|
|
TextTopAppBar(nav = nav, |
|
|
|
|
currentMenuName = currentMenuName.menuName, |
|
|
|
|
menuNames = AssociationMenu.values(), |
|
|
|
|
iconMenu = { model.switchType() }) { |
|
|
|
|
Row { |
|
|
|
|
DropdownMenu( |
|
|
|
|
expanded = expanded, |
|
|
|
|
onDismissRequest = { /*TODO*/ }, |
|
|
|
|
// offset = DpOffset.Zero.copy(x=50.dp), |
|
|
|
|
properties = PopupProperties() |
|
|
|
|
) { |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically){ |
|
|
|
|
Text(text = "申请活动") |
|
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_add_fill), contentDescription = null) |
|
|
|
|
} |
|
|
|
|
properties = PopupProperties() |
|
|
|
|
) { |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = "申请活动") |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_add_fill), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra( |
|
|
|
|
ExamActivityType::name.name, |
|
|
|
|
ExamActivityType.SET_EXAM |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
context.startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = "设置题库") |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_editor), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra(ExamActivityType::name.name, ExamActivityType.SET_EXAM) |
|
|
|
|
} |
|
|
|
|
context.startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = "设置题库") |
|
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_editor), contentDescription = null) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
context.startActivity( |
|
|
|
|
Intent( |
|
|
|
|
context, |
|
|
|
|
ReNameActivity::class.java |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = "社团命名") |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_exchange_rate), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
context.startActivity(Intent(context,ReNameActivity::class.java)) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = "社团命名") |
|
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_exchange_rate), contentDescription = null) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra( |
|
|
|
|
ExamActivityType::name.name, |
|
|
|
|
ExamActivityType.JOIN_Association |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra(ExamActivityType::name.name, ExamActivityType.JOIN_Association) |
|
|
|
|
} |
|
|
|
|
context.startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = "申请入团") |
|
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_add_account), contentDescription = null) |
|
|
|
|
} |
|
|
|
|
context.startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = "申请入团") |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_add_account), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_arrow_up), contentDescription = null, |
|
|
|
|
modifier = Modifier |
|
|
|
|
.height(30.dp) |
|
|
|
|
.fillMaxWidth()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_arrow_up), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier = Modifier |
|
|
|
|
.height(30.dp) |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
NavHost(navController = nav, startDestination = AssociationMenu.startMenu.name) { |
|
|
|
|
composable(AssociationMenu.Member.name){ |
|
|
|
|
model.clickMenu(AssociationMenu.Member) |
|
|
|
|
Member() |
|
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
|
} |
|
|
|
|
composable(AssociationMenu.Main.name){ |
|
|
|
|
model.clickMenu(AssociationMenu.Main) |
|
|
|
|
Main() |
|
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
|
} |
|
|
|
|
composable(AssociationMenu.ActivityList.name){ |
|
|
|
|
model.clickMenu(AssociationMenu.ActivityList) |
|
|
|
|
AssociationList() |
|
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
|
} |
|
|
|
|
NavHost( |
|
|
|
|
navController = nav, |
|
|
|
|
startDestination = AssociationMenu.startMenu.name |
|
|
|
|
) { |
|
|
|
|
composable(AssociationMenu.Member.name) { |
|
|
|
|
model.clickMenu(AssociationMenu.Member) |
|
|
|
|
Member() |
|
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
|
} |
|
|
|
|
composable(AssociationMenu.Main.name) { |
|
|
|
|
model.clickMenu(AssociationMenu.Main) |
|
|
|
|
Main() |
|
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
|
} |
|
|
|
|
composable(AssociationMenu.ActivityList.name) { |
|
|
|
|
model.clickMenu(AssociationMenu.ActivityList) |
|
|
|
|
AssociationList() |
|
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -149,15 +179,19 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Member(){ |
|
|
|
|
private fun Member() { |
|
|
|
|
MainFrame(background = { Background(image = BackgroundImage.AssociationMain) }) { |
|
|
|
|
val searchWeight=0.2F |
|
|
|
|
Search(modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(searchWeight)) |
|
|
|
|
MemberList(modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(1 - searchWeight)) |
|
|
|
|
val searchWeight = 0.2F |
|
|
|
|
Search( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(searchWeight) |
|
|
|
|
) |
|
|
|
|
MemberList( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(1 - searchWeight) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -167,20 +201,33 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Search(modifier:Modifier=Modifier, model: MemberViewModel= viewModel(), scaffoldModel: ScaffoldModel= viewModel()){ |
|
|
|
|
private fun Search( |
|
|
|
|
modifier: Modifier = Modifier, |
|
|
|
|
model: MemberViewModel = viewModel(), |
|
|
|
|
scaffoldModel: ScaffoldModel = viewModel() |
|
|
|
|
) { |
|
|
|
|
Column(modifier = modifier.fillMaxSize()) { |
|
|
|
|
Spacer(modifier = Modifier.weight(0.5F)) |
|
|
|
|
Row(modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(0.5F),verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Row( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(0.5F), verticalAlignment = Alignment.CenterVertically |
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
val textFieldWeight=0.4F |
|
|
|
|
val buttonWeight=0.2F |
|
|
|
|
val spaceWeight=(1-textFieldWeight-buttonWeight)/3 |
|
|
|
|
val textFieldWeight = 0.4F |
|
|
|
|
val buttonWeight = 0.2F |
|
|
|
|
val spaceWeight = (1 - textFieldWeight - buttonWeight) / 3 |
|
|
|
|
Spacer(modifier = Modifier.weight((spaceWeight))) |
|
|
|
|
BaseTextField(modifier = Modifier.weight(textFieldWeight),form = model.name,singeLine = true) |
|
|
|
|
BaseTextField( |
|
|
|
|
modifier = Modifier.weight(textFieldWeight), |
|
|
|
|
form = model.name, |
|
|
|
|
singeLine = true |
|
|
|
|
) |
|
|
|
|
Spacer(modifier = Modifier.weight(spaceWeight)) |
|
|
|
|
OutlinedButton(onClick = { model.search { scaffoldModel.update(message=it) } },modifier = Modifier.weight(buttonWeight)) { |
|
|
|
|
OutlinedButton( |
|
|
|
|
onClick = { model.search { scaffoldModel.update(message = it) } }, |
|
|
|
|
modifier = Modifier.weight(buttonWeight) |
|
|
|
|
) { |
|
|
|
|
Text(text = model.search) |
|
|
|
|
} |
|
|
|
|
Spacer(modifier = Modifier.weight(spaceWeight)) |
|
|
|
@ -193,15 +240,19 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun MemberList(modifier: Modifier=Modifier, model: MemberViewModel=viewModel(), scaffoldModel: ScaffoldModel= viewModel()){ |
|
|
|
|
val list:MutableList<MemberVo>? by model.memberList.observeAsState() |
|
|
|
|
val listState= rememberLazyListState() |
|
|
|
|
LazyColumn(state = listState,modifier = modifier) { |
|
|
|
|
private fun MemberList( |
|
|
|
|
modifier: Modifier = Modifier, |
|
|
|
|
model: MemberViewModel = viewModel(), |
|
|
|
|
scaffoldModel: ScaffoldModel = viewModel() |
|
|
|
|
) { |
|
|
|
|
val list: MutableList<MemberVo>? by model.memberList.observeAsState() |
|
|
|
|
val listState = rememberLazyListState() |
|
|
|
|
LazyColumn(state = listState, modifier = modifier) { |
|
|
|
|
list?.forEach { |
|
|
|
|
item { |
|
|
|
|
Column { |
|
|
|
|
Spacer(modifier = Modifier.height(10.dp)) |
|
|
|
|
Row{ |
|
|
|
|
Row { |
|
|
|
|
val weight = 1F / 3 |
|
|
|
|
Spacer(modifier = Modifier.weight(weight)) |
|
|
|
|
Card( |
|
|
|
@ -218,11 +269,19 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
item { |
|
|
|
|
Row(horizontalArrangement = Arrangement.Center,modifier = Modifier.fillMaxWidth()) { |
|
|
|
|
IconButton(onClick = { model.loadMore{ |
|
|
|
|
scaffoldModel.update(message=it) |
|
|
|
|
} }) { |
|
|
|
|
Icon(painter = painterResource(id = R.drawable.ic_arrow_down), contentDescription = null) |
|
|
|
|
Row( |
|
|
|
|
horizontalArrangement = Arrangement.Center, |
|
|
|
|
modifier = Modifier.fillMaxWidth() |
|
|
|
|
) { |
|
|
|
|
IconButton(onClick = { |
|
|
|
|
model.loadMore { |
|
|
|
|
scaffoldModel.update(message = it) |
|
|
|
|
} |
|
|
|
|
}) { |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_arrow_down), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -235,15 +294,17 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Main(){ |
|
|
|
|
private fun Main() { |
|
|
|
|
MainFrame(background = { |
|
|
|
|
Background(image = BackgroundImage.AssociationMain,alpha = 0.7F) |
|
|
|
|
Background(image = BackgroundImage.AssociationMain, alpha = 0.7F) |
|
|
|
|
}) { |
|
|
|
|
val nameW=0.1F |
|
|
|
|
val cardW=0.66F*0.4F |
|
|
|
|
Name(modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(nameW)) |
|
|
|
|
val nameW = 0.1F |
|
|
|
|
val cardW = 0.66F * 0.4F |
|
|
|
|
Name( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(nameW) |
|
|
|
|
) |
|
|
|
|
DescCard( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.weight(cardW) |
|
|
|
@ -253,7 +314,7 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
Commander( |
|
|
|
|
modifier = Modifier.weight(cardW) |
|
|
|
|
) |
|
|
|
|
Showcase(modifier = Modifier.weight(1F-nameW-cardW-cardW)) |
|
|
|
|
Showcase(modifier = Modifier.weight(1F - nameW - cardW - cardW)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -263,20 +324,22 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* @param modifier |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Name(modifier: Modifier){ |
|
|
|
|
private fun Name(modifier: Modifier) { |
|
|
|
|
Box(modifier = modifier) { |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.association_name_border), |
|
|
|
|
contentDescription = null, |
|
|
|
|
contentScale = ContentScale.FillBounds, |
|
|
|
|
modifier=Modifier.fillMaxSize() |
|
|
|
|
modifier = Modifier.fillMaxSize() |
|
|
|
|
) |
|
|
|
|
Column{ |
|
|
|
|
Column { |
|
|
|
|
Spacer(modifier = Modifier.weight(1.7F / 3)) |
|
|
|
|
Row(modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(1F / 3), |
|
|
|
|
horizontalArrangement = Arrangement.Center) { |
|
|
|
|
Row( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(1F / 3), |
|
|
|
|
horizontalArrangement = Arrangement.Center |
|
|
|
|
) { |
|
|
|
|
Text(text = "社团名字") |
|
|
|
|
} |
|
|
|
|
Spacer(modifier = Modifier.weight(0.3F / 3)) |
|
|
|
@ -290,11 +353,12 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* @param modifier |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Commander(modifier: Modifier){ |
|
|
|
|
Box(modifier=modifier,contentAlignment = Alignment.Center){ |
|
|
|
|
Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.Center) { |
|
|
|
|
private fun Commander(modifier: Modifier) { |
|
|
|
|
Box(modifier = modifier, contentAlignment = Alignment.Center) { |
|
|
|
|
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) { |
|
|
|
|
|
|
|
|
|
Image(painter = painterResource(id = R.drawable.persion_name_border), |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.persion_name_border), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
@ -308,12 +372,17 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* @param modifier |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Showcase(modifier: Modifier){ |
|
|
|
|
Box(modifier = modifier,contentAlignment = Alignment.Center) { |
|
|
|
|
Image(painter = painterResource(id = R.drawable.showcase_border), |
|
|
|
|
private fun Showcase(modifier: Modifier) { |
|
|
|
|
Box(modifier = modifier, contentAlignment = Alignment.Center) { |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.showcase_border), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier=Modifier.fillMaxSize()) |
|
|
|
|
Image(painter = painterResource(id = R.drawable.ic_launcher_foreground), contentDescription = null) |
|
|
|
|
modifier = Modifier.fillMaxSize() |
|
|
|
|
) |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_launcher_foreground), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -322,16 +391,25 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun AssociationList(){ |
|
|
|
|
MainFrame(background = { Background(image = BackgroundImage.AssociationMain,alpha = 07F) }) { |
|
|
|
|
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)) |
|
|
|
|
private fun AssociationList() { |
|
|
|
|
MainFrame(background = { |
|
|
|
|
Background( |
|
|
|
|
image = BackgroundImage.AssociationMain, |
|
|
|
|
alpha = 07F |
|
|
|
|
) |
|
|
|
|
}) { |
|
|
|
|
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) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -340,16 +418,19 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun OngoingActivity(modifier: Modifier=Modifier,model:OngoingActViewModel= viewModel()){ |
|
|
|
|
val context= LocalContext.current |
|
|
|
|
private fun OngoingActivity( |
|
|
|
|
modifier: Modifier = Modifier, |
|
|
|
|
model: OngoingActViewModel = viewModel() |
|
|
|
|
) { |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
val act by model.act.observeAsState() |
|
|
|
|
Row(modifier = modifier.clickable(onClick = { |
|
|
|
|
context.startActivity(Intent(context,ActivityDetailActivity::class.java)) |
|
|
|
|
}),horizontalArrangement = Arrangement.Center) { |
|
|
|
|
val weight=0.5F |
|
|
|
|
val spaceWeight=(1-0.5F)/2 |
|
|
|
|
context.startActivity(Intent(context, ActivityDetailActivity::class.java)) |
|
|
|
|
}), 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)) |
|
|
|
|
Poster(id = R.drawable.ic_launcher_foreground, modifier = Modifier.weight(weight)) |
|
|
|
|
Spacer(modifier = Modifier.weight(spaceWeight)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -361,16 +442,20 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* @param modifier |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun HistoryActivityList(modifier: Modifier,model:HistoryActViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()){ |
|
|
|
|
val listState= rememberLazyListState() |
|
|
|
|
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) { |
|
|
|
|
LazyColumn(state = listState, modifier = modifier) { |
|
|
|
|
list?.chunked(2)?.forEach { |
|
|
|
|
item { |
|
|
|
|
Row(modifier=Modifier.fillMaxWidth()) { |
|
|
|
|
HistoryActivity(modifier = Modifier.weight(0.4F),it[0]) |
|
|
|
|
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]) |
|
|
|
|
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)) |
|
|
|
@ -378,8 +463,8 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(listState.layoutInfo.totalItemsCount-listState.firstVisibleItemIndex==model.initSize/2-1){ |
|
|
|
|
model.loadMore { scaffoldModel.update(message=it) } |
|
|
|
|
if (listState.layoutInfo.totalItemsCount - listState.firstVisibleItemIndex == model.initSize / 2 - 1) { |
|
|
|
|
model.loadMore { scaffoldModel.update(message = it) } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -389,17 +474,21 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
* @param modifier |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun HistoryActivity(modifier: Modifier,historyActVo: HistoryActVo){ |
|
|
|
|
val context= LocalContext.current |
|
|
|
|
Box(modifier=modifier.clickable(onClick = { |
|
|
|
|
context.startActivity(Intent(context,ActivityDetailActivity::class.java)) |
|
|
|
|
}),contentAlignment = Alignment.Center){ |
|
|
|
|
Image(painter = painterResource(id = R.drawable.history_activity_border), |
|
|
|
|
private fun HistoryActivity(modifier: Modifier, historyActVo: HistoryActVo) { |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
Box(modifier = modifier.clickable(onClick = { |
|
|
|
|
context.startActivity(Intent(context, ActivityDetailActivity::class.java)) |
|
|
|
|
}), 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), |
|
|
|
|
modifier = Modifier.fillMaxSize() |
|
|
|
|
) |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_launcher_foreground), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier = Modifier.fillMaxSize()) |
|
|
|
|
modifier = Modifier.fillMaxSize() |
|
|
|
|
) |
|
|
|
|
Text(text = historyActVo.name) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -407,7 +496,7 @@ class AssociationActivity: ComponentActivity() { |
|
|
|
|
|
|
|
|
|
@Preview |
|
|
|
|
@Composable |
|
|
|
|
fun NamePreview(){ |
|
|
|
|
fun NamePreview() { |
|
|
|
|
Divider(color = MaterialTheme.colors.background) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|