You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
6.8 KiB
166 lines
6.8 KiB
package com.gyf.csams.main.ui
|
|
|
|
import android.content.Intent
|
|
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.clickable
|
|
import androidx.compose.foundation.layout.*
|
|
import androidx.compose.material.*
|
|
import androidx.compose.runtime.*
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.res.stringResource
|
|
import androidx.compose.ui.unit.dp
|
|
import com.gyf.csams.R
|
|
import com.gyf.lib.uikit.Body
|
|
import com.gyf.lib.uikit.MainColumnFrame
|
|
|
|
|
|
/**
|
|
* 部门管理
|
|
*
|
|
*/
|
|
class DepartmentActivity : ComponentActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContent {
|
|
Body {
|
|
MainColumnFrame(background = { /*TODO*/ }) {
|
|
val weight = 0.1F
|
|
val departWeight = 0.2F
|
|
val space = 0.05F
|
|
var dialogContent: Int? by remember {
|
|
mutableStateOf(null)
|
|
}
|
|
|
|
dialogContent?.let {
|
|
AlertDialog(onDismissRequest = { /*TODO*/ },
|
|
text = {
|
|
Card(backgroundColor = MaterialTheme.colors.background) {
|
|
Column {
|
|
Row(
|
|
modifier = Modifier.fillMaxWidth(),
|
|
horizontalArrangement = Arrangement.Center
|
|
) {
|
|
Text(text = stringResource(id = R.string.department_desc))
|
|
}
|
|
|
|
Spacer(modifier = Modifier.height(10.dp))
|
|
Box(
|
|
modifier = Modifier
|
|
.height(300.dp)
|
|
.fillMaxWidth(), contentAlignment = Alignment.Center
|
|
) {
|
|
when (it) {
|
|
R.string.secretariat -> Text(
|
|
text = stringResource(id = R.string.secretariat_desc)
|
|
)
|
|
R.string.propaganda_department -> Text(
|
|
text = stringResource(id = R.string.propaganda_desc)
|
|
)
|
|
R.string.public_relations_department -> Text(
|
|
text = stringResource(id = R.string.public_relations_department_desc)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, buttons = {
|
|
Row(
|
|
modifier = Modifier.fillMaxWidth(),
|
|
horizontalArrangement = Arrangement.Center
|
|
) {
|
|
OutlinedButton(onClick = { dialogContent = null }) {
|
|
Text(text = stringResource(id = R.string.close))
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
Row(
|
|
modifier = Modifier
|
|
.fillMaxWidth()
|
|
.weight(weight = weight),
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
horizontalArrangement = Arrangement.Center
|
|
) {
|
|
Text(text = stringResource(id = R.string.department_management))
|
|
}
|
|
|
|
|
|
|
|
DepartmentItem(modifier = Modifier.weight(weight = departWeight),
|
|
id = R.string.secretariat,
|
|
onClick = { dialogContent = R.string.secretariat })
|
|
Spacer(modifier = Modifier.weight(space))
|
|
DepartmentItem(modifier = Modifier.weight(weight = departWeight),
|
|
id = R.string.propaganda_department,
|
|
onClick = { dialogContent = R.string.propaganda_department })
|
|
Spacer(modifier = Modifier.weight(space))
|
|
DepartmentItem(modifier = Modifier.weight(weight = departWeight),
|
|
id = R.string.public_relations_department,
|
|
onClick = { dialogContent = R.string.public_relations_department })
|
|
Spacer(modifier = Modifier.weight(space))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Composable
|
|
private fun DepartmentItem(
|
|
modifier: Modifier = Modifier,
|
|
@StringRes id: Int,
|
|
onClick: () -> Unit
|
|
) {
|
|
Row(
|
|
modifier = modifier
|
|
.fillMaxWidth()
|
|
.padding(20.dp)
|
|
) {
|
|
Box(
|
|
modifier = Modifier
|
|
.weight(0.40F)
|
|
.fillMaxHeight()
|
|
.border(
|
|
width = 1.dp,
|
|
color = MaterialTheme.colors.onBackground
|
|
)
|
|
.clickable(onClick = onClick),
|
|
contentAlignment = Alignment.Center
|
|
) {
|
|
Text(text = stringResource(id = id))
|
|
}
|
|
Spacer(modifier = Modifier.weight(0.1F))
|
|
Column(
|
|
modifier = Modifier
|
|
.weight(0.40F)
|
|
.fillMaxHeight(),
|
|
verticalArrangement = Arrangement.SpaceBetween
|
|
) {
|
|
RowItem(text = "部门部长:")
|
|
OutlinedButton(modifier = Modifier.fillMaxWidth(), onClick = {
|
|
startActivity(Intent(applicationContext, ManagementOfficerActivity::class.java))
|
|
}) {
|
|
Text(text = stringResource(id = R.string.management_officer))
|
|
}
|
|
RowItem(text = "部门总人数:")
|
|
}
|
|
}
|
|
}
|
|
|
|
@Composable
|
|
private fun RowItem(text: String) {
|
|
Row(
|
|
modifier = Modifier
|
|
.fillMaxWidth()
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
|
|
horizontalArrangement = Arrangement.Center
|
|
) {
|
|
Text(text = text)
|
|
}
|
|
}
|
|
} |