主界面热门活动和社团活动列表跳转到活动详情

master
pan 4 years ago
parent 4ee124d927
commit 74c4bfd352
  1. 10
      app/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt
  2. 15
      app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt
  3. 10
      app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
  4. 2
      app/src/main/java/com/gyf/csams/uikit/BaseView.kt

@ -111,8 +111,18 @@ class MemberViewModel:ScrollList<MemberVo>(){
}
}
data class OngoingActVo(val name:String)
class OngoingActViewModel:ViewModel(){
private val _act=MutableLiveData<OngoingActVo>()
val act:LiveData<OngoingActVo> = _act
}
data class HistoryActVo(val name: String)
/**
* 历史活动
*

@ -6,6 +6,7 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
@ -25,6 +26,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.gyf.csams.R
import com.gyf.csams.activity.ui.ActivityDetailActivity
import com.gyf.csams.association.model.*
import com.gyf.csams.uikit.*
import com.gyf.csams.uikit.theme.CSAMSTheme
@ -338,8 +340,12 @@ class AssociationActivity: ComponentActivity() {
*
*/
@Composable
private fun OngoingActivity(modifier: Modifier=Modifier){
Row(modifier = modifier,horizontalArrangement = Arrangement.Center) {
private fun OngoingActivity(modifier: Modifier=Modifier,model:OngoingActViewModel= viewModel()){
val context= LocalContext.current
val act by model.act.observeAsState()
Row(modifier = modifier.clickable(onClick = {
context.startActivity(Intent(context,ActivityDetailActivity::class.java))
}),horizontalArrangement = Arrangement.Center) {
val weight=0.5F
val spaceWeight=(1-0.5F)/2
Spacer(modifier = Modifier.weight(spaceWeight))
@ -384,7 +390,10 @@ class AssociationActivity: ComponentActivity() {
*/
@Composable
private fun HistoryActivity(modifier: Modifier,historyActVo: HistoryActVo){
Box(modifier=modifier,contentAlignment = Alignment.Center){
val context= LocalContext.current
Box(modifier=modifier.clickable(onClick = {
context.startActivity(Intent(context,ActivityDetailActivity::class.java))
}),contentAlignment = Alignment.Center){
Image(painter = painterResource(id = R.drawable.history_activity_border),
contentDescription = null,
modifier = Modifier.fillMaxSize())

@ -27,6 +27,7 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.gyf.csams.R
import com.gyf.csams.activity.ui.ActivityDetailActivity
import com.gyf.csams.association.ui.AssociationActivity
import com.gyf.csams.association.ui.RegAssociationActivity
import com.gyf.csams.main.model.*
@ -367,10 +368,15 @@ class MainActivity : ComponentActivity() {
@Composable
private fun PosterWithDesc(model: CarouselViewModel = viewModel()) {
Carousel(model = model) {
Column {
val context= LocalContext.current
Column(modifier = Modifier.clickable(onClick = {
context.startActivity(Intent(context,ActivityDetailActivity::class.java))
})) {
Poster(modifier = Modifier
.weight(0.6F)
.fillMaxWidth(),id = it)
.fillMaxWidth()
,id = it)
DescCard(
modifier = Modifier
.weight(0.4F)

@ -199,7 +199,7 @@ fun TextTopAppBar(
TopAppBar(backgroundColor = MaterialTheme.colors.secondary) {
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
val context= LocalContext.current as Activity
IconButton(onClick = {context.onBackPressed()}, modifier = Modifier.weight(0.1F)) {
IconButton(onClick = {context.finish()}, modifier = Modifier.weight(0.1F)) {
Icon(
painter = painterResource(id = R.drawable.ic_arrow_left),
contentDescription = null

Loading…
Cancel
Save