社团换名申请表

社团信息管理
master
pan 4 years ago
parent a68a79ddb5
commit 531c022328
  1. 21
      background/src/main/AndroidManifest.xml
  2. 11
      background/src/main/java/com/gyf/csams/main/model/MainViewModel.kt
  3. 8
      background/src/main/java/com/gyf/csams/main/model/MenuViewModel.kt
  4. 59
      background/src/main/java/com/gyf/csams/main/model/RenameViewModel.kt
  5. 16
      background/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
  6. 146
      background/src/main/java/com/gyf/csams/main/ui/RenameActivity.kt
  7. 16
      lib/src/main/java/com/gyf/lib/ScrollList.kt
  8. 8
      lib/src/main/res/values-en/strings.xml
  9. 8
      lib/src/main/res/values-zh/strings.xml
  10. 8
      lib/src/main/res/values/strings.xml

@ -23,21 +23,12 @@
</intent-filter>
</activity>
<activity
android:name=".main.ui.MainActivity"
android:exported="true" />
<activity
android:name=".main.ui.DepartmentActivity"
android:exported="true" />
<activity
android:name=".main.ui.ManagementOfficerActivity"
android:exported="true" />
<activity
android:name=".main.ui.AssociationManagementActivity"
android:exported="true" />
<activity
android:name=".main.ui.MenuActivity"
android:exported="true" />
<activity android:name=".main.ui.MainActivity" />
<activity android:name=".main.ui.DepartmentActivity" />
<activity android:name=".main.ui.ManagementOfficerActivity" />
<activity android:name=".main.ui.AssociationManagementActivity" />
<activity android:name=".main.ui.MenuActivity" />
<activity android:name=".main.ui.RenameActivity" />
</application>
</manifest>

@ -6,6 +6,17 @@ import androidx.lifecycle.ViewModel
import com.gyf.lib.uikit.PersonInfoVo
import com.gyf.lib.util.randomChinese
object LocalToken {
lateinit var token: String
lateinit var infoVo: PersonInfoVo
fun register(token: String, infoVo: PersonInfoVo) {
this.token = token
this.infoVo = infoVo
}
}
/**
* 部长
*

@ -3,11 +3,17 @@ package com.gyf.csams.main.model
import android.app.Activity
import androidx.lifecycle.ViewModel
import com.gyf.csams.main.ui.AssociationManagementActivity
import com.gyf.csams.main.ui.RenameActivity
enum class MenuType(val desc: String, val clazz: Map<String, Class<out Activity>>) {
//老师
//总部长
Association("社团管理", mapOf("社团信息管理" to AssociationManagementActivity::class.java))
Association(
"社团管理", mapOf(
"社团信息管理" to AssociationManagementActivity::class.java,
"审核换名申请表" to RenameActivity::class.java
)
)
}
class MenuViewModel : ViewModel() {

@ -0,0 +1,59 @@
package com.gyf.csams.main.model
import android.app.Application
import androidx.lifecycle.viewModelScope
import com.gyf.csams.R
import com.gyf.lib.ScrollListW
import com.gyf.lib.uikit.StringForm
import com.gyf.lib.util.randomChinese
import com.gyf.lib.util.randomNum
import kotlinx.coroutines.launch
/**
* 换名申请表
*
* @property studentId 学号
* @property oldName 社团原名
* @property newName 社团新名
* @property reason 申请理由
*/
data class RenameVo(
val studentId: String,
val oldName: String,
val newName: String,
val reason: String
)
class RenameViewModel(application: Application) : ScrollListW<RenameVo>(application) {
val approverOrigin =
StringForm(formDesc = application.getString(R.string.approver_origin), textLength = 30)
override val initSize: Int = 10
init {
load()
}
override fun load() {
viewModelScope.launch {
_data.value?.apply {
repeat(initSize) {
add(
RenameVo(
studentId = randomNum(8),
oldName = randomChinese(5),
newName = randomChinese(5),
reason = randomChinese(10)
)
)
}
}
}
}
override fun loadMore(callback: (message: String) -> Unit) {
TODO("Not yet implemented")
}
}

@ -10,19 +10,16 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.OutlinedButton
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.gyf.csams.R
import com.gyf.csams.main.model.MainViewModel
import com.gyf.csams.main.model.MenuType
import com.gyf.lib.uikit.*
import com.gyf.lib.uikit.theme.CSAMSTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@ -68,16 +65,3 @@ class MainActivity : ComponentActivity() {
}
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
CSAMSTheme {
Greeting("Android")
}
}

@ -0,0 +1,146 @@
package com.gyf.csams.main.ui
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.annotation.StringRes
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.gyf.csams.R
import com.gyf.csams.main.model.RenameViewModel
import com.gyf.csams.main.model.RenameVo
import com.gyf.lib.uikit.BaseTextField
import com.gyf.lib.uikit.BodyS
import com.gyf.lib.uikit.MainColumnFrame
import com.gyf.lib.uikit.ScaffoldModel
import com.gyf.lib.util.BottomButton
class RenameActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BodyS {
MainColumnFrame(background = { /*TODO*/ }) {
val listState = rememberLazyListState()
val model: RenameViewModel = viewModel()
val data by model.data.observeAsState()
Row(
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxWidth()
.padding(10.dp)
) {
Text(
text = stringResource(id = R.string.rename_form),
style = MaterialTheme.typography.h4
)
}
LazyColumn(state = listState) {
data?.forEach {
item {
RenameForm(renameVo = it)
Spacer(modifier = Modifier.height(10.dp))
}
}
}
}
}
}
}
@Composable
private fun RenameForm(modifier: Modifier = Modifier, renameVo: RenameVo) {
val model: RenameViewModel = viewModel()
val scaffoldModel: ScaffoldModel = viewModel()
Column(modifier = modifier) {
val baseHeight = 50.dp
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.petitioner,
value = renameVo.studentId
)
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.oldname,
value = renameVo.oldName
)
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.newname,
value = renameVo.newName
)
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.reason_for_application,
value = renameVo.reason
)
RowItem(
modifier = Modifier.height(baseHeight), key = R.string.approver, value = ""
/**TODO 获取审批人**/
)
RowItem(modifier = Modifier.height(baseHeight * 3), key = R.string.approver_origin) {
BaseTextField(modifier = Modifier.fillMaxSize(), form = model.approverOrigin)
}
val message = stringResource(id = R.string.not_impl_error)
BottomButton(modifier = Modifier.fillMaxWidth()) {
scaffoldModel.update(message = message)
}
}
}
@Composable
private fun RowItem(
modifier: Modifier = Modifier,
@StringRes key: Int,
value: String? = null,
content: (@Composable () -> Unit)? = null
) {
Row(
modifier = modifier
.fillMaxWidth()
.border(width = 1.dp, color = Color.Black)
) {
Cell(
modifier = Modifier.weight(0.5F),
value = stringResource(id = key)
)
Cell(modifier = Modifier.weight(0.5F), value = value, content = content)
}
}
@Composable
private fun Cell(
modifier: Modifier = Modifier,
value: String? = null,
content: (@Composable () -> Unit)? = null
) {
Box(
modifier = modifier
.fillMaxSize()
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
contentAlignment = Alignment.Center
) {
if (content != null) content() else Text(
text = value ?: throw IllegalArgumentException(
"参数错误"
)
)
}
}
}

@ -1,9 +1,12 @@
package com.gyf.lib
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
@Deprecated(message = "", replaceWith = ReplaceWith(""))
abstract class ScrollList<T> : ViewModel() {
protected val _data = MutableLiveData<MutableList<T>>(mutableListOf())
val data: LiveData<MutableList<T>> = _data
@ -16,3 +19,16 @@ abstract class ScrollList<T> : ViewModel() {
//加载更多数据
abstract fun loadMore(callback: (message: String) -> Unit)
}
abstract class ScrollListW<T>(application: Application) : AndroidViewModel(application) {
protected val _data = MutableLiveData<MutableList<T>>(mutableListOf())
val data: LiveData<MutableList<T>> = _data
abstract val initSize: Int
//加载列表
abstract fun load()
//加载更多数据
abstract fun loadMore(callback: (message: String) -> Unit)
}

@ -12,4 +12,12 @@
<string name="activity_desc">活动介绍</string>
<string name="search_btn">检索</string>
<string name="search_null">未找到结果</string>
<string name="rename_form">社团换名申请表</string>
<string name="petitioner">申请人</string>
<string name="oldname">社团原名</string>
<string name="newname">社团新名</string>
<string name="reason_for_application">申请理由</string>
<string name="approver">审批人</string>
<string name="approver_origin">审核理由</string>
<string name="not_impl_error">抱歉此功能尚未开放</string>
</resources>

@ -12,4 +12,12 @@
<string name="activity_desc">活动介绍</string>
<string name="search_btn">检索</string>
<string name="search_null">未找到结果</string>
<string name="rename_form">社团换名申请表</string>
<string name="petitioner">申请人</string>
<string name="oldname">社团原名</string>
<string name="newname">社团新名</string>
<string name="reason_for_application">申请理由</string>
<string name="approver">审批人</string>
<string name="approver_origin">审核理由</string>
<string name="not_impl_error">抱歉此功能尚未开放</string>
</resources>

@ -12,4 +12,12 @@
<string name="activity_desc">活动介绍</string>
<string name="search_btn">检索</string>
<string name="search_null">未找到结果</string>
<string name="rename_form">社团换名申请表</string>
<string name="petitioner">申请人</string>
<string name="oldname">社团原名</string>
<string name="newname">社团新名</string>
<string name="reason_for_application">申请理由</string>
<string name="approver">审批人</string>
<string name="approver_origin">审核理由</string>
<string name="not_impl_error">抱歉此功能尚未开放</string>
</resources>
Loading…
Cancel
Save