Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement MainActivity with navigation setup #22

Merged
merged 24 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
adba4cd
refactor: update composable skeletons to accept NavigationActions as …
Kenzoud Oct 11, 2024
bf96382
feat: update NavigationActions with missing screens, routes, and revi…
Kenzoud Oct 11, 2024
29314dd
feat: add BottomNavigationMenu composable in navigation package
Kenzoud Oct 11, 2024
1e3a996
chore: add missing Profile and SkyTracker composable files
Kenzoud Oct 11, 2024
0cde534
feat: implement MainActivity with NavHost and navigation setup
Kenzoud Oct 11, 2024
3daa51b
fix: correct screen call in NavigationActions tests
Kenzoud Oct 11, 2024
5304110
chore: temporary commit to enable merge with main branch
Kenzoud Oct 13, 2024
7f14fe6
Merge branch 'main' of github.com:LookUpGroup27/LookUp into feature/u…
Kenzoud Oct 13, 2024
532e3f4
test: add additional coverage for NavigationActions with top-level de…
Kenzoud Oct 14, 2024
c759bb2
feat: update MainActivity to integrate CalendarScreen with ViewModel …
Kenzoud Oct 14, 2024
241292d
feat: update MainActivity to integrate CalendarScreen with ViewModel …
Kenzoud Oct 14, 2024
8d26896
fix: resolve merge conflicts with main branch
Kenzoud Oct 14, 2024
0d4fecc
fix: resolve duplicated value in NavigationActions after merge
Kenzoud Oct 14, 2024
6d4b665
style: apply ktfmt formatting
Kenzoud Oct 14, 2024
58e35d1
fix: resolve merge conflicts with main branch
Kenzoud Oct 14, 2024
f1bae7d
fix: correct navigation action for MAP screen on LandingScreen
Kenzoud Oct 14, 2024
a851781
feat: update theme and color palette for dark, galaxy-inspired design
Kenzoud Oct 14, 2024
b131b7b
chore: delete unnecessary files to clean up repository
Kenzoud Oct 14, 2024
6baaa37
feat: implement MainActivity with updated navigation and theme setup
Kenzoud Oct 14, 2024
5fadc21
style: update SignIn screen with galaxy-themed colors and typography
Kenzoud Oct 14, 2024
c65324c
style: apply ktfmt formatting
Kenzoud Oct 14, 2024
cf9080c
refactor: replace "SampleApp" references with "LookUp"
Kenzoud Oct 14, 2024
46c3f65
test: update login test functionality
Kenzoud Oct 14, 2024
c8bdae8
feat: update navigation in SignIn screen
Kenzoud Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LoginTest : TestCase() {
fun titleAndButtonAreCorrectlyDisplayed() {
// Assert that the title "Welcome" and the Google Sign-In button are displayed correctly
composeTestRule.onNodeWithTag("loginTitle").assertIsDisplayed()
composeTestRule.onNodeWithTag("loginTitle").assertTextEquals("Welcome")
composeTestRule.onNodeWithTag("loginTitle").assertTextEquals("Welcome to the Cosmos")

composeTestRule.onNodeWithTag("loginButton").assertIsDisplayed()
composeTestRule.onNodeWithTag("loginButton").assertHasClickAction()
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SampleApp"
android:theme="@style/Theme.LookUpApp"
tools:targetApi="31">
<activity
android:name=".SecondActivity"
android:exported="false"
android:label="@string/title_activity_second"
android:theme="@style/Theme.SampleApp" />

<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/title_activity_main"
android:theme="@style/Theme.SampleApp">
android:theme="@style/Theme.LookUpApp">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
99 changes: 60 additions & 39 deletions app/src/main/java/com/github/lookupgroup27/lookup/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,77 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.*
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.*
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.*
import androidx.navigation.navigation
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController
import com.github.lookupgroup27.lookup.model.calendar.CalendarViewModel
import com.github.lookupgroup27.lookup.resources.C
import com.github.lookupgroup27.lookup.ui.authentication.SignInScreen
import com.github.lookupgroup27.lookup.ui.map.MapScreen
import com.github.lookupgroup27.lookup.ui.navigation.*
import com.github.lookupgroup27.lookup.ui.overview.*
import com.github.lookupgroup27.lookup.ui.theme.SampleAppTheme
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
import com.github.lookupgroup27.lookup.ui.navigation.Route
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.skytracker.SkyTrackerScreen
import com.github.lookupgroup27.lookup.ui.theme.LookUpTheme
import com.google.firebase.auth.FirebaseAuth

class MainActivity : ComponentActivity() {

private lateinit var auth: FirebaseAuth

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
SampleAppTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize().semantics { testTag = C.Tag.main_screen_container },
color = MaterialTheme.colorScheme.background) {
LookUpApp()
}
}
}

auth = FirebaseAuth.getInstance()
auth.currentUser?.let { auth.signOut() }

setContent { LookUpTheme { Surface(modifier = Modifier.fillMaxSize()) { LookUpApp() } } }
}
}

