Advertisement
itszainboi

Untitled

Dec 29th, 2024
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 5.69 KB | None | 0 0
  1. package com.example.waifushowcase
  2.  
  3. import android.os.Bundle
  4. import androidx.activity.ComponentActivity
  5. import androidx.activity.compose.setContent
  6. import androidx.activity.enableEdgeToEdge
  7. import androidx.annotation.DrawableRes
  8. import androidx.annotation.StringRes
  9. import androidx.compose.foundation.Image
  10. import androidx.compose.foundation.background
  11. import androidx.compose.foundation.border
  12. import androidx.compose.foundation.layout.Arrangement
  13. import androidx.compose.foundation.layout.Box
  14. import androidx.compose.foundation.layout.Column
  15. import androidx.compose.foundation.layout.Row
  16. import androidx.compose.foundation.layout.Spacer
  17. import androidx.compose.foundation.layout.aspectRatio
  18. import androidx.compose.foundation.layout.fillMaxSize
  19. import androidx.compose.foundation.layout.fillMaxWidth
  20. import androidx.compose.foundation.layout.height
  21. import androidx.compose.foundation.layout.offset
  22. import androidx.compose.foundation.layout.padding
  23. import androidx.compose.foundation.layout.size
  24. import androidx.compose.foundation.shape.RoundedCornerShape
  25. import androidx.compose.material3.Button
  26. import androidx.compose.material3.Scaffold
  27. import androidx.compose.material3.Text
  28. import androidx.compose.runtime.Composable
  29. import androidx.compose.runtime.mutableStateOf
  30. import androidx.compose.runtime.remember
  31. import androidx.compose.ui.Modifier
  32. import androidx.compose.ui.graphics.Color
  33. import androidx.compose.ui.graphics.painter.Painter
  34. import androidx.compose.ui.res.painterResource
  35. import androidx.compose.ui.res.stringResource
  36. import androidx.compose.ui.tooling.preview.Preview
  37. import androidx.compose.ui.unit.dp
  38. import com.example.waifushowcase.ui.theme.WaifuShowcaseTheme
  39. import androidx.compose.runtime.getValue
  40. import androidx.compose.runtime.mutableIntStateOf
  41. import androidx.compose.runtime.setValue
  42. import androidx.compose.ui.Alignment
  43. import androidx.compose.ui.draw.clip
  44. import androidx.compose.ui.draw.shadow
  45. import androidx.compose.ui.text.style.LineHeightStyle
  46.  
  47.  
  48. class MainActivity : ComponentActivity() {
  49.     override fun onCreate(savedInstanceState: Bundle?) {
  50.         super.onCreate(savedInstanceState)
  51.         enableEdgeToEdge()
  52.         setContent {
  53.             WaifuShowcaseTheme {
  54.                 WaifuApp()
  55.             }
  56.         }
  57.     }
  58. }
  59.  
  60. // Data class for waifus
  61. data class Waifu(
  62.     @DrawableRes val imageRes: Int,
  63.     val name: String,
  64.     val description: String
  65. )
  66.  
  67. // main screen
  68. @Composable
  69. fun WaifuApp(modifier: Modifier = Modifier) {
  70.     var currentWaifu by remember { mutableIntStateOf(0) }
  71.  
  72.     val waifus = listOf(
  73.         Waifu(
  74.             imageRes = R.drawable.makise,
  75.             name = "Makise Kurisu",
  76.             description = "Best Tsundere"
  77.         ),
  78.         Waifu(
  79.             imageRes = R.drawable.mikasa_ackerman,
  80.             name = "Mikasa Ackerman",
  81.             description = "EREEEH"
  82.         )
  83.     )
  84.  
  85.     Box(
  86.         modifier = Modifier
  87.             .fillMaxSize()
  88.     ) {
  89.         // Picture of waifus
  90.         Column(
  91.             horizontalAlignment = Alignment.CenterHorizontally,
  92.             verticalArrangement = Arrangement.Center,
  93.             modifier = Modifier
  94.                 .align(Alignment.Center) // Center the content
  95.                 .offset(y = (-100).dp)
  96.                 .clip(shape = RoundedCornerShape(16.dp))
  97.                 .background(color = Color.White, shape = RoundedCornerShape(16.dp))
  98.                 .shadow(elevation = 3.dp, shape = RoundedCornerShape(16.dp))
  99.                 .padding(20.dp)
  100.                 .size(300.dp)
  101.         ) {
  102.             Image(
  103.                 painter = painterResource(id = waifus[currentWaifu].imageRes),
  104.                 contentDescription = null,
  105.                 modifier = Modifier
  106.                     .fillMaxSize()
  107.                     .clip(shape = RoundedCornerShape(16.dp))
  108.             )
  109.         }
  110.  
  111.         // Description box
  112.         Column(
  113.             horizontalAlignment = Alignment.CenterHorizontally,
  114.             verticalArrangement = Arrangement.Center,
  115.             modifier = Modifier
  116.                 .align(Alignment.Center)
  117.                 .offset(y = 210.dp)
  118.                 .size(width = 250.dp, height = 100.dp)
  119.                 .clip(shape = RoundedCornerShape(16.dp))
  120.                 .background(color = Color.LightGray)
  121.  
  122.         ) {
  123.             Text("Test1")
  124.             Text("Test2")
  125.         }
  126.  
  127.         // Navigation buttons at the bottom
  128.         Box(
  129.             modifier = Modifier
  130.                 .fillMaxWidth()
  131.                 .align(Alignment.BottomCenter) // Align buttons to the bottom
  132.         ) {
  133.             Row(
  134.                 modifier = Modifier
  135.                     .fillMaxWidth()
  136.             ) {
  137.                 //Previous button
  138.                 Button(
  139.                     onClick = {
  140.                         if (currentWaifu > 0)
  141.                             currentWaifu--
  142.                               },
  143.                     modifier = Modifier
  144. //                .size(160.dp, 70.dp)
  145.                         .weight(1f)
  146.                         .padding(16.dp)
  147.                 ) {
  148.                     Text(text = "<")
  149.                 }
  150.  
  151.                 //Next button
  152.                 Button(
  153.                     onClick = {
  154.                         if (currentWaifu < waifus.size - 1)
  155.                             currentWaifu++
  156.                               },
  157.                     modifier = Modifier
  158.                         .weight(1f)
  159.                         .padding(16.dp)
  160.                 ) {
  161.                     Text(text = ">")
  162.                 }
  163.             }
  164.         }
  165.     }
  166. }
  167.  
  168.  
  169. @Preview(showBackground = true)
  170. @Composable
  171. fun GreetingPreview() {
  172.     WaifuShowcaseTheme {
  173.         WaifuApp()
  174.     }
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement