first steps for hotel info

This commit is contained in:
VictoriaPresnyakova 2023-10-04 16:12:27 +04:00
parent 72c903a0b3
commit 3b192d27cb
6 changed files with 169 additions and 11 deletions

View File

@ -4,12 +4,14 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.example.androidlabs.Navigation.Navigate
import com.example.androidlabs.hotelScreen.HotelInfo
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Navigate()
///Navigate()
HotelInfo(Hotel("hotel", R.drawable.img_1, 4, "location"))
}
}
}

View File

@ -29,7 +29,7 @@ import com.example.androidlabs.Hotel
import com.example.androidlabs.R
@Composable
fun Card (hotel: Hotel){
fun HotelCard (hotel: Hotel){
androidx.compose.material.Card(
modifier = Modifier
.fillMaxWidth()
@ -101,6 +101,6 @@ fun Card (hotel: Hotel){
@Composable
fun CardPreview() {
Card(Hotel("hotel", R.drawable.img, 4, "location"))
HotelCard(Hotel("hotel", R.drawable.img, 4, "location"))
}

View File

@ -18,7 +18,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.androidlabs.R
import com.example.androidlabs.homeScreen.CardItem.Card
import com.example.androidlabs.homeScreen.CardItem.HotelCard
import com.example.androidlabs.Hotel
import com.example.androidlabs.homeScreen.SearchField.SearchField
@ -55,7 +55,7 @@ fun HomeScreen() {
//.verticalScroll(rememberScrollState())
){
items(count = 100 ){
Card(Hotel("hotel", R.drawable.img, it % 6, "location"))
HotelCard(Hotel("hotel", R.drawable.img, it % 6, "location"))
}
}

View File

@ -0,0 +1,161 @@
package com.example.androidlabs.hotelScreen
import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.ButtonColors
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.androidlabs.Hotel
import com.example.androidlabs.R
import com.example.androidlabs.homeScreen.CardItem.HotelCard
@Composable
fun HotelInfo(hotel: Hotel) {
Column (
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.background(Color.White)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.SpaceBetween,
){
Image(
painter = painterResource(id = hotel.img),
contentDescription = "hotel",
contentScale = ContentScale.FillWidth,
modifier = Modifier
.fillMaxWidth()
)
Box(
modifier = Modifier.background(Color.White)
){
Row (
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly
){
Text(text = hotel.name)
// stars
}
}
Divider(color = Color.Black, thickness = 1.dp)
Box(
modifier = Modifier.background(Color.White)
){
Row (
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly
){
Text(text = "1 room | 1 Night")
Text(text = "Rs. 4000")
}
}
Divider(color = Color.Black, thickness = 1.dp)
Box(
modifier = Modifier
.background(Color.White)
){
Column (
modifier = Modifier
.fillMaxWidth()
,
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceEvenly
){
Text(text = "Location")
Text(text = hotel.location)
}
}
Divider(color = Color.Black, thickness = 1.dp)
Box(
modifier = Modifier
.background(Color.White)
){
Column (
modifier = Modifier
.fillMaxWidth()
,
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceEvenly
){
Text(text = "Amenties")
Text(text = "wifi")
}
}
Divider(color = Color.Black, thickness = 1.dp)
Box(
modifier = Modifier
.background(Color.White)
){
Column (
modifier = Modifier
.fillMaxWidth()
,
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceEvenly
){
Text(text = "Info")
Text(text = "inf")
}
}
//Divider(color = Color.Black, thickness = 1.dp)
Row(
modifier = Modifier
//.fillMaxHeight()
.padding(horizontal = 60.dp),
verticalAlignment = Alignment.Bottom
){
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = (Color(red = 0x2A, green = 0x7D, blue = 0xB9, alpha = 0xFF)),
contentColor = Color.White
),
onClick = {
//TODO
//navController.navigate("booking")
},
modifier = Modifier
.fillMaxWidth()
) {
Text("Select Room")
}
}
}
}
@Preview(showBackground = true)
@Composable
fun HotelInfoPreview() {
HotelInfo(Hotel("hotel", R.drawable.img_1, 4, "location"))
}

View File

@ -21,6 +21,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import androidx.compose.material.Text as Text1
@Composable
@ -102,9 +103,3 @@ fun LoginScreen(navController : NavHostController) {
fun performLogin(username: String, password: String) {
}
@Composable
@Preview
fun SignInScreen(){
//LoginScreen()
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB