mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3659 Multiplayer | Support link without approve, fixes (#2445)
This commit is contained in:
parent
55e430c70b
commit
bd9ccaff50
4 changed files with 101 additions and 9 deletions
|
@ -146,6 +146,10 @@ class RequestJoinSpaceFragment : BaseBottomSheetComposeFragment() {
|
|||
JoinSpaceWithoutApproveScreen(
|
||||
isLoading = isLoading,
|
||||
onRequestJoinSpaceClicked = vm::onRequestToJoinClicked,
|
||||
onCancelClicked = {
|
||||
vm.onCancelJoinSpaceRequestClicked()
|
||||
dismiss()
|
||||
},
|
||||
spaceName = spaceName,
|
||||
createdByName = createdByName
|
||||
)
|
||||
|
@ -155,6 +159,10 @@ class RequestJoinSpaceFragment : BaseBottomSheetComposeFragment() {
|
|||
onRequestJoinSpaceClicked = vm::onRequestToJoinClicked,
|
||||
spaceName = spaceName,
|
||||
createdByName = createdByName,
|
||||
onCancelClicked = {
|
||||
vm.onCancelJoinSpaceRequestClicked()
|
||||
dismiss()
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.anytypeio.anytype.core_ui.views.Title2
|
|||
@Composable
|
||||
fun JoinSpaceScreen(
|
||||
onRequestJoinSpaceClicked: () -> Unit,
|
||||
onCancelClicked: () -> Unit,
|
||||
spaceName: String,
|
||||
createdByName: String,
|
||||
isLoading: Boolean = false
|
||||
|
@ -87,7 +88,16 @@ fun JoinSpaceScreen(
|
|||
loading = isLoading
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
ButtonSecondary(
|
||||
onClick = throttledClick(
|
||||
onClick = { onCancelClicked() }
|
||||
),
|
||||
text = stringResource(R.string.cancel),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
size = ButtonSize.Large,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.multiplayer_request_to_join_explanation),
|
||||
style = Caption1Regular,
|
||||
|
@ -102,6 +112,7 @@ fun JoinSpaceScreen(
|
|||
@Composable
|
||||
fun JoinSpaceWithoutApproveScreen(
|
||||
onRequestJoinSpaceClicked: () -> Unit,
|
||||
onCancelClicked: () -> Unit,
|
||||
spaceName: String,
|
||||
createdByName: String,
|
||||
isLoading: Boolean = false
|
||||
|
@ -162,7 +173,7 @@ fun JoinSpaceWithoutApproveScreen(
|
|||
Spacer(modifier = Modifier.height(8.dp))
|
||||
ButtonSecondary(
|
||||
onClick = throttledClick(
|
||||
onClick = { onRequestJoinSpaceClicked() }
|
||||
onClick = { onCancelClicked() }
|
||||
),
|
||||
text = stringResource(R.string.cancel),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
@ -172,6 +183,63 @@ fun JoinSpaceWithoutApproveScreen(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun JoinSpaceRequestSentScreen(
|
||||
onDoneClicked: () -> Unit,
|
||||
onManageSpaces: () -> Unit
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp)
|
||||
) {
|
||||
Dragger(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(vertical = 6.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.multiplayer_request_to_join_sent_title,),
|
||||
style = HeadlineHeading,
|
||||
color = colorResource(id = R.color.text_primary),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.multiplayer_request_to_join_sent_description,),
|
||||
style = Title2,
|
||||
color = colorResource(id = R.color.text_primary),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.height(19.dp))
|
||||
ButtonPrimaryLoading(
|
||||
onClick = throttledClick(
|
||||
onClick = { }
|
||||
),
|
||||
size = ButtonSize.Large,
|
||||
text = stringResource(R.string.done),
|
||||
modifierButton = Modifier.fillMaxWidth(),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
ButtonSecondary(
|
||||
onClick = throttledClick(
|
||||
onClick = { }
|
||||
),
|
||||
text = stringResource(R.string.multiplayer_request_to_join_btn_manage_spaces),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
size = ButtonSize.Large,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun JoiningLoadingState(
|
||||
onCancelLoadingInviteClicked: () -> Unit
|
||||
|
@ -227,7 +295,8 @@ fun JoinSpaceScreenPreview() {
|
|||
JoinSpaceScreen(
|
||||
onRequestJoinSpaceClicked = {},
|
||||
spaceName = "Anytype Android App",
|
||||
createdByName = "Konstantin"
|
||||
createdByName = "Konstantin",
|
||||
onCancelClicked = {}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -237,7 +306,8 @@ fun JoinSpaceScreenPreviewWithEmptyNames() {
|
|||
JoinSpaceScreen(
|
||||
onRequestJoinSpaceClicked = {},
|
||||
spaceName = "",
|
||||
createdByName = ""
|
||||
createdByName = "",
|
||||
onCancelClicked = {}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -247,6 +317,7 @@ fun JoinSpaceScreenPreviewWithoutApprove() {
|
|||
JoinSpaceWithoutApproveScreen(
|
||||
onRequestJoinSpaceClicked = {},
|
||||
spaceName = "",
|
||||
createdByName = ""
|
||||
createdByName = "",
|
||||
onCancelClicked = {}
|
||||
)
|
||||
}
|
|
@ -1361,6 +1361,9 @@
|
|||
<string name="multiplayer_request_to_join_without_approve_title">Join %1$s</string>
|
||||
<string name="multiplayer_request_to_join_without_approve_desc">You\'ve been invited to join %1$s, created by %2$s</string>
|
||||
<string name="multiplayer_request_to_join_without_approve_button">Join Space</string>
|
||||
<string name="multiplayer_request_to_join_sent_title">Request sent</string>
|
||||
<string name="multiplayer_request_to_join_sent_description">You will receive a notification when the space owner will approve your request.</string>
|
||||
<string name="multiplayer_request_to_join_btn_manage_spaces">Manage spaces</string>
|
||||
|
||||
<string name="multiplayer_request_to_join_loading_text"> Hang tight — we’re setting things up for you. This should only take a moment.</string>
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.anytypeio.anytype.presentation.common.BaseViewModel
|
|||
import com.anytypeio.anytype.presentation.common.TypedViewState
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -54,6 +53,7 @@ class RequestJoinSpaceViewModel(
|
|||
val commands = MutableSharedFlow<Command>(0)
|
||||
val showLoadingInviteProgress = MutableStateFlow(false)
|
||||
private var getSpaceInviteViewJob: Job? = null
|
||||
private var joinSpaceRequestJob: Job? = null
|
||||
|
||||
init {
|
||||
Timber.i("RequestJoinSpaceViewModel, init")
|
||||
|
@ -132,7 +132,8 @@ class RequestJoinSpaceViewModel(
|
|||
fun onRequestToJoinClicked() {
|
||||
when(val curr = state.value) {
|
||||
is TypedViewState.Success -> {
|
||||
viewModelScope.launch {
|
||||
joinSpaceRequestJob?.cancel()
|
||||
joinSpaceRequestJob = viewModelScope.launch {
|
||||
val fileKey = spaceInviteResolver.parseFileKey(params.link)
|
||||
val contentId = spaceInviteResolver.parseContentId(params.link)
|
||||
if (contentId != null && fileKey != null) {
|
||||
|
@ -156,10 +157,14 @@ class RequestJoinSpaceViewModel(
|
|||
onSuccess = {
|
||||
analytics.sendEvent(eventName = screenRequestSent)
|
||||
if (notificator.areNotificationsEnabled) {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
if (!curr.data.withoutApprove) {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
}
|
||||
commands.emit(Command.Dismiss)
|
||||
} else {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
if (!curr.data.withoutApprove) {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
}
|
||||
showEnableNotificationDialog.value = true
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +178,11 @@ class RequestJoinSpaceViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onCancelJoinSpaceRequestClicked() {
|
||||
joinSpaceRequestJob?.cancel()
|
||||
isRequestInProgress.value = false
|
||||
}
|
||||
|
||||
fun onOpenSpaceClicked(space: SpaceId) {
|
||||
viewModelScope.launch {
|
||||
val curr = spaceManager.get()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue