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