1
0
Fork 0

Fix elevation for snackbar and fab

master
David Walsh 2020-05-26 14:06:29 -05:00 committed by Jeff Boek
parent e9bcc9bb1e
commit 8b843ac9e5
5 changed files with 27 additions and 19 deletions

View File

@ -221,9 +221,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
tabTrayDialog.dismiss() tabTrayDialog.dismiss()
} }
override fun onTabClosed(tab: Tab) { override fun onTabClosed(tab: Tab) { /* noop */ }
TODO("Not yet implemented")
}
override fun onNewTabTapped(private: Boolean) { override fun onNewTabTapped(private: Boolean) {
(activity as HomeActivity).browsingModeManager.mode = BrowsingMode.fromBoolean(private) (activity as HomeActivity).browsingModeManager.mode = BrowsingMode.fromBoolean(private)

View File

@ -373,7 +373,7 @@ class HomeFragment : Fragment() {
} }
override fun onTabClosed(tab: mozilla.components.concept.tabstray.Tab) { override fun onTabClosed(tab: mozilla.components.concept.tabstray.Tab) {
TODO("Not yet implemented") /* noop */
} }
} }
} }

View File

@ -68,7 +68,6 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
} }
override fun onTabClosed(tab: Tab) { override fun onTabClosed(tab: Tab) {
// interactor?.onTabClosed(tab)
val sessionManager = view?.context?.components?.core?.sessionManager val sessionManager = view?.context?.components?.core?.sessionManager
val snapshot = sessionManager val snapshot = sessionManager
?.findSessionById(tab.id)?.let { ?.findSessionById(tab.id)?.let {
@ -84,16 +83,18 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
getString(R.string.snackbar_tab_closed) getString(R.string.snackbar_tab_closed)
} }
viewLifecycleOwner.lifecycleScope.allowUndo( view?.tabLayout?.let {
requireView(), viewLifecycleOwner.lifecycleScope.allowUndo(
snackbarMessage, it,
getString(R.string.snackbar_deleted_undo), snackbarMessage,
{ getString(R.string.snackbar_deleted_undo),
sessionManager.add(snapshot.session, isSelected, engineSessionState = state) {
}, sessionManager.add(snapshot.session, isSelected, engineSessionState = state)
operation = { }, },
anchorView = view?.handle operation = { },
) elevation = ELEVATION
)
}
} }
override fun onTabSelected(tab: Tab) { override fun onTabSelected(tab: Tab) {
@ -107,4 +108,8 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
override fun onTabTrayDismissed() { override fun onTabTrayDismissed() {
dismissAllowingStateLoss() dismissAllowingStateLoss()
} }
companion object {
private const val ELEVATION = 80f
}
} }

View File

@ -52,7 +52,7 @@ class TabTrayView(
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, slideOffset: Float) { override fun onSlide(bottomSheet: View, slideOffset: Float) {
if (slideOffset > SLIDE_OFFSET) { if (slideOffset >= SLIDE_OFFSET) {
fabView.new_tab_button.show() fabView.new_tab_button.show()
} else { } else {
fabView.new_tab_button.hide() fabView.new_tab_button.hide()
@ -120,7 +120,7 @@ class TabTrayView(
companion object { companion object {
private const val DEFAULT_TAB_ID = 0 private const val DEFAULT_TAB_ID = 0
private const val PRIVATE_TAB_ID = 1 private const val PRIVATE_TAB_ID = 1
private const val SLIDE_OFFSET = 0.4 private const val SLIDE_OFFSET = 0
private const val ELEVATION = 41f private const val ELEVATION = 90f
} }
} }

View File

@ -36,7 +36,8 @@ fun CoroutineScope.allowUndo(
undoActionTitle: String, undoActionTitle: String,
onCancel: suspend () -> Unit = {}, onCancel: suspend () -> Unit = {},
operation: suspend () -> Unit, operation: suspend () -> Unit,
anchorView: View? = null anchorView: View? = null,
elevation: Float? = null
) { ) {
// By using an AtomicBoolean, we achieve memory effects of reading and // By using an AtomicBoolean, we achieve memory effects of reading and
// writing a volatile variable. // writing a volatile variable.
@ -58,6 +59,10 @@ fun CoroutineScope.allowUndo(
} }
} }
elevation?.also {
snackbar.view.elevation = it
}
snackbar.show() snackbar.show()
// Wait a bit, and if user didn't request cancellation, proceed with // Wait a bit, and if user didn't request cancellation, proceed with