@Composable
fun LookUpApp() {
val navController = rememberNavController()
val navigationActions = NavigationActions(navController)
val calendarViewModel: CalendarViewModel = viewModel()

NavHost(navController = navController, startDestination = Route.LANDING) {
navigation(
startDestination = Screen.AUTH,
route = Route.AUTH,
) {
composable(Screen.AUTH) { SignInScreen(navigationActions) }
}

navigation(
startDestination = Screen.LANDING,
route = Route.LANDING,
) {
composable(Screen.LANDING) { LandingScreen(navigationActions) }
composable(Screen.MENU) { MenuScreen(navigationActions) }
composable(Screen.MAP) { MapScreen(navigationActions) }
}

navigation(
startDestination = Screen.MENU,
route = Route.MENU,
) {
composable(Screen.MENU) { MenuScreen(navigationActions) }
composable(Screen.PROFILE) { ProfileScreen(navigationActions) }

composable(Screen.CALENDAR) { CalendarScreen(calendarViewModel, navigationActions) }

@Composable
fun LookUpApp() {
val navController = rememberNavController()
val navigationActions = NavigationActions(navController)
val calendarViewModel: CalendarViewModel = viewModel()

NavHost(navController = navController, startDestination = Route.LANDING) {
navigation(
startDestination = Screen.LANDING,
route = Route.LANDING,
) {
composable(Screen.LANDING) { LandingScreen(navigationActions) }
}
navigation(startDestination = Screen.MENU, route = Route.MENU) {
composable(Screen.MENU) { MenuScreen(navigationActions) }
composable(Screen.QUIZ) { QuizScreen(navigationActions) }
composable(Screen.CALENDAR) { CalendarScreen(calendarViewModel, navigationActions) }
}
navigation(startDestination = Screen.MAP, route = Route.MAP) {
composable(Screen.MAP) { MapScreen(navigationActions) }
}
composable(Screen.SKY_TRACKER) { SkyTrackerScreen(navigationActions) }
composable(Screen.QUIZ) { QuizScreen(navigationActions) }
}
}
}

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/java/com/github/lookupgroup27/lookup/SimpleData.kt

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/java/com/github/lookupgroup27/lookup/resources/C.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ 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
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.ApiException
Expand All @@ -50,7 +51,7 @@ fun SignInScreen(navigationActions: NavigationActions) {
onAuthComplete = { result ->
Log.d("SignInScreen", "User signed in: ${result.user?.displayName}")
Toast.makeText(context, "Login successful!", Toast.LENGTH_LONG).show()
// TODO: navigate to the next screen
navigationActions.navigateTo(Screen.PROFILE)
},
onAuthError = {
Log.e("SignInScreen", "Failed to sign in: ${it.statusCode}")
Expand All @@ -60,7 +61,7 @@ fun SignInScreen(navigationActions: NavigationActions) {

Scaffold(
modifier = Modifier.fillMaxSize(),
containerColor = Color.White,
containerColor = Color.Black,
content = { padding ->
Column(
modifier = Modifier.fillMaxSize().padding(padding),
Expand All @@ -78,14 +79,17 @@ fun SignInScreen(navigationActions: NavigationActions) {
// Welcome Text
Text(
modifier = Modifier.testTag("loginTitle"),
text = "Welcome",
text = "Welcome to the Cosmos",
style =
MaterialTheme.typography.headlineLarge.copy(fontSize = 57.sp, lineHeight = 64.sp),
fontWeight = FontWeight.Bold,
// center the text

MaterialTheme.typography.headlineMedium.copy(
fontSize = 42.sp,
lineHeight = 50.sp,
letterSpacing = 1.5.sp // Add letter spacing for a futuristic effect
),
fontWeight = FontWeight.SemiBold, // Use SemiBold for a smoother look
textAlign = TextAlign.Center,
color = Color.White)
color = Color(0xFF8A9BB7) // A softer, muted star-like color
)

Spacer(modifier = Modifier.height(48.dp))

Expand All @@ -108,9 +112,9 @@ fun SignInScreen(navigationActions: NavigationActions) {
fun GoogleSignInButton(onSignInClick: () -> Unit) {
Button(
onClick = onSignInClick,
colors = ButtonDefaults.buttonColors(containerColor = Color.White), // Button color
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF1A1A2E)), // Button color
shape = RoundedCornerShape(50), // Circular edges for the button
border = BorderStroke(1.dp, Color.LightGray),
border = BorderStroke(1.dp, Color(0xFF9DACE6)),
modifier =
Modifier.padding(8.dp)
.height(48.dp) // Adjust height as needed
Expand All @@ -130,7 +134,7 @@ fun GoogleSignInButton(onSignInClick: () -> Unit) {
// Text for the button
Text(
text = "Sign in with Google",
color = Color.Gray, // Text color
color = Color.White, // Text color
fontSize = 16.sp, // Font size
fontWeight = FontWeight.Medium)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.github.lookupgroup27.lookup.ui.navigation

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp

@Composable
fun BottomNavigationMenu(
onTabSelect: (TopLevelDestination) -> Unit,
tabList: List<TopLevelDestination>,
selectedItem: String
) {
NavigationBar(
modifier = Modifier.fillMaxWidth().height(60.dp).testTag("bottomNavigationMenu"),
containerColor = MaterialTheme.colorScheme.surface,
content = {
tabList.forEach { tab ->
NavigationBarItem(
icon = { Icon(tab.icon, contentDescription = null) },
label = { Text(tab.textId) },
selected = tab.route == selectedItem,
onClick = { onTabSelect(tab) },
modifier = Modifier.clip(RoundedCornerShape(50.dp)).testTag(tab.textId))
}
},
)
}
Loading
Loading