diff --git a/app/src/main/java/com/example/android_programming/Navigation/NavController.kt b/app/src/main/java/com/example/android_programming/Navigation/NavController.kt index 034959f..4a89694 100644 --- a/app/src/main/java/com/example/android_programming/Navigation/NavController.kt +++ b/app/src/main/java/com/example/android_programming/Navigation/NavController.kt @@ -7,7 +7,8 @@ import androidx.navigation.compose.composable import com.example.android_programming.HomeScreen.HomeScreen import com.example.android_programming.LikeScreen.LikeScreen 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 fun NavController(navController: NavHostController){ @@ -25,7 +26,10 @@ fun NavController(navController: NavHostController){ OrderScreen() } composable(NavItem.Profile.route){ - ProfileScreen() + ProfileScreen(navController) + } + composable(NavItem.SignIn.route){ + LoginScreen() } } } \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt b/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt index 8a3b5d2..665c96f 100644 --- a/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt +++ b/app/src/main/java/com/example/android_programming/Navigation/NavItem.kt @@ -7,9 +7,10 @@ import androidx.compose.material.icons.filled.Person import androidx.compose.material.icons.filled.ShoppingCart 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 Like : NavItem("like", Icons.Default.Favorite) object Order : NavItem("order", Icons.Default.ShoppingCart) object Profile : NavItem("profile", Icons.Default.Person) + object SignIn : NavItem("login", null) } \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt b/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt index 90b64ac..c5025eb 100644 --- a/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt +++ b/app/src/main/java/com/example/android_programming/Navigation/Navigate.kt @@ -61,11 +61,13 @@ fun Navigate(){ Modifier } - Icon( - imageVector = it.icon, - contentDescription = null, - modifier = iconModifier.then(Modifier.size(24.dp)) - ) + it.icon?.let { it1 -> + Icon( + imageVector = it1, + contentDescription = null, + modifier = iconModifier.then(Modifier.size(24.dp)) + ) + } } ) } diff --git a/app/src/main/java/com/example/android_programming/ProfileScreen/Profile/ProfileScreen.kt b/app/src/main/java/com/example/android_programming/ProfileScreen/Profile/ProfileScreen.kt new file mode 100644 index 0000000..19a1d51 --- /dev/null +++ b/app/src/main/java/com/example/android_programming/ProfileScreen/Profile/ProfileScreen.kt @@ -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) +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/ProfileScreen/SignIn/SignInScreen.kt b/app/src/main/java/com/example/android_programming/ProfileScreen/SignIn/SignInScreen.kt new file mode 100644 index 0000000..a48efea --- /dev/null +++ b/app/src/main/java/com/example/android_programming/ProfileScreen/SignIn/SignInScreen.kt @@ -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() +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android_programming/Screens/ProfileScreen.kt b/app/src/main/java/com/example/android_programming/Screens/ProfileScreen.kt deleted file mode 100644 index 8954f37..0000000 --- a/app/src/main/java/com/example/android_programming/Screens/ProfileScreen.kt +++ /dev/null @@ -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() -} \ No newline at end of file