|
|
|
@ -12,12 +12,12 @@ import androidx.compose.foundation.lazy.LazyColumn |
|
|
|
|
import androidx.compose.foundation.lazy.rememberLazyListState |
|
|
|
|
import androidx.compose.material.* |
|
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
|
import androidx.compose.runtime.LaunchedEffect |
|
|
|
|
import androidx.compose.runtime.getValue |
|
|
|
|
import androidx.compose.runtime.livedata.observeAsState |
|
|
|
|
import androidx.compose.ui.Alignment |
|
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
|
import androidx.compose.ui.layout.ContentScale |
|
|
|
|
import androidx.compose.ui.platform.LocalContext |
|
|
|
|
import androidx.compose.ui.res.painterResource |
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview |
|
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
@ -33,7 +33,6 @@ import com.gyf.csams.uikit.* |
|
|
|
|
import com.gyf.lib.uikit.* |
|
|
|
|
import com.gyf.lib.util.HistoryActVo |
|
|
|
|
import com.gyf.lib.util.MemberVo |
|
|
|
|
import com.gyf.lib.util.randomChinese |
|
|
|
|
import com.orhanobut.logger.Logger |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -42,137 +41,150 @@ import com.orhanobut.logger.Logger |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
class AssociationActivity : ComponentActivity() { |
|
|
|
|
|
|
|
|
|
val associationId: Int |
|
|
|
|
get() { |
|
|
|
|
val id = intent.getIntExtra( |
|
|
|
|
AssociationActivity::javaClass.name, |
|
|
|
|
0 |
|
|
|
|
) |
|
|
|
|
return if (id == 0) throw IllegalArgumentException("社团id:${id}不合法,初始化失败") else id |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
|
setContent { |
|
|
|
|
|
|
|
|
|
NavBody { 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 intent = Intent(this, 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*/ }, |
|
|
|
|
properties = PopupProperties() |
|
|
|
|
) { |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
startActivity(Intent(context, ApplyActActivity::class.java)) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.apply_act_menu)) |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_add_fill), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
TextTopAppBar(nav = nav, |
|
|
|
|
currentMenuName = currentMenuName.menuName, |
|
|
|
|
menuNames = AssociationMenu.values(), |
|
|
|
|
iconMenu = { model.switchType() }) { |
|
|
|
|
Row { |
|
|
|
|
DropdownMenu( |
|
|
|
|
expanded = expanded, |
|
|
|
|
onDismissRequest = { }, |
|
|
|
|
properties = PopupProperties() |
|
|
|
|
) { |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
startActivity( |
|
|
|
|
Intent( |
|
|
|
|
this@AssociationActivity, |
|
|
|
|
ApplyActActivity::class.java |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.apply_act_menu)) |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_add_fill), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra( |
|
|
|
|
ExamActivityType::name.name, |
|
|
|
|
ExamActivityType.SET_EXAM |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.set_exam_menu)) |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_editor), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra( |
|
|
|
|
ExamActivityType::name.name, |
|
|
|
|
ExamActivityType.SET_EXAM |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
startActivity( |
|
|
|
|
Intent( |
|
|
|
|
context, |
|
|
|
|
ReNameActivity::class.java |
|
|
|
|
) |
|
|
|
|
startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.set_exam_menu)) |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_editor), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.rename_menu)) |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_exchange_rate), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra( |
|
|
|
|
ExamActivityType::name.name, |
|
|
|
|
ExamActivityType.JOIN_Association |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.join_association)) |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_add_account), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DropdownMenuItem(onClick = { |
|
|
|
|
startActivity( |
|
|
|
|
Intent( |
|
|
|
|
this@AssociationActivity, |
|
|
|
|
ReNameActivity::class.java |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.rename_menu)) |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_exchange_rate), |
|
|
|
|
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 = { |
|
|
|
|
intent.apply { |
|
|
|
|
putExtra( |
|
|
|
|
ExamActivityType::name.name, |
|
|
|
|
ExamActivityType.JOIN_Association |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
startActivity(intent) |
|
|
|
|
model.close() |
|
|
|
|
}) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(text = getString(R.string.join_association)) |
|
|
|
|
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() |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -297,7 +309,10 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Main() { |
|
|
|
|
private fun Main(model: AssociationViewModel = viewModel()) { |
|
|
|
|
LaunchedEffect(associationId) { |
|
|
|
|
model.load(associationId) |
|
|
|
|
} |
|
|
|
|
MainColumnFrame(background = { |
|
|
|
|
Background(image = BackgroundImage.AssociationMain, alpha = 0.7F) |
|
|
|
|
}) { |
|
|
|
@ -308,12 +323,15 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.weight(nameW) |
|
|
|
|
) |
|
|
|
|
DescCard( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.weight(cardW) |
|
|
|
|
.fillMaxWidth(), |
|
|
|
|
content = randomChinese(500) |
|
|
|
|
) |
|
|
|
|
val associationVo by model.associationVo.observeAsState() |
|
|
|
|
associationVo?.associationVo?.desc?.let { |
|
|
|
|
DescCard( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.weight(cardW) |
|
|
|
|
.fillMaxWidth(), |
|
|
|
|
content = it |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
Commander( |
|
|
|
|
modifier = Modifier.weight(cardW) |
|
|
|
|
) |
|
|
|
@ -327,7 +345,8 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
* @param modifier |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Name(modifier: Modifier) { |
|
|
|
|
private fun Name(modifier: Modifier, model: AssociationViewModel = viewModel()) { |
|
|
|
|
val associationVo by model.associationVo.observeAsState() |
|
|
|
|
Box(modifier = modifier) { |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.association_name_border), |
|
|
|
@ -343,7 +362,7 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
.weight(1F / 3), |
|
|
|
|
horizontalArrangement = Arrangement.Center |
|
|
|
|
) { |
|
|
|
|
Text(text = "社团名字") |
|
|
|
|
associationVo?.associationVo?.name?.let { Text(text = it) } |
|
|
|
|
} |
|
|
|
|
Spacer(modifier = Modifier.weight(0.3F / 3)) |
|
|
|
|
} |
|
|
|
@ -356,7 +375,7 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
* @param modifier |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Commander(modifier: Modifier) { |
|
|
|
|
private fun Commander(modifier: Modifier, model: AssociationViewModel = viewModel()) { |
|
|
|
|
Box(modifier = modifier, contentAlignment = Alignment.Center) { |
|
|
|
|
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) { |
|
|
|
|
|
|
|
|
@ -365,7 +384,11 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
Text(text = "团长") |
|
|
|
|
val info by model.associationVo.observeAsState() |
|
|
|
|
info?.head?.let { |
|
|
|
|
Text(text = it.name) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -425,12 +448,11 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
modifier: Modifier = Modifier, |
|
|
|
|
model: OngoingActViewModel = viewModel() |
|
|
|
|
) { |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
val act by model.act.observeAsState() |
|
|
|
|
// TODO 解决Build Warnning |
|
|
|
|
Logger.i("$act") |
|
|
|
|
Row(modifier = modifier.clickable(onClick = { |
|
|
|
|
context.startActivity(Intent(context, ActivityDetailActivity::class.java)) |
|
|
|
|
startActivity(Intent(this, ActivityDetailActivity::class.java)) |
|
|
|
|
}), horizontalArrangement = Arrangement.Center) { |
|
|
|
|
val weight = 0.5F |
|
|
|
|
val spaceWeight = (1 - 0.5F) / 2 |
|
|
|
@ -480,9 +502,8 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun HistoryActivity(modifier: Modifier, historyActVo: HistoryActVo) { |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
Box(modifier = modifier.clickable(onClick = { |
|
|
|
|
context.startActivity(Intent(context, ActivityDetailActivity::class.java)) |
|
|
|
|
startActivity(Intent(this, ActivityDetailActivity::class.java)) |
|
|
|
|
}), contentAlignment = Alignment.Center) { |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.history_activity_border), |
|
|
|
@ -508,3 +529,4 @@ class AssociationActivity : ComponentActivity() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|