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.
91 lines
3.8 KiB
91 lines
3.8 KiB
package com.gyf.csams.main.ui
|
|
|
|
import android.content.Intent
|
|
import android.os.Bundle
|
|
import androidx.activity.compose.setContent
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
import androidx.compose.foundation.layout.Column
|
|
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.getValue
|
|
import androidx.compose.runtime.livedata.observeAsState
|
|
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.account.model.LoginViewModel
|
|
import com.gyf.csams.main.model.MainViewModel
|
|
import com.gyf.csams.main.model.MenuType
|
|
import com.gyf.lib.service.BaseActivity
|
|
import com.gyf.lib.uikit.*
|
|
import com.gyf.lib.util.ClientType
|
|
|
|
class MainActivity : BaseActivity() {
|
|
|
|
override val clientType: ClientType = ClientType.Background
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContent {
|
|
Body {
|
|
val model: MainViewModel = viewModel()
|
|
val loginViewModel: LoginViewModel = viewModel()
|
|
val scaffoldModel: ScaffoldModel = viewModel()
|
|
val person by model.person.observeAsState()
|
|
MainColumnFrame(background = { /*TODO*/ }) {
|
|
person?.let {
|
|
Profile(
|
|
modifier = Modifier
|
|
.weight(0.3F)
|
|
.padding(10.dp), personInfoVo = it
|
|
)
|
|
}
|
|
Column(
|
|
modifier = Modifier.weight(0.7F),
|
|
verticalArrangement = Arrangement.SpaceEvenly
|
|
) {
|
|
OutlinedButton(onClick = {
|
|
startActivity(Intent(this@MainActivity, DepartmentActivity::class.java))
|
|
}, modifier = Modifier.fillMaxWidth()) {
|
|
Text(text = stringResource(id = R.string.department_management))
|
|
}
|
|
OutlinedButton(onClick = {
|
|
startActivity(
|
|
Intent(
|
|
this@MainActivity,
|
|
MenuActivity::class.java
|
|
).apply {
|
|
putExtra(MenuType::name.name, MenuType.Association)
|
|
})
|
|
}, modifier = Modifier.fillMaxWidth()) {
|
|
Text(text = stringResource(id = R.string.association_management))
|
|
}
|
|
OutlinedButton(onClick = {
|
|
startActivity(
|
|
Intent(
|
|
this@MainActivity,
|
|
MenuActivity::class.java
|
|
).apply {
|
|
putExtra(MenuType::name.name, MenuType.Act)
|
|
})
|
|
}, modifier = Modifier.fillMaxWidth()) {
|
|
Text(text = stringResource(id = R.string.activity_management))
|
|
}
|
|
|
|
OutlinedButton(onClick = {
|
|
loginViewModel.logout(this@MainActivity) {
|
|
scaffoldModel.update(message = it)
|
|
}
|
|
}, modifier = Modifier.fillMaxWidth()) {
|
|
Text(text = "退出登录")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |