From 714fa5d480fc1d9a3b0927da9ca72f8688c66df7 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 1 Nov 2024 12:59:42 -0400 Subject: [PATCH 1/7] First pass at converting SiteMonitorParentActivity to M3 --- .../sitemonitor/SiteMonitorParentActivity.kt | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt index 8411cb9e33eb..083631231c22 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt @@ -18,11 +18,11 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Button -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState @@ -53,7 +53,7 @@ import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.ui.WPWebViewActivity import org.wordpress.android.ui.compose.components.MainTopAppBar import org.wordpress.android.ui.compose.components.NavigationIcons -import org.wordpress.android.ui.compose.theme.AppThemeM2 +import org.wordpress.android.ui.compose.theme.AppThemeM3 import org.wordpress.android.ui.compose.utils.uiStringText import org.wordpress.android.util.extensions.getSerializableExtraCompat import javax.inject.Inject @@ -115,7 +115,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. currentSelectItemId = getInitialTab() } setContent { - AppThemeM2 { + AppThemeM3 { Surface( modifier = Modifier.fillMaxSize(), ) { @@ -152,7 +152,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. } @Composable - @SuppressLint("UnusedMaterialScaffoldPaddingParameter") + @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") fun SiteMonitorScreen(initialTab: Int, modifier: Modifier = Modifier) { Scaffold( topBar = { @@ -182,13 +182,13 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. Column(modifier = modifier.fillMaxWidth()) { TabRow( selectedTabIndex = tabIndex, - containerColor = MaterialTheme.colors.surface, - contentColor = MaterialTheme.colors.onSurface, + containerColor = MaterialTheme.colorScheme.surface, + contentColor = MaterialTheme.colorScheme.onSurface, indicator = { tabPositions -> // Customizing the indicator color and style TabRowDefaults.SecondaryIndicator( Modifier.tabIndicatorOffset(tabPositions[tabIndex]), - color = MaterialTheme.colors.onSurface, + color = MaterialTheme.colorScheme.onSurface, height = 2.0.dp ) } @@ -226,11 +226,12 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. siteMonitorParentViewModel.getUiState(tabType) } when (uiState) { - is SiteMonitorUiState.Preparing -> LoadingState(modifier) + is SiteMonitorUiState.Preparing -> + LoadingState(modifier) is SiteMonitorUiState.Prepared, is SiteMonitorUiState.Loaded -> SiteMonitorWebViewContent(uiState, tabType, modifier) - - is SiteMonitorUiState.Error -> SiteMonitorError(uiState as SiteMonitorUiState.Error, modifier) + is SiteMonitorUiState.Error -> + SiteMonitorError(uiState as SiteMonitorUiState.Error, modifier) } } @@ -241,7 +242,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. modifier = modifier.fillMaxSize() ) { CircularProgressIndicator( - color = MaterialTheme.colors.onSurface + color = MaterialTheme.colorScheme.onSurface ) } } @@ -256,14 +257,14 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. .fillMaxWidth() .fillMaxHeight(), ) { - androidx.compose.material.Text( + Text( text = uiStringText(uiString = error.title), - style = androidx.compose.material.MaterialTheme.typography.h5, + style = MaterialTheme.typography.headlineSmall, textAlign = TextAlign.Center ) - androidx.compose.material.Text( + Text( text = uiStringText(uiString = error.description), - style = androidx.compose.material.MaterialTheme.typography.body1, + style = MaterialTheme.typography.bodyLarge, textAlign = TextAlign.Center, modifier = Modifier.padding(top = 8.dp) ) @@ -285,7 +286,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. tabType: SiteMonitorType, modifier: Modifier = Modifier ) { - // retrieve the webview from the actvity + // retrieve the webview from the activity val webView = when (tabType) { SiteMonitorType.METRICS -> metricsWebView SiteMonitorType.PHP_LOGS -> phpLogsWebView @@ -304,7 +305,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. } } - @OptIn(ExperimentalMaterialApi::class) + @OptIn(ExperimentalMaterial3Api::class) @Composable private fun SiteMonitorWebView(tabWebView: WebView, tabType: SiteMonitorType, modifier: Modifier = Modifier) { // the webview is retrieved from the activity, so we need to use a mutable variable @@ -336,7 +337,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. refreshing = refreshState.value, state = pullRefreshState, modifier = Modifier.align(Alignment.TopCenter), - contentColor = MaterialTheme.colors.primaryVariant, + contentColor = MaterialTheme.colorScheme.secondary, ) } } From 22060316f4ac010ea0aea06ac89b06347e00aa18 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 1 Nov 2024 13:20:57 -0400 Subject: [PATCH 2/7] second pass at converting SiteMonitorParentActivity to M3 --- .../sitemonitor/SiteMonitorParentActivity.kt | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt index 083631231c22..5d018a1ebff0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt @@ -23,15 +23,14 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text -import androidx.compose.material.pullrefresh.PullRefreshIndicator -import androidx.compose.material.pullrefresh.pullRefresh -import androidx.compose.material.pullrefresh.rememberPullRefreshState +import androidx.compose.material3.pulltorefresh.PullToRefreshBox import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Surface import androidx.compose.material3.Tab import androidx.compose.material3.TabRow import androidx.compose.material3.TabRowDefaults import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset +import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -314,15 +313,12 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. val refreshState = siteMonitorParentViewModel.getRefreshState(tabType) - val pullRefreshState = rememberPullRefreshState( - refreshing = refreshState.value, - onRefresh = { siteMonitorParentViewModel.refreshData(tabType) } - ) - - Box( + PullToRefreshBox( + isRefreshing = refreshState.value, + state = rememberPullToRefreshState(), + onRefresh = { siteMonitorParentViewModel.refreshData(tabType) }, modifier = modifier .fillMaxSize() - .pullRefresh(pullRefreshState) ) { LazyColumn(modifier = Modifier.fillMaxHeight()) { item { @@ -333,12 +329,12 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. ) } } - PullRefreshIndicator( + /*PullRefreshIndicator( refreshing = refreshState.value, state = pullRefreshState, modifier = Modifier.align(Alignment.TopCenter), contentColor = MaterialTheme.colorScheme.secondary, - ) + )*/ } } From 263891c9771025475c75935c289ee0429f49b043 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 1 Nov 2024 13:33:52 -0400 Subject: [PATCH 3/7] Use M3 PullToRefreshBox --- .../sitemonitor/SiteMonitorParentActivity.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt index 5d018a1ebff0..fea303bbfae0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt @@ -19,17 +19,18 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.Button +import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.material3.pulltorefresh.PullToRefreshBox -import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Surface import androidx.compose.material3.Tab import androidx.compose.material3.TabRow import androidx.compose.material3.TabRowDefaults import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset +import androidx.compose.material3.Text +import androidx.compose.material3.pulltorefresh.PullToRefreshBox +import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -312,13 +313,22 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. var webView = tabWebView val refreshState = siteMonitorParentViewModel.getRefreshState(tabType) + val pullToRefreshState = rememberPullToRefreshState() PullToRefreshBox( + modifier = modifier + .fillMaxSize(), isRefreshing = refreshState.value, - state = rememberPullToRefreshState(), + state = pullToRefreshState, onRefresh = { siteMonitorParentViewModel.refreshData(tabType) }, - modifier = modifier - .fillMaxSize() + indicator = { + PullToRefreshDefaults.Indicator( + state = pullToRefreshState, + isRefreshing = refreshState.value, + color = MaterialTheme.colorScheme.secondary, + modifier = Modifier.align(Alignment.TopCenter), + ) + } ) { LazyColumn(modifier = Modifier.fillMaxHeight()) { item { @@ -329,12 +339,6 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. ) } } - /*PullRefreshIndicator( - refreshing = refreshState.value, - state = pullRefreshState, - modifier = Modifier.align(Alignment.TopCenter), - contentColor = MaterialTheme.colorScheme.secondary, - )*/ } } From 878dfaed3c48949959410feedfe7dcaa9dbc85fb Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 1 Nov 2024 14:09:52 -0400 Subject: [PATCH 4/7] Fixed scaffold & tabs --- .../sitemonitor/SiteMonitorParentActivity.kt | 96 +++++++++++++------ 1 file changed, 69 insertions(+), 27 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt index fea303bbfae0..4cd6017d098d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt @@ -18,17 +18,21 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.Button import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.PrimaryTabRow import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Tab -import androidx.compose.material3.TabRow import androidx.compose.material3.TabRowDefaults -import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar import androidx.compose.material3.pulltorefresh.PullToRefreshBox import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState @@ -43,6 +47,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.fragment.app.Fragment @@ -51,8 +56,6 @@ import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.ui.WPWebViewActivity -import org.wordpress.android.ui.compose.components.MainTopAppBar -import org.wordpress.android.ui.compose.components.NavigationIcons import org.wordpress.android.ui.compose.theme.AppThemeM3 import org.wordpress.android.ui.compose.utils.uiStringText import org.wordpress.android.util.extensions.getSerializableExtraCompat @@ -151,28 +154,62 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. const val SAVED_STATE_CURRENT_TAB_KEY = "CurrentTabKey" } + @OptIn(ExperimentalMaterial3Api::class) @Composable - @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") - fun SiteMonitorScreen(initialTab: Int, modifier: Modifier = Modifier) { + fun SiteMonitorScreen(initialTab: Int) { Scaffold( topBar = { - MainTopAppBar( - title = stringResource(id = R.string.site_monitoring), - navigationIcon = NavigationIcons.BackIcon, - onNavigationIconClick = onBackPressedDispatcher::onBackPressed, + TopAppBar( + title = { + Text( + text = stringResource(id = R.string.site_monitoring) + ) + }, + navigationIcon = { + IconButton(onClick = onBackPressedDispatcher::onBackPressed) { + Icon( + Icons.AutoMirrored.Filled.ArrowBack, + stringResource(R.string.back) + ) + } + }, ) }, - content = { - SiteMonitorHeader(initialTab, modifier = modifier) + ) { contentPadding -> + SiteMonitorHeader(initialTab, modifier = Modifier.padding(contentPadding)) + } + } + + // TODO remove this preview + @Preview + @Composable + @OptIn(ExperimentalMaterial3Api::class) + fun TestPreview() { + var state by remember { mutableIntStateOf(0) } + val titles = listOf("Tab 1", "Tab 2", "Tab 3 with lots of text") + Column { + PrimaryTabRow(selectedTabIndex = state) { + titles.forEachIndexed { index, title -> + Tab( + selected = state == index, + onClick = { state = index }, + text = { Text(text = title, maxLines = 2, overflow = TextOverflow.Ellipsis) } + ) + } } - ) + Text( + modifier = Modifier.align(Alignment.CenterHorizontally), + text = "Text tab ${state + 1} selected", + style = MaterialTheme.typography.bodyLarge + ) + } } + @OptIn(ExperimentalMaterial3Api::class) @Composable @SuppressLint("UnusedMaterialScaffoldPaddingParameter") fun SiteMonitorHeader(initialTab: Int, modifier: Modifier = Modifier) { var tabIndex by remember { mutableIntStateOf(initialTab) } - val tabs = SiteMonitorTabItem.entries LaunchedEffect(true) { @@ -180,14 +217,13 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. } Column(modifier = modifier.fillMaxWidth()) { - TabRow( + PrimaryTabRow( selectedTabIndex = tabIndex, containerColor = MaterialTheme.colorScheme.surface, contentColor = MaterialTheme.colorScheme.onSurface, - indicator = { tabPositions -> - // Customizing the indicator color and style + indicator = { TabRowDefaults.SecondaryIndicator( - Modifier.tabIndicatorOffset(tabPositions[tabIndex]), + // Modifier.tabIndicatorOffset(tabPositions[tabIndex]), color = MaterialTheme.colorScheme.onSurface, height = 2.0.dp ) @@ -196,13 +232,11 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. tabs.forEachIndexed { index, item -> Tab( text = { - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text( - text = stringResource(item.title).uppercase(), - maxLines = 1, - overflow = TextOverflow.Ellipsis - ) - } + Text( + text = stringResource(item.title).uppercase(), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) }, selected = tabIndex == index, onClick = { @@ -228,8 +262,10 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. when (uiState) { is SiteMonitorUiState.Preparing -> LoadingState(modifier) + is SiteMonitorUiState.Prepared, is SiteMonitorUiState.Loaded -> SiteMonitorWebViewContent(uiState, tabType, modifier) + is SiteMonitorUiState.Error -> SiteMonitorError(uiState as SiteMonitorUiState.Error, modifier) } @@ -293,21 +329,27 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. SiteMonitorType.WEB_SERVER_LOGS -> webServerLogsWebView } - when(uiState) { + when (uiState) { is SiteMonitorUiState.Prepared -> { webView.postUrl(WPWebViewActivity.WPCOM_LOGIN_URL, uiState.model.addressToLoad.toByteArray()) LoadingState() } + is SiteMonitorUiState.Loaded -> { SiteMonitorWebView(webView, tabType, modifier) } + else -> {} } } @OptIn(ExperimentalMaterial3Api::class) @Composable - private fun SiteMonitorWebView(tabWebView: WebView, tabType: SiteMonitorType, modifier: Modifier = Modifier) { + private fun SiteMonitorWebView( + tabWebView: WebView, + tabType: SiteMonitorType, + modifier: Modifier = Modifier + ) { // the webview is retrieved from the activity, so we need to use a mutable variable // to assign to android view var webView = tabWebView From cfca702e78b00c4c898230bf2e9772a6c4d9e876 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 1 Nov 2024 14:16:42 -0400 Subject: [PATCH 5/7] Use correct fontWeight --- .../sitemonitor/SiteMonitorParentActivity.kt | 31 ++----------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt index 4cd6017d098d..7a30191b0886 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt @@ -45,9 +45,9 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.fragment.app.Fragment @@ -180,31 +180,6 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. } } - // TODO remove this preview - @Preview - @Composable - @OptIn(ExperimentalMaterial3Api::class) - fun TestPreview() { - var state by remember { mutableIntStateOf(0) } - val titles = listOf("Tab 1", "Tab 2", "Tab 3 with lots of text") - Column { - PrimaryTabRow(selectedTabIndex = state) { - titles.forEachIndexed { index, title -> - Tab( - selected = state == index, - onClick = { state = index }, - text = { Text(text = title, maxLines = 2, overflow = TextOverflow.Ellipsis) } - ) - } - } - Text( - modifier = Modifier.align(Alignment.CenterHorizontally), - text = "Text tab ${state + 1} selected", - style = MaterialTheme.typography.bodyLarge - ) - } - } - @OptIn(ExperimentalMaterial3Api::class) @Composable @SuppressLint("UnusedMaterialScaffoldPaddingParameter") @@ -223,7 +198,6 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. contentColor = MaterialTheme.colorScheme.onSurface, indicator = { TabRowDefaults.SecondaryIndicator( - // Modifier.tabIndicatorOffset(tabPositions[tabIndex]), color = MaterialTheme.colorScheme.onSurface, height = 2.0.dp ) @@ -235,7 +209,8 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. Text( text = stringResource(item.title).uppercase(), maxLines = 1, - overflow = TextOverflow.Ellipsis + overflow = TextOverflow.Ellipsis, + fontWeight = FontWeight.Normal ) }, selected = tabIndex == index, From de2a202794869a6788910f9bb0685b59213fa7b9 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 1 Nov 2024 15:14:28 -0400 Subject: [PATCH 6/7] Use correct tab indicator --- .../android/ui/sitemonitor/SiteMonitorParentActivity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt index 7a30191b0886..7784d6662a6b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt @@ -199,7 +199,8 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. indicator = { TabRowDefaults.SecondaryIndicator( color = MaterialTheme.colorScheme.onSurface, - height = 2.0.dp + height = 2.0.dp, + modifier = Modifier.tabIndicatorOffset(tabIndex) ) } ) { From 431783bdc6e07f8ab895a7bd821fdacf4445731a Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 1 Nov 2024 16:01:44 -0400 Subject: [PATCH 7/7] Minor cleanup --- .../ui/sitemonitor/SiteMonitorParentActivity.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt index 7784d6662a6b..2921c605bb8f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorParentActivity.kt @@ -117,6 +117,7 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. siteMonitorParentViewModel.start(getSite()) currentSelectItemId = getInitialTab() } + setContent { AppThemeM3 { Surface( @@ -148,12 +149,6 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. } } - companion object { - const val ARG_SITE_MONITOR_TYPE_KEY = "ARG_SITE_MONITOR_TYPE_KEY" - const val SAVED_STATE_CONTAINER_KEY = "ContainerKey" - const val SAVED_STATE_CURRENT_TAB_KEY = "CurrentTabKey" - } - @OptIn(ExperimentalMaterial3Api::class) @Composable fun SiteMonitorScreen(initialTab: Int) { @@ -298,7 +293,6 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. tabType: SiteMonitorType, modifier: Modifier = Modifier ) { - // retrieve the webview from the activity val webView = when (tabType) { SiteMonitorType.METRICS -> metricsWebView SiteMonitorType.PHP_LOGS -> phpLogsWebView @@ -374,4 +368,10 @@ class SiteMonitorParentActivity : AppCompatActivity(), SiteMonitorWebViewClient. siteMonitorParentViewModel.onWebViewError(tabType) siteMonitorUtils.trackTabLoadingError(tabType) } + + companion object { + const val ARG_SITE_MONITOR_TYPE_KEY = "ARG_SITE_MONITOR_TYPE_KEY" + const val SAVED_STATE_CONTAINER_KEY = "ContainerKey" + const val SAVED_STATE_CURRENT_TAB_KEY = "CurrentTabKey" + } }