From e8dfc71a902745670af4e58735372b951f451cc6 Mon Sep 17 00:00:00 2001
From: pan <1029559041@qq.com>
Date: Fri, 14 May 2021 23:22:55 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8D=A2=E5=90=8D=E7=94=B3=E8=AF=B7=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 5 +
.../association/model/RenameViewModel.kt | 27 +++++
.../csams/association/ui/ReNameActivity.kt | 114 ++++++++++++++++++
.../main/java/com/gyf/csams/uikit/BaseView.kt | 4 +-
.../java/com/gyf/csams/uikit/ViewModel.kt | 2 +
5 files changed, 151 insertions(+), 1 deletion(-)
create mode 100644 app/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
create mode 100644 app/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8e65dff..6c4db7e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -52,6 +52,11 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt b/app/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
new file mode 100644
index 0000000..08e3db3
--- /dev/null
+++ b/app/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
@@ -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("功能尚未实现,敬请期待")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt b/app/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
new file mode 100644
index 0000000..5b858b4
--- /dev/null
+++ b/app/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
@@ -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))
+ }
+}
diff --git a/app/src/main/java/com/gyf/csams/uikit/BaseView.kt b/app/src/main/java/com/gyf/csams/uikit/BaseView.kt
index 42084c5..ce579d8 100644
--- a/app/src/main/java/com/gyf/csams/uikit/BaseView.kt
+++ b/app/src/main/java/com/gyf/csams/uikit/BaseView.kt
@@ -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)
}
/**
diff --git a/app/src/main/java/com/gyf/csams/uikit/ViewModel.kt b/app/src/main/java/com/gyf/csams/uikit/ViewModel.kt
index 407ee1a..10c9c31 100644
--- a/app/src/main/java/com/gyf/csams/uikit/ViewModel.kt
+++ b/app/src/main/java/com/gyf/csams/uikit/ViewModel.kt
@@ -15,6 +15,8 @@ abstract class FormName(val formDesc:String){
val formPlaceholder="请输入$formDesc"
abstract fun onChange(value:T)
+
+
}
/**