Extract Provider (and rename them) to their own file and move fixture(s) there.
This commit is contained in:
parent
41965a8bcc
commit
e120ca7163
46 changed files with 593 additions and 302 deletions
|
|
@ -50,12 +50,3 @@ data class BugReportFormState(
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun aBugReportState() = BugReportState(
|
||||
formState = BugReportFormState.Default,
|
||||
hasCrashLogs = false,
|
||||
screenshotUri = null,
|
||||
sendingProgress = 0F,
|
||||
sending = Async.Uninitialized,
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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.features.rageshake.bugreport
|
||||
|
||||
import io.element.android.libraries.architecture.Async
|
||||
|
||||
fun aBugReportState() = BugReportState(
|
||||
formState = BugReportFormState.Default,
|
||||
hasCrashLogs = false,
|
||||
screenshotUri = null,
|
||||
sendingProgress = 0F,
|
||||
sending = Async.Uninitialized,
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
@ -20,8 +20,3 @@ data class CrashDetectionState(
|
|||
val crashDetected: Boolean,
|
||||
val eventSink: (CrashDetectionEvents) -> Unit
|
||||
)
|
||||
|
||||
fun aCrashDetectionState() = CrashDetectionState(
|
||||
crashDetected = false,
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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.features.rageshake.crash.ui
|
||||
|
||||
fun aCrashDetectionState() = CrashDetectionState(
|
||||
crashDetected = false,
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
@ -18,7 +18,6 @@ package io.element.android.features.rageshake.detection
|
|||
|
||||
import androidx.compose.runtime.Stable
|
||||
import io.element.android.features.rageshake.preferences.RageshakePreferencesState
|
||||
import io.element.android.features.rageshake.preferences.aRageshakePreferencesState
|
||||
|
||||
@Stable
|
||||
data class RageshakeDetectionState(
|
||||
|
|
@ -28,11 +27,3 @@ data class RageshakeDetectionState(
|
|||
val preferenceState: RageshakePreferencesState,
|
||||
val eventSink: (RageshakeDetectionEvents) -> Unit
|
||||
)
|
||||
|
||||
fun aRageshakeDetectionState() = RageshakeDetectionState(
|
||||
takeScreenshot = false,
|
||||
showDialog = false,
|
||||
isStarted = false,
|
||||
preferenceState = aRageshakePreferencesState(),
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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.features.rageshake.detection
|
||||
|
||||
import io.element.android.features.rageshake.preferences.aRageshakePreferencesState
|
||||
|
||||
fun aRageshakeDetectionState() = RageshakeDetectionState(
|
||||
takeScreenshot = false,
|
||||
showDialog = false,
|
||||
isStarted = false,
|
||||
preferenceState = aRageshakePreferencesState(),
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
@ -22,10 +22,3 @@ data class RageshakePreferencesState(
|
|||
val sensitivity: Float,
|
||||
val eventSink: (RageshakePreferencesEvents) -> Unit,
|
||||
)
|
||||
|
||||
fun aRageshakePreferencesState() = RageshakePreferencesState(
|
||||
isEnabled = false,
|
||||
isSupported = true,
|
||||
sensitivity = 0.3f,
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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.features.rageshake.preferences
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
||||
open class RageshakePreferencesStateProvider : PreviewParameterProvider<RageshakePreferencesState> {
|
||||
override val values: Sequence<RageshakePreferencesState>
|
||||
get() = sequenceOf(
|
||||
aRageshakePreferencesState().copy(isEnabled = true, isSupported = true, sensitivity = 0.5f),
|
||||
aRageshakePreferencesState().copy(isEnabled = true, isSupported = false, sensitivity = 0.5f),
|
||||
)
|
||||
}
|
||||
|
||||
fun aRageshakePreferencesState() = RageshakePreferencesState(
|
||||
isEnabled = false,
|
||||
isSupported = true,
|
||||
sensitivity = 0.3f,
|
||||
eventSink = {}
|
||||
)
|
||||
|
|
@ -24,7 +24,6 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceCategory
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceSlide
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceSwitch
|
||||
|
|
@ -77,22 +76,14 @@ fun RageshakePreferencesView(
|
|||
}
|
||||
}
|
||||
|
||||
open class RageshakePreferencesStatePreviewParameterProvider : PreviewParameterProvider<RageshakePreferencesState> {
|
||||
override val values: Sequence<RageshakePreferencesState>
|
||||
get() = sequenceOf(
|
||||
aRageshakePreferencesState().copy(isEnabled = true, isSupported = true, sensitivity = 0.5f),
|
||||
aRageshakePreferencesState().copy(isEnabled = true, isSupported = false, sensitivity = 0.5f),
|
||||
)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun RageshakePreferencesViewLightPreview(@PreviewParameter(RageshakePreferencesStatePreviewParameterProvider::class) state: RageshakePreferencesState) =
|
||||
fun RageshakePreferencesViewLightPreview(@PreviewParameter(RageshakePreferencesStateProvider::class) state: RageshakePreferencesState) =
|
||||
ElementPreviewLight { ContentToPreview(state) }
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun RageshakePreferencesViewDarkPreview(@PreviewParameter(RageshakePreferencesStatePreviewParameterProvider::class) state: RageshakePreferencesState) =
|
||||
fun RageshakePreferencesViewDarkPreview(@PreviewParameter(RageshakePreferencesStateProvider::class) state: RageshakePreferencesState) =
|
||||
ElementPreviewDark { ContentToPreview(state) }
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue