From 74c4bfd3520c8e756add6f44ce3739d0bbd16e37 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Mon, 17 May 2021 15:20:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E7=95=8C=E9=9D=A2=E7=83=AD=E9=97=A8?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=92=8C=E7=A4=BE=E5=9B=A2=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=B7=B3=E8=BD=AC=E5=88=B0=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../association/model/AssociationViewModel.kt | 10 ++++++++++ .../csams/association/ui/AssociationActivity.kt | 15 ++++++++++++--- .../java/com/gyf/csams/main/ui/MainActivity.kt | 10 ++++++++-- app/src/main/java/com/gyf/csams/uikit/BaseView.kt | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) 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