From 371cbac3ab8f26cd904259cac8b425ec7607df67 Mon Sep 17 00:00:00 2001 From: Maik Mursall Date: Mon, 15 Aug 2022 15:08:35 +0200 Subject: [PATCH] Added PopupLoadingIndicator to fill the entire screen --- .../fintecsystems/xs2awizard/XS2AWizard.kt | 9 ++++-- .../LoadingIndicator.kt | 2 +- .../loadingIndicator/PopupLoadingIndicator.kt | 30 +++++++++++++++++++ .../form/components/AutoSubmitLine.kt | 2 +- .../form/components/textLine/TextLine.kt | 2 +- 5 files changed, 39 insertions(+), 6 deletions(-) rename xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/{ => loadingIndicator}/LoadingIndicator.kt (89%) create mode 100644 xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/loadingIndicator/PopupLoadingIndicator.kt diff --git a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/XS2AWizard.kt b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/XS2AWizard.kt index 8981aa5f..340737d2 100644 --- a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/XS2AWizard.kt +++ b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/XS2AWizard.kt @@ -1,18 +1,21 @@ package com.fintecsystems.xs2awizard import android.app.Activity -import androidx.compose.foundation.* +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.* import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel -import com.fintecsystems.xs2awizard.components.LoadingIndicator import com.fintecsystems.xs2awizard.components.XS2AWizardConfig import com.fintecsystems.xs2awizard.components.XS2AWizardViewModel +import com.fintecsystems.xs2awizard.components.loadingIndicator.PopupLoadingIndicator import com.fintecsystems.xs2awizard.components.networking.ConnectionState import com.fintecsystems.xs2awizard.components.networking.ConnectivityStatusBanner import com.fintecsystems.xs2awizard.components.theme.XS2ATheme @@ -85,7 +88,7 @@ fun XS2AWizard( } if (loadingIndicatorLock) { - LoadingIndicator( + PopupLoadingIndicator( modifier = Modifier .fillMaxSize() .clickable( diff --git a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/LoadingIndicator.kt b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/loadingIndicator/LoadingIndicator.kt similarity index 89% rename from xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/LoadingIndicator.kt rename to xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/loadingIndicator/LoadingIndicator.kt index 84dae840..4bf15f6e 100644 --- a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/LoadingIndicator.kt +++ b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/loadingIndicator/LoadingIndicator.kt @@ -1,4 +1,4 @@ -package com.fintecsystems.xs2awizard.components +package com.fintecsystems.xs2awizard.components.loadingIndicator import androidx.compose.foundation.layout.Box import androidx.compose.material.CircularProgressIndicator diff --git a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/loadingIndicator/PopupLoadingIndicator.kt b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/loadingIndicator/PopupLoadingIndicator.kt new file mode 100644 index 00000000..baa5e45d --- /dev/null +++ b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/components/loadingIndicator/PopupLoadingIndicator.kt @@ -0,0 +1,30 @@ +package com.fintecsystems.xs2awizard.components.loadingIndicator + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.IntRect +import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.unit.LayoutDirection +import androidx.compose.ui.window.Popup +import androidx.compose.ui.window.PopupPositionProvider + +@Composable +fun PopupLoadingIndicator( + modifier: Modifier = Modifier, +) { + val popupPositionProvider = object : PopupPositionProvider { + override fun calculatePosition( + anchorBounds: IntRect, + windowSize: IntSize, + layoutDirection: LayoutDirection, + popupContentSize: IntSize + ): IntOffset { + return IntOffset.Zero + } + } + + Popup(popupPositionProvider = popupPositionProvider) { + LoadingIndicator(modifier) + } +} \ No newline at end of file diff --git a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/AutoSubmitLine.kt b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/AutoSubmitLine.kt index 0cadf20b..a870cd9a 100644 --- a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/AutoSubmitLine.kt +++ b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/AutoSubmitLine.kt @@ -4,7 +4,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier -import com.fintecsystems.xs2awizard.components.LoadingIndicator +import com.fintecsystems.xs2awizard.components.loadingIndicator.LoadingIndicator import com.fintecsystems.xs2awizard.components.XS2AWizardViewModel import com.fintecsystems.xs2awizard.form.AutoSubmitLineData import kotlinx.coroutines.delay diff --git a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/textLine/TextLine.kt b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/textLine/TextLine.kt index 80ace182..17884254 100644 --- a/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/textLine/TextLine.kt +++ b/xs2awizard/src/main/java/com/fintecsystems/xs2awizard/form/components/textLine/TextLine.kt @@ -21,7 +21,7 @@ import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.toSize import androidx.compose.ui.window.PopupProperties import com.fintecsystems.xs2awizard.R -import com.fintecsystems.xs2awizard.components.LoadingIndicator +import com.fintecsystems.xs2awizard.components.loadingIndicator.LoadingIndicator import com.fintecsystems.xs2awizard.components.XS2AWizardViewModel import com.fintecsystems.xs2awizard.components.theme.XS2ATheme import com.fintecsystems.xs2awizard.form.TextLineData