|
|
|
@ -74,36 +74,103 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
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) { |
|
|
|
|
Column(modifier = Modifier |
|
|
|
|
.weight(0.33F) |
|
|
|
|
.fillMaxWidth(),verticalArrangement = Arrangement.Bottom) { |
|
|
|
|
Card(backgroundColor = MaterialTheme.colors.background) { |
|
|
|
|
val context= LocalContext.current |
|
|
|
|
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 |
|
|
|
|
) { |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
|
|
|
|
|
val info by model.info.observeAsState() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Column( |
|
|
|
|
modifier = Modifier.weight(0.3F).padding(10.dp), |
|
|
|
|
) { |
|
|
|
|
info?.let { |
|
|
|
|
Row(modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.clickable(onClick = { |
|
|
|
|
context.startActivity(Intent(context, AssociationActivity::class.java)) |
|
|
|
|
}),verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Spacer(modifier = Modifier.weight(0.33F)) |
|
|
|
|
Row(modifier = Modifier.weight(0.33F),horizontalArrangement = Arrangement.Center) { |
|
|
|
|
Text(text = model.myAssociationDesc) |
|
|
|
|
.weight(0.7F) |
|
|
|
|
.border(width = 1.dp, color = MaterialTheme.colors.background), |
|
|
|
|
horizontalArrangement = Arrangement.SpaceBetween) { |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource( |
|
|
|
|
id = R.drawable.ic_launcher_foreground |
|
|
|
|
), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier = Modifier |
|
|
|
|
.weight(0.4F) |
|
|
|
|
.fillMaxHeight() |
|
|
|
|
) |
|
|
|
|
Column( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.weight(0.4F) |
|
|
|
|
.fillMaxHeight() |
|
|
|
|
.border(width = 1.dp, color = MaterialTheme.colors.background), |
|
|
|
|
verticalArrangement = Arrangement.SpaceEvenly, |
|
|
|
|
horizontalAlignment = Alignment.CenterHorizontally |
|
|
|
|
) { |
|
|
|
|
Text(text = it.name) |
|
|
|
|
Text(text = it.duty) |
|
|
|
|
} |
|
|
|
|
Row(modifier = Modifier.weight(0.33F),horizontalArrangement = Arrangement.End) { |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_arrow_right), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier = Modifier.size(50.dp) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Spacer(modifier = Modifier.weight(0.05F)) |
|
|
|
|
|
|
|
|
|
Card(backgroundColor = MaterialTheme.colors.background,modifier = Modifier.weight(0.15F)) { |
|
|
|
|
Row( |
|
|
|
|
modifier = Modifier.fillMaxWidth(), |
|
|
|
|
horizontalArrangement = Arrangement.Center |
|
|
|
|
) { |
|
|
|
|
Text(text = it.desc) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Column( |
|
|
|
|
modifier = Modifier.weight(0.7F), |
|
|
|
|
verticalArrangement = Arrangement.SpaceEvenly |
|
|
|
|
) { |
|
|
|
|
CenterMenuItem(text = model.myAssociationDesc) { |
|
|
|
|
context.startActivity(Intent(context, AssociationActivity::class.java)) |
|
|
|
|
} |
|
|
|
|
CenterMenuItem(text = model.myJoinActivity) |
|
|
|
|
CenterMenuItem(text = model.myLikeActivity) |
|
|
|
|
CenterMenuItem(text = model.myCollectActivity) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|
private fun CenterMenuItem(text: String, onClick: () -> Unit = {}) { |
|
|
|
|
Card(backgroundColor = MaterialTheme.colors.background) { |
|
|
|
|
|
|
|
|
|
Row( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.clickable(onClick = onClick), |
|
|
|
|
horizontalArrangement = Arrangement.SpaceBetween, |
|
|
|
|
verticalAlignment = Alignment.CenterVertically |
|
|
|
|
) { |
|
|
|
|
Spacer(modifier = Modifier) |
|
|
|
|
Row { |
|
|
|
|
Text(text = text) |
|
|
|
|
} |
|
|
|
|
Row { |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_arrow_right), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier = Modifier.size(50.dp) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Spacer(modifier = Modifier |
|
|
|
|
.weight(0.66F) |
|
|
|
|
.fillMaxWidth()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -112,7 +179,11 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
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)) { |
|
|
|
|
Notification() |
|
|
|
|
MessageBoard() |
|
|
|
@ -151,7 +222,7 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun RegisterAssociation() { |
|
|
|
|
val context= LocalContext.current |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
Row( |
|
|
|
|
horizontalArrangement = Arrangement.End, |
|
|
|
|
modifier = Modifier |
|
|
|
@ -175,52 +246,68 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private 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 listState = rememberLazyListState() |
|
|
|
|
|
|
|
|
|
LazyColumn(state = listState) { |
|
|
|
|
LazyColumn(state = listState) { |
|
|
|
|
associationList?.chunked(2)?.forEach { |
|
|
|
|
item{ |
|
|
|
|
Row { |
|
|
|
|
item { |
|
|
|
|
Row { |
|
|
|
|
Spacer(modifier = Modifier.weight(0.1F)) |
|
|
|
|
Box(modifier = Modifier.weight(0.35F)) { |
|
|
|
|
Association(associationDto = it[0]) |
|
|
|
|
} |
|
|
|
|
Spacer(modifier = Modifier.weight(0.05F)) |
|
|
|
|
if(it.size==2) { |
|
|
|
|
if (it.size == 2) { |
|
|
|
|
Box(modifier = Modifier.weight(0.35F)) { |
|
|
|
|
Association(associationDto = it[1]) |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
Box(modifier = Modifier |
|
|
|
|
.weight(0.35F) |
|
|
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground)) |
|
|
|
|
} else { |
|
|
|
|
Box( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.weight(0.35F) |
|
|
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
Spacer(modifier = Modifier.weight(0.1F)) |
|
|
|
|
} |
|
|
|
|
Spacer(modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.height(10.dp)) |
|
|
|
|
Spacer( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
.height(10.dp) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(listState.layoutInfo.totalItemsCount-listState.firstVisibleItemIndex==model.associationListSize/2-1){ |
|
|
|
|
model.loadMore { scaffoldModel.update(message=it) } |
|
|
|
|
if (listState.layoutInfo.totalItemsCount - listState.firstVisibleItemIndex == model.associationListSize / 2 - 1) { |
|
|
|
|
model.loadMore { scaffoldModel.update(message = it) } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|
private fun Association(associationDto: AssociationDto) { |
|
|
|
|
val context= LocalContext.current |
|
|
|
|
Card(modifier = Modifier.clickable(onClick = { context.startActivity(Intent(context,AssociationActivity::class.java)) })) { |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
Card(modifier = Modifier.clickable(onClick = { |
|
|
|
|
context.startActivity( |
|
|
|
|
Intent( |
|
|
|
|
context, |
|
|
|
|
AssociationActivity::class.java |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
})) { |
|
|
|
|
Image( |
|
|
|
|
painter = painterResource(id = R.drawable.association_list_border), |
|
|
|
|
contentDescription = null |
|
|
|
|
) |
|
|
|
|
Row(modifier = Modifier.fillMaxWidth(), |
|
|
|
|
horizontalArrangement = Arrangement.Center) { |
|
|
|
|
Row( |
|
|
|
|
modifier = Modifier.fillMaxWidth(), |
|
|
|
|
horizontalArrangement = Arrangement.Center |
|
|
|
|
) { |
|
|
|
|
Text(text = associationDto.name) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -233,18 +320,35 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private 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)) { |
|
|
|
|
Column { |
|
|
|
|
|
|
|
|
|
BaseTextField(form = model.name,singeLine = true,modifier = Modifier.padding(horizontal = 10.dp)) |
|
|
|
|
BaseTextField(form = model.desc,singeLine = true,modifier = Modifier.padding(horizontal = 10.dp)) |
|
|
|
|
BaseTextField( |
|
|
|
|
form = model.name, |
|
|
|
|
singeLine = true, |
|
|
|
|
modifier = Modifier.padding(horizontal = 10.dp) |
|
|
|
|
) |
|
|
|
|
BaseTextField( |
|
|
|
|
form = model.desc, |
|
|
|
|
singeLine = true, |
|
|
|
|
modifier = Modifier.padding(horizontal = 10.dp) |
|
|
|
|
) |
|
|
|
|
Spacer( |
|
|
|
|
modifier = Modifier.height(10.dp) |
|
|
|
|
) |
|
|
|
|
Row(horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth()) { |
|
|
|
|
OutlinedButton(onClick = { model.search { scaffoldModel.update(message=it) } }, modifier = Modifier.width(100.dp)) { |
|
|
|
|
Row( |
|
|
|
|
horizontalArrangement = Arrangement.Center, |
|
|
|
|
modifier = Modifier.fillMaxWidth() |
|
|
|
|
) { |
|
|
|
|
OutlinedButton( |
|
|
|
|
onClick = { model.search { scaffoldModel.update(message = it) } }, |
|
|
|
|
modifier = Modifier.width(100.dp) |
|
|
|
|
) { |
|
|
|
|
Text(text = model.searchDesc) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -262,7 +366,10 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun Notification(mainViewModel: MainViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
|
private fun Notification( |
|
|
|
|
mainViewModel: MainViewModel = viewModel(), |
|
|
|
|
scaffoldModel: ScaffoldModel = viewModel() |
|
|
|
|
) { |
|
|
|
|
Row( |
|
|
|
|
horizontalArrangement = Arrangement.End, |
|
|
|
|
modifier = Modifier |
|
|
|
@ -270,7 +377,7 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
.padding(10.dp) |
|
|
|
|
) { |
|
|
|
|
IconButton(onClick = { |
|
|
|
|
mainViewModel.openNotification { scaffoldModel.update(message=it) } |
|
|
|
|
mainViewModel.openNotification { scaffoldModel.update(message = it) } |
|
|
|
|
}) { |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_notification), |
|
|
|
@ -306,13 +413,17 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Composable |
|
|
|
|
private fun MessageBoard(model: MarqueeViewModel = viewModel(),mainViewModel:MainViewModel= viewModel(),scaffoldModel: ScaffoldModel= viewModel()) { |
|
|
|
|
private fun MessageBoard( |
|
|
|
|
model: MarqueeViewModel = viewModel(), |
|
|
|
|
mainViewModel: MainViewModel = viewModel(), |
|
|
|
|
scaffoldModel: ScaffoldModel = viewModel() |
|
|
|
|
) { |
|
|
|
|
MyBorder { |
|
|
|
|
Row( |
|
|
|
|
verticalAlignment = Alignment.CenterVertically |
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
IconButton(onClick = { mainViewModel.openDialog() }) { |
|
|
|
|
IconButton(onClick = { mainViewModel.openDialog() }) { |
|
|
|
|
Icon( |
|
|
|
|
painter = painterResource(id = R.drawable.ic_comments), |
|
|
|
|
contentDescription = null, |
|
|
|
@ -370,14 +481,15 @@ class MainActivity : ComponentActivity() { |
|
|
|
|
@Composable |
|
|
|
|
private fun PosterWithDesc(model: CarouselViewModel = viewModel()) { |
|
|
|
|
Carousel(model = model) { |
|
|
|
|
val context= LocalContext.current |
|
|
|
|
val context = LocalContext.current |
|
|
|
|
Column(modifier = Modifier.clickable(onClick = { |
|
|
|
|
context.startActivity(Intent(context,ActivityDetailActivity::class.java)) |
|
|
|
|
context.startActivity(Intent(context, ActivityDetailActivity::class.java)) |
|
|
|
|
})) { |
|
|
|
|
Poster(modifier = Modifier |
|
|
|
|
.weight(0.6F) |
|
|
|
|
.fillMaxWidth() |
|
|
|
|
,id = it) |
|
|
|
|
Poster( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.weight(0.6F) |
|
|
|
|
.fillMaxWidth(), id = it |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
DescCard( |
|
|
|
|
modifier = Modifier |
|
|
|
|