Feature: signIn and move to ProfileScreen
This commit is contained in:
parent
e9285732a7
commit
a9b847eee0
@ -7,7 +7,8 @@ import androidx.navigation.compose.composable
|
|||||||
import com.example.android_programming.HomeScreen.HomeScreen
|
import com.example.android_programming.HomeScreen.HomeScreen
|
||||||
import com.example.android_programming.LikeScreen.LikeScreen
|
import com.example.android_programming.LikeScreen.LikeScreen
|
||||||
import com.example.android_programming.Screens.OrderScreen
|
import com.example.android_programming.Screens.OrderScreen
|
||||||
import com.example.android_programming.Screens.ProfileScreen
|
import com.example.android_programming.ProfileScreen.Profile.ProfileScreen
|
||||||
|
import com.example.android_programming.ProfileScreen.SignIn.LoginScreen
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NavController(navController: NavHostController){
|
fun NavController(navController: NavHostController){
|
||||||
@ -25,7 +26,10 @@ fun NavController(navController: NavHostController){
|
|||||||
OrderScreen()
|
OrderScreen()
|
||||||
}
|
}
|
||||||
composable(NavItem.Profile.route){
|
composable(NavItem.Profile.route){
|
||||||
ProfileScreen()
|
ProfileScreen(navController)
|
||||||
|
}
|
||||||
|
composable(NavItem.SignIn.route){
|
||||||
|
LoginScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,9 +7,10 @@ import androidx.compose.material.icons.filled.Person
|
|||||||
import androidx.compose.material.icons.filled.ShoppingCart
|
import androidx.compose.material.icons.filled.ShoppingCart
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
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 Like : NavItem("like", Icons.Default.Favorite)
|
||||||
object Order : NavItem("order", Icons.Default.ShoppingCart)
|
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)
|
||||||
}
|
}
|
@ -61,11 +61,13 @@ fun Navigate(){
|
|||||||
Modifier
|
Modifier
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon(
|
it.icon?.let { it1 ->
|
||||||
imageVector = it.icon,
|
Icon(
|
||||||
contentDescription = null,
|
imageVector = it1,
|
||||||
modifier = iconModifier.then(Modifier.size(24.dp))
|
contentDescription = null,
|
||||||
)
|
modifier = iconModifier.then(Modifier.size(24.dp))
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.example.android_programming.ProfileScreen.Profile;
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.requiredSize
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
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.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import com.example.android_programming.Navigation.NavController
|
||||||
|
import com.example.android_programming.ProfileScreen.SignIn.LoginScreen
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ProfileScreen(navController: NavHostController) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White),
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
){
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(vertical = 16.dp)
|
||||||
|
){
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
navController.navigate("login")
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.requiredSize(100.dp, 40.dp)
|
||||||
|
) {
|
||||||
|
Text(text = "Sign In")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row{
|
||||||
|
Button(
|
||||||
|
onClick = { /*TODO*/ },
|
||||||
|
modifier = Modifier
|
||||||
|
.requiredSize(100.dp, 40.dp)
|
||||||
|
) {
|
||||||
|
Text(text = "Sign Up")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@Preview
|
||||||
|
fun ProfileScreenPreview(){
|
||||||
|
val navController = rememberNavController()
|
||||||
|
ProfileScreen(navController = navController)
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package com.example.android_programming.ProfileScreen.SignIn
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
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.Text
|
||||||
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.input.pointer.PointerIcon.Companion.Text
|
||||||
|
import androidx.compose.ui.semantics.SemanticsProperties.Text
|
||||||
|
import androidx.compose.ui.text.Placeholder
|
||||||
|
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.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.navigation.NavController
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import androidx.compose.material.Text as Text1
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun LoginScreen(navController : NavHostController) {
|
||||||
|
var username by remember { mutableStateOf("") }
|
||||||
|
var password by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Color.White)
|
||||||
|
.padding(15.dp, 0.dp)
|
||||||
|
,
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text1(text = "Sign In", fontSize = 24.sp, fontWeight = FontWeight.Bold)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
BasicTextField(
|
||||||
|
value = username,
|
||||||
|
onValueChange = { username = 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 = password,
|
||||||
|
onValueChange = { password = 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(
|
||||||
|
onClick = {
|
||||||
|
navController.navigate("login")
|
||||||
|
},
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Text1("Sign In")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun performLogin(username: String, password: String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@Preview
|
||||||
|
fun SignInScreen(){
|
||||||
|
LoginScreen()
|
||||||
|
}
|
@ -1,36 +0,0 @@
|
|||||||
package com.example.android_programming.Screens;
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.material.MaterialTheme
|
|
||||||
import androidx.compose.material.Text
|
|
||||||
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.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun ProfileScreen() {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(Color.White),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "Profile",
|
|
||||||
fontSize = MaterialTheme.typography.h3.fontSize,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = Color.Black
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun ProfileScreenPreview(){
|
|
||||||
ProfileScreen()
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user