parent
9bb51bf564
commit
e8dfc71a90
@ -0,0 +1,27 @@ |
||||
package com.gyf.csams.association.model |
||||
|
||||
import androidx.lifecycle.ViewModel |
||||
import com.gyf.csams.uikit.StringForm |
||||
|
||||
/** |
||||
* 社团重命名状态管理 |
||||
* |
||||
*/ |
||||
class RenameViewModel:ViewModel() { |
||||
val menuName="换名申请表" |
||||
|
||||
val oldName=StringForm(formDesc = "社团原名",textLength = 10) |
||||
val newName=StringForm(formDesc = "社团新名",textLength = 10) |
||||
val cause=StringForm(formDesc = "换名原因",textLength = 30) |
||||
|
||||
val postDesc="提交申请" |
||||
val back="返回" |
||||
|
||||
/** |
||||
* TODO 提交表单 |
||||
* |
||||
*/ |
||||
fun post(callback:(message:String) -> Unit){ |
||||
callback("功能尚未实现,敬请期待") |
||||
} |
||||
} |
@ -0,0 +1,114 @@ |
||||
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(it)} }) { |
||||
Text(text = model.postDesc) |
||||
} |
||||
Spacer(modifier = Modifier.width(10.dp)) |
||||
OutlinedButton(onClick = { context.onBackPressed() }) { |
||||
Text(text = model.back) |
||||
} |
||||
} |
||||
Spacer(modifier = Modifier.weight(weight)) |
||||
} |
||||
} |
Loading…
Reference in new issue