|
|
@ -24,11 +24,11 @@ import androidx.compose.ui.text.style.TextOverflow |
|
|
|
import androidx.compose.ui.tooling.preview.Preview |
|
|
|
import androidx.compose.ui.tooling.preview.Preview |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel |
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel |
|
|
|
import androidx.navigation.NavController |
|
|
|
import androidx.navigation.NavHostController |
|
|
|
import androidx.navigation.compose.NavHost |
|
|
|
import androidx.navigation.compose.NavHost |
|
|
|
import androidx.navigation.compose.composable |
|
|
|
import androidx.navigation.compose.composable |
|
|
|
import androidx.navigation.compose.rememberNavController |
|
|
|
|
|
|
|
import com.gyf.csams.R |
|
|
|
import com.gyf.csams.R |
|
|
|
|
|
|
|
import com.gyf.csams.association.ui.AssociationActivity |
|
|
|
import com.gyf.csams.association.ui.RegAssociationActivity |
|
|
|
import com.gyf.csams.association.ui.RegAssociationActivity |
|
|
|
import com.gyf.csams.main.model.* |
|
|
|
import com.gyf.csams.main.model.* |
|
|
|
import com.gyf.csams.uikit.* |
|
|
|
import com.gyf.csams.uikit.* |
|
|
@ -45,38 +45,27 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
|
|
|
|
|
|
|
setContent { |
|
|
|
setContent { |
|
|
|
CSAMSTheme { |
|
|
|
CSAMSTheme { |
|
|
|
Body() |
|
|
|
Body { nav, scaffoldState -> |
|
|
|
} |
|
|
|
NavHost(navController = nav, startDestination = MainMenu.Main.name) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
fun Body() { |
|
|
|
|
|
|
|
// A surface container using the 'background' color from the theme |
|
|
|
|
|
|
|
Surface(color = MaterialTheme.colors.background) { |
|
|
|
|
|
|
|
val navController = rememberNavController() |
|
|
|
|
|
|
|
val scaffoldState = rememberScaffoldState() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Scaffold(scaffoldState = scaffoldState) { |
|
|
|
|
|
|
|
NavHost(navController, startDestination = MainMenu.Main.name) { |
|
|
|
|
|
|
|
composable(MainMenu.Main.name) { |
|
|
|
composable(MainMenu.Main.name) { |
|
|
|
Main(navController = navController) |
|
|
|
Main(navController = nav) |
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
} |
|
|
|
} |
|
|
|
composable(MainMenu.List.name) { |
|
|
|
composable(MainMenu.List.name) { |
|
|
|
AssociationList(navController = navController) |
|
|
|
AssociationList(navController = nav) |
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
} |
|
|
|
} |
|
|
|
composable(MainMenu.Center.name) { |
|
|
|
composable(MainMenu.Center.name) { |
|
|
|
Center(navController = navController) |
|
|
|
Center(navController = nav) |
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
ShowSnackbar(scaffoldState = scaffoldState) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -85,16 +74,17 @@ fun Body() { |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun Center(model:CenterViewModel= viewModel(), scaffoldModel: ScaffoldModel= viewModel(), navController: NavController){ |
|
|
|
private fun Center(model:CenterViewModel= viewModel(), scaffoldModel: ScaffoldModel= viewModel(), navController: NavHostController){ |
|
|
|
MainFrame(background = { Background(image = BackgroundImage.center,alpha = 0.5F) }, mainMenu = MainMenu.Center, nav = navController) { |
|
|
|
MainFrame(background = { Background(image = BackgroundImage.center,alpha = 0.5F) }, mainMenu = MainMenu.Center, nav = navController) { |
|
|
|
Column(modifier = Modifier |
|
|
|
Column(modifier = Modifier |
|
|
|
.weight(0.33F) |
|
|
|
.weight(0.33F) |
|
|
|
.fillMaxWidth(),verticalArrangement = Arrangement.Bottom) { |
|
|
|
.fillMaxWidth(),verticalArrangement = Arrangement.Bottom) { |
|
|
|
Card(backgroundColor = MaterialTheme.colors.background) { |
|
|
|
Card(backgroundColor = MaterialTheme.colors.background) { |
|
|
|
|
|
|
|
val context= LocalContext.current |
|
|
|
Row(modifier = Modifier |
|
|
|
Row(modifier = Modifier |
|
|
|
.fillMaxWidth() |
|
|
|
.fillMaxWidth() |
|
|
|
.clickable(onClick = { |
|
|
|
.clickable(onClick = { |
|
|
|
model.openMyAssociation { scaffoldModel.update(it) } |
|
|
|
context.startActivity(Intent(context, AssociationActivity::class.java)) |
|
|
|
}),verticalAlignment = Alignment.CenterVertically) { |
|
|
|
}),verticalAlignment = Alignment.CenterVertically) { |
|
|
|
Spacer(modifier = Modifier.weight(0.33F)) |
|
|
|
Spacer(modifier = Modifier.weight(0.33F)) |
|
|
|
Row(modifier = Modifier.weight(0.33F),horizontalArrangement = Arrangement.Center) { |
|
|
|
Row(modifier = Modifier.weight(0.33F),horizontalArrangement = Arrangement.Center) { |
|
|
@ -121,7 +111,7 @@ fun Center(model:CenterViewModel= viewModel(), scaffoldModel: ScaffoldModel= vie |
|
|
|
* 主界面 |
|
|
|
* 主界面 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun Main(navController: NavController) { |
|
|
|
private fun Main(navController: NavHostController) { |
|
|
|
MainFrame(background = { Background(image = BackgroundImage.main) }, mainMenu = MainMenu.Main, nav = navController) { |
|
|
|
MainFrame(background = { Background(image = BackgroundImage.main) }, mainMenu = MainMenu.Main, nav = navController) { |
|
|
|
Column(modifier = Modifier.weight(0.33F)) { |
|
|
|
Column(modifier = Modifier.weight(0.33F)) { |
|
|
|
Notification() |
|
|
|
Notification() |
|
|
@ -143,7 +133,7 @@ fun Main(navController: NavController) { |
|
|
|
* @param navController |
|
|
|
* @param navController |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun AssociationList(navController: NavController) { |
|
|
|
private fun AssociationList(navController: NavHostController) { |
|
|
|
MainFrame( |
|
|
|
MainFrame( |
|
|
|
background = { Background(image = BackgroundImage.list) }, |
|
|
|
background = { Background(image = BackgroundImage.list) }, |
|
|
|
mainMenu = MainMenu.List, |
|
|
|
mainMenu = MainMenu.List, |
|
|
@ -160,7 +150,7 @@ fun AssociationList(navController: NavController) { |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun RegisterAssociation() { |
|
|
|
private fun RegisterAssociation() { |
|
|
|
val context= LocalContext.current |
|
|
|
val context= LocalContext.current |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
horizontalArrangement = Arrangement.End, |
|
|
|
horizontalArrangement = Arrangement.End, |
|
|
@ -185,7 +175,7 @@ fun RegisterAssociation() { |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun AssociationListBody(model: ListViewModel = viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
private fun AssociationListBody(model: ListViewModel = viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
val associationList: MutableList<AssociationDto>? by model.associationDto.observeAsState() |
|
|
|
val associationList: MutableList<AssociationDto>? by model.associationDto.observeAsState() |
|
|
|
val listState = rememberLazyListState() |
|
|
|
val listState = rememberLazyListState() |
|
|
|
|
|
|
|
|
|
|
@ -222,8 +212,9 @@ fun AssociationListBody(model: ListViewModel = viewModel(),scaffoldModel: Scaffo |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun Association(associationDto: AssociationDto) { |
|
|
|
private fun Association(associationDto: AssociationDto) { |
|
|
|
Card { |
|
|
|
val context= LocalContext.current |
|
|
|
|
|
|
|
Card(modifier = Modifier.clickable(onClick = { context.startActivity(Intent(context,AssociationActivity::class.java)) })) { |
|
|
|
Image( |
|
|
|
Image( |
|
|
|
painter = painterResource(id = R.drawable.association_list_border), |
|
|
|
painter = painterResource(id = R.drawable.association_list_border), |
|
|
|
contentDescription = null |
|
|
|
contentDescription = null |
|
|
@ -242,7 +233,7 @@ fun Association(associationDto: AssociationDto) { |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun AssociationSearch(model: ListViewModel = viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
private fun AssociationSearch(model: ListViewModel = viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
|
|
|
|
|
|
|
|
Card(modifier = Modifier.padding(horizontal = 50.dp, vertical = 10.dp)) { |
|
|
|
Card(modifier = Modifier.padding(horizontal = 50.dp, vertical = 10.dp)) { |
|
|
|
Column { |
|
|
|
Column { |
|
|
@ -271,7 +262,7 @@ fun AssociationSearch(model: ListViewModel = viewModel(),scaffoldModel: Scaffold |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun Notification(mainViewModel: MainViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
private fun Notification(mainViewModel: MainViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
horizontalArrangement = Arrangement.End, |
|
|
|
horizontalArrangement = Arrangement.End, |
|
|
|
modifier = Modifier |
|
|
|
modifier = Modifier |
|
|
@ -295,7 +286,7 @@ fun Notification(mainViewModel: MainViewModel= viewModel(),scaffoldModel: Scaffo |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun MyBorder(content: @Composable BoxScope.() -> Unit) { |
|
|
|
private fun MyBorder(content: @Composable BoxScope.() -> Unit) { |
|
|
|
Box(modifier = Modifier.padding(horizontal = 15.dp)) { |
|
|
|
Box(modifier = Modifier.padding(horizontal = 15.dp)) { |
|
|
|
Box( |
|
|
|
Box( |
|
|
|
modifier = Modifier |
|
|
|
modifier = Modifier |
|
|
@ -315,7 +306,7 @@ fun MyBorder(content: @Composable BoxScope.() -> Unit) { |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun MessageBoard(model: MarqueeViewModel = viewModel(),mainViewModel:MainViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
private fun MessageBoard(model: MarqueeViewModel = viewModel(),mainViewModel:MainViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
MyBorder { |
|
|
|
MyBorder { |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
verticalAlignment = Alignment.CenterVertically |
|
|
|
verticalAlignment = Alignment.CenterVertically |
|
|
@ -350,7 +341,7 @@ fun MessageBoard(model: MarqueeViewModel = viewModel(),mainViewModel:MainViewMod |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun ClubActivitiesTitle() { |
|
|
|
private fun ClubActivitiesTitle() { |
|
|
|
MyBorder { |
|
|
|
MyBorder { |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
modifier = Modifier |
|
|
|
modifier = Modifier |
|
|
@ -369,12 +360,13 @@ fun ClubActivitiesTitle() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 活动海报 |
|
|
|
* 活动海报 |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun ClubActivitiesImage(model: CarouselViewModel = viewModel()) { |
|
|
|
private fun ClubActivitiesImage(model: CarouselViewModel = viewModel()) { |
|
|
|
Carousel(model = model) { |
|
|
|
Carousel(model = model) { |
|
|
|
Column { |
|
|
|
Column { |
|
|
|
Card( |
|
|
|
Card( |
|
|
@ -393,35 +385,11 @@ fun ClubActivitiesImage(model: CarouselViewModel = viewModel()) { |
|
|
|
contentDescription = null |
|
|
|
contentDescription = null |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
Card( |
|
|
|
DescCard( |
|
|
|
modifier = Modifier |
|
|
|
modifier = Modifier |
|
|
|
.weight(0.4F) |
|
|
|
.weight(0.4F) |
|
|
|
.fillMaxWidth(), |
|
|
|
.fillMaxWidth() |
|
|
|
backgroundColor = Color.Transparent |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
Image( |
|
|
|
|
|
|
|
painter = painterResource(id = R.drawable.hot_activity_desc_background), |
|
|
|
|
|
|
|
contentDescription = null |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Row(modifier = Modifier.fillMaxWidth()) { |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.weight(0.2F)) |
|
|
|
|
|
|
|
Column( |
|
|
|
|
|
|
|
modifier = Modifier |
|
|
|
|
|
|
|
.weight(0.5F) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.weight(0.1F)) |
|
|
|
|
|
|
|
Text( |
|
|
|
|
|
|
|
text = "文字对任何界面都属于核心内容,而利用 Jetpack Compose 可以更轻松地显示或写入文字。Compose 可以充分利用其构建块的组合,这意味着您无需覆盖各种属性和方法,也无需扩展大型类,即可拥有特定的可组合项设计以及按您期望的方式运行的逻辑。" |
|
|
|
|
|
|
|
.repeat(10), overflow = TextOverflow.Ellipsis, |
|
|
|
|
|
|
|
modifier = Modifier.weight(0.8F) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
Spacer(modifier = Modifier.weight(0.1F)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.weight(0.2F)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|