Modern Apps git

← Modern-Apps.git

youpipe+office: tab chrome and outline drawer in screenshots

Commit
f3563c219173f073f8149355df92012e4ef75c04
Author
vayun-mathur <[email protected]>
When
2026-10-25 21:50 UTC (1 month ago)
Parents
c48a351

Diff

metadata_data/photos/office/phone/5.png
diff --git a/metadata_data/photos/office/phone/5.png b/metadata_data/photos/office/phone/5.pngnew file mode 100644index 0000000000..aab3ce8883Binary files /dev/null and b/metadata_data/photos/office/phone/5.png differ
metadata_data/photos/youpipe/phone/1.png
diff --git a/metadata_data/photos/youpipe/phone/1.png b/metadata_data/photos/youpipe/phone/1.pngindex 7d368e75bf..9b39b44592 100644Binary files a/metadata_data/photos/youpipe/phone/1.png and b/metadata_data/photos/youpipe/phone/1.png differ
office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt
diff --git a/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt b/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.ktindex 612a0e72d2..91bef89779 100644--- a/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt+++ b/office/src/screenshotTest/kotlin/com/vayunmathur/office/ui/MetadataPreviews.kt@@ -2,20 +2,26 @@ package com.vayunmathur.office.ui  import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.library.ui.DrawerValue import com.vayunmathur.library.ui.DynamicTheme import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.IconHome+import com.vayunmathur.library.ui.ModalNavigationDrawer import com.vayunmathur.library.ui.PagerTab import com.vayunmathur.library.ui.TabStyle import com.vayunmathur.library.ui.TabbedPagerScaffold import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.rememberDrawerState import com.vayunmathur.library.ui.odf.OdfCell import com.vayunmathur.library.ui.odf.OdfDocument import com.vayunmathur.library.ui.odf.OdfFrame@@ -26,6 +32,8 @@ import com.vayunmathur.library.ui.odf.OdfSlide import com.vayunmathur.library.ui.odf.OdfSlideElement import com.vayunmathur.library.ui.odf.OdfSpan import com.vayunmathur.library.ui.odf.ParagraphStyle+import com.vayunmathur.office.DocumentChrome+import com.vayunmathur.office.DrawerOutline import com.vayunmathur.office.HomeScreen import com.vayunmathur.office.OfficeLightTheme @@ -249,6 +257,48 @@ class MetadataPreviews {             )         }     }++    @PreviewTest+    @Preview(name = "6-outline-drawer", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview6OutlineDrawer() {+        Paper {+            val drawerState = rememberDrawerState(DrawerValue.Open)+            val listState = rememberLazyListState()+            val scope = rememberCoroutineScope()+            val chrome = remember(SampleTextDocument) {+                DocumentChrome(+                    isEditMode = false,+                    hasUnsavedChanges = false,+                    isOnline = false,+                    onlineEnabled = false,+                    isSaving = false,+                    canUndo = false,+                    canRedo = false,+                    nightMode = false,+                    documentDarkMode = false,+                    isTextDoc = true,+                    isSpreadsheet = false,+                    isPresentation = false,+                    canEdit = false,+                    saveAsName = "sample1.odt",+                    headings = extractHeadings(SampleTextDocument),+                    wordCount = 0,+                    charCount = 0,+                    readingTime = 0,+                    bookmarks = emptyList(),+                )+            }+            ModalNavigationDrawer(+                drawerState = drawerState,+                gesturesEnabled = chrome.isTextDoc &&+                    (chrome.headings.isNotEmpty() || chrome.bookmarks.isNotEmpty()),+                drawerContent = { DrawerOutline(chrome, listState, drawerState, scope) },+            ) {+                TextDocumentView(doc = SampleTextDocument, listState = listState)+            }+        }+    } }  /**
youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt
diff --git a/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt b/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.ktindex d731f727d1..0819977953 100644--- a/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt+++ b/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt@@ -3,13 +3,23 @@ package com.vayunmathur.youpipe.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.IconHistory+import com.vayunmathur.library.ui.IconHome+import com.vayunmathur.library.ui.IconSave+import com.vayunmathur.library.ui.IconSettings+import com.vayunmathur.library.ui.IconSubscriptions+import com.vayunmathur.library.ui.PagerTab+import com.vayunmathur.library.ui.TabStyle+import com.vayunmathur.library.ui.TabbedPagerScaffold import com.vayunmathur.youpipe.util.SearchActions import com.vayunmathur.youpipe.util.SearchUiState import com.vayunmathur.youpipe.util.SubscriptionFeedActions@@ -50,53 +60,7 @@ class MetadataPreviews {     @Preview(name = "1-home", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview1Home() {-        DynamicTheme(darkTheme = true) {-            SearchScreen(-                state = SearchUiState(-                    recommendations = listOf(-                        VideoRowState(-                            videoID = 1,-                            title = "The Absurd Engineering Inside a Modern Camera Sensor",-                            author = "Veritasium",-                            stats = "4.1M views | 2 weeks ago",-                            reason = "you watch a lot of optics",-                            percentWatched = 0.42f,-                        ),-                        VideoRowState(-                            videoID = 2,-                            title = "I Rebuilt My Home Server Rack (Again)",-                            author = "Linus Tech Tips",-                            stats = "1.2M views | 3 days ago",-                            reason = "from a channel you follow",-                        ),-                        VideoRowState(-                            videoID = 3,-                            title = "Why Bridges Don't Fall Down",-                            author = "Practical Engineering",-                            stats = "873K views | 1 month ago",-                            reason = "similar to Structural Failures Explained",-                            percentWatched = 1f,-                        ),-                        VideoRowState(-                            videoID = 4,-                            title = "Making Sourdough With No Starter",-                            author = "Adam Ragusea",-                            stats = "612K views | 5 days ago",-                            reason = "new upload",-                        ),-                        VideoRowState(-                            videoID = 5,-                            title = "Every Rust Borrow Checker Error, Explained",-                            author = "No Boilerplate",-                            stats = "298K views | 2 months ago",-                            reason = "you watch a lot of Rust",-                            percentWatched = 0.15f,-                        ),-                    ),-                ),-                actions = SearchActions.Noop,-            )-        }+        ChromePreview(selectedTab = 0)     }      @PreviewTest@@ -131,8 +95,15 @@ class MetadataPreviews {     @Composable     fun Preview4Subscriptions() {         DynamicTheme(darkTheme = true) {-            SubscriptionVideosScreen(-                state = SubscriptionFeedUiState(+            SubscriptionFeedContent()+        }+    }++    /** The Subscriptions tab body (Preview4), factored out so [ChromePreview] can reuse it. */+    @Composable+    private fun SubscriptionFeedContent() {+        SubscriptionVideosScreen(+            state = SubscriptionFeedUiState(                     videos = listOf(                         VideoRowState(                             videoID = 11,@@ -170,7 +141,6 @@ class MetadataPreviews {                 ),                 actions = SubscriptionFeedActions.Noop,             )-        }     }      @PreviewTest@@ -270,6 +240,84 @@ class MetadataPreviews {             )         }     }++    /** The Home tab body, factored out so [ChromePreview] can host it behind the real tabs. */+    @Composable+    private fun HomeContent() {+        SearchScreen(+            state = SearchUiState(+                recommendations = listOf(+                    VideoRowState(+                        videoID = 1,+                        title = "The Absurd Engineering Inside a Modern Camera Sensor",+                        author = "Veritasium",+                        stats = "4.1M views | 2 weeks ago",+                        reason = "you watch a lot of optics",+                        percentWatched = 0.42f,+                    ),+                    VideoRowState(+                        videoID = 2,+                        title = "I Rebuilt My Home Server Rack (Again)",+                        author = "Linus Tech Tips",+                        stats = "1.2M views | 3 days ago",+                        reason = "from a channel you follow",+                    ),+                    VideoRowState(+                        videoID = 3,+                        title = "Why Bridges Don't Fall Down",+                        author = "Practical Engineering",+                        stats = "873K views | 1 month ago",+                        reason = "similar to Structural Failures Explained",+                        percentWatched = 1f,+                    ),+                    VideoRowState(+                        videoID = 4,+                        title = "Making Sourdough With No Starter",+                        author = "Adam Ragusea",+                        stats = "612K views | 5 days ago",+                        reason = "new upload",+                    ),+                    VideoRowState(+                        videoID = 5,+                        title = "Every Rust Borrow Checker Error, Explained",+                        author = "No Boilerplate",+                        stats = "298K views | 2 months ago",+                        reason = "you watch a lot of Rust",+                        percentWatched = 0.15f,+                    ),+                ),+            ),+            actions = SearchActions.Noop,+        )+    }++    /**+     * The app's real tab chrome around the home content: the same five+     * [PagerTab]s `YouPipeTabs` in MainActivity declares, in the same+     * [TabbedPagerScaffold] with [TabStyle.BottomNav]. History/Saved/Settings+     * take their ViewModels directly, so those entries show an empty page+     * (never visible — the shot stays on the selected tab).+     */+    @Composable+    private fun ChromePreview(selectedTab: Int) {+        DynamicTheme(darkTheme = true) {+            val tabs = listOf(+                PagerTab("Home", { IconHome() }) { HomeContent() },+                PagerTab("Subscriptions", { IconSubscriptions() }) { SubscriptionFeedContent() },+                // ViewModel-coupled: empty placeholder, never visible.+                PagerTab("History", { IconHistory() }) { Box(Modifier.fillMaxSize()) },+                // ViewModel-coupled: empty placeholder, never visible.+                PagerTab("Saved", { IconSave() }) { Box(Modifier.fillMaxSize()) },+                // ViewModel-coupled: empty placeholder, never visible.+                PagerTab("Settings", { IconSettings() }) { Box(Modifier.fillMaxSize()) },+            )+            TabbedPagerScaffold(+                tabs = tabs,+                pagerState = rememberPagerState(initialPage = selectedTab, pageCount = { tabs.size }),+                tabStyle = TabStyle.BottomNav,+            )+        }+    } }  /** Stands in for the player surface, which Layoutlib cannot render. */