[fenix] Revert "Closes https://github.com/mozilla-mobile/fenix/issues/26750: add Wallpapers Onboarding dialog"
This reverts commit 2a96c8ee06377f3103b0d4d3efe82e7b2112d0ac.pull/600/head
parent
6171a8f85b
commit
83e28ebf0e
@ -1,97 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.onboarding
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kotlinx.coroutines.launch
|
||||
import mozilla.components.lib.state.ext.observeAsComposableState
|
||||
import org.mozilla.fenix.NavGraphDirections
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
import org.mozilla.fenix.wallpapers.Wallpaper
|
||||
import org.mozilla.fenix.wallpapers.WallpaperOnboarding
|
||||
|
||||
/**
|
||||
* Dialog displaying the wallpapers onboarding.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
class WallpaperOnboardingDialogFragment : BottomSheetDialogFragment() {
|
||||
private val appStore by lazy {
|
||||
requireComponents.appStore
|
||||
}
|
||||
|
||||
private val wallpaperUseCases by lazy {
|
||||
requireComponents.useCases.wallpaperUseCases
|
||||
}
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.WallpaperOnboardingDialogStyle)
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
requireContext().settings().showWallpaperOnboarding = false
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View = ComposeView(requireContext()).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
|
||||
setContent {
|
||||
FirefoxTheme {
|
||||
val wallpapers = appStore.observeAsComposableState { state ->
|
||||
state.wallpaperState.availableWallpapers.subList(0, THUMBNAILS_COUNT)
|
||||
}.value ?: listOf()
|
||||
val currentWallpaper = appStore.observeAsComposableState { state ->
|
||||
state.wallpaperState.currentWallpaper
|
||||
}.value ?: Wallpaper.Default
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
WallpaperOnboarding(
|
||||
wallpapers = wallpapers,
|
||||
currentWallpaper = currentWallpaper,
|
||||
onCloseClicked = { dismiss() },
|
||||
onBottomButtonClicked = {
|
||||
val directions = NavGraphDirections.actionGlobalWallpaperSettingsFragment()
|
||||
findNavController().navigate(directions)
|
||||
},
|
||||
loadWallpaperResource = { wallpaperUseCases.loadThumbnail(it) },
|
||||
onSelectWallpaper = {
|
||||
coroutineScope.launch { wallpaperUseCases.selectWallpaper(it) }
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val THUMBNAILS_COUNT = 6
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.wallpapers
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.settings.wallpaper.WallpaperThumbnails
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
import org.mozilla.fenix.theme.Theme
|
||||
|
||||
/**
|
||||
* A view that shows content of a WallpaperOnboarding dialog.
|
||||
*
|
||||
* @param wallpapers Wallpapers to add to grid.
|
||||
* @param currentWallpaper The currently selected wallpaper.
|
||||
* @param loadWallpaperResource Callback to handle loading a wallpaper bitmap. Only optional in the default case.
|
||||
* @param onCloseClicked Callback for when the close button is clicked.
|
||||
* @param onBottomButtonClicked Callback for when the bottom text button is clicked.
|
||||
* @param onSelectWallpaper Callback for when a new wallpaper is selected.
|
||||
*/
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
fun WallpaperOnboarding(
|
||||
wallpapers: List<Wallpaper>,
|
||||
currentWallpaper: Wallpaper,
|
||||
loadWallpaperResource: suspend (Wallpaper) -> Bitmap?,
|
||||
onCloseClicked: () -> Unit,
|
||||
onBottomButtonClicked: () -> Unit,
|
||||
onSelectWallpaper: (Wallpaper) -> Unit,
|
||||
) {
|
||||
Surface(
|
||||
color = FirefoxTheme.colors.layer2,
|
||||
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.mozac_ic_close),
|
||||
contentDescription = stringResource(id = R.string.close_tab),
|
||||
tint = FirefoxTheme.colors.iconPrimary,
|
||||
modifier = Modifier
|
||||
.clickable { onCloseClicked() }
|
||||
.size(24.dp)
|
||||
.align(Alignment.End)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.wallpapers_onboarding_dialog_title_text),
|
||||
style = FirefoxTheme.typography.headline7,
|
||||
color = FirefoxTheme.colors.textPrimary,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.wallpapers_onboarding_dialog_body_text),
|
||||
style = FirefoxTheme.typography.caption,
|
||||
color = FirefoxTheme.colors.textSecondary,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
)
|
||||
|
||||
WallpaperThumbnails(
|
||||
wallpapers = wallpapers,
|
||||
defaultWallpaper = Wallpaper.Default,
|
||||
loadWallpaperResource = { loadWallpaperResource(it) },
|
||||
selectedWallpaper = currentWallpaper,
|
||||
onSelectWallpaper = { onSelectWallpaper(it) },
|
||||
verticalPadding = 16,
|
||||
horizontalPadding = 0
|
||||
)
|
||||
|
||||
TextButton(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.fillMaxWidth(),
|
||||
onClick = { onBottomButtonClicked() }
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.wallpapers_onboarding_dialog_explore_more_button_text),
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = FirefoxTheme.colors.textAccent,
|
||||
fontSize = 14.sp,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
private fun WallpaperSnackbarPreview() {
|
||||
FirefoxTheme(theme = Theme.getTheme()) {
|
||||
WallpaperOnboarding(
|
||||
wallpapers = listOf(Wallpaper.Default),
|
||||
currentWallpaper = Wallpaper.Default,
|
||||
onCloseClicked = {},
|
||||
onBottomButtonClicked = {},
|
||||
loadWallpaperResource = { null },
|
||||
onSelectWallpaper = {}
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue