Merge develop into feature/fga/update_rust_sdk
This commit is contained in:
commit
22fd4ac7f0
410 changed files with 2937 additions and 607 deletions
|
|
@ -22,7 +22,10 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.theme.components.Button
|
||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
import io.element.android.libraries.designsystem.theme.components.IconButton
|
||||
|
|
@ -31,14 +34,14 @@ import io.element.android.libraries.designsystem.theme.components.Text
|
|||
@Composable
|
||||
internal fun ShowkaseButton(
|
||||
isVisible: Boolean,
|
||||
onClick: () -> Unit,
|
||||
onCloseClicked: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: () -> Unit = {},
|
||||
onCloseClicked: () -> Unit = {},
|
||||
) {
|
||||
if (isVisible) {
|
||||
Button(
|
||||
modifier = modifier
|
||||
.padding(top = 32.dp, start = 16.dp),
|
||||
.padding(top = 32.dp),
|
||||
onClick = onClick
|
||||
) {
|
||||
Text(text = "Showkase Browser")
|
||||
|
|
@ -53,3 +56,16 @@ internal fun ShowkaseButton(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
internal fun ShowkaseButtonLightPreview() = ElementPreviewLight { ContentToPreview() }
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
internal fun ShowkaseButtonDarkPreview() = ElementPreviewDark { ContentToPreview() }
|
||||
|
||||
@Composable
|
||||
private fun ContentToPreview() {
|
||||
ShowkaseButton(isVisible = true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,29 +19,23 @@ package io.element.android.x.root
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import io.element.android.features.rageshake.bugreport.BugReportPresenter
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionPresenter
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import javax.inject.Inject
|
||||
|
||||
class RootPresenter @Inject constructor(
|
||||
private val bugReportPresenter: BugReportPresenter,
|
||||
private val crashDetectionPresenter: CrashDetectionPresenter,
|
||||
private val rageshakeDetectionPresenter: RageshakeDetectionPresenter,
|
||||
) : Presenter<RootState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): RootState {
|
||||
val isBugReportVisible = rememberSaveable {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
val isShowkaseButtonVisible = rememberSaveable {
|
||||
mutableStateOf(true)
|
||||
}
|
||||
val rageshakeDetectionState = rageshakeDetectionPresenter.present()
|
||||
val crashDetectionState = crashDetectionPresenter.present()
|
||||
val bugReportState = bugReportPresenter.present()
|
||||
|
||||
fun handleEvent(event: RootEvents) {
|
||||
when (event) {
|
||||
|
|
@ -50,11 +44,9 @@ class RootPresenter @Inject constructor(
|
|||
}
|
||||
|
||||
return RootState(
|
||||
isBugReportVisible = isBugReportVisible.value,
|
||||
isShowkaseButtonVisible = isShowkaseButtonVisible.value,
|
||||
rageshakeDetectionState = rageshakeDetectionState,
|
||||
crashDetectionState = crashDetectionState,
|
||||
bugReportState = bugReportState,
|
||||
eventSink = ::handleEvent
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,13 @@
|
|||
package io.element.android.x.root
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import io.element.android.features.rageshake.bugreport.BugReportState
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionState
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionState
|
||||
|
||||
@Stable
|
||||
data class RootState(
|
||||
val isBugReportVisible: Boolean,
|
||||
val isShowkaseButtonVisible: Boolean,
|
||||
val rageshakeDetectionState: RageshakeDetectionState,
|
||||
val crashDetectionState: CrashDetectionState,
|
||||
val bugReportState: BugReportState,
|
||||
val eventSink: (RootEvents) -> Unit
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.x.root
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.features.rageshake.crash.ui.aCrashDetectionState
|
||||
import io.element.android.features.rageshake.detection.aRageshakeDetectionState
|
||||
|
||||
open class RootStateProvider : PreviewParameterProvider<RootState> {
|
||||
override val values: Sequence<RootState>
|
||||
get() = sequenceOf(
|
||||
aRootState().copy(
|
||||
isShowkaseButtonVisible = true,
|
||||
rageshakeDetectionState = aRageshakeDetectionState().copy(showDialog = false),
|
||||
crashDetectionState = aCrashDetectionState().copy(crashDetected = true),
|
||||
),
|
||||
aRootState().copy(
|
||||
isShowkaseButtonVisible = true,
|
||||
rageshakeDetectionState = aRageshakeDetectionState().copy(showDialog = true),
|
||||
crashDetectionState = aCrashDetectionState().copy(crashDetected = false),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun aRootState() = RootState(
|
||||
isShowkaseButtonVisible = false,
|
||||
rageshakeDetectionState = aRageshakeDetectionState(),
|
||||
crashDetectionState = aCrashDetectionState(),
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
@ -24,10 +24,15 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionEvents
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionView
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionEvents
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionView
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.tests.uitests.openShowkase
|
||||
import io.element.android.x.component.ShowkaseButton
|
||||
|
||||
|
|
@ -68,3 +73,18 @@ fun RootView(
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
internal fun RootLightPreview(@PreviewParameter(RootStateProvider::class) rootState: RootState) = ElementPreviewLight { ContentToPreview(rootState) }
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
internal fun RootDarkPreview(@PreviewParameter(RootStateProvider::class) rootState: RootState) = ElementPreviewDark { ContentToPreview(rootState) }
|
||||
|
||||
@Composable
|
||||
private fun ContentToPreview(rootState: RootState) {
|
||||
RootView(rootState) {
|
||||
Text("Children")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,10 @@ import app.cash.molecule.RecompositionClock
|
|||
import app.cash.molecule.moleculeFlow
|
||||
import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.features.rageshake.bugreport.BugReportPresenter
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionPresenter
|
||||
import io.element.android.features.rageshake.preferences.RageshakePreferencesPresenter
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
|
|
@ -58,17 +56,11 @@ class RootPresenterTest {
|
|||
}
|
||||
}
|
||||
|
||||
private fun TestScope.createPresenter(): RootPresenter {
|
||||
private fun createPresenter(): RootPresenter {
|
||||
val crashDataStore = FakeCrashDataStore()
|
||||
val rageshakeDataStore = FakeRageshakeDataStore()
|
||||
val rageshake = FakeRageShake()
|
||||
val screenshotHolder = FakeScreenshotHolder()
|
||||
val bugReportPresenter = BugReportPresenter(
|
||||
bugReporter = FakeBugReporter(),
|
||||
crashDataStore = crashDataStore,
|
||||
screenshotHolder = screenshotHolder,
|
||||
appCoroutineScope = this,
|
||||
)
|
||||
val crashDetectionPresenter = CrashDetectionPresenter(
|
||||
crashDataStore = crashDataStore
|
||||
)
|
||||
|
|
@ -81,7 +73,6 @@ class RootPresenterTest {
|
|||
)
|
||||
)
|
||||
return RootPresenter(
|
||||
bugReportPresenter = bugReportPresenter,
|
||||
crashDetectionPresenter = crashDetectionPresenter,
|
||||
rageshakeDetectionPresenter = rageshakeDetectionPresenter,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue