From b2cdc73c8a8fe73af9227ff0210074611609dfc9 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Sat, 6 Sep 2025 21:48:34 +0530 Subject: [PATCH] Fixed: The `ActionMode` title and back button color did not match our pure white theme. * Applied a custom style to `ActionMode`. Now, both the title and back button appear in white, which looks better on the blue background. Additionally, increased the `ActionMode` height to align with the Compose-based AppBar. * Removed some unused files from the project. --- .../ui/components/LazyListScrollListener.kt | 74 ------------------- .../main/res/drawable/border_tab_switcher.xml | 8 -- .../src/main/res/drawable/fullscreen_exit.xml | 9 --- .../main/res/drawable/progress_bar_state.xml | 21 ------ .../search_placeholder_background.xml | 12 --- .../res/layout/action_mode_back_button.xml | 33 +++++++++ core/src/main/res/values/themes.xml | 17 ++++- 7 files changed, 49 insertions(+), 125 deletions(-) delete mode 100644 core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/LazyListScrollListener.kt delete mode 100644 core/src/main/res/drawable/border_tab_switcher.xml delete mode 100644 core/src/main/res/drawable/fullscreen_exit.xml delete mode 100644 core/src/main/res/drawable/progress_bar_state.xml delete mode 100644 core/src/main/res/drawable/search_placeholder_background.xml create mode 100644 core/src/main/res/layout/action_mode_back_button.xml diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/LazyListScrollListener.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/LazyListScrollListener.kt deleted file mode 100644 index da3ed1d5e..000000000 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/LazyListScrollListener.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Kiwix Android - * Copyright (c) 2025 Kiwix - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package org.kiwix.kiwixmobile.core.ui.components - -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberUpdatedState -import androidx.compose.runtime.setValue -import androidx.compose.runtime.snapshotFlow - -const val ONE_THOUSAND = 1000 - -@Composable -fun rememberLazyListScrollListener( - lazyListState: LazyListState, - onScrollChanged: (ScrollDirection) -> Unit, - scrollThreshold: Int = 20 -): LazyListState { - val updatedOnScrollChanged = rememberUpdatedState(onScrollChanged) - - var previousScrollPosition by remember { mutableIntStateOf(0) } - var lastScrollDirection by remember { mutableStateOf(ScrollDirection.IDLE) } - - LaunchedEffect(lazyListState) { - snapshotFlow { - lazyListState.firstVisibleItemIndex to lazyListState.firstVisibleItemScrollOffset - }.collect { (index, offset) -> - val currentScrollPosition = index * ONE_THOUSAND + offset - val scrollDelta = currentScrollPosition - previousScrollPosition - - val scrollDirection = when { - scrollDelta > scrollThreshold -> ScrollDirection.SCROLL_DOWN - scrollDelta < -scrollThreshold -> ScrollDirection.SCROLL_UP - else -> lastScrollDirection - } - - if (scrollDirection != lastScrollDirection) { - lastScrollDirection = scrollDirection - updatedOnScrollChanged.value(scrollDirection) - } - - previousScrollPosition = currentScrollPosition - } - } - - return lazyListState -} - -enum class ScrollDirection { - SCROLL_UP, - SCROLL_DOWN, - IDLE -} diff --git a/core/src/main/res/drawable/border_tab_switcher.xml b/core/src/main/res/drawable/border_tab_switcher.xml deleted file mode 100644 index c380a6e48..000000000 --- a/core/src/main/res/drawable/border_tab_switcher.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/core/src/main/res/drawable/fullscreen_exit.xml b/core/src/main/res/drawable/fullscreen_exit.xml deleted file mode 100644 index d431c4b7c..000000000 --- a/core/src/main/res/drawable/fullscreen_exit.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/core/src/main/res/drawable/progress_bar_state.xml b/core/src/main/res/drawable/progress_bar_state.xml deleted file mode 100644 index 46820b216..000000000 --- a/core/src/main/res/drawable/progress_bar_state.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/res/drawable/search_placeholder_background.xml b/core/src/main/res/drawable/search_placeholder_background.xml deleted file mode 100644 index b50065e49..000000000 --- a/core/src/main/res/drawable/search_placeholder_background.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/core/src/main/res/layout/action_mode_back_button.xml b/core/src/main/res/layout/action_mode_back_button.xml new file mode 100644 index 000000000..19462fd0d --- /dev/null +++ b/core/src/main/res/layout/action_mode_back_button.xml @@ -0,0 +1,33 @@ + + + diff --git a/core/src/main/res/values/themes.xml b/core/src/main/res/values/themes.xml index c5869f938..a32860832 100644 --- a/core/src/main/res/values/themes.xml +++ b/core/src/main/res/values/themes.xml @@ -83,7 +83,11 @@ + + +