mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Introduce fun aShowLocationState to reduce boilerplate code.
This commit is contained in:
committed by
Benoit Marty
parent
1e7c9b2256
commit
367e4bdbda
+28
-59
@@ -24,78 +24,47 @@ private const val APP_NAME = "ApplicationName"
|
|||||||
class ShowLocationStateProvider : PreviewParameterProvider<ShowLocationState> {
|
class ShowLocationStateProvider : PreviewParameterProvider<ShowLocationState> {
|
||||||
override val values: Sequence<ShowLocationState>
|
override val values: Sequence<ShowLocationState>
|
||||||
get() = sequenceOf(
|
get() = sequenceOf(
|
||||||
ShowLocationState(
|
aShowLocationState(),
|
||||||
ShowLocationState.Dialog.None,
|
aShowLocationState(
|
||||||
Location(1.23, 2.34, 4f),
|
permissionDialog = ShowLocationState.Dialog.PermissionDenied,
|
||||||
description = null,
|
|
||||||
hasLocationPermission = false,
|
|
||||||
isTrackMyLocation = false,
|
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
),
|
||||||
ShowLocationState(
|
aShowLocationState(
|
||||||
ShowLocationState.Dialog.PermissionDenied,
|
permissionDialog = ShowLocationState.Dialog.PermissionRationale,
|
||||||
Location(1.23, 2.34, 4f),
|
|
||||||
description = null,
|
|
||||||
hasLocationPermission = false,
|
|
||||||
isTrackMyLocation = false,
|
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
),
|
||||||
ShowLocationState(
|
aShowLocationState(
|
||||||
ShowLocationState.Dialog.PermissionRationale,
|
|
||||||
Location(1.23, 2.34, 4f),
|
|
||||||
description = null,
|
|
||||||
hasLocationPermission = false,
|
|
||||||
isTrackMyLocation = false,
|
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
|
||||||
ShowLocationState(
|
|
||||||
ShowLocationState.Dialog.None,
|
|
||||||
Location(1.23, 2.34, 4f),
|
|
||||||
description = null,
|
|
||||||
hasLocationPermission = true,
|
hasLocationPermission = true,
|
||||||
isTrackMyLocation = false,
|
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
),
|
||||||
ShowLocationState(
|
aShowLocationState(
|
||||||
ShowLocationState.Dialog.None,
|
|
||||||
Location(1.23, 2.34, 4f),
|
|
||||||
description = null,
|
|
||||||
hasLocationPermission = true,
|
hasLocationPermission = true,
|
||||||
isTrackMyLocation = true,
|
isTrackMyLocation = true,
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
),
|
||||||
ShowLocationState(
|
aShowLocationState(
|
||||||
ShowLocationState.Dialog.None,
|
|
||||||
Location(1.23, 2.34, 4f),
|
|
||||||
description = "My favourite place!",
|
description = "My favourite place!",
|
||||||
hasLocationPermission = false,
|
|
||||||
isTrackMyLocation = false,
|
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
),
|
||||||
ShowLocationState(
|
aShowLocationState(
|
||||||
ShowLocationState.Dialog.None,
|
|
||||||
Location(1.23, 2.34, 4f),
|
|
||||||
description = "For some reason I decided to to write a small essay that wraps at just two lines!",
|
description = "For some reason I decided to to write a small essay that wraps at just two lines!",
|
||||||
hasLocationPermission = false,
|
|
||||||
isTrackMyLocation = false,
|
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
),
|
||||||
ShowLocationState(
|
aShowLocationState(
|
||||||
ShowLocationState.Dialog.None,
|
|
||||||
Location(1.23, 2.34, 4f),
|
|
||||||
description = "For some reason I decided to write a small essay in the location description. " +
|
description = "For some reason I decided to write a small essay in the location description. " +
|
||||||
"It is so long that it will wrap onto more than two lines!",
|
"It is so long that it will wrap onto more than two lines!",
|
||||||
hasLocationPermission = false,
|
|
||||||
isTrackMyLocation = false,
|
|
||||||
appName = APP_NAME,
|
|
||||||
eventSink = {},
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun aShowLocationState(
|
||||||
|
permissionDialog: ShowLocationState.Dialog = ShowLocationState.Dialog.None,
|
||||||
|
location: Location = Location(1.23, 2.34, 4f),
|
||||||
|
description: String? = null,
|
||||||
|
hasLocationPermission: Boolean = false,
|
||||||
|
isTrackMyLocation: Boolean = false,
|
||||||
|
appName: String = APP_NAME,
|
||||||
|
eventSink: (ShowLocationEvents) -> Unit = {},
|
||||||
|
) = ShowLocationState(
|
||||||
|
permissionDialog = permissionDialog,
|
||||||
|
location = location,
|
||||||
|
description = description,
|
||||||
|
hasLocationPermission = hasLocationPermission,
|
||||||
|
isTrackMyLocation = isTrackMyLocation,
|
||||||
|
appName = appName,
|
||||||
|
eventSink = eventSink,
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user