调整前台部分边框颜色

前后台的个人中心的个人名片调整。
后台增加部门干事管理界面
master
pan 4 years ago
parent 671b682711
commit 24b12f9778
  1. 3
      background/src/main/AndroidManifest.xml
  2. 123
      background/src/main/java/com/gyf/csams/main/model/ManagementOfficerModel.kt
  3. 172
      background/src/main/java/com/gyf/csams/main/ui/ManagementOfficerActivity.kt
  4. 6
      background/src/main/res/values-en/strings.xml
  5. 6
      background/src/main/res/values-zh/strings.xml
  6. 6
      background/src/main/res/values/strings.xml
  7. 6
      foreground/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt
  8. 3
      foreground/src/main/java/com/gyf/csams/association/ui/RegAssociationActivity.kt
  9. 2
      foreground/src/main/java/com/gyf/csams/uikit/BaseView.kt
  10. 9
      lib/src/main/java/com/gyf/lib/uikit/Profile.kt

@ -29,6 +29,9 @@
<activity
android:name=".main.ui.DepartmentActivity"
android:exported="true" />
<activity
android:name=".main.ui.ManagementOfficerActivity"
android:exported="true" />
</application>
</manifest>

@ -0,0 +1,123 @@
package com.gyf.csams.main.model
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.gyf.lib.util.randomChinese
import com.gyf.lib.util.randomNum
import com.orhanobut.logger.Logger
import kotlinx.coroutines.launch
enum class ColumnType {
Text,
DropMenu
}
/**
* 职务
*
* @property desc
*/
enum class Duty(val desc: String) {
Minister("部长"),
Manager("干事")
}
/**
* 人员信息
*
* @property name 名字
* @property studentId 学号
* @property mobile 手机号
* @property duty 职务
* @property counselor 导员
*/
data class OfficerVo(
val name: String,
val studentId: String,
val mobile: String,
val duty: Duty,
val counselor: String
)
data class AllOfficerVo(
val secretariat: MutableList<OfficerVo>,
val propaganda: MutableList<OfficerVo>,
val publicRelationsDepartment: MutableList<OfficerVo>
)
/**
* 部门干事数据状态管理
*
*/
class ManagementOfficerModel : ViewModel() {
private val _data = MutableLiveData<AllOfficerVo>()
val data: LiveData<AllOfficerVo> = _data
init {
load()
}
private fun replace(
list: MutableList<OfficerVo>,
index: Int,
callback: (s: MutableList<OfficerVo>) -> Unit
) {
val s = mutableListOf<OfficerVo>()
list[index] = list[index].copy(duty = Duty.Minister)
s.add(list[index])
s.addAll(list.filter { officerVo -> officerVo != list[index] }
.map { officerVo -> officerVo.copy(duty = Duty.Manager) })
callback(s)
}
fun updateDuty(list: MutableList<OfficerVo>, index: Int) {
_data.value?.apply {
Logger.i("$secretariat")
when (list) {
secretariat -> replace(list = list, index = index) {
_data.postValue(copy(secretariat = it))
}
propaganda -> replace(list = list, index = index) {
_data.postValue(copy(propaganda = it))
}
publicRelationsDepartment -> replace(list = list, index = index) {
_data.postValue(copy(publicRelationsDepartment = it))
}
}
}
}
/**
* TODO 加载部门成员
*
*/
private fun load() {
viewModelScope.launch {
val officerVoList = mutableListOf<OfficerVo>()
val baseSize = 3
val peopleSize = 5
repeat(peopleSize * baseSize) {
officerVoList.add(
OfficerVo(
name = randomChinese(3), studentId = randomNum(8), mobile = randomNum(11),
if (it % peopleSize == 0) Duty.Minister else Duty.Manager, counselor = ""
)
)
}
val all = officerVoList.chunked(peopleSize)
_data.postValue(
AllOfficerVo(
secretariat = all[0].toMutableList(),
propaganda = all[1].toMutableList(),
publicRelationsDepartment = all[2].toMutableList()
)
)
}
}
}

@ -0,0 +1,172 @@
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.ExperimentalFoundationApi
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
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.R
import com.gyf.csams.main.model.Duty
import com.gyf.csams.main.model.ManagementOfficerModel
import com.gyf.csams.main.model.MinisterVo
import com.gyf.csams.main.model.OfficerVo
import com.gyf.lib.uikit.*
import com.orhanobut.logger.Logger
/**
* 部门干事管理
*
*/
class ManagementOfficerActivity : ComponentActivity() {
@ExperimentalFoundationApi
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Body { scaffoldState ->
MainColumnFrame(background = { /*TODO*/ }) {
val weight = 1 / 3F
val model: ManagementOfficerModel = viewModel()
val data by model.data.observeAsState()
Logger.i("$data")
data?.apply {
Table(
modifier = Modifier
.weight(weight = weight),
id = R.string.secretariat,
officerVoList = secretariat
)
Table(
modifier = Modifier
.weight(weight = weight),
id = R.string.propaganda_department,
officerVoList = propaganda
)
Table(
modifier = Modifier
.weight(weight = weight),
id = R.string.public_relations_department,
officerVoList = publicRelationsDepartment
)
}
ShowSnackbar(scaffoldState = scaffoldState)
}
}
}
}
@Composable
private fun BoxItem(content: @Composable () -> Unit) {
Box(
Modifier
.width(150.dp)
.height(40.dp)
.border(
width = 1.dp,
color = MaterialTheme.colors.onBackground
)
.padding(vertical = 10.dp),
contentAlignment = Alignment.Center
) {
content()
}
}
/**
*
* 表格
*/
@ExperimentalFoundationApi
@Composable
private fun Table(
modifier: Modifier = Modifier,
model: ManagementOfficerModel = viewModel(),
scaffoldModel: ScaffoldModel = viewModel(),
@StringRes id: Int,
officerVoList: MutableList<OfficerVo>,
) {
Column(
modifier = modifier
.padding(horizontal = 10.dp)
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
verticalArrangement = Arrangement.SpaceEvenly
) {
val context = LocalContext.current
Spacer(modifier = Modifier.weight(0.05F))
Text(text = context.getString(id), modifier = Modifier.weight(0.1F))
Spacer(modifier = Modifier.weight(0.05F))
val columnSize = 4
LazyRow(modifier = Modifier.weight(0.6F)) {
officerVoList.withIndex().forEach {
item {
var expanded by remember {
mutableStateOf(false)
}
Profile(
modifier = Modifier
.width(200.dp)
.fillMaxHeight()
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
personInfoVo =
MinisterVo(
name = it.value.name,
duty = it.value.duty.desc,
headImg = "",
desc = it.value.mobile
)
) {
Text(
text = it.value.duty.desc,
modifier = Modifier.clickable(onClick = {
if (it.value.duty.desc != Duty.Minister.desc) expanded =
true else scaffoldModel
.update(message = context.getString(R.string.update_duty_error))
})
)
// Text(
// text = it.duty.desc,
// modifier = Modifier.clickable(onClick = {
// if (duty.desc != Duty.Minister.desc) expanded =
// true else scaffoldModel
// .update(message = context.getString(R.string.update_duty_error))
// })
// )
DropdownMenu(
expanded = expanded,
onDismissRequest = { /*TODO*/ }) {
DropdownMenuItem(onClick = {
model.updateDuty(list = officerVoList, index = it.index)
expanded = false
}) {
Text(text = Duty.Minister.desc)
}
}
}
}
}
}
Spacer(modifier = Modifier.weight(0.05F))
}
}
}

@ -11,4 +11,10 @@
<string name="propaganda_desc">专门负责学校社团各种活动的宣传,出海报以及网络上的宣传工作。 负责学生思想政治教育和学生会各项宣传报道工作的组织和规划。 围绕学院各阶段的中心工作和学院组织和各项活动,做好宣传鼓动工作。 组织学生参加社团开设的学术讲座和学术活动,督促和指导各班学习委员开展工作。</string>
<string name="public_relations_department_desc"><![CDATA[外联部最主要的任务就是为社团和学生活动筹集资金,也就是拉赞助。 为社团部门的各项活动开展做好外联工作。 筹措社团部门各项活动的资金。 负责与兄弟院校的交流联络工作 。 负责社团部门各项活动的节目演出、协助各文体性质社团开展各项活动。 经常性参与开展品牌文体活动。]]></string>
<string name="department_desc">部门介绍</string>
<string name="name">名字</string>
<string name="studentId">学号</string>
<string name="mobile">手机号</string>
<string name="duty">职务</string>
<string name="counselor">导员</string>
<string name="update_duty_error">只能调整干事职务!</string>
</resources>

