[fix] Cover height meansure
This commit is contained in:
		| @@ -95,8 +95,9 @@ fun ComicGridView( | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     LaunchedEffect(Unit) { |     LaunchedEffect(comicGridViewModel) { | ||||||
|         comicGridViewModel.coverHeight = screenHeight * 0.4f |         comicGridViewModel.coverHeight = screenHeight * 0.4f | ||||||
|  |         if(comicGridViewModel.maxHeight == 0.dp) | ||||||
|             comicGridViewModel.maxHeight = screenHeight * 0.8f |             comicGridViewModel.maxHeight = screenHeight * 0.8f | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,10 +5,12 @@ import androidx.compose.animation.slideInVertically | |||||||
| import androidx.compose.animation.slideOutVertically | import androidx.compose.animation.slideOutVertically | ||||||
| import androidx.compose.foundation.background | import androidx.compose.foundation.background | ||||||
| import androidx.compose.foundation.clickable | import androidx.compose.foundation.clickable | ||||||
|  | import androidx.compose.foundation.gestures.detectTapGestures | ||||||
| import androidx.compose.foundation.layout.Arrangement | import androidx.compose.foundation.layout.Arrangement | ||||||
| import androidx.compose.foundation.layout.Box | import androidx.compose.foundation.layout.Box | ||||||
| import androidx.compose.foundation.layout.Column | import androidx.compose.foundation.layout.Column | ||||||
| import androidx.compose.foundation.layout.Row | import androidx.compose.foundation.layout.Row | ||||||
|  | import androidx.compose.foundation.layout.Spacer | ||||||
| import androidx.compose.foundation.layout.fillMaxHeight | import androidx.compose.foundation.layout.fillMaxHeight | ||||||
| import androidx.compose.foundation.layout.fillMaxSize | import androidx.compose.foundation.layout.fillMaxSize | ||||||
| import androidx.compose.foundation.layout.fillMaxWidth | import androidx.compose.foundation.layout.fillMaxWidth | ||||||
| @@ -36,7 +38,9 @@ import androidx.compose.runtime.setValue | |||||||
| import androidx.compose.ui.Alignment | import androidx.compose.ui.Alignment | ||||||
| import androidx.compose.ui.Modifier | import androidx.compose.ui.Modifier | ||||||
| import androidx.compose.ui.draw.clip | import androidx.compose.ui.draw.clip | ||||||
|  | import androidx.compose.ui.graphics.Brush | ||||||
| import androidx.compose.ui.graphics.Color | import androidx.compose.ui.graphics.Color | ||||||
|  | import androidx.compose.ui.input.pointer.pointerInput | ||||||
| import androidx.compose.ui.layout.ContentScale | import androidx.compose.ui.layout.ContentScale | ||||||
| import androidx.compose.ui.platform.LocalContext | import androidx.compose.ui.platform.LocalContext | ||||||
| import androidx.compose.ui.platform.LocalView | import androidx.compose.ui.platform.LocalView | ||||||
| @@ -92,7 +96,9 @@ fun ComicPageView( | |||||||
|                     .fillMaxSize() |                     .fillMaxSize() | ||||||
|                     .align(Alignment.Center) |                     .align(Alignment.Center) | ||||||
|                     .background(Color.Black) |                     .background(Color.Black) | ||||||
|                     .clickable { |                     .pointerInput(Unit) { | ||||||
|  |                         detectTapGestures( | ||||||
|  |                             onTap = { | ||||||
|                                 showPlane = !showPlane |                                 showPlane = !showPlane | ||||||
|                                 if (showPlane) { |                                 if (showPlane) { | ||||||
|                                     comicPageViewModel.viewModelScope.launch { |                                     comicPageViewModel.viewModelScope.launch { | ||||||
| @@ -100,6 +106,8 @@ fun ComicPageView( | |||||||
|                                     } |                                     } | ||||||
|                                 } |                                 } | ||||||
|                             } |                             } | ||||||
|  |                         ) | ||||||
|  |                     } | ||||||
|             ) { page -> |             ) { page -> | ||||||
|                 AsyncImage( |                 AsyncImage( | ||||||
|                     model = ImageRequest.Builder(LocalContext.current) |                     model = ImageRequest.Builder(LocalContext.current) | ||||||
| @@ -123,29 +131,29 @@ fun ComicPageView( | |||||||
|                 modifier = Modifier |                 modifier = Modifier | ||||||
|                     .align(Alignment.TopCenter) |                     .align(Alignment.TopCenter) | ||||||
|             ) { |             ) { | ||||||
|                 Box() |  | ||||||
|                 { |  | ||||||
|                 Column(Modifier |                 Column(Modifier | ||||||
|                     .align(Alignment.TopCenter) |                     .align(Alignment.TopCenter) | ||||||
|                         .fillMaxWidth()) |  | ||||||
|                     { |  | ||||||
|                         Card( |  | ||||||
|                             colors = CardDefaults.cardColors(containerColor = colorScheme.primary), |  | ||||||
|                             shape = RoundedCornerShape(12.dp), |  | ||||||
|                             modifier = Modifier |  | ||||||
|                     .fillMaxWidth() |                     .fillMaxWidth() | ||||||
|                                 .padding(top = 18.dp) |                     .background( | ||||||
|                                 .padding(horizontal = 12.dp) |                         brush = Brush.verticalGradient( | ||||||
|                                 .height(42.dp) |                             colors = listOf( | ||||||
|  |                                 Color.Black.copy(alpha = 0.9f), | ||||||
|  |                                 Color.Transparent, | ||||||
|                             ) |                             ) | ||||||
|  |                         ) | ||||||
|  |                     )) | ||||||
|                 { |                 { | ||||||
|                             Row(modifier = Modifier.fillMaxSize()) |                     Row(modifier = Modifier | ||||||
|  |                         .fillMaxWidth() | ||||||
|  |                         .padding(horizontal =  16.dp).padding(top = 16.dp)) | ||||||
|                     { |                     { | ||||||
|                         Text( |                         Text( | ||||||
|                             text = title, |                             text = title, | ||||||
|                             fontSize = 16.sp, |                             fontSize = 16.sp, | ||||||
|  |                             lineHeight = 19.sp, | ||||||
|                             fontWeight = FontWeight.Bold, |                             fontWeight = FontWeight.Bold, | ||||||
|                             maxLines = 1, |                             maxLines = 1, | ||||||
|  |                             color = Color.White, | ||||||
|                             modifier = Modifier |                             modifier = Modifier | ||||||
|                                 .padding(8.dp) |                                 .padding(8.dp) | ||||||
|                                 .padding(horizontal = 10.dp) |                                 .padding(horizontal = 10.dp) | ||||||
| @@ -155,27 +163,19 @@ fun ComicPageView( | |||||||
|  |  | ||||||
|                         Text( |                         Text( | ||||||
|                             text = "${pagerState.currentPage + 1}/${pagerState.pageCount}", |                             text = "${pagerState.currentPage + 1}/${pagerState.pageCount}", | ||||||
|                                     fontSize = 18.sp, |                             fontSize = 16.sp, | ||||||
|  |                             lineHeight = 19.sp, | ||||||
|                             fontWeight = FontWeight.Bold, |                             fontWeight = FontWeight.Bold, | ||||||
|                             maxLines = 1, |                             maxLines = 1, | ||||||
|  |                             color = Color.White, | ||||||
|                             modifier = Modifier |                             modifier = Modifier | ||||||
|                                 .padding(8.dp) |                                 .padding(8.dp) | ||||||
|                                 .widthIn(min = 60.dp) |                                 .widthIn(min = 60.dp) | ||||||
|                                 .align(Alignment.CenterVertically) |                                 .align(Alignment.CenterVertically) | ||||||
|                         ) |                         ) | ||||||
|                     } |                     } | ||||||
|                         } |                     Box(Modifier.fillMaxWidth() | ||||||
|  |                         .padding(horizontal = 16.dp)) | ||||||
|                         Box(Modifier.fillMaxWidth()) { |  | ||||||
|                             Card( |  | ||||||
|                                 modifier = Modifier |  | ||||||
|                                     .align(Alignment.CenterStart) |  | ||||||
|                                     .padding(top = 6.dp) |  | ||||||
|                                     .padding(horizontal = 12.dp) |  | ||||||
|                                     .height(42.dp), |  | ||||||
|                                 colors = CardDefaults.cardColors(containerColor = colorScheme.primary), |  | ||||||
|                                 shape = RoundedCornerShape(12.dp) |  | ||||||
|                             ) |  | ||||||
|                     { |                     { | ||||||
|                         Row { |                         Row { | ||||||
|                             val k = it.getPageChapterIndex(pagerState.currentPage) |                             val k = it.getPageChapterIndex(pagerState.currentPage) | ||||||
| @@ -184,6 +184,7 @@ fun ComicPageView( | |||||||
|                                 fontSize = 16.sp, |                                 fontSize = 16.sp, | ||||||
|                                 fontWeight = FontWeight.Bold, |                                 fontWeight = FontWeight.Bold, | ||||||
|                                 maxLines = 1, |                                 maxLines = 1, | ||||||
|  |                                 color = Color.White, | ||||||
|                                 modifier = Modifier |                                 modifier = Modifier | ||||||
|                                     .padding(8.dp) |                                     .padding(8.dp) | ||||||
|                                     .padding(horizontal = 10.dp) |                                     .padding(horizontal = 10.dp) | ||||||
| @@ -195,13 +196,13 @@ fun ComicPageView( | |||||||
|                                 fontSize = 18.sp, |                                 fontSize = 18.sp, | ||||||
|                                 fontWeight = FontWeight.Bold, |                                 fontWeight = FontWeight.Bold, | ||||||
|                                 maxLines = 1, |                                 maxLines = 1, | ||||||
|  |                                 color = Color.White, | ||||||
|                                 modifier = Modifier |                                 modifier = Modifier | ||||||
|                                     .padding(8.dp) |                                     .padding(8.dp) | ||||||
|                                     .widthIn(min = 60.dp) |                                     .widthIn(min = 60.dp) | ||||||
|                                     .align(Alignment.CenterVertically) |                                     .align(Alignment.CenterVertically) | ||||||
|                             ) |                             ) | ||||||
|                         } |                         } | ||||||
|                             } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|                         Card( |                         Card( | ||||||
| @@ -210,7 +211,7 @@ fun ComicPageView( | |||||||
|                                 .padding(top = 6.dp) |                                 .padding(top = 6.dp) | ||||||
|                                 .padding(horizontal = 12.dp) |                                 .padding(horizontal = 12.dp) | ||||||
|                                 .height(42.dp), |                                 .height(42.dp), | ||||||
|                                 colors = CardDefaults.cardColors(containerColor = colorScheme.primary), |                             colors = CardDefaults.cardColors(containerColor = colorScheme.surface), | ||||||
|                             shape = RoundedCornerShape(12.dp) |                             shape = RoundedCornerShape(12.dp) | ||||||
|                         ) |                         ) | ||||||
|                         { |                         { | ||||||
| @@ -226,7 +227,7 @@ fun ComicPageView( | |||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     } |                     Spacer(Modifier.height(64.dp)) | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ class ComicGridViewModel @Inject constructor( | |||||||
| )  : ViewModel() | )  : ViewModel() | ||||||
| { | { | ||||||
|     var coverHeight by mutableStateOf(220.dp) |     var coverHeight by mutableStateOf(220.dp) | ||||||
|     var maxHeight = 220.dp |     var maxHeight = 0.dp | ||||||
|  |  | ||||||
|     var imageLoader: ImageLoader? = null |     var imageLoader: ImageLoader? = null | ||||||
|     var comic = mutableStateOf<Comic?>(null) |     var comic = mutableStateOf<Comic?>(null) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 acite
					acite