You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.6 KiB
117 lines
3.6 KiB
package com.gyf.csams.association.ui
|
|
|
|
import android.os.Bundle
|
|
import androidx.activity.ComponentActivity
|
|
import androidx.activity.compose.setContent
|
|
import androidx.compose.foundation.layout.*
|
|
import androidx.compose.material.MaterialTheme
|
|
import androidx.compose.material.OutlinedButton
|
|
import androidx.compose.material.Text
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
import com.gyf.csams.association.model.RenameViewModel
|
|
import com.gyf.csams.uikit.*
|
|
|
|
/**
|
|
* 社团重命名
|
|
*
|
|
*/
|
|
class ReNameActivity : ComponentActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContent {
|
|
Body { scaffoldState ->
|
|
MainFrame(background = { Background(image = BackgroundImage.Rename) }) {
|
|
Spacer(
|
|
modifier = Modifier
|
|
.weight(0.2F)
|
|
)
|
|
Title(modifier = Modifier.weight(0.1F))
|
|
|
|
OldName(modifier = Modifier.weight(0.1F))
|
|
|
|
NewName(modifier = Modifier.weight(0.1F))
|
|
|
|
Cause(modifier = Modifier.weight(0.2F))
|
|
|
|
Spacer(modifier = Modifier.height(10.dp))
|
|
BottomButton(modifier = Modifier.weight(0.1F))
|
|
|
|
Spacer(modifier = Modifier.weight(1 - 0.2F * 2 - 0.1F * 4))
|
|
ShowSnackbar(scaffoldState = scaffoldState)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 标题
|
|
*
|
|
*/
|
|
@Composable
|
|
private fun Title(modifier: Modifier = Modifier, model: RenameViewModel = viewModel()) {
|
|
Row(modifier = modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
|
Text(text = model.menuName, style = MaterialTheme.typography.h4)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 社团原名
|
|
*
|
|
*/
|
|
@Composable
|
|
private fun OldName(modifier: Modifier = Modifier, model: RenameViewModel = viewModel()) {
|
|
BaseTextField(form = model.oldName, modifier = modifier.fillMaxWidth(), singeLine = true)
|
|
}
|
|
|
|
/**
|
|
* 社团新名
|
|
*
|
|
*/
|
|
@Composable
|
|
private fun NewName(modifier: Modifier = Modifier, model: RenameViewModel = viewModel()) {
|
|
BaseTextField(form = model.newName, modifier = modifier.fillMaxWidth(), singeLine = true)
|
|
}
|
|
|
|
/**
|
|
* 换名原因
|
|
*
|
|
*/
|
|
@Composable
|
|
private fun Cause(modifier: Modifier = Modifier, model: RenameViewModel = viewModel()) {
|
|
BaseTextField(form = model.cause, modifier = modifier.fillMaxWidth())
|
|
}
|
|
|
|
/**
|
|
* 操作按钮
|
|
*
|
|
* @param modifier
|
|
* @param model
|
|
*/
|
|
@Composable
|
|
private fun BottomButton(
|
|
modifier: Modifier = Modifier,
|
|
model: RenameViewModel = viewModel(),
|
|
scaffoldModel: ScaffoldModel = viewModel()
|
|
) {
|
|
Row(modifier = modifier.fillMaxWidth()) {
|
|
val weight = (1 - 0.5F) / 2
|
|
val context = LocalContext.current as ReNameActivity
|
|
Spacer(modifier = Modifier.weight(weight))
|
|
Row(modifier = Modifier.weight(0.5F)) {
|
|
OutlinedButton(onClick = { model.post { scaffoldModel.update(message = it) } }) {
|
|
Text(text = model.postDesc)
|
|
}
|
|
Spacer(modifier = Modifier.width(10.dp))
|
|
OutlinedButton(onClick = { context.onBackPressed() }) {
|
|
Text(text = model.back)
|
|
}
|
|
}
|
|
Spacer(modifier = Modifier.weight(weight))
|
|
}
|
|
}
|
|
} |