diff --git a/app/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt b/app/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt index 1e7de0f..7fbd9f2 100644 --- a/app/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt +++ b/app/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt @@ -111,8 +111,18 @@ class MemberViewModel:ScrollList(){ } } + + +data class OngoingActVo(val name:String) + +class OngoingActViewModel:ViewModel(){ + private val _act=MutableLiveData() + val act:LiveData = _act +} + data class HistoryActVo(val name: String) + /** * 历史活动 * diff --git a/app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt b/app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt index d1927a4..b0bc6a0 100644 --- a/app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt +++ b/app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt @@ -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()) diff --git a/app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt b/app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt index 949a4a9..f2c43bf 100644 --- a/app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt +++ b/app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt @@ -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) diff --git a/app/src/main/java/com/gyf/csams/uikit/BaseView.kt b/app/src/main/java/com/gyf/csams/uikit/BaseView.kt index 458e602..7bbc403 100644 --- a/app/src/main/java/com/gyf/csams/uikit/BaseView.kt +++ b/app/src/main/java/com/gyf/csams/uikit/BaseView.kt @@ -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