Skip to content

Commit

Permalink
Merge pull request #14 from LookUpGroup27/feature/general-navigation
Browse files Browse the repository at this point in the history
feat: add navigation setup and actions
  • Loading branch information
Kenzoud authored Oct 7, 2024
2 parents 6b3cfe3 + 0b6adac commit 745345d
Show file tree
Hide file tree
Showing 9 changed files with 339 additions and 138 deletions.
129 changes: 82 additions & 47 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {

defaultConfig {
applicationId = "com.github.lookupgroup27.lookup"
minSdk = 28
minSdk = 29
targetSdk = 34
versionCode = 1
versionName = "1.0"
Expand Down Expand Up @@ -47,21 +47,29 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion = "1.4.2"
kotlinCompilerExtensionVersion = "1.5.1"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
merges += "META-INF/LICENSE.md"
merges += "META-INF/LICENSE-notice.md"
excludes += "META-INF/LICENSE-notice.md"
excludes += "META-INF/LICENSE.md"
excludes += "META-INF/LICENSE"
excludes += "META-INF/LICENSE.txt"
excludes += "META-INF/NOTICE"
excludes += "META-INF/NOTICE.txt"
}
}

Expand Down Expand Up @@ -113,48 +121,75 @@ fun DependencyHandlerScope.globalTestImplementation(dep: Any) {
}

dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(platform(libs.compose.bom))
testImplementation(libs.junit)
globalTestImplementation(libs.androidx.junit)
globalTestImplementation(libs.androidx.espresso.core)

// ------------- Jetpack Compose ------------------
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
globalTestImplementation(composeBom)

implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
// Material Design 3
implementation(libs.compose.material3)
// Integration with activities
implementation(libs.compose.activity)
// Integration with ViewModels
implementation(libs.compose.viewmodel)
// Android Studio Preview support
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
// UI Tests
globalTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)

// --------- Kaspresso test framework ----------
globalTestImplementation(libs.kaspresso)
globalTestImplementation(libs.kaspresso.compose)

// ---------- Robolectric ------------
testImplementation(libs.robolectric)

// ---------- Firebase ------------
implementation(libs.firebase.database.ktx)
implementation(libs.firebase.firestore)
implementation(libs.firebase.ui.auth)
implementation(libs.firebase.auth.ktx)
implementation(libs.firebase.auth)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)

// Jetpack Compose BOM
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Jetpack Compose
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.material3)
implementation(libs.compose.activity)
implementation(libs.compose.viewmodel)
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
androidTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)

// Kaspresso test framework
androidTestImplementation(libs.kaspresso)
androidTestImplementation(libs.kaspresso.compose)

// Robolectric
testImplementation(libs.robolectric)

// Firebase
implementation(libs.firebase.database.ktx)
implementation(libs.firebase.firestore)
implementation(libs.firebase.ui.auth)
implementation(libs.firebase.auth.ktx)

// Navigation
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)

// Unit Testing
testImplementation(libs.junit)
androidTestImplementation(libs.mockk)
androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.mockk.agent)
testImplementation(libs.json)

// UI Testing
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.espresso.intents)
androidTestImplementation(libs.androidx.ui.test.junit4)
androidTestImplementation(platform(libs.androidx.compose.bom))
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.kotlin)
androidTestImplementation(libs.mockito.android)
androidTestImplementation(libs.mockito.kotlin)
testImplementation(libs.robolectric)

// Kaspresso Allure
androidTestImplementation(libs.kaspresso.allure.support)
androidTestImplementation(libs.kaspresso.compose.support)

// Coroutines Testing
testImplementation(libs.kotlinx.coroutines.test)

// Networking with OkHttp
implementation(libs.okhttp)

}

tasks.withType<Test> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.github.lookupgroup27.lookup.ui.navigation

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.DateRange
import androidx.compose.material.icons.outlined.Place
import androidx.compose.material.icons.outlined.PlayArrow
import androidx.compose.material.icons.outlined.Star
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavHostController

object Route {
const val MAP = "Map"
const val CALENDAR = "Calendar"
const val SKY_TRACKER = "SkyTracker"
const val QUIZ = "Quiz"
const val PROFILE = "Profile"
const val MENU = "Menu"
const val COLLECTION = "Collection"
}

object Screen {
const val MAP = "Map Screen"
const val CALENDAR = "Calendar Screen"
const val SKY_TRACKER = "Sky Tracker Screen"
const val QUIZ = "Quiz Screen"
const val PROFILE = "Profile Screen"
const val MENU = "Menu Screen"
const val COLLECTION = "Collection Screen"
}

data class TopLevelDestination(val route: String, val icon: ImageVector, val textId: String)

object TopLevelDestinations {
val MAP = TopLevelDestination(route = Route.MAP, icon = Icons.Outlined.Place, textId = "Map")
val CALENDAR =
TopLevelDestination(
route = Route.CALENDAR, icon = Icons.Outlined.DateRange, textId = "Calendar")
val SKY_TRACKER =
TopLevelDestination(
route = Route.SKY_TRACKER, icon = Icons.Outlined.Star, textId = "Sky Tracker")
val QUIZ =
TopLevelDestination(route = Route.QUIZ, icon = Icons.Outlined.PlayArrow, textId = "Quiz")
}

val LIST_TOP_LEVEL_DESTINATION =
listOf(
TopLevelDestinations.MAP,
TopLevelDestinations.CALENDAR,
TopLevelDestinations.SKY_TRACKER,
TopLevelDestinations.QUIZ)

open class NavigationActions(
private val navController: NavHostController,
) {
/**
* Navigate to the specified [TopLevelDestination].
*
* @param destination The top-level destination to navigate to. Clear the back stack when
* navigating to a new destination.
*/
open fun navigateTo(destination: TopLevelDestination) {
navController.navigate(destination.route) {
// Pop up to the start destination of the graph to avoid stacking destinations.
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
inclusive = true
}

// Avoid multiple copies of the same destination.
launchSingleTop = true

// Restore state when reselecting a previously selected item.
restoreState = true
}
}

/**
* Navigate to the specified screen.
*
* @param screen The screen to navigate to.
*/
open fun navigateTo(screen: String) {
navController.navigate(screen)
}

/** Navigate back to the previous screen. */
open fun goBack() {
navController.popBackStack()
}

/**
* Get the current route of the navigation controller.
*
* @return The current route.
*/
open fun currentRoute(): String {
return navController.currentDestination?.route ?: ""
}
}

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions app/src/test/java/com/github/lookupgroup27/lookup/PointTest.kt

This file was deleted.

This file was deleted.

Loading

0 comments on commit 745345d

Please sign in to comment.