Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material 3: Voice to content #21427

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
2nd pass at converting voice to content to Material3
  • Loading branch information
nbradbury committed Nov 6, 2024
commit 19e7a186c8a1693ec5a61353d25d80c48863b4b4
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.ContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
Expand All @@ -30,7 +30,7 @@ import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.wordpress.android.R
import org.wordpress.android.ui.compose.theme.AppThemeM2
import org.wordpress.android.ui.compose.theme.AppThemeM3

@OptIn(ExperimentalAnimationApi::class)
@Suppress("DEPRECATION")
Expand All @@ -41,14 +41,14 @@ fun MicToStopIcon(model: RecordingPanelUIModel, isRecording: Boolean) {
val isLight = !isSystemInDarkTheme()

val circleColor by animateColorAsState(
targetValue = if (!isEnabled) MaterialTheme.colors.onSurface.copy(alpha = 0.3f)
else if (isMic) MaterialTheme.colors.primary
targetValue = if (!isEnabled) MaterialTheme.colorScheme.onSurface.copy(alpha = 0.3f)
else if (isMic) MaterialTheme.colorScheme.primary
else if (isLight) Color.Black
else Color.White, label = ""
)

val iconColor by animateColorAsState(
targetValue = if (!isEnabled) MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)
targetValue = if (!isEnabled) MaterialTheme.colorScheme.onSurface.copy(alpha = ContentAlpha.disabled)
else if (isMic) Color.White
else if (isLight) Color.White
else Color.Black, label = ""
Expand Down Expand Up @@ -115,7 +115,7 @@ fun MicToStopIcon(model: RecordingPanelUIModel, isRecording: Boolean) {
@Preview(showBackground = true, device = Devices.PIXEL_4_XL, uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
fun ExistingLayoutPreview() {
AppThemeM2 {
AppThemeM3 {
MicToStopIcon(
RecordingPanelUIModel(
isEligibleForFeature = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
Expand All @@ -28,7 +27,7 @@ import org.wordpress.android.R
import org.wordpress.android.ui.ActivityLauncher
import org.wordpress.android.ui.ActivityNavigator
import org.wordpress.android.ui.PagePostCreationSourcesDetail
import org.wordpress.android.ui.compose.theme.AppThemeM2
import org.wordpress.android.ui.compose.theme.AppThemeM3
import org.wordpress.android.ui.voicetocontent.VoiceToContentActionEvent.Dismiss
import org.wordpress.android.ui.voicetocontent.VoiceToContentActionEvent.LaunchEditPost
import org.wordpress.android.ui.voicetocontent.VoiceToContentActionEvent.LaunchExternalBrowser
Expand All @@ -43,12 +42,11 @@ class VoiceToContentDialogFragment : BottomSheetDialogFragment() {

private val viewModel: VoiceToContentViewModel by viewModels()

@ExperimentalMaterialApi
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View = ComposeView(requireContext()).apply {
setContent {
AppThemeM2 {
AppThemeM3 {
VoiceToContentScreen(
viewModel = viewModel
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,43 +336,43 @@ fun ClickableTextViewWithLinkImage(

private val headerStyle: TextStyle
@Composable
get() = androidx.compose.material3.MaterialTheme.typography.bodyLarge.copy(
get() = MaterialTheme.typography.bodyLarge.copy(
fontWeight = FontWeight.SemiBold,
fontSize = 20.sp,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = ContentAlpha.high)
)

private val secondaryHeaderStyle: TextStyle
@Composable
get() = androidx.compose.material3.MaterialTheme.typography.bodySmall.copy(
get() = MaterialTheme.typography.bodySmall.copy(
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = ContentAlpha.medium)
)

private val actionLabelStyle: TextStyle
@Composable
get() = androidx.compose.material3.MaterialTheme.typography.bodyMedium.copy(
get() = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onSurface.copy(alpha = ContentAlpha.high)
)

private val actionLabelStyleDisabled: TextStyle
@Composable
get() = androidx.compose.material3.MaterialTheme.typography.bodyMedium.copy(
get() = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onSurface.copy(alpha = ContentAlpha.disabled)
)

private val errorMessageStyle: TextStyle
@Composable
get() = androidx.compose.material3.MaterialTheme.typography.titleMedium.copy(
get() = MaterialTheme.typography.titleMedium.copy(
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = ContentAlpha.high)
)

private val errorUrlLinkCTA: TextStyle
@Composable
get() = androidx.compose.material3.MaterialTheme.typography.titleMedium.copy(
get() = MaterialTheme.typography.titleMedium.copy(
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.wordpress.android.ui.voicetocontent
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableIntStateOf
Expand All @@ -23,7 +23,7 @@ fun WaveformOblongVisualizer(recordingUpdate: RecordingUpdate, currentPosition:
val minRadius = 50f // increased minimum radius for the oblongs
val maxAmplitude = 32767f // maximum possible amplitude from MediaRecorder
val oblongWidth = 20f // fixed width of the oblongs
val color = MaterialTheme.colors.primary
val color = MaterialTheme.colorScheme.primary

Canvas(modifier = Modifier
.fillMaxWidth()
Expand Down