Commit 1123ae67 authored by clairehurst's avatar clairehurst 🌱 Committed by henry
Browse files

TB 44031 [android]: 2025 YEC preview

parent 944163bd
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
/* 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 mozilla.components.compose.base.annotation

import androidx.compose.ui.tooling.preview.Preview

/**
 * A wrapper annotation for creating a preview that renders a preview for each value of portrait and landscape for english, arabic, and german.
 */
@Preview(
    name = "mobile portrait",
    group = "english",
    widthDp = 360,
    heightDp = 780,
    locale = "en",
    device = "id:pixel_5",
)
@Preview(
    name = "mobile landscape",
    group = "english",
    widthDp = 780,
    heightDp = 360,
    locale = "en",
    device = "spec:parent=pixel_5,orientation=landscape",
)
@Preview(
    name = "mobile portrait",
    group = "arabic",
    widthDp = 360,
    heightDp = 780,
    locale = "ar",
    device = "id:pixel_5",
)
@Preview(
    name = "mobile landscape",
    group = "arabic",
    widthDp = 780,
    heightDp = 360,
    locale = "ar",
    device = "spec:parent=pixel_5,orientation=landscape",
)
@Preview(
    name = "mobile portrait",
    group = "german",
    widthDp = 360,
    heightDp = 780,
    locale = "de",
    device = "id:pixel_5",
)
@Preview(
    name = "mobile landscape",
    group = "german",
    widthDp = 780,
    heightDp = 360,
    locale = "de",
    device = "spec:parent=pixel_5,orientation=landscape",
)
annotation class FlexibleWindowPreviewPortraitLandscapeEnglishArabicGerman
+3 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import org.mozilla.fenix.R
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.theme.Theme
import mozilla.components.ui.icons.R as iconsR

private val searchBarShape = RoundedCornerShape(28.dp)
@@ -83,8 +84,8 @@ internal fun SearchBar(

@Composable
@PreviewLightDark
private fun SearchBarPreview() {
    FirefoxTheme {
fun SearchBarPreview() {
    FirefoxTheme (theme = Theme.Private) {
        SearchBar(
            modifier = Modifier
                .background(color = MaterialTheme.colorScheme.surface)
+47 −0
Original line number Diff line number Diff line
package org.mozilla.fenix.tor

import android.annotation.SuppressLint
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import mozilla.components.compose.base.annotation.FlexibleWindowPreviewPortraitLandscapeEnglishArabicGerman
import org.mozilla.fenix.home.ui.SearchBarPreview

@SuppressLint("UnrememberedMutableState")
@FlexibleWindowPreviewPortraitLandscapeEnglishArabicGerman
@Composable
/**
 * Relevant documentation https://developer.android.com/develop/ui/compose/tooling/previews#preview-viewmodel
 */
private fun TorHomePagePreview(
    @PreviewParameter(BooleanBooleanPreviewParameterProvider::class) booleanMatrix: Pair<Boolean, Boolean>,
) {
    val toolbarAtTop = booleanMatrix.second
    Box(
        contentAlignment = if (toolbarAtTop) Alignment.Companion.TopStart else Alignment.Companion.BottomStart,
        modifier = Modifier.Companion.fillMaxSize(),
    ) {
        SearchBarPreview() // unrestricted vertically so will follow contentAlignment
        TorHomePage(
            // restricted vertically so will not follow contentAlignment
            shouldInitiallyShowPromo = mutableStateOf(booleanMatrix.first),
            toolBarAtTop = toolbarAtTop,
        )
    }
}

private class BooleanBooleanPreviewParameterProvider :
    PreviewParameterProvider<Pair<Boolean, Boolean>> {
    override val values: Sequence<Pair<Boolean, Boolean>>
        get() = sequenceOf(
            Pair(true, true),
            Pair(true, false),
            Pair(false, true),
            Pair(false, false),
        )
}
+8 −0
Original line number Diff line number Diff line
@@ -2254,4 +2254,12 @@
  -->
  <string name="beta_feature">النسخة التجريبية</string>
  <!-- TextField Design System Component -->

<!--   Not meant for production. Uncomment for the compose preview in [TorHomePage] -->
<!--  <string name="donate_now_yec">تبرع الآن</string>-->
<!--  <string name="free_the_internet_yec">حرروا الإنترنت</string>-->
<!--  <string name="body1_yec">دعم الأدوات التي تكسر قيود الرقابة والمراقبة. %s</string>-->
<!--  <string name="body1_link_yec">تبرع لمشروع Tor اليوم.</string>-->
<!--  <string name="body2_yec">حتى 31 ديسمبر، سيتم مضاعفة تبرعك،  بحد أقصى 250,000 دولار!</string>-->
<!--  <string name="no_donation_required_yec">سيكون متصفح Tor لنظام Android مجانيا دائما للاستخدام - لا يلزم التبرع لاستخدام هذا التطبيق.</string>-->
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -3938,4 +3938,12 @@
  <string name="terms_of_use_prompt_accept">Annehmen</string>
  <!-- Label for a button to postpone accepting the terms of use -->
  <string name="terms_of_use_prompt_postpone">Später erinnern</string>

  <!-- Not meant for production. Uncomment for the compose preview in [TorHomePage] -->
<!--  <string name="donate_now_yec">Jetzt spenden</string>-->
<!--  <string name="free_the_internet_yec">Befreit das Internet</string>-->
<!--  <string name="body1_yec">Unterstützen Sie Tools, die die Ketten der Zensur und Überwachung sprengen. %s</string>-->
<!--  <string name="body1_link_yec">Spenden Sie noch heute für das Tor-Projekt.</string>-->
<!--  <string name="body2_yec">Bis zum 31. Dezember wird Ihre Spende bis zu einer Höhe von 250.000 Dollar verdoppelt!</string>-->
<!--  <string name="no_donation_required_yec">Der Tor-Browser für Android wird immer kostenlos sein – es ist keine Spende erforderlich, um diese App zu nutzen.</string>-->
</resources>