Skip to content

Commit

Permalink
feat: Add navigation from quiz landing screen to play quiz screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismaillat committed Oct 16, 2024
1 parent ad28ca3 commit 1e5d91f
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 111 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.lookupgroup27.lookup.ui.overview
package com.github.lookupgroup27.lookup.ui.quiz

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
import org.junit.Rule
Expand All @@ -21,8 +20,8 @@ class QuizScreenTest {
fun quizScreen_displaysQuizText() {
composeTestRule.setContent { QuizScreen(navigationActions = mockNavigationActions) }

// Verify that the "Quiz Screen" text is displayed
composeTestRule.onNodeWithText("Quiz Screen").assertIsDisplayed()
// Verify that the "quiz_screen" text is displayed
composeTestRule.onNodeWithTag("quiz_screen").assertIsDisplayed()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import com.github.lookupgroup27.lookup.ui.navigation.Screen
import com.github.lookupgroup27.lookup.ui.overview.CalendarScreen
import com.github.lookupgroup27.lookup.ui.overview.LandingScreen
import com.github.lookupgroup27.lookup.ui.overview.MenuScreen
import com.github.lookupgroup27.lookup.ui.overview.QuizScreen
import com.github.lookupgroup27.lookup.ui.profile.ProfileScreen
import com.github.lookupgroup27.lookup.ui.quiz.QuizPlayScreen
import com.github.lookupgroup27.lookup.ui.quiz.QuizScreen
import com.github.lookupgroup27.lookup.ui.skytracker.SkyTrackerScreen
import com.github.lookupgroup27.lookup.ui.theme.LookUpTheme
import com.google.firebase.auth.FirebaseAuth
Expand Down Expand Up @@ -75,5 +76,10 @@ fun LookUpApp() {
composable(Screen.SKY_TRACKER) { SkyTrackerScreen(navigationActions) }
composable(Screen.QUIZ) { QuizScreen(navigationActions) }
}

navigation(startDestination = Screen.QUIZ, route = Route.QUIZ) {
composable(Screen.QUIZ) { QuizScreen(navigationActions) }
composable(Screen.QUIZ_PLAY) { QuizPlayScreen(navigationActions) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ object Route {
const val CALENDAR = "Calendar"
const val SKY_TRACKER = "SkyTracker"
const val QUIZ = "Quiz"
const val QUIZ_PLAY = "QuizPlay"
const val PROFILE = "Profile"
const val MENU = "Menu"
const val COLLECTION = "Collection"
Expand All @@ -26,6 +27,7 @@ object Screen {
const val CALENDAR = "Calendar Screen"
const val SKY_TRACKER = "Sky Tracker Screen"
const val QUIZ = "Quiz Screen"
const val QUIZ_PLAY = "Quiz Play Screen"
const val PROFILE = "Profile Screen"
const val MENU = "Menu Screen"
const val COLLECTION = "Collection Screen"
Expand Down
106 changes: 0 additions & 106 deletions app/src/main/java/com/github/lookupgroup27/lookup/ui/overview/Quiz.kt

This file was deleted.

91 changes: 91 additions & 0 deletions app/src/main/java/com/github/lookupgroup27/lookup/ui/quiz/Quiz.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.github.lookupgroup27.lookup.ui.quiz

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.blur
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.github.lookupgroup27.lookup.R
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
import com.github.lookupgroup27.lookup.ui.navigation.Screen

@Composable
fun QuizScreen(navigationActions: NavigationActions) {
Box(
modifier = Modifier.fillMaxSize().testTag("quiz_screen"),
contentAlignment = Alignment.Center,
) {

// Background Image
Image(
painter = painterResource(id = R.drawable.landing_screen_bckgrnd),
contentDescription = "Background",
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize().blur(10.dp).testTag("quiz_background"))

IconButton(
onClick = { navigationActions.goBack() },
modifier =
Modifier.padding(16.dp).align(Alignment.TopStart).testTag("go_back_button_quiz")) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = "Back",
tint = Color.White)
}

// Overlay for content
Column(
modifier = Modifier.align(Alignment.Center).padding(horizontal = 32.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(32.dp)) {
// Title Text
Text(
text = "Take a Quiz",
color = Color.White,
style =
MaterialTheme.typography.displaySmall.copy(
fontWeight = FontWeight.Bold, fontSize = 32.sp),
modifier = Modifier.testTag("quiz_title"))

// Earth Button
Button(
onClick = { navigationActions.navigateTo(Screen.QUIZ_PLAY) },
shape = RoundedCornerShape(16.dp),
modifier = Modifier.fillMaxWidth().height(56.dp).testTag("earth_button")) {
Text(
text = "Earth",
fontSize = 20.sp,
color = Color.White,
fontWeight = FontWeight.SemiBold)
}

// Solar System Button
Button(
onClick = { navigationActions.navigateTo(Screen.QUIZ_PLAY) },
shape = RoundedCornerShape(16.dp),
modifier = Modifier.fillMaxWidth().height(56.dp).testTag("solar_system_button")) {
Text(
text = "Solar System",
fontSize = 20.sp,
color = Color.White,
fontWeight = FontWeight.SemiBold)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.lookupgroup27.lookup.ui.quiz

import androidx.compose.runtime.Composable
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
import com.github.lookupgroup27.lookup.ui.overview.SampleScreen

@Composable
fun QuizPlayScreen(navigationActions: NavigationActions) {
SampleScreen(
screenText = "Quiz Play Screen",
navigationActions = navigationActions,
screenTag = "quiz_play_screen",
backButtonTag = "go_back_button_quiz")
}

0 comments on commit 1e5d91f

Please sign in to comment.