Loading feature/notification/api/src/commonMain/kotlin/net/thunderbird/feature/notification/api/ui/style/InAppNotificationStyle.kt +0 −5 Original line number Original line Diff line number Diff line Loading @@ -36,11 +36,6 @@ sealed interface InAppNotificationStyle { val duration: Duration = 10.seconds, val duration: Duration = 10.seconds, ) : InAppNotificationStyle ) : InAppNotificationStyle /** * @see [InAppNotificationStyleBuilder.bottomSheet] */ data object BottomSheetNotification : InAppNotificationStyle /** /** * @see [InAppNotificationStyleBuilder.dialog] * @see [InAppNotificationStyleBuilder.dialog] */ */ Loading feature/notification/api/src/commonMain/kotlin/net/thunderbird/feature/notification/api/ui/style/builder/InAppNotificationStyleBuilder.kt +3 −22 Original line number Original line Diff line number Diff line Loading @@ -6,6 +6,7 @@ import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerGlobalNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerGlobalNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerInlineNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerInlineNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.DialogNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.DialogNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.SnackbarNotification import net.thunderbird.feature.notification.api.ui.style.NotificationStyleMarker import net.thunderbird.feature.notification.api.ui.style.NotificationStyleMarker /** /** Loading Loading @@ -89,28 +90,8 @@ class InAppNotificationStyleBuilder internal constructor() { */ */ @NotificationStyleMarker @NotificationStyleMarker fun snackbar(duration: Duration = 10.seconds) { fun snackbar(duration: Duration = 10.seconds) { checkSingleStyleEntry<InAppNotificationStyle.SnackbarNotification>() checkSingleStyleEntry<SnackbarNotification>() styles += InAppNotificationStyle.SnackbarNotification(duration) styles += SnackbarNotification(duration) } /** * Use to inform the user about a required permission needed to enable or complete a key feature of the app. * * ### USAGE GUIDELINES * * #### Use for: * - Requesting background activity permission from the user * - Clearly and succinctly explaining why the permission is needed and how it affects the app experience * * #### Do not use for: * - Displaying errors * - Requesting contacts permission, as it does not critically impact app functionality * - Requesting notification permission, which should follow the system-standard prompt or alternative pattern */ @NotificationStyleMarker fun bottomSheet() { checkSingleStyleEntry<InAppNotificationStyle.BottomSheetNotification>() styles += InAppNotificationStyle.BottomSheetNotification } } /** /** Loading feature/notification/api/src/commonTest/kotlin/net/thunderbird/feature/notification/api/ui/style/InAppNotificationStyleTest.kt +0 −62 Original line number Original line Diff line number Diff line Loading @@ -69,20 +69,6 @@ class InAppNotificationStyleTest { assertThat(inAppStyles).containsExactly(elements = expectedStyles) assertThat(inAppStyles).containsExactly(elements = expectedStyles) } } @Test fun `inAppNotificationStyle dsl should create a bottomSheet in-app notification style`() { // Arrange val expectedStyles = arrayOf<InAppNotificationStyle>(InAppNotificationStyle.BottomSheetNotification) // Act val inAppStyles = inAppNotificationStyles { bottomSheet() } // Assert assertThat(inAppStyles).containsExactly(elements = expectedStyles) } @Test @Test fun `inAppNotificationStyle dsl should create a dialog in-app notification style`() { fun `inAppNotificationStyle dsl should create a dialog in-app notification style`() { // Arrange // Arrange Loading @@ -104,7 +90,6 @@ class InAppNotificationStyleTest { InAppNotificationStyle.BannerInlineNotification, InAppNotificationStyle.BannerInlineNotification, InAppNotificationStyle.BannerGlobalNotification, InAppNotificationStyle.BannerGlobalNotification, InAppNotificationStyle.SnackbarNotification(), InAppNotificationStyle.SnackbarNotification(), InAppNotificationStyle.BottomSheetNotification, InAppNotificationStyle.DialogNotification, InAppNotificationStyle.DialogNotification, ) ) Loading @@ -113,7 +98,6 @@ class InAppNotificationStyleTest { bannerInline() bannerInline() bannerGlobal() bannerGlobal() snackbar() snackbar() bottomSheet() dialog() dialog() } } Loading Loading @@ -190,52 +174,6 @@ class InAppNotificationStyleTest { .hasMessage(expectedErrorMessage) .hasMessage(expectedErrorMessage) } } @Test fun `inAppNotificationStyle dsl should throw IllegalStateException when bottomSheet style is added multiple times`() { // Arrange val expectedErrorMessage = "An in-app notification can only have at most one type of ${ InAppNotificationStyle.BottomSheetNotification::class.simpleName } style" // Act val actual = assertFails { inAppNotificationStyles { bottomSheet() bottomSheet() bottomSheet() } } // Assert assertThat(actual) .isInstanceOf<IllegalStateException>() .hasMessage(expectedErrorMessage) } @Test fun `inAppNotificationStyle dsl should throw IllegalStateException when dialog style is added multiple times`() { // Arrange val expectedErrorMessage = "An in-app notification can only have at most one type of ${ InAppNotificationStyle.DialogNotification::class.simpleName } style" // Act val actual = assertFails { inAppNotificationStyles { dialog() dialog() dialog() } } // Assert assertThat(actual) .isInstanceOf<IllegalStateException>() .hasMessage(expectedErrorMessage) } @Test @Test fun `inAppNotificationStyle dsl should throw IllegalStateException when in-app notification style is called without any style configuration`() { fun `inAppNotificationStyle dsl should throw IllegalStateException when in-app notification style is called without any style configuration`() { // Arrange & Act // Arrange & Act Loading Loading
feature/notification/api/src/commonMain/kotlin/net/thunderbird/feature/notification/api/ui/style/InAppNotificationStyle.kt +0 −5 Original line number Original line Diff line number Diff line Loading @@ -36,11 +36,6 @@ sealed interface InAppNotificationStyle { val duration: Duration = 10.seconds, val duration: Duration = 10.seconds, ) : InAppNotificationStyle ) : InAppNotificationStyle /** * @see [InAppNotificationStyleBuilder.bottomSheet] */ data object BottomSheetNotification : InAppNotificationStyle /** /** * @see [InAppNotificationStyleBuilder.dialog] * @see [InAppNotificationStyleBuilder.dialog] */ */ Loading
feature/notification/api/src/commonMain/kotlin/net/thunderbird/feature/notification/api/ui/style/builder/InAppNotificationStyleBuilder.kt +3 −22 Original line number Original line Diff line number Diff line Loading @@ -6,6 +6,7 @@ import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerGlobalNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerGlobalNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerInlineNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.BannerInlineNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.DialogNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.DialogNotification import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle.SnackbarNotification import net.thunderbird.feature.notification.api.ui.style.NotificationStyleMarker import net.thunderbird.feature.notification.api.ui.style.NotificationStyleMarker /** /** Loading Loading @@ -89,28 +90,8 @@ class InAppNotificationStyleBuilder internal constructor() { */ */ @NotificationStyleMarker @NotificationStyleMarker fun snackbar(duration: Duration = 10.seconds) { fun snackbar(duration: Duration = 10.seconds) { checkSingleStyleEntry<InAppNotificationStyle.SnackbarNotification>() checkSingleStyleEntry<SnackbarNotification>() styles += InAppNotificationStyle.SnackbarNotification(duration) styles += SnackbarNotification(duration) } /** * Use to inform the user about a required permission needed to enable or complete a key feature of the app. * * ### USAGE GUIDELINES * * #### Use for: * - Requesting background activity permission from the user * - Clearly and succinctly explaining why the permission is needed and how it affects the app experience * * #### Do not use for: * - Displaying errors * - Requesting contacts permission, as it does not critically impact app functionality * - Requesting notification permission, which should follow the system-standard prompt or alternative pattern */ @NotificationStyleMarker fun bottomSheet() { checkSingleStyleEntry<InAppNotificationStyle.BottomSheetNotification>() styles += InAppNotificationStyle.BottomSheetNotification } } /** /** Loading
feature/notification/api/src/commonTest/kotlin/net/thunderbird/feature/notification/api/ui/style/InAppNotificationStyleTest.kt +0 −62 Original line number Original line Diff line number Diff line Loading @@ -69,20 +69,6 @@ class InAppNotificationStyleTest { assertThat(inAppStyles).containsExactly(elements = expectedStyles) assertThat(inAppStyles).containsExactly(elements = expectedStyles) } } @Test fun `inAppNotificationStyle dsl should create a bottomSheet in-app notification style`() { // Arrange val expectedStyles = arrayOf<InAppNotificationStyle>(InAppNotificationStyle.BottomSheetNotification) // Act val inAppStyles = inAppNotificationStyles { bottomSheet() } // Assert assertThat(inAppStyles).containsExactly(elements = expectedStyles) } @Test @Test fun `inAppNotificationStyle dsl should create a dialog in-app notification style`() { fun `inAppNotificationStyle dsl should create a dialog in-app notification style`() { // Arrange // Arrange Loading @@ -104,7 +90,6 @@ class InAppNotificationStyleTest { InAppNotificationStyle.BannerInlineNotification, InAppNotificationStyle.BannerInlineNotification, InAppNotificationStyle.BannerGlobalNotification, InAppNotificationStyle.BannerGlobalNotification, InAppNotificationStyle.SnackbarNotification(), InAppNotificationStyle.SnackbarNotification(), InAppNotificationStyle.BottomSheetNotification, InAppNotificationStyle.DialogNotification, InAppNotificationStyle.DialogNotification, ) ) Loading @@ -113,7 +98,6 @@ class InAppNotificationStyleTest { bannerInline() bannerInline() bannerGlobal() bannerGlobal() snackbar() snackbar() bottomSheet() dialog() dialog() } } Loading Loading @@ -190,52 +174,6 @@ class InAppNotificationStyleTest { .hasMessage(expectedErrorMessage) .hasMessage(expectedErrorMessage) } } @Test fun `inAppNotificationStyle dsl should throw IllegalStateException when bottomSheet style is added multiple times`() { // Arrange val expectedErrorMessage = "An in-app notification can only have at most one type of ${ InAppNotificationStyle.BottomSheetNotification::class.simpleName } style" // Act val actual = assertFails { inAppNotificationStyles { bottomSheet() bottomSheet() bottomSheet() } } // Assert assertThat(actual) .isInstanceOf<IllegalStateException>() .hasMessage(expectedErrorMessage) } @Test fun `inAppNotificationStyle dsl should throw IllegalStateException when dialog style is added multiple times`() { // Arrange val expectedErrorMessage = "An in-app notification can only have at most one type of ${ InAppNotificationStyle.DialogNotification::class.simpleName } style" // Act val actual = assertFails { inAppNotificationStyles { dialog() dialog() dialog() } } // Assert assertThat(actual) .isInstanceOf<IllegalStateException>() .hasMessage(expectedErrorMessage) } @Test @Test fun `inAppNotificationStyle dsl should throw IllegalStateException when in-app notification style is called without any style configuration`() { fun `inAppNotificationStyle dsl should throw IllegalStateException when in-app notification style is called without any style configuration`() { // Arrange & Act // Arrange & Act Loading