-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from SwEnt-Group13/feature/loginScreen
feat(ui/welcomeScreen): create welcome screen before authentication
- Loading branch information
Showing
6 changed files
with
144 additions
and
17 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/src/androidTest/java/com/android/unio/ui/AuthenticationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.android.unio.ui | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import com.android.unio.ui.authentication.WelcomeScreen | ||
import com.android.unio.ui.navigation.NavigationAction | ||
import com.android.unio.ui.navigation.Screen | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.mockito.kotlin.eq | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.verify | ||
|
||
class AuthenticationTest { | ||
|
||
private lateinit var navigationAction: NavigationAction | ||
|
||
@get:Rule val composeTestRule = createComposeRule() | ||
|
||
@Before | ||
fun setUp() { | ||
navigationAction = mock { NavigationAction::class.java } | ||
composeTestRule.setContent { WelcomeScreen(navigationAction) } | ||
} | ||
|
||
@Test | ||
fun testNavigationWelcomeToLogin() { | ||
composeTestRule.onNodeWithTag("LoginButton").assertIsDisplayed() | ||
composeTestRule.onNodeWithTag("LoginButton").performClick() | ||
verify(navigationAction).navigateTo(eq(Screen.AUTH)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 44 additions & 5 deletions
49
app/src/main/java/com/android/unio/ui/authentication/Login.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,53 @@ | ||
package com.android.unio.ui.authentication | ||
|
||
import android.annotation.SuppressLint | ||
import androidx.compose.material.Scaffold | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.OutlinedTextField | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.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.platform.testTag | ||
import androidx.compose.ui.unit.dp | ||
import com.android.unio.ui.navigation.NavigationAction | ||
import com.android.unio.ui.navigation.Screen | ||
|
||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter") | ||
@Composable | ||
fun LoginScreen() { | ||
Scaffold(content = { Text("Login screen") }, modifier = Modifier.testTag("LoginScreen")) | ||
fun LoginScreen(navigationAction: NavigationAction) { | ||
var email by remember { mutableStateOf("") } | ||
var password by remember { mutableStateOf("") } | ||
Scaffold( | ||
modifier = Modifier.testTag("LoginScreen").fillMaxSize(), | ||
content = { padding -> | ||
Column( | ||
modifier = Modifier.padding(padding).padding(vertical = 200.dp, horizontal = 50.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally) { | ||
OutlinedTextField( | ||
modifier = Modifier.padding(16.dp), | ||
label = { Text("Enter your university address") }, | ||
onValueChange = { email = it }, | ||
value = email) | ||
OutlinedTextField( | ||
modifier = Modifier.padding(16.dp), | ||
label = { Text("And your password") }, | ||
onValueChange = { password = it }, | ||
value = password) | ||
Button( | ||
onClick = { | ||
/* TODO Handle login with Tequila/Microsoft if possible */ | ||
navigationAction.navigateTo(Screen.HOME) | ||
}) { | ||
Text("Continue") | ||
} | ||
} | ||
}) | ||
} |
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/android/unio/ui/authentication/Welcome.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.android.unio.ui.authentication | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import com.android.unio.ui.navigation.NavigationAction | ||
import com.android.unio.ui.navigation.Screen | ||
|
||
@Composable | ||
fun WelcomeScreen(navigationAction: NavigationAction) { | ||
Scaffold(modifier = Modifier.fillMaxSize().testTag("WelcomeScreen")) { | ||
Column( | ||
modifier = Modifier.padding(it).padding(vertical = 200.dp, horizontal = 100.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally) { | ||
// Image( | ||
// // Placeholder for the Unio logo | ||
// painter = painterResource(id = R.drawable.ic_launcher_foreground), | ||
// contentDescription = "Unio logo", | ||
// modifier = Modifier.padding(16.dp)) | ||
Text( | ||
"The world’s largest campus life platform !", | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier.padding(16.dp)) | ||
Button( | ||
onClick = { navigationAction.navigateTo(Screen.AUTH) }, | ||
modifier = Modifier.testTag("LoginButton").padding(16.dp)) { | ||
Text("Login") | ||
} | ||
Button(onClick = { navigationAction.navigateTo(Screen.HOME) }) { | ||
Text("<Debug> Skip to Home") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters