-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Common bottom sheet for not allowed operations and signer raw not sup…
…ported info (#378) * Common bottom sheet for not allowed operations and signer raw not supported info
- Loading branch information
Showing
11 changed files
with
160 additions
and
30 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...c/main/java/io/novafoundation/nova/common/view/bottomSheet/ActionNotAllowedBottomSheet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.novafoundation.nova.common.view.bottomSheet | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.annotation.DrawableRes | ||
import androidx.core.view.setPadding | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
import io.novafoundation.nova.common.R | ||
import io.novafoundation.nova.common.utils.WithContextExtensions | ||
import io.novafoundation.nova.common.view.PrimaryButton | ||
import kotlinx.android.synthetic.main.bottom_sheet_action_not_allowed.actionNotAllowedImage | ||
import kotlinx.android.synthetic.main.bottom_sheet_action_not_allowed.actionNotAllowedOk | ||
import kotlinx.android.synthetic.main.bottom_sheet_action_not_allowed.actionNotAllowedSubtitle | ||
import kotlinx.android.synthetic.main.bottom_sheet_action_not_allowed.actionNotAllowedTitle | ||
|
||
open class ActionNotAllowedBottomSheet( | ||
context: Context, | ||
private val onSuccess: () -> Unit, | ||
) : BottomSheetDialog(context, R.style.BottomSheetDialog), WithContextExtensions by WithContextExtensions(context) { | ||
|
||
val image: ImageView | ||
get() = actionNotAllowedImage | ||
|
||
val title: TextView | ||
get() = actionNotAllowedTitle | ||
|
||
val subtitle: TextView | ||
get() = actionNotAllowedSubtitle | ||
|
||
val button: PrimaryButton | ||
get() = actionNotAllowedOk | ||
|
||
init { | ||
setContentView(R.layout.bottom_sheet_action_not_allowed) | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setOnDismissListener { onSuccess() } | ||
|
||
actionNotAllowedOk.setOnClickListener { | ||
dismiss() | ||
} | ||
} | ||
|
||
// make it final so we will be able to call it from constructor without the risk of initialization conflict | ||
final override fun setContentView(layoutResId: Int) { | ||
super.setContentView(layoutResId) | ||
} | ||
|
||
protected fun applyBigIconStyle(@DrawableRes src: Int) = with(image) { | ||
setPadding(12.dp) | ||
setBackgroundResource(R.drawable.bg_icon_big) | ||
setImageResource(src) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../presentation/paritySigner/sign/notSupported/AcknowledgeSigningNotSupportedBottomSheet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.novafoundation.nova.feature_account_impl.presentation.paritySigner.sign.notSupported | ||
|
||
import android.content.Context | ||
import android.content.DialogInterface | ||
import android.os.Bundle | ||
import io.novafoundation.nova.common.utils.DialogExtensions | ||
import io.novafoundation.nova.common.view.bottomSheet.ActionNotAllowedBottomSheet | ||
import io.novafoundation.nova.feature_account_impl.R | ||
|
||
class AcknowledgeSigningNotSupportedBottomSheet( | ||
context: Context, | ||
private val onConfirm: () -> Unit | ||
) : ActionNotAllowedBottomSheet( | ||
context = context, | ||
onSuccess = onConfirm, | ||
), DialogExtensions { | ||
|
||
override val dialogInterface: DialogInterface | ||
get() = this | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
title.setText(R.string.account_parity_signer_not_supported_title) | ||
subtitle.setText(R.string.account_parity_signer_not_supported_subtitle) | ||
|
||
applyBigIconStyle(R.drawable.ic_parity_signer) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...presentation/paritySigner/sign/notSupported/ParitySignerSigningNotSupportedPresentable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.novafoundation.nova.feature_account_impl.presentation.paritySigner.sign.notSupported | ||
|
||
import io.novafoundation.nova.common.resources.ContextManager | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import kotlin.coroutines.resume | ||
import kotlin.coroutines.suspendCoroutine | ||
|
||
interface ParitySignerSigningNotSupportedPresentable { | ||
|
||
suspend fun presentSigningNotSupported() | ||
} | ||
|
||
class RealParitySignerSigningNotSupportedPresentable( | ||
private val contextManager: ContextManager, | ||
) : ParitySignerSigningNotSupportedPresentable { | ||
|
||
override suspend fun presentSigningNotSupported(): Unit = withContext(Dispatchers.Main) { | ||
suspendCoroutine { | ||
AcknowledgeSigningNotSupportedBottomSheet( | ||
context = contextManager.getActivity()!!, | ||
onConfirm = { it.resume(Unit) } | ||
).show() | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters