добавила букинг

по хорошему нужно доделать дезигн всего
This commit is contained in:
VictoriaPresnyakova 2023-10-05 00:29:25 +04:00
parent 3b192d27cb
commit 9b61677603
10 changed files with 160 additions and 23 deletions

View File

@ -10,8 +10,8 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContent { setContent {
///Navigate() Navigate()
HotelInfo(Hotel("hotel", R.drawable.img_1, 4, "location")) //HotelInfo(Hotel("hotel", R.drawable.img_1, 4, "location"))
} }
} }
} }

View File

@ -4,7 +4,12 @@ import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController 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 com.example.androidlabs.Hotel
import com.example.androidlabs.R
import com.example.androidlabs.booking.BookingScreen
import com.example.androidlabs.homeScreen.CardItem.HotelCard
import com.example.androidlabs.homeScreen.HomeScreen import com.example.androidlabs.homeScreen.HomeScreen
import com.example.androidlabs.hotelScreen.HotelInfo
import com.example.androidlabs.profileScreen.profile.ProfileScreen import com.example.androidlabs.profileScreen.profile.ProfileScreen
import com.example.androidlabs.profileScreen.signIn.LoginScreen import com.example.androidlabs.profileScreen.signIn.LoginScreen
@ -15,17 +20,20 @@ fun NavController(navController: NavHostController){
navController = navController, navController = navController,
startDestination = NavItem.Home.route startDestination = NavItem.Home.route
){ ){
composable(NavItem.Home.route){ composable(NavItem.HotelInfo.route){
HomeScreen() HotelInfo(Hotel("hotel", R.drawable.img_1, 4, "location"), navController)
}
composable(NavItem.Home.route){
HomeScreen(navController)
} }
// composable(NavItem.Like.route){
// LikeScreen()
// }
composable(NavItem.Profile.route) { composable(NavItem.Profile.route) {
ProfileScreen(navController) ProfileScreen(navController)
} }
composable(NavItem.SignIn.route){ composable(NavItem.SignIn.route){
LoginScreen(navController) LoginScreen(navController)
} }
composable(NavItem.Booking.route){
BookingScreen()
}
} }
} }

View File

@ -8,8 +8,9 @@ import androidx.compose.ui.graphics.vector.ImageVector
sealed class NavItem(val route: String, val icon: ImageVector?){ sealed class NavItem(val route: String, val icon: ImageVector?){
object Home : NavItem("home", Icons.Default.Home) object Home : NavItem("home", Icons.Default.Home)
object Like : NavItem("like", Icons.Default.Favorite)
//object Order : NavItem("order", Icons.Default.ShoppingCart)
object Profile : NavItem("profile", Icons.Default.Person) object Profile : NavItem("profile", Icons.Default.Person)
object SignIn : NavItem("login", null) object SignIn : NavItem("login", null)
object HotelInfo : NavItem("HotelInfo", null)
object Booking : NavItem("booking", null)
} }

View File

@ -23,7 +23,6 @@ fun Navigate(){
val navController = rememberNavController() val navController = rememberNavController()
val listItem = listOf( val listItem = listOf(
NavItem.Home, NavItem.Home,
NavItem.Like,
NavItem.Profile, NavItem.Profile,
) )

View File

@ -0,0 +1,111 @@
package com.example.androidlabs.booking
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@Composable
fun BookingScreen() {
var room by remember { mutableStateOf("") }
var date by remember { mutableStateOf("") }
Column(
modifier = Modifier
.fillMaxSize()
.background(Color.White)
.padding(15.dp, 0.dp)
,
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "Booking", fontSize = 24.sp, fontWeight = FontWeight.Bold)
Spacer(modifier = Modifier.height(16.dp))
BasicTextField(
value = room,
onValueChange = { room = it },
modifier = Modifier
.fillMaxWidth()
.height(50.dp)
.padding(8.dp)
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp))
.padding(8.dp),
singleLine = true,
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Next
),
keyboardActions = KeyboardActions(
onNext = {
}
),
)
BasicTextField(
value = date,
onValueChange = { date = it },
modifier = Modifier
.fillMaxWidth()
.height(50.dp)
.padding(8.dp)
.border(1.dp, Color.Gray, RoundedCornerShape(4.dp))
.padding(8.dp),
singleLine = true,
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Next
),
keyboardActions = KeyboardActions(
onNext = {
}
),
){
}
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = (Color(red = 0x2A, green = 0x7D, blue = 0xB9, alpha = 0xFF)),
contentColor = Color.White
),
onClick = {
//TODO
},
modifier = Modifier.fillMaxWidth()
) {
Text("Payment")
}
}
}

View File

@ -25,17 +25,18 @@ import androidx.compose.ui.text.font.FontWeight
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.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.example.androidlabs.Hotel import com.example.androidlabs.Hotel
import com.example.androidlabs.R import com.example.androidlabs.R
@Composable @Composable
fun HotelCard (hotel: Hotel){ fun HotelCard (hotel: Hotel, navController: NavHostController){
androidx.compose.material.Card( androidx.compose.material.Card(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(10.dp) .padding(10.dp)
.clickable { .clickable {
Log.d("My log", "Clicked") navController.navigate("HotelInfo")
}, },
shape = RoundedCornerShape(15.dp), shape = RoundedCornerShape(15.dp),
elevation = 5.dp elevation = 5.dp
@ -101,6 +102,6 @@ fun HotelCard (hotel: Hotel){
@Composable @Composable
fun CardPreview() { fun CardPreview() {
HotelCard(Hotel("hotel", R.drawable.img, 4, "location")) //HotelCard(Hotel("hotel", R.drawable.img, 4, "location"))
} }

View File

@ -17,13 +17,14 @@ import androidx.compose.ui.text.font.FontWeight
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.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.example.androidlabs.R import com.example.androidlabs.R
import com.example.androidlabs.homeScreen.CardItem.HotelCard import com.example.androidlabs.homeScreen.CardItem.HotelCard
import com.example.androidlabs.Hotel import com.example.androidlabs.Hotel
import com.example.androidlabs.homeScreen.SearchField.SearchField import com.example.androidlabs.homeScreen.SearchField.SearchField
@Composable @Composable
fun HomeScreen() { fun HomeScreen(navController: NavHostController) {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
@ -44,7 +45,8 @@ fun HomeScreen() {
Text(text="Find a Source you want to spent times", color = Color.White) Text(text="Find a Source you want to spent times", color = Color.White)
SearchField( SearchField(
modifier = Modifier modifier = Modifier
.padding(horizontal = 10.dp, vertical = 20.dp) .padding(horizontal = 10.dp, vertical = 20.dp),
) { searchText -> ) { searchText ->
// Обработка введенного текста поиска // Обработка введенного текста поиска
} }
@ -55,7 +57,7 @@ fun HomeScreen() {
//.verticalScroll(rememberScrollState()) //.verticalScroll(rememberScrollState())
){ ){
items(count = 100 ){ items(count = 100 ){
HotelCard(Hotel("hotel", R.drawable.img, it % 6, "location")) HotelCard(Hotel("hotel", R.drawable.img, it % 6, "location"), navController)
} }
} }
@ -64,5 +66,5 @@ fun HomeScreen() {
@Preview(showBackground = true) @Preview(showBackground = true)
@Composable @Composable
fun HotelPreview() { fun HotelPreview() {
HomeScreen() //HomeScreen()
} }

View File

@ -29,12 +29,13 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
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.navigation.NavHostController
import com.example.androidlabs.Hotel import com.example.androidlabs.Hotel
import com.example.androidlabs.R import com.example.androidlabs.R
import com.example.androidlabs.homeScreen.CardItem.HotelCard import com.example.androidlabs.homeScreen.CardItem.HotelCard
@Composable @Composable
fun HotelInfo(hotel: Hotel) { fun HotelInfo(hotel: Hotel, navController: NavHostController) {
Column ( Column (
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@ -130,7 +131,8 @@ fun HotelInfo(hotel: Hotel) {
Row( Row(
modifier = Modifier modifier = Modifier
//.fillMaxHeight() //.fillMaxHeight()
.padding(horizontal = 60.dp), .padding(horizontal = 60.dp)
.padding(bottom = 60.dp),
verticalAlignment = Alignment.Bottom verticalAlignment = Alignment.Bottom
){ ){
Button( Button(
@ -139,8 +141,7 @@ fun HotelInfo(hotel: Hotel) {
contentColor = Color.White contentColor = Color.White
), ),
onClick = { onClick = {
//TODO navController.navigate("booking")
//navController.navigate("booking")
}, },
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@ -156,6 +157,6 @@ fun HotelInfo(hotel: Hotel) {
@Composable @Composable
fun HotelInfoPreview() { fun HotelInfoPreview() {
HotelInfo(Hotel("hotel", R.drawable.img_1, 4, "location")) //HotelInfo(Hotel("hotel", R.drawable.img_1, 4, "location"))
} }

View File

@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredSize import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material.Button import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable; import androidx.compose.runtime.Composable;
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@ -31,6 +32,10 @@ fun ProfileScreen(navController: NavHostController) {
modifier = Modifier.padding(vertical = 16.dp) modifier = Modifier.padding(vertical = 16.dp)
){ ){
Button( Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = (Color(red = 0x2A, green = 0x7D, blue = 0xB9, alpha = 0xFF)),
contentColor = Color.White
),
onClick = { onClick = {
navController.navigate("login") navController.navigate("login")
}, },
@ -42,6 +47,10 @@ fun ProfileScreen(navController: NavHostController) {
} }
Row{ Row{
Button( Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = (Color(red = 0x2A, green = 0x7D, blue = 0xB9, alpha = 0xFF)),
contentColor = Color.White
),
onClick = { /*TODO*/ }, onClick = { /*TODO*/ },
modifier = Modifier modifier = Modifier
.requiredSize(100.dp, 40.dp) .requiredSize(100.dp, 40.dp)

View File

@ -8,6 +8,7 @@ import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Button import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -89,6 +90,10 @@ fun LoginScreen(navController : NavHostController) {
} }
Button( Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = (Color(red = 0x2A, green = 0x7D, blue = 0xB9, alpha = 0xFF)),
contentColor = Color.White
),
onClick = { onClick = {
navController.navigate("login") navController.navigate("login")
}, },