@ -11,4 +11,10 @@
<string name="propaganda_desc">专门负责学校社团各种活动的宣传,出海报以及网络上的宣传工作。 负责学生思想政治教育和学生会各项宣传报道工作的组织和规划。 围绕学院各阶段的中心工作和学院组织和各项活动,做好宣传鼓动工作。 组织学生参加社团开设的学术讲座和学术活动,督促和指导各班学习委员开展工作。</string>
<string name="public_relations_department_desc"><![CDATA[外联部最主要的任务就是为社团和学生活动筹集资金,也就是拉赞助。 为社团部门的各项活动开展做好外联工作。 筹措社团部门各项活动的资金。 负责与兄弟院校的交流联络工作 。 负责社团部门各项活动的节目演出、协助各文体性质社团开展各项活动。 经常性参与开展品牌文体活动。]]></string>
<string name="department_desc">部门介绍</string>
<string name="name">名字</string>
<string name="studentId">学号</string>
<string name="mobile">手机号</string>
<string name="duty">职务</string>
<string name="counselor">导员</string>
<string name="update_duty_error">只能调整干事职务!</string>
</resources>

@ -11,4 +11,10 @@
<string name="propaganda_desc">专门负责学校社团各种活动的宣传,出海报以及网络上的宣传工作。 负责学生思想政治教育和学生会各项宣传报道工作的组织和规划。 围绕学院各阶段的中心工作和学院组织和各项活动,做好宣传鼓动工作。 组织学生参加社团开设的学术讲座和学术活动,督促和指导各班学习委员开展工作。</string>
<string name="public_relations_department_desc"><![CDATA[外联部最主要的任务就是为社团和学生活动筹集资金,也就是拉赞助。 为社团部门的各项活动开展做好外联工作。 筹措社团部门各项活动的资金。 负责与兄弟院校的交流联络工作 。 负责社团部门各项活动的节目演出、协助各文体性质社团开展各项活动。 经常性参与开展品牌文体活动。]]></string>
<string name="department_desc">部门介绍</string>
<string name="name">名字</string>
<string name="studentId">学号</string>
<string name="mobile">手机号</string>
<string name="duty">职务</string>
<string name="counselor">导员</string>
<string name="update_duty_error">只能调整干事职务!</string>
</resources>

@ -261,7 +261,7 @@ class ActivityDetailActivity : ComponentActivity() {
// TODO 解决Build Warnning
Logger.i("$vo")
Box(
modifier = modifier.border(width = 1.dp, color = MaterialTheme.colors.background),
modifier = modifier.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
contentAlignment = Alignment.Center
) {
Image(
@ -312,7 +312,7 @@ class ActivityDetailActivity : ComponentActivity() {
.fillMaxWidth()
.weight(0.8F)
.padding(10.dp)
.border(width = 1.dp, color = MaterialTheme.colors.background)
.border(width = 1.dp, color = MaterialTheme.colors.onBackground)
) {
val listState = rememberLazyListState()
participant?.let {
@ -407,7 +407,7 @@ class ActivityDetailActivity : ComponentActivity() {
modifier = Modifier
.weight(0.9F)
.padding(10.dp)
.border(width = 1.dp, color = MaterialTheme.colors.background)
.border(width = 1.dp, color = MaterialTheme.colors.onBackground)
) {
val listState = rememberLazyListState()
val data by model.data.observeAsState()

@ -25,7 +25,6 @@ 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.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
@ -131,7 +130,7 @@ class RegAssociationActivity : ComponentActivity() {
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center, modifier = Modifier
.fillMaxSize()
.border(width = 1.dp, color = Color.Black)
.border(width = 1.dp, color = MaterialTheme.colors.onBackground)
) {
if (uri == null) {

@ -557,7 +557,7 @@ fun MyBottomAppBarPreview() {
Column(
modifier = Modifier
.weight(1F / arr.size)
.border(width = 1.dp, color = MaterialTheme.colors.background)
.border(width = 1.dp, color = MaterialTheme.colors.onBackground)
) {
Row(
modifier = Modifier.fillMaxWidth(),

@ -25,7 +25,8 @@ abstract class PersonInfoVo {
@Composable
fun Profile(
modifier: Modifier,
personInfoVo: PersonInfoVo
personInfoVo: PersonInfoVo,
duty: @Composable () -> Unit = { Text(text = personInfoVo.duty) }
) {
var headImg: ImageBitmap? by remember {
mutableStateOf(null)
@ -41,7 +42,7 @@ fun Profile(
modifier = Modifier
.fillMaxWidth()
.weight(0.7F)
.border(width = 1.dp, color = MaterialTheme.colors.background),
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
horizontalArrangement = Arrangement.SpaceBetween
) {
headImg.let {
@ -68,12 +69,12 @@ fun Profile(
modifier = Modifier
.weight(0.4F)
.fillMaxHeight()
.border(width = 1.dp, color = MaterialTheme.colors.background),
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
verticalArrangement = Arrangement.SpaceEvenly,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = personInfoVo.name)
Text(text = personInfoVo.duty)
duty()
}
}

Loading…
Cancel
Save