换名申请表

master
pan 4 years ago
parent 9bb51bf564
commit e8dfc71a90
  1. 5
      app/src/main/AndroidManifest.xml
  2. 27
      app/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
  3. 114
      app/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
  4. 4
      app/src/main/java/com/gyf/csams/uikit/BaseView.kt
  5. 2
      app/src/main/java/com/gyf/csams/uikit/ViewModel.kt

@ -52,6 +52,11 @@
<activity android:name=".association.ui.AssociationActivity"
android:exported="true">
</activity>
<!--社团重命名主界面-->
<activity android:name=".association.ui.ReNameActivity"
android:exported="true">
</activity>
</application>
</manifest>

@ -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))
}
}

@ -337,7 +337,9 @@ enum class BackgroundImage(@DrawableRes val id:Int){
//注册社团
reg_association(R.drawable.mb_bg_fb_06),
//社团主界面
association_main(R.drawable.mb_bg_fb_25_180)
association_main(R.drawable.mb_bg_fb_25_180),
//社团重命名
rename(R.drawable.mb_bg_fb_27)
}
/**

@ -15,6 +15,8 @@ abstract class FormName<T>(val formDesc:String){
val formPlaceholder="请输入$formDesc"
abstract fun onChange(value:T)
}
/**

Loading…
Cancel
Save