Skip to content

Commit

Permalink
Merge branch 'develop' into chore/websocket-compressed-payload
Browse files Browse the repository at this point in the history
  • Loading branch information
FelberMartin authored Jan 2, 2025
2 parents c952576 + f599e43 commit 01869cc
Show file tree
Hide file tree
Showing 26 changed files with 627 additions and 536 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
id("com.google.gms.google-services")
id("com.google.firebase.appdistribution")
id("com.google.android.gms.oss-licenses-plugin")
id("io.sentry.android.gradle") version "4.14.0"
id("io.sentry.android.gradle") version "4.14.1"
id("artemis.android.room")
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package de.tum.informatics.www1.artemis.native_app.android.ui.theme

import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
Expand All @@ -11,11 +12,6 @@ import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext

@Immutable
data class ExtendedColorScheme(
val customColor: ColorFamily,
)

private val lightScheme = lightColorScheme(
primary = primaryLight,
onPrimary = onPrimaryLight,
Expand Down Expand Up @@ -244,60 +240,6 @@ private val highContrastDarkColorScheme = darkColorScheme(
surfaceContainerHighest = surfaceContainerHighestDarkHighContrast,
)

val extendedLight = ExtendedColorScheme(
customColor = ColorFamily(
customColorLight,
onCustomColorLight,
customColorContainerLight,
onCustomColorContainerLight,
),
)

val extendedDark = ExtendedColorScheme(
customColor = ColorFamily(
customColorDark,
onCustomColorDark,
customColorContainerDark,
onCustomColorContainerDark,
),
)

val extendedLightMediumContrast = ExtendedColorScheme(
customColor = ColorFamily(
customColorLightMediumContrast,
onCustomColorLightMediumContrast,
customColorContainerLightMediumContrast,
onCustomColorContainerLightMediumContrast,
),
)

val extendedLightHighContrast = ExtendedColorScheme(
customColor = ColorFamily(
customColorLightHighContrast,
onCustomColorLightHighContrast,
customColorContainerLightHighContrast,
onCustomColorContainerLightHighContrast,
),
)

val extendedDarkMediumContrast = ExtendedColorScheme(
customColor = ColorFamily(
customColorDarkMediumContrast,
onCustomColorDarkMediumContrast,
customColorContainerDarkMediumContrast,
onCustomColorContainerDarkMediumContrast,
),
)

val extendedDarkHighContrast = ExtendedColorScheme(
customColor = ColorFamily(
customColorDarkHighContrast,
onCustomColorDarkHighContrast,
customColorContainerDarkHighContrast,
onCustomColorContainerDarkHighContrast,
),
)

@Immutable
data class ColorFamily(
val color: Color,
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "2.1.0"
kotlin("plugin.serialization") version "2.0.21"
kotlin("plugin.serialization") version "2.1.0"
// id("java-gradle-plugin")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.navigation

import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.togetherWith


object DefaultTransition {
const val duration = 220

val fadeIn = fadeIn(tween(duration))
val fadeOut = fadeOut(tween(duration))

val navigateForward = enter togetherWith exit
val navigateBack = popEnter togetherWith popExit
val navigateNeutral = fadeIn togetherWith fadeOut

val enter
get() = slideIn(AnimatedContentTransitionScope.SlideDirection.Left)

val exit
get() = slideOut(AnimatedContentTransitionScope.SlideDirection.Left)

val popEnter
get() = slideIn(AnimatedContentTransitionScope.SlideDirection.Right)

val popExit
get() = slideOut(AnimatedContentTransitionScope.SlideDirection.Right)

fun slideIn(
direction: AnimatedContentTransitionScope.SlideDirection
): EnterTransition = slideInHorizontally(
animationSpec = tween(duration)
) { width ->
return@slideInHorizontally when(direction) {
AnimatedContentTransitionScope.SlideDirection.Left -> width
else -> - width
}
} + fadeIn

fun slideOut(
direction: AnimatedContentTransitionScope.SlideDirection
): ExitTransition = slideOutHorizontally(
animationSpec = tween(duration)
) { width ->
return@slideOutHorizontally when(direction) {
AnimatedContentTransitionScope.SlideDirection.Left -> - width
else -> width
}
} + fadeOut
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.navigation

import androidx.compose.animation.AnimatedContentScope
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.runtime.Composable
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavDeepLink
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import kotlin.reflect.KType


inline fun <reified T : Any> NavGraphBuilder.animatedComposable(
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
noinline enterTransition:
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
EnterTransition?)? = { DefaultTransition.enter },
noinline exitTransition:
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
ExitTransition?)? = { DefaultTransition.exit },
noinline popEnterTransition:
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
EnterTransition?)? = { DefaultTransition.popEnter },
noinline popExitTransition:
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
ExitTransition?)? = { DefaultTransition.popExit },
noinline sizeTransform:
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
SizeTransform?)? =
null,
noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
) = composable<T>(
enterTransition = enterTransition,
exitTransition = exitTransition,
popEnterTransition = popEnterTransition,
popExitTransition = popExitTransition,
sizeTransform = sizeTransform,
typeMap = typeMap,
deepLinks = deepLinks,
content = content
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import de.tum.informatics.www1.artemis.native_app.core.common.test.DefaultTestTi
import de.tum.informatics.www1.artemis.native_app.core.common.test.EndToEndTest
import de.tum.informatics.www1.artemis.native_app.core.common.test.testServerUrl
import de.tum.informatics.www1.artemis.native_app.core.data.dataModule
import de.tum.informatics.www1.artemis.native_app.core.data.service.impl.JsonProvider
import de.tum.informatics.www1.artemis.native_app.core.data.service.network.ServerTimeService
import de.tum.informatics.www1.artemis.native_app.core.data.test.service.TrustAllCertsKtorProvider
import de.tum.informatics.www1.artemis.native_app.core.test.BaseComposeTest
import de.tum.informatics.www1.artemis.native_app.core.test.coreTestModules
import de.tum.informatics.www1.artemis.native_app.core.test.test_setup.DefaultTimeoutMillis
import de.tum.informatics.www1.artemis.native_app.feature.login.loginModule
Expand All @@ -16,23 +15,20 @@ import de.tum.informatics.www1.artemis.native_app.feature.login.test.testLoginMo
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import org.junit.experimental.categories.Category
import org.junit.runner.RunWith
import org.koin.android.ext.koin.androidContext
import org.koin.test.KoinTest
import org.koin.test.KoinTestRule
import org.robolectric.RobolectricTestRunner
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

@Category(EndToEndTest::class)
@RunWith(RobolectricTestRunner::class)
class SyncServerTimeE2eTest : KoinTest {
class SyncServerTimeE2eTest : BaseComposeTest() {

@get:Rule
val koinRule = KoinTestRule.create {
Expand All @@ -43,7 +39,7 @@ class SyncServerTimeE2eTest : KoinTest {
}

@Test(timeout = DefaultTestTimeoutMillis)
fun `sync server time`() = runTest(timeout = DefaultTimeoutMillis.milliseconds) {
fun `sync server time`() = runTest(timeout = DefaultTimeoutMillis.milliseconds * 2) { // Multiplied by 2, because flaky test
val serverTimeService: ServerTimeService = koinRule.koin.get()

val accessToken = performTestLogin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptionsBuilder
import androidx.navigation.compose.composable
import de.tum.informatics.www1.artemis.native_app.core.data.DataState
import de.tum.informatics.www1.artemis.native_app.core.model.Course
import de.tum.informatics.www1.artemis.native_app.core.ui.AwaitDeferredCompletion
Expand All @@ -63,6 +62,7 @@ import de.tum.informatics.www1.artemis.native_app.core.ui.common.course.computeC
import de.tum.informatics.www1.artemis.native_app.core.ui.common.course.computeCourseItemModifier
import de.tum.informatics.www1.artemis.native_app.core.ui.getWindowSizeClass
import de.tum.informatics.www1.artemis.native_app.core.ui.markdown.MarkdownText
import de.tum.informatics.www1.artemis.native_app.core.ui.navigation.animatedComposable
import kotlinx.coroutines.Deferred
import kotlinx.serialization.Serializable
import org.koin.androidx.compose.koinViewModel
Expand All @@ -82,7 +82,7 @@ fun NavGraphBuilder.courseRegistration(
onNavigateUp: () -> Unit,
onRegisteredInCourse: (courseId: Long) -> Unit
) {
composable<CourseRegistrationScreen> {
animatedComposable<CourseRegistrationScreen> {
RegisterForCourseScreen(
modifier = Modifier.fillMaxSize(),
viewModel = koinViewModel(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package de.tum.informatics.www1.artemis.native_app.feature.courseview.ui.course_

import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
Expand All @@ -20,7 +17,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
Expand All @@ -33,9 +29,6 @@ import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptionsBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import androidx.navigation.navDeepLink
import androidx.navigation.toRoute
import de.tum.informatics.www1.artemis.native_app.core.data.DataState
Expand All @@ -46,17 +39,19 @@ import de.tum.informatics.www1.artemis.native_app.core.ui.common.BasicDataStateU
import de.tum.informatics.www1.artemis.native_app.core.ui.common.EmptyDataStateUi
import de.tum.informatics.www1.artemis.native_app.core.ui.exercise.BoundExerciseActions
import de.tum.informatics.www1.artemis.native_app.core.ui.generateLinks
import de.tum.informatics.www1.artemis.native_app.core.ui.navigation.DefaultTransition
import de.tum.informatics.www1.artemis.native_app.core.ui.navigation.animatedComposable
import de.tum.informatics.www1.artemis.native_app.feature.courseview.GroupedByWeek
import de.tum.informatics.www1.artemis.native_app.feature.courseview.R
import de.tum.informatics.www1.artemis.native_app.feature.courseview.ui.CourseViewModel
import de.tum.informatics.www1.artemis.native_app.feature.courseview.ui.LectureListUi
import de.tum.informatics.www1.artemis.native_app.feature.courseview.ui.exercise_list.ExerciseListUi
import de.tum.informatics.www1.artemis.native_app.feature.metis.NavigateToUserConversation
import de.tum.informatics.www1.artemis.native_app.feature.metis.NothingOpened
import de.tum.informatics.www1.artemis.native_app.feature.metis.OpenedConversation
import de.tum.informatics.www1.artemis.native_app.feature.metis.OpenedThread
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.StandalonePostId
import de.tum.informatics.www1.artemis.native_app.feature.metis.ui.ConversationFacadeUi
import de.tum.informatics.www1.artemis.native_app.feature.metis.ui.NavigateToUserConversation
import de.tum.informatics.www1.artemis.native_app.feature.metis.ui.NothingOpened
import de.tum.informatics.www1.artemis.native_app.feature.metis.ui.OpenedConversation
import de.tum.informatics.www1.artemis.native_app.feature.metis.ui.OpenedThread
import kotlinx.serialization.Serializable
import org.koin.androidx.compose.koinViewModel
import org.koin.core.parameter.parametersOf
Expand Down Expand Up @@ -98,7 +93,7 @@ fun NavGraphBuilder.course(
generateLinks("courses/{courseId}/exercises") +
generateLinks("courses/{courseId}/messages?conversationId={conversationId}") +
generateLinks("courses/{courseId}/messages?username={username}")
composable<CourseUiScreen>(
animatedComposable<CourseUiScreen>(
deepLinks = deepLinks
) { backStackEntry ->
val route: CourseUiScreen = backStackEntry.toRoute()
Expand Down Expand Up @@ -346,11 +341,9 @@ internal fun CourseUiScreen(
targetState = selectedTabIndex,
transitionSpec = {
if (targetState > initialState) {
slideInHorizontally { width -> width } togetherWith
slideOutHorizontally { width -> -width }
DefaultTransition.navigateForward
} else {
slideInHorizontally { width -> -width } togetherWith
slideOutHorizontally { width -> width }
DefaultTransition.navigateBack
}.using(
SizeTransform(clip = false)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptionsBuilder
import androidx.navigation.compose.composable
import de.tum.informatics.www1.artemis.native_app.core.model.Dashboard
import de.tum.informatics.www1.artemis.native_app.core.ui.common.BasicDataStateUi
import de.tum.informatics.www1.artemis.native_app.core.ui.navigation.animatedComposable
import de.tum.informatics.www1.artemis.native_app.feature.dashboard.BuildConfig
import de.tum.informatics.www1.artemis.native_app.feature.dashboard.R
import de.tum.informatics.www1.artemis.native_app.feature.dashboard.service.BetaHintService
Expand All @@ -71,7 +71,7 @@ fun NavGraphBuilder.dashboard(
onClickRegisterForCourse: () -> Unit,
onViewCourse: (courseId: Long) -> Unit
) {
composable<DashboardScreen> {
animatedComposable<DashboardScreen> {
CoursesOverview(
modifier = Modifier.fillMaxSize(),
viewModel = koinViewModel(),
Expand Down
Loading

0 comments on commit 01869cc

Please sign in to comment.