parent
531c022328
commit
f531b72442
@ -0,0 +1,51 @@ |
||||
package com.gyf.csams.main.model |
||||
|
||||
import android.app.Application |
||||
import androidx.lifecycle.viewModelScope |
||||
import com.gyf.ApplyViewModel |
||||
import com.gyf.lib.util.format |
||||
import com.gyf.lib.util.randomChinese |
||||
import com.gyf.lib.util.randomDateTime |
||||
import kotlinx.coroutines.launch |
||||
|
||||
data class ApplyActVo( |
||||
val activityName: String, val activityTime: String, |
||||
val location: String, val desc: String, |
||||
val size: Int |
||||
) |
||||
|
||||
|
||||
/** |
||||
* 活动数据管理 |
||||
* |
||||
*/ |
||||
class CheckActViewModel(application: Application) : ApplyViewModel<ApplyActVo>(application) { |
||||
override val initSize: Int = 10 |
||||
|
||||
init { |
||||
load() |
||||
} |
||||
|
||||
override fun load() { |
||||
viewModelScope.launch { |
||||
_data.value?.apply { |
||||
repeat(initSize) { |
||||
add( |
||||
ApplyActVo( |
||||
activityName = randomChinese(5), |
||||
activityTime = randomDateTime().format(), |
||||
location = randomChinese(10), |
||||
desc = randomChinese(10), |
||||
size = 10 |
||||
) |
||||
) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun loadMore(callback: (message: String) -> Unit) { |
||||
TODO("Not yet implemented") |
||||
} |
||||
|
||||
} |
@ -0,0 +1,62 @@ |
||||
package com.gyf.csams.main.model |
||||
|
||||
import android.app.Application |
||||
import androidx.annotation.IntRange |
||||
import androidx.lifecycle.viewModelScope |
||||
import com.gyf.ApplyViewModel |
||||
import com.gyf.lib.util.randomChinese |
||||
import kotlinx.coroutines.launch |
||||
|
||||
|
||||
const val MAX_SCORE = 5L |
||||
|
||||
/** |
||||
* 活动质量汇报单 |
||||
* |
||||
* @property applyName 申请人 |
||||
* @property activityName 活动名称 |
||||
* @property merit 优点 |
||||
* @property defect 缺点 |
||||
* @property score 星级评价 |
||||
*/ |
||||
data class QualityReportVo( |
||||
val applyName: String, |
||||
val activityName: String, |
||||
val merit: String, |
||||
val defect: String, |
||||
@IntRange(from = 1L, to = MAX_SCORE) val score: Int |
||||
) |
||||
|
||||
/** |
||||
* 活动质量汇报单评价 |
||||
* |
||||
*/ |
||||
class CheckQualityReportViewModel(application: Application) : ApplyViewModel<QualityReportVo>( |
||||
application |
||||
) { |
||||
override val initSize: Int = 10 |
||||
|
||||
init { |
||||
load() |
||||
} |
||||
|
||||
override fun load() { |
||||
viewModelScope.launch { |
||||
_data.value?.apply { |
||||
repeat(initSize) { |
||||
add( |
||||
QualityReportVo( |
||||
applyName = randomChinese(3), activityName = randomChinese(10), |
||||
merit = randomChinese(10), defect = randomChinese(10), |
||||
score = (1..5).random() |
||||
) |
||||
) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun loadMore(callback: (message: String) -> Unit) { |
||||
TODO("Not yet implemented") |
||||
} |
||||
} |
@ -0,0 +1,87 @@ |
||||
package com.gyf.csams.main.ui |
||||
|
||||
import android.os.Bundle |
||||
import androidx.activity.ComponentActivity |
||||
import androidx.activity.compose.setContent |
||||
import androidx.compose.foundation.layout.Column |
||||
import androidx.compose.foundation.layout.fillMaxSize |
||||
import androidx.compose.foundation.layout.fillMaxWidth |
||||
import androidx.compose.foundation.layout.height |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.runtime.ExperimentalComposeApi |
||||
import androidx.compose.ui.Modifier |
||||
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.ApplyActVo |
||||
import com.gyf.csams.main.model.CheckActViewModel |
||||
import com.gyf.csams.uikit.RowItem |
||||
import com.gyf.csams.uikit.TestTable |
||||
import com.gyf.lib.uikit.BaseTextField |
||||
import com.gyf.lib.uikit.ScaffoldModel |
||||
import com.gyf.lib.util.BottomButton |
||||
|
||||
/** |
||||
* 审批社团活动 |
||||
* |
||||
*/ |
||||
class CheckActActivity : ComponentActivity() { |
||||
@ExperimentalComposeApi |
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
|
||||
setContent { |
||||
TestTable( |
||||
clazz = CheckActViewModel::class.java, |
||||
title = R.string.activity_application |
||||
) { |
||||
ApplyActForm(vo = it) |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Composable |
||||
private fun ApplyActForm( |
||||
modifier: Modifier = Modifier, model: CheckActViewModel = viewModel(), |
||||
scaffoldModel: ScaffoldModel = viewModel(), vo: ApplyActVo |
||||
) { |
||||
Column(modifier = modifier) { |
||||
val baseHeight = 50.dp |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight), |
||||
key = R.string.activity_name, |
||||
value = vo.activityName |
||||
) |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight * 1.5F), |
||||
key = R.string.activity_address, |
||||
value = vo.location |
||||
) |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight * 3), |
||||
key = R.string.activity_desc, |
||||
value = vo.desc |
||||
) |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight), |
||||
key = R.string.activity_size, |
||||
value = "${vo.size}" |
||||
) |
||||
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( |
||||
confirmDesc = R.string.reported_btn, backDesc = R.string.reject_btn, |
||||
modifier = Modifier.fillMaxWidth() |
||||
) { |
||||
scaffoldModel.update(message = message) |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,104 @@ |
||||
package com.gyf.csams.main.ui |
||||
|
||||
import android.os.Bundle |
||||
import androidx.activity.ComponentActivity |
||||
import androidx.activity.compose.setContent |
||||
import androidx.compose.foundation.Image |
||||
import androidx.compose.foundation.layout.* |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.runtime.ExperimentalComposeApi |
||||
import androidx.compose.ui.Modifier |
||||
import androidx.compose.ui.res.painterResource |
||||
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.CheckQualityReportViewModel |
||||
import com.gyf.csams.main.model.MAX_SCORE |
||||
import com.gyf.csams.main.model.QualityReportVo |
||||
import com.gyf.csams.uikit.RowItem |
||||
import com.gyf.csams.uikit.TestTable |
||||
import com.gyf.lib.uikit.BaseTextField |
||||
import com.gyf.lib.uikit.ScaffoldModel |
||||
import com.gyf.lib.util.BottomButton |
||||
|
||||
/** |
||||
* 审批质量报告单 |
||||
* |
||||
*/ |
||||
class CheckQualityReportActivity : ComponentActivity() { |
||||
@ExperimentalComposeApi |
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
|
||||
setContent { |
||||
TestTable( |
||||
clazz = CheckQualityReportViewModel::class.java, |
||||
title = R.string.quality_report_title |
||||
) { |
||||
CheckQualityReportForm(vo = it) |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Composable |
||||
private fun CheckQualityReportForm( |
||||
modifier: Modifier = Modifier, model: CheckQualityReportViewModel = viewModel(), |
||||
scaffoldModel: ScaffoldModel = viewModel(), vo: QualityReportVo |
||||
) { |
||||
Column(modifier = modifier) { |
||||
val baseHeight = 50.dp |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight), |
||||
key = R.string.petitioner, |
||||
value = vo.applyName |
||||
) |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight), |
||||
key = R.string.activity_name, |
||||
value = vo.activityName |
||||
) |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight * 3), |
||||
key = R.string.activity_merit, |
||||
value = vo.merit |
||||
) |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight * 3), |
||||
key = R.string.activitiy_defect, |
||||
value = vo.defect |
||||
) |
||||
RowItem( |
||||
modifier = Modifier.height(baseHeight), |
||||
key = R.string.activity_evaluate |
||||
) { |
||||
Row( |
||||
modifier = Modifier.fillMaxWidth(), |
||||
horizontalArrangement = Arrangement.Center |
||||
) { |
||||
repeat(MAX_SCORE.toInt()) { |
||||
Image( |
||||
modifier = Modifier.weight(1F / MAX_SCORE), |
||||
painter = painterResource(id = if (it < vo.score) R.drawable.ic_collection_fill else R.drawable.ic_collection), |
||||
contentDescription = null |
||||
) |
||||
} |
||||
} |
||||
} |
||||
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( |
||||
confirmDesc = R.string.reported_btn, backDesc = R.string.reject_btn, |
||||
modifier = Modifier.fillMaxWidth() |
||||
) { |
||||
scaffoldModel.update(message = message) |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
package com.gyf.csams.main.ui |
||||
|
||||
import androidx.activity.ComponentActivity |
||||
|
||||
class ManagerActActivity : ComponentActivity() { |
||||
} |
@ -0,0 +1,111 @@ |
||||
package com.gyf.csams.uikit |
||||
|
||||
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.ExperimentalComposeApi |
||||
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.lib.ScrollListW |
||||
import com.gyf.lib.uikit.BodyS |
||||
import com.gyf.lib.uikit.MainColumnFrame |
||||
|
||||
/** |
||||
* 表格 |
||||
* |
||||
* @param callback |
||||
*/ |
||||
@ExperimentalComposeApi |
||||
@Composable |
||||
fun <A> TestTable( |
||||
clazz: Class<out ScrollListW<A>>, |
||||
@StringRes title: Int, |
||||
callback: @Composable (vo: A) -> Unit |
||||
) { |
||||
BodyS { |
||||
MainColumnFrame(background = { /*TODO*/ }) { |
||||
val listState = rememberLazyListState() |
||||
val model = viewModel(modelClass = clazz) |
||||
val data by model.data.observeAsState() |
||||
Row( |
||||
horizontalArrangement = Arrangement.Center, |
||||
modifier = Modifier |
||||
.fillMaxWidth() |
||||
.padding(10.dp) |
||||
) { |
||||
Text( |
||||
text = stringResource(id = title), |
||||
style = MaterialTheme.typography.h4 |
||||
) |
||||
} |
||||
LazyColumn(state = listState) { |
||||
data?.forEach { |
||||
item { |
||||
callback(vo = it) |
||||
Spacer(modifier = Modifier.height(10.dp)) |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 表格行 |
||||
* |
||||
* @param modifier |
||||
* @param key |
||||
* @param value |
||||
* @param content |
||||
*/ |
||||
@Composable |
||||
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( |
||||
"参数错误" |
||||
) |
||||
) |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="64dp" |
||||
android:height="64dp" |
||||
android:viewportWidth="1024" |
||||
android:viewportHeight="1024"> |
||||
<path |
||||
android:fillColor="#FF000000" |
||||
android:pathData="M490.26,173.44a49.07,49.07 0,0 1,64.06 19.18l1.66,3.09 87.85,177.81 196.35,28.5a49.07,49.07 0,0 1,29.72 81.07l-2.54,2.65L725.33,624l33.54,195.35a49.07,49.07 0,0 1,-68.01 53.27l-3.16,-1.51L512,778.86l-175.7,92.27a49.07,49.07 0,0 1,-71.64 -48.43l0.47,-3.33L298.67,624.02 156.63,485.76a49.07,49.07 0,0 1,23.89 -83.11l3.29,-0.6 196.35,-28.5 87.85,-177.81a49.07,49.07 0,0 1,22.25 -22.27zM422.63,432.02l-199.66,28.99 144.47,140.65 -34.13,198.74L512,706.56l178.69,93.85 -34.13,-198.74 144.47,-140.65 -199.66,-28.99L512,251.16l-89.39,180.86z" /> |
||||
</vector> |
@ -0,0 +1,9 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="64dp" |
||||
android:height="64dp" |
||||
android:viewportWidth="1024" |
||||
android:viewportHeight="1024"> |
||||
<path |
||||
android:pathData="M490.26,173.44a49.07,49.07 0,0 1,64.06 19.18l1.66,3.09 87.85,177.81 196.35,28.5a49.07,49.07 0,0 1,29.72 81.07l-2.54,2.65L725.33,624l33.54,195.35a49.07,49.07 0,0 1,-68.01 53.27l-3.16,-1.51L512,778.86l-175.7,92.27a49.07,49.07 0,0 1,-71.64 -48.43l0.47,-3.33L298.67,624.02 156.63,485.76a49.07,49.07 0,0 1,23.89 -83.11l3.29,-0.6 196.35,-28.5 87.85,-177.81a49.07,49.07 0,0 1,22.25 -22.27z" |
||||
android:fillColor="#f4ea2a" /> |
||||
</vector> |
@ -0,0 +1,11 @@ |
||||
package com.gyf |
||||
|
||||
import android.app.Application |
||||
import com.gyf.lib.R |
||||
import com.gyf.lib.ScrollListW |
||||
import com.gyf.lib.uikit.StringForm |
||||
|
||||
abstract class ApplyViewModel<T>(application: Application) : ScrollListW<T>(application) { |
||||
val approverOrigin = |
||||
StringForm(formDesc = application.getString(R.string.approver_origin), textLength = 30) |
||||
} |
Loading…
Reference in new issue