s/view/show/

This commit is contained in:
Chris Smith 2023-07-05 10:19:07 +01:00
parent 514bab48e8
commit 87853b467f
19 changed files with 51 additions and 51 deletions

View file

@ -21,7 +21,7 @@ import com.bumble.appyx.core.node.Node
import io.element.android.libraries.architecture.FeatureEntryPoint import io.element.android.libraries.architecture.FeatureEntryPoint
import io.element.android.libraries.architecture.NodeInputs import io.element.android.libraries.architecture.NodeInputs
interface ViewLocationEntryPoint : FeatureEntryPoint { interface ShowLocationEntryPoint : FeatureEntryPoint {
data class Inputs(val location: Location, val description: String?) : NodeInputs data class Inputs(val location: Location, val description: String?) : NodeInputs

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import io.element.android.features.location.api.Location import io.element.android.features.location.api.Location

View file

@ -14,19 +14,19 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import com.bumble.appyx.core.modality.BuildContext import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node import com.bumble.appyx.core.node.Node
import com.squareup.anvil.annotations.ContributesBinding import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.features.location.api.ViewLocationEntryPoint import io.element.android.features.location.api.ShowLocationEntryPoint
import io.element.android.libraries.architecture.createNode import io.element.android.libraries.architecture.createNode
import io.element.android.libraries.di.AppScope import io.element.android.libraries.di.AppScope
import javax.inject.Inject import javax.inject.Inject
@ContributesBinding(AppScope::class) @ContributesBinding(AppScope::class)
class ViewLocationEntryPointImpl @Inject constructor() : ViewLocationEntryPoint { class ShowLocationEntryPointImpl @Inject constructor() : ShowLocationEntryPoint {
override fun createNode(parentNode: Node, buildContext: BuildContext, inputs: ViewLocationEntryPoint.Inputs): Node { override fun createNode(parentNode: Node, buildContext: BuildContext, inputs: ShowLocationEntryPoint.Inputs): Node {
return parentNode.createNode<ViewLocationNode>(buildContext, listOf(inputs)) return parentNode.createNode<ShowLocationNode>(buildContext, listOf(inputs))
} }
} }

View file

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
sealed interface ViewLocationEvents { sealed interface ShowLocationEvents {
object Share : ViewLocationEvents object Share : ShowLocationEvents
} }

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -26,14 +26,14 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.analytics.plan.MobileScreen
import io.element.android.anvilannotations.ContributesNode import io.element.android.anvilannotations.ContributesNode
import io.element.android.features.location.api.ViewLocationEntryPoint import io.element.android.features.location.api.ShowLocationEntryPoint
import io.element.android.libraries.architecture.inputs import io.element.android.libraries.architecture.inputs
import io.element.android.libraries.di.RoomScope import io.element.android.libraries.di.RoomScope
import io.element.android.services.analytics.api.AnalyticsService import io.element.android.services.analytics.api.AnalyticsService
@ContributesNode(RoomScope::class) @ContributesNode(RoomScope::class)
class ViewLocationNode @AssistedInject constructor( class ShowLocationNode @AssistedInject constructor(
presenterFactory: ViewLocationPresenter.Factory, presenterFactory: ShowLocationPresenter.Factory,
analyticsService: AnalyticsService, analyticsService: AnalyticsService,
@Assisted buildContext: BuildContext, @Assisted buildContext: BuildContext,
@Assisted plugins: List<Plugin>, @Assisted plugins: List<Plugin>,
@ -47,12 +47,12 @@ class ViewLocationNode @AssistedInject constructor(
) )
} }
private val inputs: ViewLocationEntryPoint.Inputs = inputs() private val inputs: ShowLocationEntryPoint.Inputs = inputs()
private val presenter = presenterFactory.create(inputs.location, inputs.description) private val presenter = presenterFactory.create(inputs.location, inputs.description)
@Composable @Composable
override fun View(modifier: Modifier) { override fun View(modifier: Modifier) {
ViewLocationView( ShowLocationView(
state = presenter.present(), state = presenter.present(),
modifier = modifier, modifier = modifier,
onBackPressed = ::navigateUp onBackPressed = ::navigateUp

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
@ -26,28 +26,28 @@ import io.element.android.libraries.architecture.Presenter
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class ViewLocationPresenter @AssistedInject constructor( class ShowLocationPresenter @AssistedInject constructor(
private val actions: LocationActions, private val actions: LocationActions,
@Assisted private val location: Location, @Assisted private val location: Location,
@Assisted private val description: String? @Assisted private val description: String?
) : Presenter<ViewLocationState> { ) : Presenter<ShowLocationState> {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory {
fun create(location: Location, description: String?): ViewLocationPresenter fun create(location: Location, description: String?): ShowLocationPresenter
} }
@Composable @Composable
override fun present(): ViewLocationState { override fun present(): ShowLocationState {
val coroutineScope = rememberCoroutineScope() val coroutineScope = rememberCoroutineScope()
actions.Configure() actions.Configure()
return ViewLocationState( return ShowLocationState(
location = location, location = location,
description = description description = description
) { ) {
when (it) { when (it) {
ViewLocationEvents.Share -> coroutineScope.share(location, description) ShowLocationEvents.Share -> coroutineScope.share(location, description)
} }
} }
} }

View file

@ -14,12 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import io.element.android.features.location.api.Location import io.element.android.features.location.api.Location
data class ViewLocationState( data class ShowLocationState(
val location: Location, val location: Location,
val description: String?, val description: String?,
val eventSink: (ViewLocationEvents) -> Unit, val eventSink: (ShowLocationEvents) -> Unit,
) )

View file

@ -14,25 +14,25 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import io.element.android.features.location.api.Location import io.element.android.features.location.api.Location
class ViewLocationStateProvider : PreviewParameterProvider<ViewLocationState> { class ShowLocationStateProvider : PreviewParameterProvider<ShowLocationState> {
override val values: Sequence<ViewLocationState> override val values: Sequence<ShowLocationState>
get() = sequenceOf( get() = sequenceOf(
ViewLocationState( ShowLocationState(
Location(1.23, 2.34, 4f), Location(1.23, 2.34, 4f),
description = null, description = null,
eventSink = {}, eventSink = {},
), ),
ViewLocationState( ShowLocationState(
Location(1.23, 2.34, 4f), Location(1.23, 2.34, 4f),
description = "My favourite place!", description = "My favourite place!",
eventSink = {}, eventSink = {},
), ),
ViewLocationState( ShowLocationState(
Location(1.23, 2.34, 4f), 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!",

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.ExperimentalLayoutApi
@ -49,8 +49,8 @@ import io.element.android.libraries.ui.strings.CommonStrings
@OptIn(ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class) @OptIn(ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class)
@Composable @Composable
fun ViewLocationView( fun ShowLocationView(
state: ViewLocationState, state: ShowLocationState,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onBackPressed: () -> Unit = {}, onBackPressed: () -> Unit = {},
) { ) {
@ -72,7 +72,7 @@ fun ViewLocationView(
BackButton(onClick = onBackPressed) BackButton(onClick = onBackPressed)
}, },
actions = { actions = {
IconButton(onClick = { state.eventSink(ViewLocationEvents.Share) }) { IconButton(onClick = { state.eventSink(ShowLocationEvents.Share) }) {
Icon(imageVector = Icons.Outlined.Share, contentDescription = stringResource(CommonStrings.action_share)) Icon(imageVector = Icons.Outlined.Share, contentDescription = stringResource(CommonStrings.action_share))
} }
} }
@ -108,17 +108,17 @@ fun ViewLocationView(
@Preview @Preview
@Composable @Composable
internal fun ViewLocationViewLightPreview(@PreviewParameter(ViewLocationStateProvider::class) state: ViewLocationState) = internal fun ShowLocationViewLightPreview(@PreviewParameter(ShowLocationStateProvider::class) state: ShowLocationState) =
ElementPreviewLight { ContentToPreview(state) } ElementPreviewLight { ContentToPreview(state) }
@Preview @Preview
@Composable @Composable
internal fun ViewLocationViewDarkPreview(@PreviewParameter(ViewLocationStateProvider::class) state: ViewLocationState) = internal fun ShowLocationViewDarkPreview(@PreviewParameter(ShowLocationStateProvider::class) state: ShowLocationState) =
ElementPreviewDark { ContentToPreview(state) } ElementPreviewDark { ContentToPreview(state) }
@Composable @Composable
private fun ContentToPreview(state: ViewLocationState) { private fun ContentToPreview(state: ShowLocationState) {
ViewLocationView( ShowLocationView(
state = state, state = state,
onBackPressed = {}, onBackPressed = {},
) )

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import io.element.android.features.location.api.Location import io.element.android.features.location.api.Location

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.location.impl.view package io.element.android.features.location.impl.show
import app.cash.molecule.RecompositionClock import app.cash.molecule.RecompositionClock
import app.cash.molecule.moleculeFlow import app.cash.molecule.moleculeFlow
@ -24,14 +24,14 @@ import io.element.android.features.location.api.Location
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.junit.Test import org.junit.Test
class ViewLocationPresenterTest { class ShowLocationPresenterTest {
private val actions = FakeLocationActions() private val actions = FakeLocationActions()
private val location = Location(1.23, 4.56, 7.8f) private val location = Location(1.23, 4.56, 7.8f)
@Test @Test
fun `emits initial state`() = runTest { fun `emits initial state`() = runTest {
val presenter = ViewLocationPresenter( val presenter = ShowLocationPresenter(
actions, actions,
location, location,
A_DESCRIPTION, A_DESCRIPTION,
@ -48,7 +48,7 @@ class ViewLocationPresenterTest {
@Test @Test
fun `uses action to share location`() = runTest { fun `uses action to share location`() = runTest {
val presenter = ViewLocationPresenter( val presenter = ShowLocationPresenter(
actions, actions,
location, location,
A_DESCRIPTION, A_DESCRIPTION,
@ -58,7 +58,7 @@ class ViewLocationPresenterTest {
presenter.present() presenter.present()
}.test { }.test {
val initialState = awaitItem() val initialState = awaitItem()
initialState.eventSink(ViewLocationEvents.Share) initialState.eventSink(ShowLocationEvents.Share)
Truth.assertThat(actions.configured).isTrue() Truth.assertThat(actions.configured).isTrue()
Truth.assertThat(actions.sharedLocation).isEqualTo(location) Truth.assertThat(actions.sharedLocation).isEqualTo(location)

View file

@ -31,7 +31,7 @@ import dagger.assisted.AssistedInject
import io.element.android.anvilannotations.ContributesNode import io.element.android.anvilannotations.ContributesNode
import io.element.android.features.location.api.Location import io.element.android.features.location.api.Location
import io.element.android.features.location.api.SendLocationEntryPoint import io.element.android.features.location.api.SendLocationEntryPoint
import io.element.android.features.location.api.ViewLocationEntryPoint import io.element.android.features.location.api.ShowLocationEntryPoint
import io.element.android.features.messages.api.MessagesEntryPoint import io.element.android.features.messages.api.MessagesEntryPoint
import io.element.android.features.messages.impl.attachments.Attachment import io.element.android.features.messages.impl.attachments.Attachment
import io.element.android.features.messages.impl.attachments.preview.AttachmentsPreviewNode import io.element.android.features.messages.impl.attachments.preview.AttachmentsPreviewNode
@ -62,7 +62,7 @@ class MessagesFlowNode @AssistedInject constructor(
@Assisted buildContext: BuildContext, @Assisted buildContext: BuildContext,
@Assisted plugins: List<Plugin>, @Assisted plugins: List<Plugin>,
private val sendLocationEntryPoint: SendLocationEntryPoint, private val sendLocationEntryPoint: SendLocationEntryPoint,
private val viewLocationEntryPoint: ViewLocationEntryPoint, private val showLocationEntryPoint: ShowLocationEntryPoint,
) : BackstackNode<MessagesFlowNode.NavTarget>( ) : BackstackNode<MessagesFlowNode.NavTarget>(
backstack = BackStack( backstack = BackStack(
initialElement = NavTarget.Messages, initialElement = NavTarget.Messages,
@ -155,8 +155,8 @@ class MessagesFlowNode @AssistedInject constructor(
createNode<AttachmentsPreviewNode>(buildContext, listOf(inputs)) createNode<AttachmentsPreviewNode>(buildContext, listOf(inputs))
} }
is NavTarget.LocationViewer -> { is NavTarget.LocationViewer -> {
val inputs = ViewLocationEntryPoint.Inputs(navTarget.location, navTarget.description) val inputs = ShowLocationEntryPoint.Inputs(navTarget.location, navTarget.description)
viewLocationEntryPoint.createNode(this, buildContext, inputs) showLocationEntryPoint.createNode(this, buildContext, inputs)
} }
is NavTarget.EventDebugInfo -> { is NavTarget.EventDebugInfo -> {
val inputs = EventDebugInfoNode.Inputs(navTarget.eventId, navTarget.debugInfo) val inputs = EventDebugInfoNode.Inputs(navTarget.eventId, navTarget.debugInfo)