From 54edddbd2d99a35a7215ad9f9f31d225041ea079 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 29 Sep 2023 13:57:10 -0400 Subject: [PATCH] Migrates to Material 3 --- app/build.gradle | 4 +- .../material3/pullrefresh/PullRefresh.kt | 120 +++++++ .../pullrefresh/PullRefreshIndicator.kt | 238 +++++++++++++ .../PullRefreshIndicatorTransform.kt | 75 +++++ .../material3/pullrefresh/PullRefreshState.kt | 228 +++++++++++++ .../vitorpamplona/amethyst/ui/MainActivity.kt | 6 +- .../ui/actions/JoinUserOrChannelView.kt | 20 +- .../amethyst/ui/actions/NewChannelView.kt | 16 +- .../amethyst/ui/actions/NewMediaView.kt | 16 +- .../amethyst/ui/actions/NewPollClosing.kt | 22 +- .../ui/actions/NewPollConsensusThreshold.kt | 22 +- .../amethyst/ui/actions/NewPollOption.kt | 6 +- .../ui/actions/NewPollPrimaryDescription.kt | 18 +- .../ui/actions/NewPollRecipientsField.kt | 10 +- .../ui/actions/NewPollVoteValueRange.kt | 28 +- .../amethyst/ui/actions/NewPostView.kt | 182 +++++----- .../amethyst/ui/actions/NewRelayListView.kt | 88 ++--- .../ui/actions/NewUserMetadataView.kt | 34 +- .../ui/actions/RelayInformationDialog.kt | 4 +- .../ui/actions/RelaySelectionDialog.kt | 6 +- .../amethyst/ui/actions/SaveToGallery.kt | 27 +- .../amethyst/ui/actions/UploadFromGallery.kt | 4 +- .../amethyst/ui/buttons/ChannelFabColumn.kt | 31 +- .../amethyst/ui/buttons/NewChannelButton.kt | 10 +- .../ui/buttons/NewCommunityNoteButton.kt | 16 +- .../amethyst/ui/buttons/NewImageButton.kt | 29 +- .../amethyst/ui/buttons/NewNoteButton.kt | 16 +- .../ui/components/AudioWaveformReadOnly.kt | 4 +- .../amethyst/ui/components/CashuRedeem.kt | 8 +- .../amethyst/ui/components/ClickableEmail.kt | 6 +- .../ui/components/ClickableNoteTag.kt | 6 +- .../amethyst/ui/components/ClickablePhone.kt | 6 +- .../amethyst/ui/components/ClickableRoute.kt | 21 +- .../amethyst/ui/components/ClickableUrl.kt | 6 +- .../ui/components/ClickableUserTag.kt | 6 +- .../ui/components/ClickableWithdrawal.kt | 8 +- .../ui/components/ExpandableRichTextViewer.kt | 12 +- .../amethyst/ui/components/InvoicePreview.kt | 6 +- .../amethyst/ui/components/InvoiceRequest.kt | 22 +- .../amethyst/ui/components/RichTextViewer.kt | 31 +- .../ui/components/SelectTextDialog.kt | 8 +- .../ui/components/SensitivityWarning.kt | 16 +- .../amethyst/ui/components/SlidingCarousel.kt | 8 +- .../amethyst/ui/components/TextSpinner.kt | 12 +- .../amethyst/ui/components/UrlPreviewCard.kt | 12 +- .../amethyst/ui/components/VideoView.kt | 14 +- .../ui/components/ZapRaiserRequest.kt | 14 +- .../ui/components/ZoomableContentView.kt | 74 ++-- .../ui/navigation/AccountSwitchBottomSheet.kt | 33 +- .../amethyst/ui/navigation/AppBottomBar.kt | 34 +- .../amethyst/ui/navigation/AppTopBar.kt | 231 ++++--------- .../amethyst/ui/navigation/DrawerContent.kt | 145 ++++---- .../amethyst/ui/note/AddBountyAmountDialog.kt | 10 +- .../amethyst/ui/note/BadgeCompose.kt | 20 +- .../amethyst/ui/note/BlankNote.kt | 12 +- .../amethyst/ui/note/ChannelCardCompose.kt | 24 +- .../amethyst/ui/note/ChatroomHeaderCompose.kt | 18 +- .../ui/note/ChatroomMessageCompose.kt | 28 +- .../vitorpamplona/amethyst/ui/note/Icons.kt | 29 +- .../amethyst/ui/note/MessageSetCompose.kt | 8 +- .../amethyst/ui/note/MultiSetCompose.kt | 16 +- .../ui/note/NIP05VerificationDisplay.kt | 30 +- .../amethyst/ui/note/NoteCompose.kt | 140 ++++---- .../amethyst/ui/note/NoteQuickActionMenu.kt | 39 ++- .../amethyst/ui/note/PollNote.kt | 12 +- .../amethyst/ui/note/ReactionsRow.kt | 49 ++- .../amethyst/ui/note/RelayCompose.kt | 26 +- .../amethyst/ui/note/RelayListBox.kt | 8 +- .../amethyst/ui/note/RelayListRow.kt | 11 +- .../amethyst/ui/note/ReplyInformation.kt | 28 +- .../ui/note/UpdateReactionTypeDialog.kt | 26 +- .../amethyst/ui/note/UpdateZapAmountDialog.kt | 34 +- .../amethyst/ui/note/UserCompose.kt | 2 +- .../amethyst/ui/note/UserProfilePicture.kt | 171 ++++++---- .../amethyst/ui/note/UserReactionsRow.kt | 8 +- .../amethyst/ui/note/UsernameDisplay.kt | 14 +- .../amethyst/ui/note/ZapCustomDialog.kt | 40 ++- .../amethyst/ui/note/ZapNoteCompose.kt | 8 +- .../amethyst/ui/note/ZapUserSetCompose.kt | 8 +- .../amethyst/ui/qrcode/QrCodeDrawer.kt | 6 +- .../amethyst/ui/qrcode/ShowQRDialog.kt | 18 +- .../amethyst/ui/screen/CardFeedView.kt | 8 +- .../amethyst/ui/screen/ChatroomFeedView.kt | 4 +- .../amethyst/ui/screen/FeedView.kt | 14 +- .../amethyst/ui/screen/RelayFeedView.kt | 8 +- .../amethyst/ui/screen/StringFeedView.kt | 4 +- .../amethyst/ui/screen/ThreadFeedView.kt | 46 ++- .../ui/screen/loggedIn/AccountBackupDialog.kt | 24 +- .../ui/screen/loggedIn/AccountViewModel.kt | 9 + .../ui/screen/loggedIn/BookmarkListScreen.kt | 11 +- .../ui/screen/loggedIn/ChannelScreen.kt | 149 ++++---- .../ui/screen/loggedIn/ChatroomListScreen.kt | 68 ++-- .../ui/screen/loggedIn/ChatroomScreen.kt | 46 +-- .../ui/screen/loggedIn/ConnectOrbotDialog.kt | 27 +- .../ui/screen/loggedIn/DiscoverScreen.kt | 11 +- .../ui/screen/loggedIn/GeoHashScreen.kt | 4 +- .../ui/screen/loggedIn/HashtagScreen.kt | 4 +- .../ui/screen/loggedIn/HiddenUsersScreen.kt | 43 +-- .../amethyst/ui/screen/loggedIn/HomeScreen.kt | 15 +- .../ui/screen/loggedIn/LoadRedirectScreen.kt | 2 +- .../amethyst/ui/screen/loggedIn/MainScreen.kt | 317 ++++++++++-------- .../ui/screen/loggedIn/NotificationScreen.kt | 6 +- .../ui/screen/loggedIn/ProfileScreen.kt | 211 ++++++------ .../ui/screen/loggedIn/ReportNoteDialog.kt | 34 +- .../ui/screen/loggedIn/SearchScreen.kt | 18 +- .../ui/screen/loggedIn/SettingsScreen.kt | 25 +- .../ui/screen/loggedIn/VideoScreen.kt | 18 +- .../ui/screen/loggedOff/LoginScreen.kt | 32 +- .../vitorpamplona/amethyst/ui/theme/Color.kt | 3 + .../vitorpamplona/amethyst/ui/theme/Shape.kt | 4 +- .../vitorpamplona/amethyst/ui/theme/Theme.kt | 80 ++--- .../vitorpamplona/amethyst/ui/theme/Type.kt | 4 +- .../components/TranslatableRichTextViewer.kt | 206 ++++++------ build.gradle | 1 + 114 files changed, 2477 insertions(+), 1841 deletions(-) create mode 100644 app/src/main/java/androidx/compose/material3/pullrefresh/PullRefresh.kt create mode 100644 app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicator.kt create mode 100644 app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicatorTransform.kt create mode 100644 app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshState.kt diff --git a/app/build.gradle b/app/build.gradle index 84c9fd55c..9e34e9df1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -102,7 +102,7 @@ dependencies { // Observe Live data as State implementation "androidx.compose.runtime:runtime-livedata:$compose_ui_version" - implementation "androidx.compose.material:material:$compose_ui_version" + implementation "androidx.compose.material3:material3:${material3_version}" implementation "androidx.compose.material:material-icons-extended:$compose_ui_version" // Lifecycle @@ -155,7 +155,7 @@ dependencies { // Markdown (With fix for full-image bleeds) implementation('com.github.vitorpamplona.compose-richtext:richtext-ui:a0954aba63') - implementation('com.github.vitorpamplona.compose-richtext:richtext-ui-material:a0954aba63') + implementation('com.github.vitorpamplona.compose-richtext:richtext-ui-material3:a0954aba63') implementation('com.github.vitorpamplona.compose-richtext:richtext-commonmark:a0954aba63') // Language picker and Theme chooser diff --git a/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefresh.kt b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefresh.kt new file mode 100644 index 000000000..2f8cf6729 --- /dev/null +++ b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefresh.kt @@ -0,0 +1,120 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package androidx.compose.material3.pullrefresh + +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.input.nestedscroll.NestedScrollConnection +import androidx.compose.ui.input.nestedscroll.NestedScrollSource +import androidx.compose.ui.input.nestedscroll.NestedScrollSource.Companion.Drag +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.debugInspectorInfo +import androidx.compose.ui.platform.inspectable +import androidx.compose.ui.unit.Velocity + +/** + * A nested scroll modifier that provides scroll events to [state]. + * + * Note that this modifier must be added above a scrolling container, such as a lazy column, in + * order to receive scroll events. For example: + * + * @sample androidx.compose.material.samples.PullRefreshSample + * + * @param state The [PullRefreshState] associated with this pull-to-refresh component. + * The state will be updated by this modifier. + * @param enabled If not enabled, all scroll delta and fling velocity will be ignored. + */ +// TODO(b/244423199): Move pullRefresh into its own material library similar to material-ripple. +fun Modifier.pullRefresh( + state: PullRefreshState, + enabled: Boolean = true +) = inspectable( + inspectorInfo = debugInspectorInfo { + name = "pullRefresh" + properties["state"] = state + properties["enabled"] = enabled + } +) { + Modifier.pullRefresh(state::onPull, state::onRelease, enabled) +} + +/** + * A nested scroll modifier that provides [onPull] and [onRelease] callbacks to aid building custom + * pull refresh components. + * + * Note that this modifier must be added above a scrolling container, such as a lazy column, in + * order to receive scroll events. For example: + * + * @sample androidx.compose.material.samples.CustomPullRefreshSample + * + * @param onPull Callback for dispatching vertical scroll delta, takes float pullDelta as argument. + * Positive delta (pulling down) is dispatched only if the child does not consume it (i.e. pulling + * down despite being at the top of a scrollable component), whereas negative delta (swiping up) is + * dispatched first (in case it is needed to push the indicator back up), and then the unconsumed + * delta is passed on to the child. The callback returns how much delta was consumed. + * @param onRelease Callback for when drag is released, takes float flingVelocity as argument. + * The callback returns how much velocity was consumed - in most cases this should only consume + * velocity if pull refresh has been dragged already and the velocity is positive (the fling is + * downwards), as an upwards fling should typically still scroll a scrollable component beneath the + * pullRefresh. This is invoked before any remaining velocity is passed to the child. + * @param enabled If not enabled, all scroll delta and fling velocity will be ignored and neither + * [onPull] nor [onRelease] will be invoked. + */ +fun Modifier.pullRefresh( + onPull: (pullDelta: Float) -> Float, + onRelease: suspend (flingVelocity: Float) -> Float, + enabled: Boolean = true +) = inspectable( + inspectorInfo = debugInspectorInfo { + name = "pullRefresh" + properties["onPull"] = onPull + properties["onRelease"] = onRelease + properties["enabled"] = enabled + } +) { + Modifier.nestedScroll(PullRefreshNestedScrollConnection(onPull, onRelease, enabled)) +} + +private class PullRefreshNestedScrollConnection( + private val onPull: (pullDelta: Float) -> Float, + private val onRelease: suspend (flingVelocity: Float) -> Float, + private val enabled: Boolean +) : NestedScrollConnection { + + override fun onPreScroll( + available: Offset, + source: NestedScrollSource + ): Offset = when { + !enabled -> Offset.Zero + source == Drag && available.y < 0 -> Offset(0f, onPull(available.y)) // Swiping up + else -> Offset.Zero + } + + override fun onPostScroll( + consumed: Offset, + available: Offset, + source: NestedScrollSource + ): Offset = when { + !enabled -> Offset.Zero + source == Drag && available.y > 0 -> Offset(0f, onPull(available.y)) // Pulling down + else -> Offset.Zero + } + + override suspend fun onPreFling(available: Velocity): Velocity { + return Velocity(0f, onRelease(available.y)) + } +} diff --git a/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicator.kt b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicator.kt new file mode 100644 index 000000000..e351e5f56 --- /dev/null +++ b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicator.kt @@ -0,0 +1,238 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package androidx.compose.material3.pullrefresh + +import androidx.compose.animation.Crossfade +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.core.tween +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.contentColorFor +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.geometry.center +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.PathFillType +import androidx.compose.ui.graphics.StrokeCap +import androidx.compose.ui.graphics.drawscope.DrawScope +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.graphics.drawscope.rotate +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.dp +import kotlin.math.abs +import kotlin.math.max +import kotlin.math.min +import kotlin.math.pow + +/** + * The default indicator for Compose pull-to-refresh, based on Android's SwipeRefreshLayout. + * + * @sample androidx.compose.material.samples.PullRefreshSample + * + * @param refreshing A boolean representing whether a refresh is occurring. + * @param state The [PullRefreshState] which controls where and how the indicator will be drawn. + * @param modifier Modifiers for the indicator. + * @param backgroundColor The color of the indicator's background. + * @param contentColor The color of the indicator's arc and arrow. + * @param scale A boolean controlling whether the indicator's size scales with pull progress or not. + */ +// TODO(b/244423199): Consider whether the state parameter should be replaced with lambdas to +// enable people to use this indicator with custom pull-to-refresh components. +@Composable +fun PullRefreshIndicator( + refreshing: Boolean, + state: PullRefreshState, + modifier: Modifier = Modifier, + backgroundColor: Color = MaterialTheme.colorScheme.surface, + contentColor: Color = contentColorFor(backgroundColor), + scale: Boolean = false +) { + val showElevation by remember(refreshing, state) { + derivedStateOf { refreshing || state.position > 0.5f } + } + + Surface( + modifier = modifier + .size(IndicatorSize) + .pullRefreshIndicatorTransform(state, scale), + shape = SpinnerShape, + color = backgroundColor, + shadowElevation = if (showElevation) Elevation else 0.dp + ) { + Crossfade( + targetState = refreshing, + animationSpec = tween(durationMillis = CrossfadeDurationMs) + ) { refreshing -> + Box( + modifier = Modifier.fillMaxSize(), + contentAlignment = Alignment.Center + ) { + val spinnerSize = (ArcRadius + StrokeWidth).times(2) + + if (refreshing) { + CircularProgressIndicator( + color = contentColor, + strokeWidth = StrokeWidth, + modifier = Modifier.size(spinnerSize) + ) + } else { + CircularArrowIndicator(state, contentColor, Modifier.size(spinnerSize)) + } + } + } + } +} + +/** + * Modifier.size MUST be specified. + */ +@Composable +private fun CircularArrowIndicator( + state: PullRefreshState, + color: Color, + modifier: Modifier +) { + val path = remember { Path().apply { fillType = PathFillType.EvenOdd } } + + val targetAlpha by remember(state) { + derivedStateOf { + if (state.progress >= 1f) MaxAlpha else MinAlpha + } + } + + val alphaState = animateFloatAsState(targetValue = targetAlpha, animationSpec = AlphaTween) + + // Empty semantics for tests + Canvas(modifier.semantics {}) { + val values = ArrowValues(state.progress) + val alpha = alphaState.value + + rotate(degrees = values.rotation) { + val arcRadius = ArcRadius.toPx() + StrokeWidth.toPx() / 2f + val arcBounds = Rect( + size.center.x - arcRadius, + size.center.y - arcRadius, + size.center.x + arcRadius, + size.center.y + arcRadius + ) + drawArc( + color = color, + alpha = alpha, + startAngle = values.startAngle, + sweepAngle = values.endAngle - values.startAngle, + useCenter = false, + topLeft = arcBounds.topLeft, + size = arcBounds.size, + style = Stroke( + width = StrokeWidth.toPx(), + cap = StrokeCap.Square + ) + ) + drawArrow(path, arcBounds, color, alpha, values) + } + } +} + +@Immutable +private class ArrowValues( + val rotation: Float, + val startAngle: Float, + val endAngle: Float, + val scale: Float +) + +private fun ArrowValues(progress: Float): ArrowValues { + // Discard first 40% of progress. Scale remaining progress to full range between 0 and 100%. + val adjustedPercent = max(min(1f, progress) - 0.4f, 0f) * 5 / 3 + // How far beyond the threshold pull has gone, as a percentage of the threshold. + val overshootPercent = abs(progress) - 1.0f + // Limit the overshoot to 200%. Linear between 0 and 200. + val linearTension = overshootPercent.coerceIn(0f, 2f) + // Non-linear tension. Increases with linearTension, but at a decreasing rate. + val tensionPercent = linearTension - linearTension.pow(2) / 4 + + // Calculations based on SwipeRefreshLayout specification. + val endTrim = adjustedPercent * MaxProgressArc + val rotation = (-0.25f + 0.4f * adjustedPercent + tensionPercent) * 0.5f + val startAngle = rotation * 360 + val endAngle = (rotation + endTrim) * 360 + val scale = min(1f, adjustedPercent) + + return ArrowValues(rotation, startAngle, endAngle, scale) +} + +private fun DrawScope.drawArrow( + arrow: Path, + bounds: Rect, + color: Color, + alpha: Float, + values: ArrowValues +) { + arrow.reset() + arrow.moveTo(0f, 0f) // Move to left corner + arrow.lineTo(x = ArrowWidth.toPx() * values.scale, y = 0f) // Line to right corner + + // Line to tip of arrow + arrow.lineTo( + x = ArrowWidth.toPx() * values.scale / 2, + y = ArrowHeight.toPx() * values.scale + ) + + val radius = min(bounds.width, bounds.height) / 2f + val inset = ArrowWidth.toPx() * values.scale / 2f + arrow.translate( + Offset( + x = radius + bounds.center.x - inset, + y = bounds.center.y + StrokeWidth.toPx() / 2f + ) + ) + arrow.close() + rotate(degrees = values.endAngle) { + drawPath(path = arrow, color = color, alpha = alpha) + } +} + +private const val CrossfadeDurationMs = 100 +private const val MaxProgressArc = 0.8f + +private val IndicatorSize = 40.dp +private val SpinnerShape = CircleShape +private val ArcRadius = 7.5.dp +private val StrokeWidth = 2.5.dp +private val ArrowWidth = 10.dp +private val ArrowHeight = 5.dp +private val Elevation = 6.dp + +// Values taken from SwipeRefreshLayout +private const val MinAlpha = 0.3f +private const val MaxAlpha = 1f +private val AlphaTween = tween(300, easing = LinearEasing) diff --git a/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicatorTransform.kt b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicatorTransform.kt new file mode 100644 index 000000000..6377d759e --- /dev/null +++ b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshIndicatorTransform.kt @@ -0,0 +1,75 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package androidx.compose.material3.pullrefresh + +import androidx.compose.animation.core.LinearOutSlowInEasing +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.drawWithContent +import androidx.compose.ui.graphics.drawscope.clipRect +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.platform.debugInspectorInfo +import androidx.compose.ui.platform.inspectable + +/** + * A modifier for translating the position and scaling the size of a pull-to-refresh indicator + * based on the given [PullRefreshState]. + * + * @sample androidx.compose.material.samples.PullRefreshIndicatorTransformSample + * + * @param state The [PullRefreshState] which determines the position of the indicator. + * @param scale A boolean controlling whether the indicator's size scales with pull progress or not. + */ +// TODO: Consider whether the state parameter should be replaced with lambdas. +fun Modifier.pullRefreshIndicatorTransform( + state: PullRefreshState, + scale: Boolean = false +) = inspectable( + inspectorInfo = debugInspectorInfo { + name = "pullRefreshIndicatorTransform" + properties["state"] = state + properties["scale"] = scale + } +) { + Modifier + // Essentially we only want to clip the at the top, so the indicator will not appear when + // the position is 0. It is preferable to clip the indicator as opposed to the layout that + // contains the indicator, as this would also end up clipping shadows drawn by items in a + // list for example - so we leave the clipping to the scrolling container. We use MAX_VALUE + // for the other dimensions to allow for more room for elevation / arbitrary indicators - we + // only ever really want to clip at the top edge. + .drawWithContent { + clipRect( + top = 0f, + left = -Float.MAX_VALUE, + right = Float.MAX_VALUE, + bottom = Float.MAX_VALUE + ) { + this@drawWithContent.drawContent() + } + } + .graphicsLayer { + translationY = state.position - size.height + + if (scale && !state.refreshing) { + val scaleFraction = LinearOutSlowInEasing + .transform(state.position / state.threshold) + .coerceIn(0f, 1f) + scaleX = scaleFraction + scaleY = scaleFraction + } + } +} diff --git a/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshState.kt b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshState.kt new file mode 100644 index 000000000..86383eb70 --- /dev/null +++ b/app/src/main/java/androidx/compose/material3/pullrefresh/PullRefreshState.kt @@ -0,0 +1,228 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package androidx.compose.material3.pullrefresh + +import androidx.compose.animation.core.animate +import androidx.compose.foundation.MutatorMutex +import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect +import androidx.compose.runtime.State +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.runtime.setValue +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch +import kotlin.math.abs +import kotlin.math.pow + +/** + * Creates a [PullRefreshState] that is remembered across compositions. + * + * Changes to [refreshing] will result in [PullRefreshState] being updated. + * + * @sample androidx.compose.material.samples.PullRefreshSample + * + * @param refreshing A boolean representing whether a refresh is currently occurring. + * @param onRefresh The function to be called to trigger a refresh. + * @param refreshThreshold The threshold below which, if a release + * occurs, [onRefresh] will be called. + * @param refreshingOffset The offset at which the indicator will be drawn while refreshing. This + * offset corresponds to the position of the bottom of the indicator. + */ +@Composable +fun rememberPullRefreshState( + refreshing: Boolean, + onRefresh: () -> Unit, + refreshThreshold: Dp = PullRefreshDefaults.RefreshThreshold, + refreshingOffset: Dp = PullRefreshDefaults.RefreshingOffset +): PullRefreshState { + require(refreshThreshold > 0.dp) { "The refresh trigger must be greater than zero!" } + + val scope = rememberCoroutineScope() + val onRefreshState = rememberUpdatedState(onRefresh) + val thresholdPx: Float + val refreshingOffsetPx: Float + + with(LocalDensity.current) { + thresholdPx = refreshThreshold.toPx() + refreshingOffsetPx = refreshingOffset.toPx() + } + + val state = remember(scope) { + PullRefreshState(scope, onRefreshState, refreshingOffsetPx, thresholdPx) + } + + SideEffect { + state.setRefreshing(refreshing) + state.setThreshold(thresholdPx) + state.setRefreshingOffset(refreshingOffsetPx) + } + + return state +} + +/** + * A state object that can be used in conjunction with [pullRefresh] to add pull-to-refresh + * behaviour to a scroll component. Based on Android's SwipeRefreshLayout. + * + * Provides [progress], a float representing how far the user has pulled as a percentage of the + * refreshThreshold. Values of one or less indicate that the user has not yet pulled past the + * threshold. Values greater than one indicate how far past the threshold the user has pulled. + * + * Can be used in conjunction with [pullRefreshIndicatorTransform] to implement Android-like + * pull-to-refresh behaviour with a custom indicator. + * + * Should be created using [rememberPullRefreshState]. + */ +class PullRefreshState internal constructor( + private val animationScope: CoroutineScope, + private val onRefreshState: State<() -> Unit>, + refreshingOffset: Float, + threshold: Float +) { + /** + * A float representing how far the user has pulled as a percentage of the refreshThreshold. + * + * If the component has not been pulled at all, progress is zero. If the pull has reached + * halfway to the threshold, progress is 0.5f. A value greater than 1 indicates that pull has + * gone beyond the refreshThreshold - e.g. a value of 2f indicates that the user has pulled to + * two times the refreshThreshold. + */ + val progress get() = adjustedDistancePulled / threshold + + internal val refreshing get() = _refreshing + internal val position get() = _position + internal val threshold get() = _threshold + + private val adjustedDistancePulled by derivedStateOf { distancePulled * DragMultiplier } + + private var _refreshing by mutableStateOf(false) + private var _position by mutableStateOf(0f) + private var distancePulled by mutableStateOf(0f) + private var _threshold by mutableStateOf(threshold) + private var _refreshingOffset by mutableStateOf(refreshingOffset) + + internal fun onPull(pullDelta: Float): Float { + if (_refreshing) return 0f // Already refreshing, do nothing. + + val newOffset = (distancePulled + pullDelta).coerceAtLeast(0f) + val dragConsumed = newOffset - distancePulled + distancePulled = newOffset + _position = calculateIndicatorPosition() + return dragConsumed + } + + internal fun onRelease(velocity: Float): Float { + if (refreshing) return 0f // Already refreshing, do nothing + + if (adjustedDistancePulled > threshold) { + onRefreshState.value() + } + animateIndicatorTo(0f) + val consumed = when { + // We are flinging without having dragged the pull refresh (for example a fling inside + // a list) - don't consume + distancePulled == 0f -> 0f + // If the velocity is negative, the fling is upwards, and we don't want to prevent the + // the list from scrolling + velocity < 0f -> 0f + // We are showing the indicator, and the fling is downwards - consume everything + else -> velocity + } + distancePulled = 0f + return consumed + } + + internal fun setRefreshing(refreshing: Boolean) { + if (_refreshing != refreshing) { + _refreshing = refreshing + distancePulled = 0f + animateIndicatorTo(if (refreshing) _refreshingOffset else 0f) + } + } + + internal fun setThreshold(threshold: Float) { + _threshold = threshold + } + + internal fun setRefreshingOffset(refreshingOffset: Float) { + if (_refreshingOffset != refreshingOffset) { + _refreshingOffset = refreshingOffset + if (refreshing) animateIndicatorTo(refreshingOffset) + } + } + + // Make sure to cancel any existing animations when we launch a new one. We use this instead of + // Animatable as calling snapTo() on every drag delta has a one frame delay, and some extra + // overhead of running through the animation pipeline instead of directly mutating the state. + private val mutatorMutex = MutatorMutex() + + private fun animateIndicatorTo(offset: Float) = animationScope.launch { + mutatorMutex.mutate { + animate(initialValue = _position, targetValue = offset) { value, _ -> + _position = value + } + } + } + + private fun calculateIndicatorPosition(): Float = when { + // If drag hasn't gone past the threshold, the position is the adjustedDistancePulled. + adjustedDistancePulled <= threshold -> adjustedDistancePulled + else -> { + // How far beyond the threshold pull has gone, as a percentage of the threshold. + val overshootPercent = abs(progress) - 1.0f + // Limit the overshoot to 200%. Linear between 0 and 200. + val linearTension = overshootPercent.coerceIn(0f, 2f) + // Non-linear tension. Increases with linearTension, but at a decreasing rate. + val tensionPercent = linearTension - linearTension.pow(2) / 4 + // The additional offset beyond the threshold. + val extraOffset = threshold * tensionPercent + threshold + extraOffset + } + } +} + +/** + * Default parameter values for [rememberPullRefreshState]. + */ +object PullRefreshDefaults { + /** + * If the indicator is below this threshold offset when it is released, a refresh + * will be triggered. + */ + val RefreshThreshold = 80.dp + + /** + * The offset at which the indicator should be rendered whilst a refresh is occurring. + */ + val RefreshingOffset = 56.dp +} + +/** + * The distance pulled is multiplied by this value to give us the adjusted distance pulled, which + * is used in calculating the indicator position (when the adjusted distance pulled is less than + * the refresh threshold, it is the indicator position, otherwise the indicator position is + * derived from the progress). + */ +private const val DragMultiplier = 0.5f diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt index 3b6383e5e..a5b67c81b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt @@ -16,8 +16,8 @@ import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import androidx.core.os.LocaleListCompat import androidx.lifecycle.viewmodel.compose.viewModel @@ -70,7 +70,7 @@ class MainActivity : AppCompatActivity() { // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colors.background + color = MaterialTheme.colorScheme.background ) { val accountStateViewModel: AccountStateViewModel = viewModel { AccountStateViewModel(this@MainActivity) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/JoinUserOrChannelView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/JoinUserOrChannelView.kt index 042348437..351637a8c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/JoinUserOrChannelView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/JoinUserOrChannelView.kt @@ -16,15 +16,15 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Clear +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -135,7 +135,7 @@ fun JoinUserOrChannelView(searchBarViewModel: SearchBarViewModel, onClose: () -> Text( text = "", - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, fontWeight = FontWeight.Bold ) } @@ -272,7 +272,7 @@ private fun SearchEditTextForJoin( placeholder = { Text( text = stringResource(R.string.channel_list_user_or_group_id_demo), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, trailingIcon = { @@ -437,7 +437,7 @@ private fun DisplayUserAboutInfo(baseUser: User) { Text( text = about, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, overflow = TextOverflow.Ellipsis ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewChannelView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewChannelView.kt index db732c870..5987a7cb4 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewChannelView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewChannelView.kt @@ -10,11 +10,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -75,7 +75,7 @@ fun NewChannelView(onClose: () -> Unit, accountViewModel: AccountViewModel, chan placeholder = { Text( text = stringResource(R.string.my_awesome_group), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -94,7 +94,7 @@ fun NewChannelView(onClose: () -> Unit, accountViewModel: AccountViewModel, chan placeholder = { Text( text = "http://mygroup.com/logo.jpg", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) @@ -111,7 +111,7 @@ fun NewChannelView(onClose: () -> Unit, accountViewModel: AccountViewModel, chan placeholder = { Text( text = stringResource(R.string.about_us), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt index 4b044dfc9..43d634f66 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt @@ -21,12 +21,12 @@ import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -135,7 +135,7 @@ fun NewMediaView(uri: Uri, onClose: () -> Unit, postViewModel: NewMediaModel, ac painter = painterResource(R.drawable.relays), contentDescription = null, modifier = Modifier.height(25.dp), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } } @@ -292,7 +292,7 @@ fun ImageVideoPost(postViewModel: NewMediaModel, accountViewModel: AccountViewMo placeholder = { Text( text = stringResource(R.string.content_description_example), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollClosing.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollClosing.kt index d96e9c117..61a4e5029 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollClosing.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollClosing.kt @@ -5,10 +5,10 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -38,13 +38,13 @@ fun NewPollClosing(pollViewModel: NewPostViewModel) { } catch (e: Exception) { pollViewModel.isValidClosedAt.value = false } } - val colorInValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.error, + val colorInValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.error, unfocusedBorderColor = Color.Red ) - val colorValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.primary, - unfocusedBorderColor = MaterialTheme.colors.placeholderText + val colorValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.primary, + unfocusedBorderColor = MaterialTheme.colorScheme.placeholderText ) Row( @@ -60,13 +60,13 @@ fun NewPollClosing(pollViewModel: NewPostViewModel) { label = { Text( text = stringResource(R.string.poll_closing_time), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, placeholder = { Text( text = stringResource(R.string.poll_closing_time_days), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollConsensusThreshold.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollConsensusThreshold.kt index 0f2ce8b0d..571e11276 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollConsensusThreshold.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollConsensusThreshold.kt @@ -5,10 +5,10 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -38,13 +38,13 @@ fun NewPollConsensusThreshold(pollViewModel: NewPostViewModel) { } catch (e: Exception) { pollViewModel.isValidConsensusThreshold.value = false } } - val colorInValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.error, + val colorInValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.error, unfocusedBorderColor = Color.Red ) - val colorValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.primary, - unfocusedBorderColor = MaterialTheme.colors.placeholderText + val colorValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.primary, + unfocusedBorderColor = MaterialTheme.colorScheme.placeholderText ) Row( @@ -60,13 +60,13 @@ fun NewPollConsensusThreshold(pollViewModel: NewPostViewModel) { label = { Text( text = stringResource(R.string.poll_consensus_threshold), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, placeholder = { Text( text = stringResource(R.string.poll_consensus_threshold_percent), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollOption.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollOption.kt index 82a80343c..64fde5bdd 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollOption.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollOption.kt @@ -2,9 +2,9 @@ package com.vitorpamplona.amethyst.ui.actions import androidx.compose.foundation.layout.* import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Delete +import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -36,13 +36,13 @@ fun NewPollOption(pollViewModel: NewPostViewModel, optionIndex: Int) { label = { Text( text = stringResource(R.string.poll_option_index).format(optionIndex + 1), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, placeholder = { Text( text = stringResource(R.string.poll_option_description), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollPrimaryDescription.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollPrimaryDescription.kt index d3e422d75..9c374a74c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollPrimaryDescription.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollPrimaryDescription.kt @@ -3,7 +3,7 @@ package com.vitorpamplona.amethyst.ui.components import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.* +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -33,13 +33,13 @@ fun NewPollPrimaryDescription(pollViewModel: NewPostViewModel) { isInputValid = false } - val colorInValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.error, + val colorInValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.error, unfocusedBorderColor = Color.Red ) - val colorValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.primary, - unfocusedBorderColor = MaterialTheme.colors.placeholderText + val colorValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.primary, + unfocusedBorderColor = MaterialTheme.colorScheme.placeholderText ) OutlinedTextField( @@ -50,7 +50,7 @@ fun NewPollPrimaryDescription(pollViewModel: NewPostViewModel) { label = { Text( text = stringResource(R.string.poll_primary_description), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -68,11 +68,11 @@ fun NewPollPrimaryDescription(pollViewModel: NewPostViewModel) { placeholder = { Text( text = stringResource(R.string.poll_primary_description), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, colors = if (isInputValid) colorValid else colorInValid, - visualTransformation = UrlUserTagTransformation(MaterialTheme.colors.primary), + visualTransformation = UrlUserTagTransformation(MaterialTheme.colorScheme.primary), textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollRecipientsField.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollRecipientsField.kt index b3d75ae64..0782d409b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollRecipientsField.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollRecipientsField.kt @@ -1,9 +1,9 @@ package com.vitorpamplona.amethyst.ui.components import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -30,13 +30,13 @@ fun NewPollRecipientsField(pollViewModel: NewPostViewModel, account: Account) { label = { Text( text = stringResource(R.string.poll_zap_recipients), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, placeholder = { Text( text = stringResource(R.string.poll_zap_recipients), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollVoteValueRange.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollVoteValueRange.kt index f99259dc0..45dc83377 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollVoteValueRange.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollVoteValueRange.kt @@ -7,10 +7,10 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue @@ -26,13 +26,13 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText @Composable fun NewPollVoteValueRange(pollViewModel: NewPostViewModel) { - val colorInValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.error, + val colorInValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.error, unfocusedBorderColor = Color.Red ) - val colorValid = TextFieldDefaults.outlinedTextFieldColors( - focusedBorderColor = MaterialTheme.colors.primary, - unfocusedBorderColor = MaterialTheme.colors.placeholderText + val colorValid = OutlinedTextFieldDefaults.colors( + focusedBorderColor = MaterialTheme.colorScheme.primary, + unfocusedBorderColor = MaterialTheme.colorScheme.placeholderText ) Row( @@ -48,13 +48,13 @@ fun NewPollVoteValueRange(pollViewModel: NewPostViewModel) { label = { Text( text = stringResource(R.string.poll_zap_value_min), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, placeholder = { Text( text = stringResource(R.string.sats), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) @@ -70,13 +70,13 @@ fun NewPollVoteValueRange(pollViewModel: NewPostViewModel) { label = { Text( text = stringResource(R.string.poll_zap_value_max), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, placeholder = { Text( text = stringResource(R.string.sats), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) @@ -88,7 +88,7 @@ fun NewPollVoteValueRange(pollViewModel: NewPostViewModel) { ) { Text( text = stringResource(R.string.poll_zap_value_min_max_explainer), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(vertical = 10.dp) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt index 74f9103fc..31bc92bb0 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt @@ -19,7 +19,6 @@ import androidx.compose.foundation.selection.toggleable import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowForwardIos import androidx.compose.material.icons.filled.Bolt @@ -32,6 +31,7 @@ import androidx.compose.material.icons.filled.VisibilityOff import androidx.compose.material.icons.outlined.ArrowForwardIos import androidx.compose.material.icons.outlined.Bolt import androidx.compose.material.icons.rounded.Warning +import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -46,7 +46,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment.Companion.CenterVertically import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester @@ -120,6 +119,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.lang.Math.round +@OptIn(ExperimentalMaterial3Api::class) @Composable fun NewPostView( onClose: () -> Unit, @@ -188,9 +188,7 @@ fun NewPostView( TopAppBar( title = { Row( - modifier = Modifier - .fillMaxWidth() - .padding(end = 10.dp), + modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { @@ -207,7 +205,7 @@ fun NewPostView( painter = painterResource(R.drawable.relays), contentDescription = null, modifier = Modifier.height(25.dp), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } } @@ -224,17 +222,20 @@ fun NewPostView( } }, navigationIcon = { - Spacer(modifier = StdHorzSpacer) - CloseButton(onPress = { - postViewModel.cancel() - scope.launch { - delay(100) - onClose() - } - }) + Row() { + Spacer(modifier = StdHorzSpacer) + CloseButton(onPress = { + postViewModel.cancel() + scope.launch { + delay(100) + onClose() + } + }) + } }, - backgroundColor = MaterialTheme.colors.surface, - elevation = 0.dp + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.surface + ) ) } ) { pad -> @@ -255,7 +256,6 @@ fun NewPostView( ) { Column( modifier = Modifier - .padding(top = 10.dp) .imePadding() .weight(1f) ) { @@ -276,7 +276,7 @@ fun NewPostView( makeItShort = true, unPackReply = false, isQuotedNote = true, - modifier = MaterialTheme.colors.replyModifier, + modifier = MaterialTheme.colorScheme.replyModifier, accountViewModel = accountViewModel, nav = nav ) @@ -412,7 +412,7 @@ fun NewPostView( .clip(shape = QuoteBorder) .border( 1.dp, - MaterialTheme.colors.subtleBorder, + MaterialTheme.colorScheme.subtleBorder, QuoteBorder ) ) @@ -422,7 +422,7 @@ fun NewPostView( UrlPreview(myUrlPreview, myUrlPreview, accountViewModel) } } else if (startsWithNIP19Scheme(myUrlPreview)) { - val bgColor = MaterialTheme.colors.background + val bgColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(bgColor) } @@ -469,7 +469,7 @@ fun NewPostView( ) { UploadFromGallery( isUploading = postViewModel.isUploadingImage, - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, modifier = Modifier ) { postViewModel.selectImage(it) @@ -533,10 +533,10 @@ private fun PollField(postViewModel: NewPostViewModel) { }, border = BorderStroke( 1.dp, - MaterialTheme.colors.placeholderText + MaterialTheme.colorScheme.placeholderText ), colors = ButtonDefaults.outlinedButtonColors( - contentColor = MaterialTheme.colors.placeholderText + containerColor = MaterialTheme.colorScheme.placeholderText ) ) { Image( @@ -548,7 +548,7 @@ private fun PollField(postViewModel: NewPostViewModel) { } } -@OptIn(ExperimentalComposeUiApi::class) +@OptIn(ExperimentalComposeUiApi::class, ExperimentalMaterial3Api::class) @Composable private fun MessageField( postViewModel: NewPostViewModel @@ -575,7 +575,7 @@ private fun MessageField( .fillMaxWidth() .border( width = 1.dp, - color = MaterialTheme.colors.surface, + color = MaterialTheme.colorScheme.surface, shape = RoundedCornerShape(8.dp) ) .focusRequester(focusRequester) @@ -587,15 +587,14 @@ private fun MessageField( placeholder = { Text( text = stringResource(R.string.what_s_on_your_mind), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, - colors = TextFieldDefaults - .outlinedTextFieldColors( - unfocusedBorderColor = Color.Transparent, - focusedBorderColor = Color.Transparent - ), - visualTransformation = UrlUserTagTransformation(MaterialTheme.colors.primary), + colors = OutlinedTextFieldDefaults.colors( + focusedBorderColor = Color.Transparent, + unfocusedBorderColor = Color.Transparent + ), + visualTransformation = UrlUserTagTransformation(MaterialTheme.colorScheme.primary), textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content) ) } @@ -646,7 +645,7 @@ fun ContentSensitivityExplainer(postViewModel: NewPostViewModel) { Text( text = stringResource(R.string.add_sensitive_content_explainer), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(vertical = 10.dp) ) } @@ -676,18 +675,16 @@ fun SendDirectMessageTo(postViewModel: NewPostViewModel) { placeholder = { Text( text = stringResource(R.string.messages_new_message_to_caption), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, visualTransformation = UrlUserTagTransformation( - MaterialTheme.colors.primary + MaterialTheme.colorScheme.primary ), - colors = TextFieldDefaults - .outlinedTextFieldColors( - unfocusedBorderColor = Color.Transparent, - focusedBorderColor = Color.Transparent - ), - textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content) + colors = OutlinedTextFieldDefaults.colors( + unfocusedBorderColor = Color.Transparent, + focusedBorderColor = Color.Transparent + ) ) } @@ -713,18 +710,16 @@ fun SendDirectMessageTo(postViewModel: NewPostViewModel) { placeholder = { Text( text = stringResource(R.string.messages_new_message_subject_caption), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, visualTransformation = UrlUserTagTransformation( - MaterialTheme.colors.primary + MaterialTheme.colorScheme.primary ), - colors = TextFieldDefaults - .outlinedTextFieldColors( - unfocusedBorderColor = Color.Transparent, - focusedBorderColor = Color.Transparent - ), - textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content) + colors = OutlinedTextFieldDefaults.colors( + unfocusedBorderColor = Color.Transparent, + focusedBorderColor = Color.Transparent + ) ) } @@ -778,7 +773,7 @@ fun FowardZapTo(postViewModel: NewPostViewModel, accountViewModel: AccountViewMo Text( text = stringResource(R.string.zap_split_explainer), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(vertical = 10.dp) ) @@ -823,12 +818,12 @@ fun FowardZapTo(postViewModel: NewPostViewModel, accountViewModel: AccountViewMo placeholder = { Text( text = stringResource(R.string.zap_split_serarch_and_add_user_placeholder), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true, visualTransformation = UrlUserTagTransformation( - MaterialTheme.colors.primary + MaterialTheme.colorScheme.primary ), textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content) ) @@ -876,7 +871,7 @@ fun LocationAsHash(postViewModel: NewPostViewModel) { imageVector = Icons.Default.LocationOn, null, modifier = Modifier.size(20.dp), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } @@ -896,7 +891,7 @@ fun LocationAsHash(postViewModel: NewPostViewModel) { Text( text = stringResource(R.string.geohash_explainer), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(vertical = 10.dp) ) } @@ -957,7 +952,7 @@ fun Notifying(baseMentions: ImmutableList?, onClick: (User) -> Unit) { Text( stringResource(R.string.reply_notify), fontWeight = FontWeight.Bold, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.align(CenterVertically) ) @@ -971,7 +966,7 @@ fun Notifying(baseMentions: ImmutableList?, onClick: (User) -> Unit) { Button( shape = ButtonBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.mediumImportanceLink + containerColor = MaterialTheme.colorScheme.mediumImportanceLink ), onClick = { onClick(myUser) @@ -1030,7 +1025,7 @@ private fun AddZapraiserButton( modifier = Modifier .size(20.dp) .align(Alignment.TopStart), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) Icon( imageVector = Icons.Default.Bolt, @@ -1038,7 +1033,7 @@ private fun AddZapraiserButton( modifier = Modifier .size(13.dp) .align(Alignment.BottomEnd), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } else { Icon( @@ -1074,14 +1069,14 @@ fun AddGeoHash(postViewModel: NewPostViewModel, onClick: () -> Unit) { imageVector = Icons.Default.LocationOff, null, modifier = Modifier.size(20.dp), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } else { Icon( imageVector = Icons.Default.LocationOn, null, modifier = Modifier.size(20.dp), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } } @@ -1102,7 +1097,7 @@ private fun AddLnInvoiceButton( imageVector = Icons.Default.CurrencyBitcoin, null, modifier = Modifier.size(20.dp), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } else { Icon( @@ -1137,7 +1132,7 @@ private fun ForwardZapTo( modifier = Modifier .size(20.dp) .align(Alignment.CenterStart), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) Icon( imageVector = Icons.Default.ArrowForwardIos, @@ -1145,7 +1140,7 @@ private fun ForwardZapTo( modifier = Modifier .size(13.dp) .align(Alignment.CenterEnd), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } else { Icon( @@ -1191,7 +1186,7 @@ private fun MarkAsSensitive( modifier = Modifier .size(18.dp) .align(Alignment.BottomStart), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) Icon( imageVector = Icons.Rounded.Warning, @@ -1199,7 +1194,7 @@ private fun MarkAsSensitive( modifier = Modifier .size(10.dp) .align(Alignment.TopEnd), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } else { Icon( @@ -1225,13 +1220,9 @@ private fun MarkAsSensitive( @Composable fun CloseButton(onPress: () -> Unit) { - Button( + OutlinedButton( onClick = onPress, - shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = Color.Gray - ) + contentPadding = PaddingValues(horizontal = Size5dp) ) { CloseIcon() } @@ -1241,17 +1232,11 @@ fun CloseButton(onPress: () -> Unit) { fun PostButton(onPost: () -> Unit = {}, isActive: Boolean, modifier: Modifier = Modifier) { Button( modifier = modifier, + enabled = isActive, onClick = { - if (isActive) { - onPost() - } + onPost() }, - shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray - ), - contentPadding = PaddingValues(0.dp) + shape = ButtonBorder ) { Text(text = stringResource(R.string.post), color = Color.White) } @@ -1260,19 +1245,11 @@ fun PostButton(onPost: () -> Unit = {}, isActive: Boolean, modifier: Modifier = @Composable fun SaveButton(onPost: () -> Unit = {}, isActive: Boolean, modifier: Modifier = Modifier) { Button( + enabled = isActive, modifier = modifier, - onClick = { - if (isActive) { - onPost() - } - }, - shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray - ) + onClick = onPost ) { - Text(text = stringResource(R.string.save), color = Color.White) + Text(text = stringResource(R.string.save)) } } @@ -1286,10 +1263,9 @@ fun CreateButton(onPost: () -> Unit = {}, isActive: Boolean, modifier: Modifier } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray - ) + colors = ButtonDefaults.buttonColors( + containerColor = if (isActive) MaterialTheme.colorScheme.primary else Color.Gray + ) ) { Text(text = stringResource(R.string.create), color = Color.White) } @@ -1337,7 +1313,7 @@ fun ImageVideoDescription( .clip(shape = QuoteBorder) .border( 1.dp, - MaterialTheme.colors.subtleBorder, + MaterialTheme.colorScheme.subtleBorder, QuoteBorder ) ) { @@ -1478,7 +1454,7 @@ fun ImageVideoDescription( placeholder = { Text( text = stringResource(R.string.content_description_example), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -1497,7 +1473,7 @@ fun ImageVideoDescription( }, shape = QuoteBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(text = stringResource(R.string.add_content), color = Color.White, fontSize = 20.sp) @@ -1531,21 +1507,17 @@ fun SettingSwitchItem( modifier = Modifier.weight(1.0f), verticalArrangement = Arrangement.spacedBy(3.dp) ) { - val contentAlpha = if (enabled) ContentAlpha.high else ContentAlpha.disabled - Text( text = stringResource(id = title), maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.alpha(contentAlpha) + overflow = TextOverflow.Ellipsis ) Text( text = stringResource(id = description), - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, color = Color.Gray, maxLines = 2, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.alpha(contentAlpha) + overflow = TextOverflow.Ellipsis ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewRelayListView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewRelayListView.kt index 839ed0fa1..b1ba73ed7 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewRelayListView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewRelayListView.kt @@ -14,16 +14,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Cancel import androidx.compose.material.icons.filled.DeleteSweep @@ -34,6 +24,18 @@ import androidx.compose.material.icons.filled.Public import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.SyncProblem import androidx.compose.material.icons.filled.Upload +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState @@ -83,6 +85,7 @@ import com.vitorpamplona.amethyst.ui.theme.warningColor import kotlinx.coroutines.launch import java.lang.Math.round +@OptIn(ExperimentalMaterial3Api::class) @Composable fun NewRelayListView(onClose: () -> Unit, accountViewModel: AccountViewModel, relayToAdd: String = "", nav: (String) -> Unit) { val postViewModel: NewRelayListViewModel = viewModel() @@ -137,8 +140,9 @@ fun NewRelayListView(onClose: () -> Unit, accountViewModel: AccountViewModel, re onClose() }) }, - backgroundColor = MaterialTheme.colors.surface, - elevation = 0.dp + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.surface + ) ) } ) { pad -> @@ -212,7 +216,7 @@ fun ServerConfigHeader() { maxLines = 1, fontSize = Font14SP, modifier = Modifier.weight(1.2f), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) Spacer(modifier = Modifier.size(5.dp)) @@ -222,7 +226,7 @@ fun ServerConfigHeader() { maxLines = 1, fontSize = Font14SP, modifier = Modifier.weight(1.2f), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) Spacer(modifier = Modifier.size(5.dp)) @@ -232,7 +236,7 @@ fun ServerConfigHeader() { maxLines = 1, fontSize = Font14SP, modifier = Modifier.weight(1f), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) Spacer(modifier = Modifier.size(5.dp)) @@ -242,7 +246,7 @@ fun ServerConfigHeader() { maxLines = 1, fontSize = Font14SP, modifier = Modifier.weight(1f), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) Spacer(modifier = Modifier.size(2.dp)) @@ -454,9 +458,9 @@ private fun RenderStatusRow( } ), tint = if (item.read) { - MaterialTheme.colors.allGoodColor + MaterialTheme.colorScheme.allGoodColor } else { - MaterialTheme.colors.onSurface.copy( + MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) } @@ -467,7 +471,7 @@ private fun RenderStatusRow( maxLines = 1, fontSize = 12.sp, modifier = modifier, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) Icon( @@ -490,9 +494,9 @@ private fun RenderStatusRow( } ), tint = if (item.write) { - MaterialTheme.colors.allGoodColor + MaterialTheme.colorScheme.allGoodColor } else { - MaterialTheme.colors.onSurface.copy( + MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) } @@ -503,7 +507,7 @@ private fun RenderStatusRow( maxLines = 1, fontSize = 12.sp, modifier = modifier, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) Icon( @@ -525,7 +529,7 @@ private fun RenderStatusRow( } } ), - tint = if (item.errorCount > 0) MaterialTheme.colors.warningColor else MaterialTheme.colors.allGoodColor + tint = if (item.errorCount > 0) MaterialTheme.colorScheme.warningColor else MaterialTheme.colorScheme.allGoodColor ) Text( @@ -533,7 +537,7 @@ private fun RenderStatusRow( maxLines = 1, fontSize = 12.sp, modifier = modifier, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) Icon( @@ -555,7 +559,7 @@ private fun RenderStatusRow( } } ), - tint = if (item.spamCount > 0) MaterialTheme.colors.warningColor else MaterialTheme.colors.allGoodColor + tint = if (item.spamCount > 0) MaterialTheme.colorScheme.warningColor else MaterialTheme.colorScheme.allGoodColor ) Text( @@ -563,7 +567,7 @@ private fun RenderStatusRow( maxLines = 1, fontSize = 12.sp, modifier = modifier, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } @@ -584,7 +588,7 @@ private fun RenderActiveToggles( text = stringResource(id = R.string.active_for), maxLines = 1, overflow = TextOverflow.Ellipsis, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(start = 2.dp, end = 5.dp), fontSize = 14.sp ) @@ -614,9 +618,9 @@ private fun RenderActiveToggles( } ), tint = if (item.feedTypes.contains(FeedType.FOLLOWS)) { - MaterialTheme.colors.allGoodColor + MaterialTheme.colorScheme.allGoodColor } else { - MaterialTheme.colors.onSurface.copy( + MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) } @@ -647,9 +651,9 @@ private fun RenderActiveToggles( } ), tint = if (item.feedTypes.contains(FeedType.PRIVATE_DMS)) { - MaterialTheme.colors.allGoodColor + MaterialTheme.colorScheme.allGoodColor } else { - MaterialTheme.colors.onSurface.copy( + MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) } @@ -680,9 +684,9 @@ private fun RenderActiveToggles( } ), tint = if (item.feedTypes.contains(FeedType.PUBLIC_CHATS)) { - MaterialTheme.colors.allGoodColor + MaterialTheme.colorScheme.allGoodColor } else { - MaterialTheme.colors.onSurface.copy( + MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) } @@ -713,9 +717,9 @@ private fun RenderActiveToggles( } ), tint = if (item.feedTypes.contains(FeedType.GLOBAL)) { - MaterialTheme.colors.allGoodColor + MaterialTheme.colorScheme.allGoodColor } else { - MaterialTheme.colors.onSurface.copy( + MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) } @@ -747,9 +751,9 @@ private fun RenderActiveToggles( } ), tint = if (item.feedTypes.contains(FeedType.SEARCH)) { - MaterialTheme.colors.allGoodColor + MaterialTheme.colorScheme.allGoodColor } else { - MaterialTheme.colors.onSurface.copy( + MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) } @@ -780,7 +784,7 @@ private fun FirstLine( modifier = Modifier .padding(start = 5.dp, top = 1.dp) .size(14.dp), - tint = MaterialTheme.colors.allGoodColor + tint = MaterialTheme.colorScheme.allGoodColor ) } } @@ -816,7 +820,7 @@ fun EditableServerConfig(relayToAdd: String, onNewRelay: (RelaySetupInfo) -> Uni placeholder = { Text( text = "server.com", - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) }, @@ -830,7 +834,7 @@ fun EditableServerConfig(relayToAdd: String, onNewRelay: (RelaySetupInfo) -> Uni modifier = Modifier .size(Size35dp) .padding(horizontal = 5.dp), - tint = if (read) MaterialTheme.colors.allGoodColor else MaterialTheme.colors.placeholderText + tint = if (read) MaterialTheme.colorScheme.allGoodColor else MaterialTheme.colorScheme.placeholderText ) } @@ -841,7 +845,7 @@ fun EditableServerConfig(relayToAdd: String, onNewRelay: (RelaySetupInfo) -> Uni modifier = Modifier .size(Size35dp) .padding(horizontal = 5.dp), - tint = if (write) MaterialTheme.colors.allGoodColor else MaterialTheme.colors.placeholderText + tint = if (write) MaterialTheme.colorScheme.allGoodColor else MaterialTheme.colorScheme.placeholderText ) } @@ -859,7 +863,7 @@ fun EditableServerConfig(relayToAdd: String, onNewRelay: (RelaySetupInfo) -> Uni shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = if (url.isNotBlank()) MaterialTheme.colors.primary else MaterialTheme.colors.placeholderText + containerColor = if (url.isNotBlank()) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.placeholderText ) ) { Text(text = stringResource(id = R.string.add), color = Color.White) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt index 7c20d1a70..08589e114 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt @@ -11,10 +11,10 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment @@ -94,7 +94,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = stringResource(R.string.my_display_name), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -115,7 +115,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = stringResource(id = R.string.about_me), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -134,13 +134,13 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = "https://mywebsite.com/me.jpg", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, leadingIcon = { UploadFromGallery( isUploading = postViewModel.isUploadingImageForPicture, - tint = MaterialTheme.colors.placeholderText, + tint = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(start = 5.dp) ) { postViewModel.uploadForPicture(it, context) @@ -159,13 +159,13 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = "https://mywebsite.com/mybanner.jpg", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, leadingIcon = { UploadFromGallery( isUploading = postViewModel.isUploadingImageForBanner, - tint = MaterialTheme.colors.placeholderText, + tint = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(start = 5.dp) ) { postViewModel.uploadForBanner(it, context) @@ -184,7 +184,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = "https://mywebsite.com", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true @@ -200,7 +200,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = "_@mywebsite.com", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true @@ -215,7 +215,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = "me@mylightiningnode.com", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true @@ -231,7 +231,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = stringResource(R.string.lnurl), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) @@ -246,7 +246,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = stringResource(R.string.twitter_proof_url_template), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) @@ -261,7 +261,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = stringResource(R.string.mastodon_proof_url_template), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) @@ -276,7 +276,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { placeholder = { Text( text = stringResource(R.string.github_proof_url_template), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelayInformationDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelayInformationDialog.kt index 5d2925ca7..84f7ec3fb 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelayInformationDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelayInformationDialog.kt @@ -13,8 +13,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelaySelectionDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelaySelectionDialog.kt index 31028d215..28e971e44 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelaySelectionDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/RelaySelectionDialog.kt @@ -12,9 +12,9 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.material.Surface -import androidx.compose.material.Switch -import androidx.compose.material.Text +import androidx.compose.material3.Surface +import androidx.compose.material3.Switch +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/SaveToGallery.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/SaveToGallery.kt index 3acf74183..1c0196c2d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/SaveToGallery.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/SaveToGallery.kt @@ -3,12 +3,10 @@ package com.vitorpamplona.amethyst.ui.actions import android.Manifest import android.os.Build import android.widget.Toast -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Text +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import com.google.accompanist.permissions.ExperimentalPermissionsApi @@ -66,21 +64,16 @@ fun SaveToGallery(url: String) { } } - Button( + OutlinedButton( onClick = { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || writeStoragePermissionState.status.isGranted) { saveImage() } else { writeStoragePermissionState.launchPermissionRequest() } - }, - shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = Color.Gray - ) + } ) { - Text(text = stringResource(id = R.string.save), color = Color.White) + Text(text = stringResource(id = R.string.save)) } } @@ -126,7 +119,7 @@ fun SaveToGallery(localFile: File, mimeType: String?) { } } - Button( + OutlinedButton( onClick = { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || writeStoragePermissionState.status.isGranted) { saveImage() @@ -134,12 +127,8 @@ fun SaveToGallery(localFile: File, mimeType: String?) { writeStoragePermissionState.launchPermissionRequest() } }, - shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = Color.Gray - ) + shape = ButtonBorder ) { - Text(text = stringResource(id = R.string.save), color = Color.White) + Text(text = stringResource(id = R.string.save)) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/UploadFromGallery.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/UploadFromGallery.kt index 851b019ae..1c2161381 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/UploadFromGallery.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/UploadFromGallery.kt @@ -11,9 +11,9 @@ import androidx.compose.animation.core.tween import androidx.compose.foundation.border import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AddPhotoAlternate +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -144,7 +144,7 @@ fun LoadingAnimation( ), progress = 1f, strokeWidth = 1.dp, - color = MaterialTheme.colors.background // Set background color + color = MaterialTheme.colorScheme.background // Set background color ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/ChannelFabColumn.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/ChannelFabColumn.kt index 7bedd43c8..82da658d7 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/ChannelFabColumn.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/ChannelFabColumn.kt @@ -2,13 +2,12 @@ package com.vitorpamplona.amethyst.ui.buttons import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Add +import androidx.compose.material3.FloatingActionButton +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -20,6 +19,7 @@ import com.vitorpamplona.amethyst.ui.actions.NewChannelView import com.vitorpamplona.amethyst.ui.actions.NewPostView import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.theme.Font12SP +import com.vitorpamplona.amethyst.ui.theme.Size55Modifier @Composable fun ChannelFabColumn(accountViewModel: AccountViewModel, nav: (String) -> Unit) { @@ -46,12 +46,11 @@ fun ChannelFabColumn(accountViewModel: AccountViewModel, nav: (String) -> Unit) Column() { if (isOpen) { - OutlinedButton( + FloatingActionButton( onClick = { wantsToSendNewMessage = true; isOpen = false }, - modifier = Modifier.size(55.dp), + modifier = Size55Modifier, shape = CircleShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.primary), - contentPadding = PaddingValues(bottom = 3.dp) + containerColor = MaterialTheme.colorScheme.primary ) { Text( text = stringResource(R.string.messages_new_message), @@ -63,12 +62,11 @@ fun ChannelFabColumn(accountViewModel: AccountViewModel, nav: (String) -> Unit) Spacer(modifier = Modifier.height(20.dp)) - OutlinedButton( + FloatingActionButton( onClick = { wantsToCreateChannel = true; isOpen = false }, - modifier = Modifier.size(55.dp), + modifier = Size55Modifier, shape = CircleShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.primary), - contentPadding = PaddingValues(bottom = 3.dp) + containerColor = MaterialTheme.colorScheme.primary ) { Text( text = stringResource(R.string.messages_create_public_chat), @@ -81,12 +79,11 @@ fun ChannelFabColumn(accountViewModel: AccountViewModel, nav: (String) -> Unit) Spacer(modifier = Modifier.height(20.dp)) } - OutlinedButton( + FloatingActionButton( onClick = { isOpen = !isOpen }, - modifier = Modifier.size(55.dp), + modifier = Size55Modifier, shape = CircleShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.primary), - contentPadding = PaddingValues(0.dp) + containerColor = MaterialTheme.colorScheme.primary ) { Icon( imageVector = Icons.Outlined.Add, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewChannelButton.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewChannelButton.kt index 320b82b0b..7163d7ac3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewChannelButton.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewChannelButton.kt @@ -3,12 +3,12 @@ package com.vitorpamplona.amethyst.buttons import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Add +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -36,7 +36,7 @@ fun NewChannelButton(accountViewModel: AccountViewModel) { onClick = { wantsToPost = true }, modifier = Modifier.size(55.dp), shape = CircleShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.primary), + colors = ButtonDefaults.outlinedButtonColors(containerColor = MaterialTheme.colorScheme.primary), contentPadding = PaddingValues(0.dp) ) { Icon( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewCommunityNoteButton.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewCommunityNoteButton.kt index dc0e0bb4f..802110e28 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewCommunityNoteButton.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewCommunityNoteButton.kt @@ -1,12 +1,10 @@ package com.vitorpamplona.amethyst.ui.buttons -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton +import androidx.compose.material3.FloatingActionButton +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -21,6 +19,7 @@ import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.actions.NewPostView import com.vitorpamplona.amethyst.ui.components.LoadNote import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.theme.Size55Modifier @Composable fun NewCommunityNoteButton(communityIdHex: String, accountViewModel: AccountViewModel, nav: (String) -> Unit) { @@ -41,12 +40,11 @@ fun NewCommunityNoteButton(note: Note, accountViewModel: AccountViewModel, nav: NewPostView({ wantsToPost = false }, note, accountViewModel = accountViewModel, nav = nav) } - OutlinedButton( + FloatingActionButton( onClick = { wantsToPost = true }, - modifier = Modifier.size(55.dp), + modifier = Size55Modifier, shape = CircleShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.primary), - contentPadding = PaddingValues(0.dp) + containerColor = MaterialTheme.colorScheme.primary ) { Icon( painter = painterResource(R.drawable.ic_compose), diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewImageButton.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewImageButton.kt index 41f67f0a1..b9f167b61 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewImageButton.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewImageButton.kt @@ -6,16 +6,14 @@ import android.os.Build import androidx.compose.animation.core.animateFloatAsState import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton -import androidx.compose.material.ProgressIndicatorDefaults -import androidx.compose.material.Text +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.FloatingActionButton +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ProgressIndicatorDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -41,6 +39,7 @@ import com.vitorpamplona.amethyst.ui.actions.NewMediaModel import com.vitorpamplona.amethyst.ui.actions.NewMediaView import com.vitorpamplona.amethyst.ui.navigation.Route import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.theme.Size55Modifier import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -112,12 +111,11 @@ fun NewImageButton(accountViewModel: AccountViewModel, nav: (String) -> Unit, na if (postViewModel.isUploadingImage) { ShowProgress(postViewModel) } else { - OutlinedButton( + FloatingActionButton( onClick = { wantsToPost = true }, - modifier = Modifier.size(55.dp), + modifier = Size55Modifier, shape = CircleShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.primary), - contentPadding = PaddingValues(0.dp) + containerColor = MaterialTheme.colorScheme.primary ) { Icon( painter = painterResource(R.drawable.ic_compose), @@ -137,16 +135,15 @@ private fun ShowProgress(postViewModel: NewMediaModel) { targetValue = postViewModel.uploadingPercentage.value, animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec ).value, - modifier = Modifier - .size(55.dp) + modifier = Size55Modifier .clip(CircleShape) - .background(MaterialTheme.colors.background), + .background(MaterialTheme.colorScheme.background), strokeWidth = 5.dp ) postViewModel.uploadingDescription.value?.let { Text( it, - color = MaterialTheme.colors.onSurface, + color = MaterialTheme.colorScheme.onSurface, fontSize = 10.sp, textAlign = TextAlign.Center ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewNoteButton.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewNoteButton.kt index 4caa3313d..ae61e1b99 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewNoteButton.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/buttons/NewNoteButton.kt @@ -1,12 +1,10 @@ package com.vitorpamplona.amethyst.ui.buttons -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton +import androidx.compose.material3.FloatingActionButton +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -19,6 +17,7 @@ import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.ui.actions.NewPostView import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.theme.Size55Modifier @Composable fun NewNoteButton(accountViewModel: AccountViewModel, nav: (String) -> Unit) { @@ -30,12 +29,11 @@ fun NewNoteButton(accountViewModel: AccountViewModel, nav: (String) -> Unit) { NewPostView({ wantsToPost = false }, accountViewModel = accountViewModel, nav = nav) } - OutlinedButton( + FloatingActionButton( onClick = { wantsToPost = true }, - modifier = Modifier.size(55.dp), + modifier = Size55Modifier, shape = CircleShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.primary), - contentPadding = PaddingValues(0.dp) + containerColor = MaterialTheme.colorScheme.primary ) { Icon( painter = painterResource(R.drawable.ic_compose), diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/AudioWaveformReadOnly.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/AudioWaveformReadOnly.kt index b7f68f3bb..7c1ca95e6 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/AudioWaveformReadOnly.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/AudioWaveformReadOnly.kt @@ -6,7 +6,7 @@ import androidx.compose.animation.core.tween import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.requiredHeight -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.* import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -55,7 +55,7 @@ fun AudioWaveformReadOnly( amplitudes: List, onProgressChange: (Float) -> Unit ) { - val backgroundColor = MaterialTheme.colors.background + val backgroundColor = MaterialTheme.colorScheme.background val _progress = remember(progress) { progress.coerceIn(MinProgress, MaxProgress) } val _spikeWidth = remember(spikeWidth) { spikeWidth.coerceIn(MinSpikeWidthDp, MaxSpikeWidthDp) } val _spikePadding = remember(spikePadding) { spikePadding.coerceIn(MinSpikePaddingDp, MaxSpikePaddingDp) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt index 9405b7903..1b61fbb79 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/CashuRedeem.kt @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.* +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -76,7 +76,7 @@ fun CashuPreview(token: CashuToken, accountViewModel: AccountViewModel) { .fillMaxWidth() .padding(start = 30.dp, end = 30.dp) .clip(shape = QuoteBorder) - .border(1.dp, MaterialTheme.colors.subtleBorder, QuoteBorder) + .border(1.dp, MaterialTheme.colorScheme.subtleBorder, QuoteBorder) ) { Column( modifier = Modifier @@ -157,7 +157,7 @@ fun CashuPreview(token: CashuToken, accountViewModel: AccountViewModel) { }, shape = QuoteBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text( @@ -186,7 +186,7 @@ fun CashuPreview(token: CashuToken, accountViewModel: AccountViewModel) { }, shape = QuoteBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text("⎘", color = Color.White, fontSize = 18.sp) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt index 4b7e7fc45..6a9a17c99 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt @@ -4,8 +4,8 @@ import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext @@ -19,7 +19,7 @@ fun ClickableEmail(email: String) { ClickableText( text = remember { AnnotatedString(stripped) }, onClick = { runCatching { context.sendMail(stripped) } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableNoteTag.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableNoteTag.kt index cd48515fa..32a9e136c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableNoteTag.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableNoteTag.kt @@ -1,8 +1,8 @@ package com.vitorpamplona.amethyst.ui.components import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.text.AnnotatedString import com.vitorpamplona.amethyst.model.Note @@ -16,6 +16,6 @@ fun ClickableNoteTag( ClickableText( text = AnnotatedString("@${baseNote.idNote().toShortenHex()}"), onClick = { nav("Note/${baseNote.idHex}") }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt index bc19909a8..e4d298d40 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt @@ -4,8 +4,8 @@ import android.content.Context import android.content.Intent import android.net.Uri import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext @@ -18,7 +18,7 @@ fun ClickablePhone(phone: String) { ClickableText( text = remember { AnnotatedString(phone) }, onClick = { runCatching { context.dial(phone) } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt index bad4599c1..824327093 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt @@ -7,11 +7,10 @@ import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.text.InlineTextContent import androidx.compose.foundation.text.appendInlineContent -import androidx.compose.material.LocalContentAlpha -import androidx.compose.material.LocalContentColor -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.LaunchedEffect @@ -307,8 +306,8 @@ fun CreateClickableText( nav: (String) -> Unit ) { val currentStyle = LocalTextStyle.current - val primaryColor = MaterialTheme.colors.primary - val onBackgroundColor = MaterialTheme.colors.onBackground + val primaryColor = MaterialTheme.colorScheme.primary + val onBackgroundColor = MaterialTheme.colorScheme.onBackground val clickablePartStyle = remember(primaryColor, overrideColor) { currentStyle.copy(color = overrideColor ?: primaryColor, fontWeight = fontWeight).toSpanStyle() @@ -368,7 +367,7 @@ fun CreateTextWithEmoji( val textColor = color.takeOrElse { LocalTextStyle.current.color.takeOrElse { - LocalContentColor.current.copy(alpha = LocalContentAlpha.current) + LocalContentColor.current } } @@ -424,7 +423,7 @@ fun CreateTextWithEmoji( val textColor = color.takeOrElse { LocalTextStyle.current.color.takeOrElse { - LocalContentColor.current.copy(alpha = LocalContentAlpha.current) + LocalContentColor.current } } @@ -537,14 +536,14 @@ fun CreateClickableTextWithEmoji( ClickableInLineIconRenderer( emojiLists!!.part1, maxLines, - LocalTextStyle.current.copy(color = overrideColor ?: MaterialTheme.colors.primary, fontWeight = fontWeight).toSpanStyle() + LocalTextStyle.current.copy(color = overrideColor ?: MaterialTheme.colorScheme.primary, fontWeight = fontWeight).toSpanStyle() ) { nav(route) } InLineIconRenderer( emojiLists!!.part2, - LocalTextStyle.current.copy(color = overrideColor ?: MaterialTheme.colors.onBackground, fontWeight = fontWeight).toSpanStyle(), + LocalTextStyle.current.copy(color = overrideColor ?: MaterialTheme.colorScheme.onBackground, fontWeight = fontWeight).toSpanStyle(), maxLines = maxLines ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUrl.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUrl.kt index e0283e3f6..5ae69237f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUrl.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUrl.kt @@ -1,8 +1,8 @@ package com.vitorpamplona.amethyst.ui.components import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalUriHandler @@ -23,6 +23,6 @@ fun ClickableUrl(urlText: String, url: String) { ClickableText( text = text, onClick = { runCatching { uri.openUri(doubleCheckedUrl) } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUserTag.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUserTag.kt index e18e99b17..f01fb4b05 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUserTag.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableUserTag.kt @@ -1,8 +1,8 @@ package com.vitorpamplona.amethyst.ui.components import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -28,6 +28,6 @@ fun ClickableUserTag( ClickableText( text = userName, onClick = { nav(route) }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableWithdrawal.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableWithdrawal.kt index 5a5d6db32..97b69c3e6 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableWithdrawal.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableWithdrawal.kt @@ -5,9 +5,9 @@ import android.net.Uri import android.widget.Toast import androidx.compose.animation.Crossfade import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.AnnotatedString @@ -66,6 +66,6 @@ fun ClickableWithdrawal(withdrawalString: String) { } } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ExpandableRichTextViewer.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ExpandableRichTextViewer.kt index 97eb86073..12ca76e4e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ExpandableRichTextViewer.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ExpandableRichTextViewer.kt @@ -7,10 +7,10 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.derivedStateOf @@ -97,7 +97,7 @@ fun ExpandableRichTextViewer( .fillMaxWidth() .background(getGradient(backgroundColor)) ) { - ShowMoreButton() { + ShowMoreButton { showFullText = !showFullText } } @@ -112,7 +112,7 @@ fun ShowMoreButton(onClick: () -> Unit) { onClick = onClick, shape = ButtonBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.secondaryButtonBackground + containerColor = MaterialTheme.colorScheme.secondaryButtonBackground ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt index 52c0f2c50..a50827a66 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoicePreview.kt @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.* +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -74,7 +74,7 @@ fun InvoicePreview(lnInvoice: String, amount: String?) { .fillMaxWidth() .padding(start = 30.dp, end = 30.dp) .clip(shape = QuoteBorder) - .border(1.dp, MaterialTheme.colors.subtleBorder, QuoteBorder) + .border(1.dp, MaterialTheme.colorScheme.subtleBorder, QuoteBorder) ) { Column( modifier = Modifier @@ -136,7 +136,7 @@ fun InvoicePreview(lnInvoice: String, amount: String?) { }, shape = QuoteBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(text = stringResource(R.string.pay), color = Color.White, fontSize = 20.sp) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoiceRequest.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoiceRequest.kt index 97f400502..942bab372 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoiceRequest.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/InvoiceRequest.kt @@ -8,13 +8,13 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -57,7 +57,7 @@ fun InvoiceRequestCard( .fillMaxWidth() .padding(start = 30.dp, end = 30.dp) .clip(shape = QuoteBorder) - .border(1.dp, MaterialTheme.colors.subtleBorder, QuoteBorder) + .border(1.dp, MaterialTheme.colorScheme.subtleBorder, QuoteBorder) ) { Column( modifier = Modifier @@ -116,7 +116,7 @@ fun InvoiceRequest( placeholder = { Text( text = stringResource(R.string.thank_you_so_much), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -141,7 +141,7 @@ fun InvoiceRequest( placeholder = { Text( text = "1000", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -175,7 +175,7 @@ fun InvoiceRequest( }, shape = QuoteBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(text = buttonText ?: stringResource(R.string.send_sats), color = Color.White, fontSize = 20.sp) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt index f4de579f0..4beeb0c48 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt @@ -6,13 +6,12 @@ import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.text.InlineTextContent import androidx.compose.foundation.text.appendInlineContent -import androidx.compose.material.Icon -import androidx.compose.material.LocalContentAlpha -import androidx.compose.material.LocalContentColor -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.ProvideTextStyle -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ProvideTextStyle +import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.Alignment @@ -30,7 +29,7 @@ import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.em import com.halilibo.richtext.markdown.Markdown import com.halilibo.richtext.markdown.MarkdownParseOptions -import com.halilibo.richtext.ui.material.MaterialRichText +import com.halilibo.richtext.ui.material3.Material3RichText import com.vitorpamplona.amethyst.model.HashtagIcon import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.User @@ -137,7 +136,7 @@ private fun RenderRegular( val textStyle = currentTextStyle.copy( lineHeight = 1.4.em, color = currentTextStyle.color.takeOrElse { - LocalContentColor.current.copy(alpha = LocalContentAlpha.current) + LocalContentColor.current } ) @@ -333,8 +332,8 @@ private fun RenderContentAsMarkdown(content: String, tags: ImmutableListOfLists< } ProvideTextStyle(MarkdownTextStyle) { - MaterialRichText( - style = MaterialTheme.colors.markdownStyle + Material3RichText( + style = MaterialTheme.colorScheme.markdownStyle ) { RefreshableContent(content, tags, accountViewModel) { Markdown( @@ -511,7 +510,7 @@ private fun DisplayFullNote( NoteCompose( baseNote = it, accountViewModel = accountViewModel, - modifier = MaterialTheme.colors.replyModifier, + modifier = MaterialTheme.colorScheme.replyModifier, parentBackgroundColor = backgroundColor, isQuotedNote = true, nav = nav @@ -540,12 +539,12 @@ private fun RenderHashtag( segment: HashTagSegment, nav: (String) -> Unit ) { - val primary = MaterialTheme.colors.primary + val primary = MaterialTheme.colorScheme.primary val hashtagIcon = remember(segment.hashtag) { checkForHashtagWithIcon(segment.hashtag, primary) } ClickableText( text = buildAnnotatedString { withStyle( - LocalTextStyle.current.copy(color = MaterialTheme.colors.primary).toSpanStyle() + LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary).toSpanStyle() ) { append("#${segment.hashtag}") } @@ -557,7 +556,7 @@ private fun RenderHashtag( val myId = "inlineContent" val emptytext = buildAnnotatedString { withStyle( - LocalTextStyle.current.copy(color = MaterialTheme.colors.primary).toSpanStyle() + LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary).toSpanStyle() ) { append("") appendInlineContent(myId, "[icon]") @@ -656,7 +655,7 @@ private fun DisplayNoteFromTag( NoteCompose( baseNote = baseNote, accountViewModel = accountViewModel, - modifier = MaterialTheme.colors.innerPostModifier, + modifier = MaterialTheme.colorScheme.innerPostModifier, parentBackgroundColor = backgroundColor, isQuotedNote = true, nav = nav diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SelectTextDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SelectTextDialog.kt index 926a82638..cfdf7164a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SelectTextDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SelectTextDialog.kt @@ -9,10 +9,10 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Card -import androidx.compose.material.Divider -import androidx.compose.material.IconButton -import androidx.compose.material.Text +import androidx.compose.material3.Card +import androidx.compose.material3.Divider +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SensitivityWarning.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SensitivityWarning.kt index 11d152c36..a2aba698c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SensitivityWarning.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SensitivityWarning.kt @@ -11,14 +11,14 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Visibility import androidx.compose.material.icons.rounded.Warning +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -104,7 +104,7 @@ fun ContentWarningNote(onDismiss: () -> Unit) { modifier = Modifier .size(70.dp) .align(Alignment.BottomStart), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) Icon( imageVector = Icons.Rounded.Warning, @@ -112,7 +112,7 @@ fun ContentWarningNote(onDismiss: () -> Unit) { modifier = Modifier .size(30.dp) .align(Alignment.TopEnd), - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } } @@ -141,7 +141,7 @@ fun ContentWarningNote(onDismiss: () -> Unit) { shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SlidingCarousel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SlidingCarousel.kt index 38f1f4f88..c19ecbdf8 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SlidingCarousel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/SlidingCarousel.kt @@ -14,8 +14,8 @@ import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment @@ -66,8 +66,8 @@ fun DotsIndicator( modifier: Modifier = Modifier, totalDots: Int, selectedIndex: Int, - selectedColor: Color = MaterialTheme.colors.primary /* Color.Yellow */, - unSelectedColor: Color = MaterialTheme.colors.placeholderText /* Color.Gray */, + selectedColor: Color = MaterialTheme.colorScheme.primary /* Color.Yellow */, + unSelectedColor: Color = MaterialTheme.colorScheme.placeholderText /* Color.Gray */, dotSize: Dp ) { LazyRow( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/TextSpinner.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/TextSpinner.kt index b08361ab4..e1e1eaf6f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/TextSpinner.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/TextSpinner.kt @@ -14,11 +14,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.getValue @@ -98,7 +98,7 @@ fun SpinnerSelectionDialog( horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth() ) { - Text(text = item.title, color = MaterialTheme.colors.onSurface) + Text(text = item.title, color = MaterialTheme.colorScheme.onSurface) } item.explainer?.let { Spacer(modifier = Modifier.height(5.dp)) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/UrlPreviewCard.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/UrlPreviewCard.kt index 9ddb91f3a..ec2ae6a17 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/UrlPreviewCard.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/UrlPreviewCard.kt @@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -46,7 +46,7 @@ fun UrlPreviewCard( val uri = LocalUriHandler.current Row( - modifier = MaterialTheme.colors.innerPostModifier + modifier = MaterialTheme.colorScheme.innerPostModifier .clickable { runCatching { uri.openUri(url) } } @@ -63,7 +63,7 @@ fun UrlPreviewCard( Text( text = previewInfo.verifiedUrl?.host ?: previewInfo.url, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, modifier = MaxWidthWithHorzPadding, color = Color.Gray, maxLines = 1, @@ -72,7 +72,7 @@ fun UrlPreviewCard( Text( text = previewInfo.title, - style = MaterialTheme.typography.body2, + style = MaterialTheme.typography.bodyMedium, modifier = MaxWidthWithHorzPadding, maxLines = 1, overflow = TextOverflow.Ellipsis @@ -80,7 +80,7 @@ fun UrlPreviewCard( Text( text = previewInfo.description, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, modifier = MaxWidthWithHorzPadding, color = Color.Gray, maxLines = 3, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt index d46790ddb..d6e9fdbdf 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt @@ -22,8 +22,8 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -527,7 +527,7 @@ private fun RenderVideoPlayer( } BoxWithConstraints() { - val borders = MaterialTheme.colors.imageModifier + val borders = MaterialTheme.colorScheme.imageModifier val myModifier = remember { if (roundedCorner) { @@ -797,7 +797,7 @@ private fun MuteButton( .clip(CircleShape) .fillMaxSize(0.6f) .align(Alignment.Center) - .background(MaterialTheme.colors.background) + .background(MaterialTheme.colorScheme.background) ) IconButton( @@ -838,7 +838,7 @@ private fun KeepPlayingButton( .clip(CircleShape) .fillMaxSize(0.6f) .align(Alignment.Center) - .background(MaterialTheme.colors.background) + .background(MaterialTheme.colorScheme.background) ) IconButton( @@ -849,9 +849,9 @@ private fun KeepPlayingButton( modifier = Size50Modifier ) { if (keepPlaying.value) { - LyricsIcon(Size22Modifier, MaterialTheme.colors.onBackground) + LyricsIcon(Size22Modifier, MaterialTheme.colorScheme.onBackground) } else { - LyricsOffIcon(Size22Modifier, MaterialTheme.colors.onBackground) + LyricsOffIcon(Size22Modifier, MaterialTheme.colorScheme.onBackground) } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZapRaiserRequest.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZapRaiserRequest.kt index 378e60725..a61654410 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZapRaiserRequest.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZapRaiserRequest.kt @@ -5,11 +5,11 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue @@ -60,7 +60,7 @@ fun ZapRaiserRequest( Text( text = stringResource(R.string.zapraiser_explainer), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(vertical = 10.dp) ) @@ -84,7 +84,7 @@ fun ZapRaiserRequest( placeholder = { Text( text = "1000", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt index 003338d2c..97c4bfe67 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -29,18 +30,17 @@ import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.text.InlineTextContent import androidx.compose.foundation.text.appendInlineContent -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.DropdownMenu -import androidx.compose.material.DropdownMenuItem -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Share +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.Immutable @@ -53,7 +53,6 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext @@ -86,15 +85,14 @@ import com.vitorpamplona.amethyst.ui.note.DownloadForOfflineIcon import com.vitorpamplona.amethyst.ui.note.HashCheckFailedIcon import com.vitorpamplona.amethyst.ui.note.HashCheckIcon import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.amethyst.ui.theme.ButtonBorder import com.vitorpamplona.amethyst.ui.theme.Font17SP import com.vitorpamplona.amethyst.ui.theme.Size20Modifier import com.vitorpamplona.amethyst.ui.theme.Size20dp import com.vitorpamplona.amethyst.ui.theme.Size24dp import com.vitorpamplona.amethyst.ui.theme.Size30dp import com.vitorpamplona.amethyst.ui.theme.Size5dp +import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.ui.theme.imageModifier -import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.quartz.crypto.CryptoUtils import com.vitorpamplona.quartz.encoders.toHexKey import kotlinx.collections.immutable.ImmutableList @@ -212,7 +210,7 @@ fun ZoomableContentView( } var mainImageModifier = if (roundedCorner) { - MaterialTheme.colors.imageModifier + MaterialTheme.colorScheme.imageModifier } else { Modifier.fillMaxWidth() } @@ -553,7 +551,7 @@ private fun DisplayUrlWithLoadingSymbolWait(content: ZoomableContent) { val myId = "inlineContent" val emptytext = buildAnnotatedString { withStyle( - LocalTextStyle.current.copy(color = MaterialTheme.colors.primary).toSpanStyle() + LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary).toSpanStyle() ) { append("") appendInlineContent(myId, "[icon]") @@ -637,7 +635,7 @@ fun ZoomableImageDialog( decorFitsSystemWindows = false ) ) { - Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) { + Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) { val pagerState: PagerState = rememberPagerState() { allImages.size } @@ -671,6 +669,7 @@ fun ZoomableImageDialog( if (myContent is ZoomableUrlContent) { Row() { CopyToClipboard(content = myContent) + Spacer(modifier = StdHorzSpacer) SaveToGallery(url = myContent.url) } } else if (myContent is ZoomableLocalImage && myContent.localFile != null) { @@ -691,17 +690,11 @@ private fun CopyToClipboard( ) { val popupExpanded = remember { mutableStateOf(false) } - Button( + OutlinedButton( modifier = Modifier.padding(horizontal = Size5dp), - onClick = { popupExpanded.value = true }, - shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.placeholderText - ) + onClick = { popupExpanded.value = true } ) { Icon( - tint = Color.White, imageVector = Icons.Default.Share, modifier = Size20Modifier, contentDescription = stringResource(R.string.copy_url_to_clipboard) @@ -725,20 +718,35 @@ private fun ShareImageAction( val clipboardManager = LocalClipboardManager.current if (content is ZoomableUrlContent) { - DropdownMenuItem(onClick = { clipboardManager.setText(AnnotatedString(content.url)); onDismiss() }) { - Text(stringResource(R.string.copy_url_to_clipboard)) - } - if (content.uri != null) { - DropdownMenuItem(onClick = { clipboardManager.setText(AnnotatedString(content.uri)); onDismiss() }) { - Text(stringResource(R.string.copy_the_note_id_to_the_clipboard)) + DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_url_to_clipboard)) + }, + onClick = { + clipboardManager.setText(AnnotatedString(content.url)); onDismiss() } + ) + if (content.uri != null) { + DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_the_note_id_to_the_clipboard)) + }, + onClick = { + clipboardManager.setText(AnnotatedString(content.uri)); onDismiss() + } + ) } } if (content is ZoomablePreloadedContent) { - DropdownMenuItem(onClick = { clipboardManager.setText(AnnotatedString(content.uri)); onDismiss() }) { - Text(stringResource(R.string.copy_the_note_id_to_the_clipboard)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_the_note_id_to_the_clipboard)) + }, + onClick = { + clipboardManager.setText(AnnotatedString(content.uri)); onDismiss() + } + ) } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt index 1d297683b..426894a75 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt @@ -12,17 +12,19 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.AlertDialog -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TextButton -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Logout import androidx.compose.material.icons.filled.RadioButtonChecked +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf @@ -33,7 +35,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow @@ -62,6 +63,7 @@ import com.vitorpamplona.quartz.events.toImmutableListOfLists import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +@OptIn(ExperimentalMaterial3Api::class) @Composable fun AccountSwitchBottomSheet( accountViewModel: AccountViewModel, @@ -113,8 +115,9 @@ fun AccountSwitchBottomSheet( ArrowBackIcon() } }, - backgroundColor = Color.Transparent, - elevation = 0.dp + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.surface + ) ) } } @@ -212,16 +215,14 @@ private fun ActiveMarker(acc: AccountInfo, accountViewModel: AccountViewModel) { Icon( imageVector = Icons.Default.RadioButtonChecked, contentDescription = stringResource(R.string.account_switch_active_account), - tint = MaterialTheme.colors.secondary + tint = MaterialTheme.colorScheme.secondary ) } } @Composable private fun AccountPicture(user: User, loadProfilePicture: Boolean) { - val profilePicture by user.live().metadata.map { - it.user.profilePicture() - }.observeAsState() + val profilePicture by user.live().profilePictureChanges.observeAsState() RobohashAsyncImageProxy( robot = remember(user) { user.pubkeyHex }, @@ -304,7 +305,7 @@ private fun LogoutButton( Icon( imageVector = Icons.Default.Logout, contentDescription = stringResource(R.string.log_out), - tint = MaterialTheme.colors.onSurface + tint = MaterialTheme.colorScheme.onSurface ) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppBottomBar.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppBottomBar.kt index b54d274d0..71309adc3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppBottomBar.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppBottomBar.kt @@ -11,12 +11,12 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.BottomNavigation -import androidx.compose.material.BottomNavigationItem -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -26,7 +26,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -42,6 +41,7 @@ import androidx.navigation.NavBackStackEntry import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.theme.BottomTopHeight +import com.vitorpamplona.amethyst.ui.theme.DividerThickness import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -104,12 +104,10 @@ private fun RenderBottomMenu( ) { Column(modifier = BottomTopHeight) { Divider( - thickness = 0.25.dp + thickness = DividerThickness ) - BottomNavigation( - modifier = Modifier, - elevation = 0.dp, - backgroundColor = MaterialTheme.colors.background + NavigationBar( + tonalElevation = 0.dp ) { bottomNavigationItems.forEach { item -> HasNewItemsIcon(item, accountViewModel, navEntryState, nav) @@ -133,8 +131,6 @@ private fun RowScope.HasNewItemsIcon( } } - val scope = rememberCoroutineScope() - val size = remember { if ("Home" == route.base) 25.dp else 23.dp } @@ -150,9 +146,7 @@ private fun RowScope.HasNewItemsIcon( hasNewItems = hasNewItems, navEntryState = navEntryState ) { selected -> - scope.launch { - nav(route, selected) - } + nav(route, selected) } } @@ -210,7 +204,7 @@ private fun RowScope.NavigationIcon( hasNewItems: Boolean, onClick: (Boolean) -> Unit ) { - BottomNavigationItem( + NavigationBarItem( icon = { NotifiableIcon( icon, @@ -232,7 +226,7 @@ private fun NotifiableIcon(icon: Int, size: Dp, iconSize: Dp, selected: Boolean, painter = painterResource(id = icon), contentDescription = null, modifier = remember { Modifier.size(iconSize) }, - tint = if (selected) MaterialTheme.colors.primary else Color.Unspecified + tint = if (selected) MaterialTheme.colorScheme.primary else Color.Unspecified ) if (hasNewItems) { @@ -250,7 +244,7 @@ private fun NotifiableIcon(icon: Int, size: Dp, iconSize: Dp, selected: Boolean, .width(10.dp) .height(10.dp) .clip(shape = CircleShape) - }.background(MaterialTheme.colors.primary), + }.background(MaterialTheme.colorScheme.primary), contentAlignment = Alignment.TopEnd ) { Text( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppTopBar.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppTopBar.kt index cd5294066..0681df466 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppTopBar.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppTopBar.kt @@ -17,22 +17,18 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.AppBarDefaults -import androidx.compose.material.ContentAlpha -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LocalContentAlpha -import androidx.compose.material.MaterialTheme -import androidx.compose.material.ProvideTextStyle -import androidx.compose.material.ScaffoldState -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.contentColorFor import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ExpandMore +import androidx.compose.material3.Divider +import androidx.compose.material3.DrawerState +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.runtime.Stable import androidx.compose.runtime.State @@ -51,7 +47,6 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider @@ -136,7 +131,7 @@ import kotlinx.coroutines.launch fun AppTopBar( followLists: FollowListViewModel, navEntryState: State, - scaffoldState: ScaffoldState, + drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit, navPopBack: () -> Unit @@ -153,7 +148,7 @@ fun AppTopBar( } } - RenderTopRouteBar(currentRoute, id, followLists, scaffoldState, accountViewModel, nav, navPopBack) + RenderTopRouteBar(currentRoute, id, followLists, drawerState, accountViewModel, nav, navPopBack) } @Composable @@ -161,16 +156,16 @@ private fun RenderTopRouteBar( currentRoute: String?, id: String?, followLists: FollowListViewModel, - scaffoldState: ScaffoldState, + drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit, navPopBack: () -> Unit ) { when (currentRoute) { - Route.Home.base -> HomeTopBar(followLists, scaffoldState, accountViewModel, nav) - Route.Video.base -> StoriesTopBar(followLists, scaffoldState, accountViewModel, nav) - Route.Discover.base -> DiscoveryTopBar(followLists, scaffoldState, accountViewModel, nav) - Route.Notification.base -> NotificationTopBar(followLists, scaffoldState, accountViewModel, nav) + Route.Home.base -> HomeTopBar(followLists, drawerState, accountViewModel, nav) + Route.Video.base -> StoriesTopBar(followLists, drawerState, accountViewModel, nav) + Route.Discover.base -> DiscoveryTopBar(followLists, drawerState, accountViewModel, nav) + Route.Notification.base -> NotificationTopBar(followLists, drawerState, accountViewModel, nav) Route.Settings.base -> TopBarWithBackButton(stringResource(id = R.string.application_preferences), navPopBack) else -> { if (id != null) { @@ -181,10 +176,10 @@ private fun RenderTopRouteBar( Route.Community.base -> CommunityTopBar(id, accountViewModel, nav, navPopBack) Route.Hashtag.base -> HashTagTopBar(id, accountViewModel, navPopBack) Route.Geohash.base -> GeoHashTopBar(id, accountViewModel, navPopBack) - else -> MainTopBar(scaffoldState, accountViewModel, nav) + else -> MainTopBar(drawerState, accountViewModel, nav) } } else { - MainTopBar(scaffoldState, accountViewModel, nav) + MainTopBar(drawerState, accountViewModel, nav) } } } @@ -377,8 +372,8 @@ fun NoTopBar() { } @Composable -fun StoriesTopBar(followLists: FollowListViewModel, scaffoldState: ScaffoldState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { - GenericMainTopBar(scaffoldState, accountViewModel, nav) { accountViewModel -> +fun StoriesTopBar(followLists: FollowListViewModel, drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { + GenericMainTopBar(drawerState, accountViewModel, nav) { accountViewModel -> val list by accountViewModel.storiesListLiveData.observeAsState(GLOBAL_FOLLOWS) FollowList( @@ -393,8 +388,8 @@ fun StoriesTopBar(followLists: FollowListViewModel, scaffoldState: ScaffoldState } @Composable -fun HomeTopBar(followLists: FollowListViewModel, scaffoldState: ScaffoldState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { - GenericMainTopBar(scaffoldState, accountViewModel, nav) { accountViewModel -> +fun HomeTopBar(followLists: FollowListViewModel, drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { + GenericMainTopBar(drawerState, accountViewModel, nav) { accountViewModel -> val list by accountViewModel.homeListLiveData.observeAsState(KIND3_FOLLOWS) FollowList( @@ -413,8 +408,8 @@ fun HomeTopBar(followLists: FollowListViewModel, scaffoldState: ScaffoldState, a } @Composable -fun NotificationTopBar(followLists: FollowListViewModel, scaffoldState: ScaffoldState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { - GenericMainTopBar(scaffoldState, accountViewModel, nav) { accountViewModel -> +fun NotificationTopBar(followLists: FollowListViewModel, drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { + GenericMainTopBar(drawerState, accountViewModel, nav) { accountViewModel -> val list by accountViewModel.notificationListLiveData.observeAsState(GLOBAL_FOLLOWS) FollowList( @@ -429,8 +424,8 @@ fun NotificationTopBar(followLists: FollowListViewModel, scaffoldState: Scaffold } @Composable -fun DiscoveryTopBar(followLists: FollowListViewModel, scaffoldState: ScaffoldState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { - GenericMainTopBar(scaffoldState, accountViewModel, nav) { accountViewModel -> +fun DiscoveryTopBar(followLists: FollowListViewModel, drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { + GenericMainTopBar(drawerState, accountViewModel, nav) { accountViewModel -> val list by accountViewModel.discoveryListLiveData.observeAsState(GLOBAL_FOLLOWS) FollowList( @@ -445,24 +440,25 @@ fun DiscoveryTopBar(followLists: FollowListViewModel, scaffoldState: ScaffoldSta } @Composable -fun MainTopBar(scaffoldState: ScaffoldState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { - GenericMainTopBar(scaffoldState, accountViewModel, nav) { +fun MainTopBar(drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit) { + GenericMainTopBar(drawerState, accountViewModel, nav) { AmethystClickableIcon() } } -@OptIn(coil.annotation.ExperimentalCoilApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun GenericMainTopBar( - scaffoldState: ScaffoldState, + drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit, content: @Composable (AccountViewModel) -> Unit ) { Column(modifier = BottomTopHeight) { - MyTopAppBar( - elevation = 0.dp, - backgroundColor = MaterialTheme.colors.surface, + TopAppBar( + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.surface + ), title = { Column( modifier = Modifier.fillMaxWidth(), @@ -485,7 +481,7 @@ fun GenericMainTopBar( val coroutineScope = rememberCoroutineScope() LoggedInUserPictureDrawer(accountViewModel) { coroutineScope.launch { - scaffoldState.drawerState.open() + drawerState.open() } } }, @@ -715,7 +711,7 @@ fun SimpleTextSpinner( imageVector = Icons.Default.ExpandMore, null, modifier = Modifier.size(20.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } Box( @@ -756,7 +752,7 @@ fun RenderOption(it: Name) { horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth() ) { - Text(text = "/g/$it", color = MaterialTheme.colors.onSurface) + Text(text = "/g/$it", color = MaterialTheme.colorScheme.onSurface) } } } @@ -765,7 +761,7 @@ fun RenderOption(it: Name) { horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth() ) { - Text(text = it.name(), color = MaterialTheme.colors.onSurface) + Text(text = it.name(), color = MaterialTheme.colorScheme.onSurface) } } is ResourceName -> { @@ -773,7 +769,7 @@ fun RenderOption(it: Name) { horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth() ) { - Text(text = stringResource(id = it.resourceId), color = MaterialTheme.colors.onSurface) + Text(text = stringResource(id = it.resourceId), color = MaterialTheme.colorScheme.onSurface) } } is PeopleListName -> { @@ -781,7 +777,7 @@ fun RenderOption(it: Name) { horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth() ) { - Text(text = it.name(), color = MaterialTheme.colors.onSurface) + Text(text = it.name(), color = MaterialTheme.colorScheme.onSurface) } } is CommunityName -> { @@ -793,17 +789,17 @@ fun RenderOption(it: Name) { "/n/" + (it.note as? AddressableNote)?.dTag() }.observeAsState() - Text(text = name ?: "", color = MaterialTheme.colors.onSurface) + Text(text = name ?: "", color = MaterialTheme.colorScheme.onSurface) } } } } +@OptIn(ExperimentalMaterial3Api::class) @Composable fun TopBarWithBackButton(caption: String, popBack: () -> Unit) { Column(modifier = BottomTopHeight) { - MyTopAppBar( - elevation = 0.dp, + TopAppBar( title = { Text(caption) }, navigationIcon = { IconButton( @@ -821,15 +817,12 @@ fun TopBarWithBackButton(caption: String, popBack: () -> Unit) { @Composable fun FlexibleTopBarWithBackButton( - prefixRow: (@Composable () -> Unit)? = null, title: @Composable RowScope.() -> Unit, extendableRow: (@Composable () -> Unit)? = null, popBack: () -> Unit ) { Column() { MyExtensibleTopAppBar( - elevation = 0.dp, - prefixRow = prefixRow, title = title, extendableRow = extendableRow, navigationIcon = { @@ -907,135 +900,53 @@ fun debugState(context: Context) { } } -@Composable -fun MyTopAppBar( - title: @Composable RowScope.() -> Unit, - modifier: Modifier = Modifier, - navigationIcon: @Composable (() -> Unit)? = null, - actions: @Composable RowScope.() -> Unit = {}, - backgroundColor: Color = MaterialTheme.colors.surface, - contentColor: Color = contentColorFor(backgroundColor), - elevation: Dp = AppBarDefaults.TopAppBarElevation -) { - Surface( - contentColor = contentColor, - elevation = elevation, - modifier = modifier - ) { - CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { - Row( - Modifier - .fillMaxWidth() - .padding(AppBarDefaults.ContentPadding), - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically - ) { - if (navigationIcon == null) { - Spacer(TitleInsetWithoutIcon) - } else { - Row(TitleIconModifier, verticalAlignment = Alignment.CenterVertically) { - CompositionLocalProvider( - LocalContentAlpha provides ContentAlpha.high, - content = navigationIcon - ) - } - } - - Row( - Modifier.weight(1f), - verticalAlignment = Alignment.CenterVertically - ) { - ProvideTextStyle(MaterialTheme.typography.h6) { - title() - } - } - - CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { - Row( - horizontalArrangement = Arrangement.End, - verticalAlignment = Alignment.CenterVertically, - content = actions - ) - } - } - } - } -} - +@OptIn(ExperimentalMaterial3Api::class) @Composable fun MyExtensibleTopAppBar( - prefixRow: (@Composable () -> Unit)? = null, title: @Composable RowScope.() -> Unit, extendableRow: (@Composable () -> Unit)? = null, modifier: Modifier = Modifier, navigationIcon: @Composable (() -> Unit)? = null, - actions: @Composable RowScope.() -> Unit = {}, - backgroundColor: Color = MaterialTheme.colors.surface, - contentColor: Color = contentColorFor(backgroundColor), - elevation: Dp = AppBarDefaults.TopAppBarElevation + actions: @Composable RowScope.() -> Unit = {} ) { val expanded = remember { mutableStateOf(false) } - Surface( - color = backgroundColor, - contentColor = contentColor, - elevation = elevation, - modifier = modifier.clickable { + Column( + Modifier.clickable { expanded.value = !expanded.value } ) { - CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { - Column(Modifier.fillMaxWidth()) { - Row( - Modifier - .fillMaxWidth() - .padding(AppBarDefaults.ContentPadding), - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically - ) { + Row(modifier = BottomTopHeight) { + TopAppBar( + title = { + Row( + verticalAlignment = Alignment.CenterVertically + ) { + title() + } + }, + modifier = modifier, + navigationIcon = { if (navigationIcon == null) { Spacer(TitleInsetWithoutIcon) } else { Row(TitleIconModifier, verticalAlignment = Alignment.CenterVertically) { - CompositionLocalProvider( - LocalContentAlpha provides ContentAlpha.high, - content = navigationIcon - ) + navigationIcon() } } + }, + actions = actions + ) + } - Row( - Modifier.weight(1f), - verticalAlignment = Alignment.CenterVertically - ) { - ProvideTextStyle(MaterialTheme.typography.h6) { - title() - } - } - - CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { - Row( - horizontalArrangement = Arrangement.End, - verticalAlignment = Alignment.CenterVertically, - content = actions - ) - } - } - - if (expanded.value && extendableRow != null) { - Row( - Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically - ) { - Column { - extendableRow() - } - } - } - - if (prefixRow != null) { - prefixRow() + if (expanded.value && extendableRow != null) { + Row( + Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.Start, + verticalAlignment = Alignment.CenterVertically + ) { + Column { + extendableRow() } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt index 512463ca2..a0328648f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt @@ -22,21 +22,20 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.AlertDialog -import androidx.compose.material.Divider -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.ModalBottomSheetState -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.ScaffoldState -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TextButton import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Send +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.Divider +import androidx.compose.material3.DrawerState +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ModalDrawerSheet +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -94,12 +93,12 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -@OptIn(ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun DrawerContent( nav: (String) -> Unit, - scaffoldState: ScaffoldState, - sheetState: ModalBottomSheetState, + drawerState: DrawerState, + openSheet: () -> Unit, accountViewModel: AccountViewModel ) { val automaticallyShowProfilePicture = remember { @@ -110,9 +109,9 @@ fun DrawerContent( } } - Surface( - modifier = Modifier.fillMaxWidth(), - color = MaterialTheme.colors.background + ModalDrawerSheet( + drawerContainerColor = MaterialTheme.colorScheme.background, + drawerTonalElevation = 0.dp ) { Column() { ProfileContent( @@ -121,7 +120,7 @@ fun DrawerContent( .fillMaxWidth() .padding(horizontal = 25.dp) .padding(top = 70.dp), - scaffoldState, + drawerState, accountViewModel, nav ) @@ -131,15 +130,15 @@ fun DrawerContent( ) ListContent( nav, - scaffoldState, - sheetState, + drawerState, + openSheet, modifier = Modifier .fillMaxWidth() .weight(1f), accountViewModel ) - BottomContent(accountViewModel.account.userProfile(), scaffoldState, automaticallyShowProfilePicture, nav) + BottomContent(accountViewModel.account.userProfile(), drawerState, automaticallyShowProfilePicture, nav) } } } @@ -148,7 +147,7 @@ fun DrawerContent( fun ProfileContent( baseAccountUser: User, modifier: Modifier = Modifier, - scaffoldState: ScaffoldState, + drawerState: DrawerState, accountViewModel: AccountViewModel, nav: (String) -> Unit ) { @@ -160,8 +159,8 @@ fun ProfileContent( val profileBanner = remember(accountUserState) { accountUserState?.user?.info?.banner?.ifBlank { null } } val profilePicture = remember(accountUserState) { accountUserState?.user?.profilePicture() } - val bestUserName = remember(accountUserState) { accountUserState?.user?.bestUsername() } - val bestDisplayName = remember(accountUserState) { accountUserState?.user?.bestDisplayName() } + // val bestUserName = remember(accountUserState) { accountUserState?.user?.bestUsername() } + val bestDisplayName = remember(accountUserState) { accountUserState?.user?.toBestDisplayName() } val tags = remember(accountUserState) { accountUserState?.user?.info?.latestMetadata?.tags?.toImmutableListOfLists() } val route = remember(accountUserState) { "User/${accountUserState?.user?.pubkeyHex}" } @@ -188,8 +187,7 @@ fun ProfileContent( painter = painterResource(R.drawable.profile_banner), contentDescription = stringResource(R.string.profile_banner), contentScale = ContentScale.FillWidth, - modifier = Modifier - .fillMaxWidth() + modifier = Modifier.fillMaxWidth() .height(120.dp) ) } @@ -203,12 +201,12 @@ fun ProfileContent( .width(100.dp) .height(100.dp) .clip(shape = CircleShape) - .border(3.dp, MaterialTheme.colors.background, CircleShape) - .background(MaterialTheme.colors.background) + .border(3.dp, MaterialTheme.colorScheme.background, CircleShape) + .background(MaterialTheme.colorScheme.background) .clickable(onClick = { nav(route) coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } }), loadProfilePicture = automaticallyShowProfilePicture @@ -223,7 +221,7 @@ fun ProfileContent( .clickable(onClick = { nav(route) coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } }), fontWeight = FontWeight.Bold, @@ -232,24 +230,6 @@ fun ProfileContent( overflow = TextOverflow.Ellipsis ) } - if (bestUserName != null) { - CreateTextWithEmoji( - text = remember { " @$bestUserName" }, - tags = tags, - color = Color.LightGray, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = Modifier - .clickable( - onClick = { - nav(route) - coroutineScope.launch { - scaffoldState.drawerState.close() - } - } - ) - ) - } Row(Modifier.padding(top = Size10dp)) { EditStatusBox(baseAccountUser, accountViewModel) @@ -261,7 +241,7 @@ fun ProfileContent( .clickable(onClick = { nav(route) coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } }) ) { @@ -295,7 +275,7 @@ private fun EditStatusBox(baseAccountUser: User, accountViewModel: AccountViewMo placeholder = { Text( text = stringResource(R.string.status_update), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -341,7 +321,7 @@ private fun EditStatusBox(baseAccountUser: User, accountViewModel: AccountViewMo placeholder = { Text( text = stringResource(R.string.status_update), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -384,7 +364,7 @@ fun SendButton(onClick: () -> Unit) { imageVector = Icons.Default.Send, null, modifier = Size20Modifier, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } @@ -399,7 +379,7 @@ fun UserStatusDeleteButton(onClick: () -> Unit) { imageVector = Icons.Default.Delete, null, modifier = Size20Modifier, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } @@ -460,12 +440,11 @@ fun WatchFollower(baseAccountUser: User, onReady: (String) -> Unit) { } } -@OptIn(ExperimentalMaterialApi::class) @Composable fun ListContent( nav: (String) -> Unit, - scaffoldState: ScaffoldState, - sheetState: ModalBottomSheetState, + drawerState: DrawerState, + openSheet: () -> Unit, modifier: Modifier, accountViewModel: AccountViewModel ) { @@ -493,18 +472,18 @@ fun ListContent( NavigationRow( title = stringResource(R.string.profile), icon = Route.Profile.icon, - tint = MaterialTheme.colors.primary, + tint = MaterialTheme.colorScheme.primary, nav = nav, - scaffoldState = scaffoldState, + drawerState = drawerState, route = route ) NavigationRow( title = stringResource(R.string.bookmarks), icon = Route.Bookmarks.icon, - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, nav = nav, - scaffoldState = scaffoldState, + drawerState = drawerState, route = Route.Bookmarks.route ) @@ -512,7 +491,7 @@ fun ListContent( accountViewModel = accountViewModel, onClick = { coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } wantsToEditRelays = true } @@ -521,9 +500,9 @@ fun ListContent( NavigationRow( title = stringResource(R.string.security_filters), icon = Route.BlockedUsers.icon, - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, nav = nav, - scaffoldState = scaffoldState, + drawerState = drawerState, route = Route.BlockedUsers.route ) @@ -531,10 +510,10 @@ fun ListContent( IconRow( title = stringResource(R.string.backup_keys), icon = R.drawable.ic_key, - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, onClick = { coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } backupDialogOpen = true } @@ -545,10 +524,10 @@ fun ListContent( IconRow( title = textTorProxy, icon = R.drawable.ic_tor, - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, onLongClick = { coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } conectOrbotDialogOpen = true }, @@ -557,7 +536,7 @@ fun ListContent( disconnectTorDialog = true } else { coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } conectOrbotDialogOpen = true } @@ -567,9 +546,9 @@ fun ListContent( NavigationRow( title = stringResource(R.string.settings), icon = Route.Settings.icon, - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, nav = nav, - scaffoldState = scaffoldState, + drawerState = drawerState, route = Route.Settings.route ) @@ -578,8 +557,8 @@ fun ListContent( IconRow( title = stringResource(R.string.drawer_accounts), icon = R.drawable.manage_accounts, - tint = MaterialTheme.colors.onBackground, - onClick = { coroutineScope.launch { sheetState.show() } } + tint = MaterialTheme.colorScheme.onBackground, + onClick = openSheet ) } @@ -670,7 +649,7 @@ private fun RenderRelayStatus( } } - val placeHolder = MaterialTheme.colors.placeholderText + val placeHolder = MaterialTheme.colorScheme.placeholderText val color by remember(relayPool) { derivedStateOf { @@ -685,7 +664,7 @@ private fun RenderRelayStatus( Text( text = text, color = color, - style = MaterialTheme.typography.subtitle1 + style = MaterialTheme.typography.titleMedium ) } @@ -695,14 +674,14 @@ fun NavigationRow( icon: Int, tint: Color, nav: (String) -> Unit, - scaffoldState: ScaffoldState, + drawerState: DrawerState, route: String ) { val coroutineScope = rememberCoroutineScope() IconRow(title, icon, tint, onClick = { nav(route) coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } }) } @@ -756,7 +735,7 @@ fun IconRowRelays(accountViewModel: AccountViewModel, onClick: () -> Unit) { painter = painterResource(R.drawable.relays), null, modifier = Modifier.size(22.dp), - tint = MaterialTheme.colors.onSurface + tint = MaterialTheme.colorScheme.onSurface ) Text( @@ -773,7 +752,7 @@ fun IconRowRelays(accountViewModel: AccountViewModel, onClick: () -> Unit) { } @Composable -fun BottomContent(user: User, scaffoldState: ScaffoldState, loadProfilePicture: Boolean, nav: (String) -> Unit) { +fun BottomContent(user: User, drawerState: DrawerState, loadProfilePicture: Boolean, nav: (String) -> Unit) { val coroutineScope = rememberCoroutineScope() // store the dialog open or close state @@ -812,21 +791,21 @@ fun BottomContent(user: User, scaffoldState: ScaffoldState, loadProfilePicture: painter = painterResource(R.drawable.ic_theme), null, modifier = Modifier.size(24.dp), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) }*/ Box(modifier = Modifier.weight(1F)) IconButton(onClick = { dialogOpen = true coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } }) { Icon( painter = painterResource(R.drawable.ic_qrcode), null, modifier = Modifier.size(24.dp), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } } @@ -839,7 +818,7 @@ fun BottomContent(user: User, scaffoldState: ScaffoldState, loadProfilePicture: onScan = { dialogOpen = false coroutineScope.launch { - scaffoldState.drawerState.close() + drawerState.close() } nav(it) }, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/AddBountyAmountDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/AddBountyAmountDialog.kt index 19148d6dc..4b28ff745 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/AddBountyAmountDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/AddBountyAmountDialog.kt @@ -10,10 +10,10 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -138,7 +138,7 @@ fun AddBountyAmountDialog(bounty: Note, accountViewModel: AccountViewModel, onCl placeholder = { Text( text = "10000, 50000, 5000000", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BadgeCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BadgeCompose.kt index 90f7fd6e8..57fe154cf 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BadgeCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BadgeCompose.kt @@ -9,14 +9,14 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.MilitaryTech import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -59,9 +59,9 @@ fun BadgeCompose(likeSetCard: BadgeCard, isInnerNote: Boolean = false, routeForL if (note == null) { BlankNote(Modifier, isInnerNote) } else { - val defaultBackgroundColor = MaterialTheme.colors.background + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } - val newItemColor = MaterialTheme.colors.newItemBackgroundColor + val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor LaunchedEffect(key1 = likeSetCard) { scope.launch(Dispatchers.IO) { @@ -117,7 +117,7 @@ fun BadgeCompose(likeSetCard: BadgeCard, isInnerNote: Boolean = false, routeForL modifier = Modifier .size(25.dp) .align(Alignment.TopEnd), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } } @@ -134,7 +134,7 @@ fun BadgeCompose(likeSetCard: BadgeCard, isInnerNote: Boolean = false, routeForL Text( timeAgo(note.createdAt(), context = context), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) @@ -146,7 +146,7 @@ fun BadgeCompose(likeSetCard: BadgeCard, isInnerNote: Boolean = false, routeForL imageVector = Icons.Default.MoreVert, null, modifier = Modifier.size(15.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) NoteDropDownMenu(note, popupExpanded, accountViewModel) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt index e987f7daa..a650a172d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt @@ -7,11 +7,11 @@ import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -108,7 +108,7 @@ fun HiddenNote( shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + contentColor = MaterialTheme.colorScheme.primary ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt index a56015433..e84da6ef8 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChannelCardCompose.kt @@ -15,9 +15,9 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -275,8 +275,8 @@ private fun CheckNewAndRenderChannelCard( showPopup: () -> Unit, nav: (String) -> Unit ) { - val newItemColor = MaterialTheme.colors.newItemBackgroundColor - val defaultBackgroundColor = MaterialTheme.colors.background + val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } LaunchedEffect(key1 = routeForLastRead, key2 = parentBackgroundColor?.value) { @@ -614,9 +614,9 @@ fun RenderCommunitiesThumb(baseNote: Note, accountViewModel: AccountViewModel, n ) Spacer(modifier = StdHorzSpacer) - LikeReaction(baseNote = baseNote, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav) + LikeReaction(baseNote = baseNote, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav) Spacer(modifier = StdHorzSpacer) - ZapReaction(baseNote = baseNote, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav = nav) + ZapReaction(baseNote = baseNote, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav = nav) } description?.let { @@ -624,7 +624,7 @@ fun RenderCommunitiesThumb(baseNote: Note, accountViewModel: AccountViewModel, n Row() { Text( text = it, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 3, overflow = TextOverflow.Ellipsis, fontSize = 14.sp @@ -728,9 +728,9 @@ fun RenderChannelThumb(baseNote: Note, channel: Channel, accountViewModel: Accou ) Spacer(modifier = StdHorzSpacer) - LikeReaction(baseNote = baseNote, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav) + LikeReaction(baseNote = baseNote, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav) Spacer(modifier = StdHorzSpacer) - ZapReaction(baseNote = baseNote, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav = nav) + ZapReaction(baseNote = baseNote, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav = nav) } description?.let { @@ -738,7 +738,7 @@ fun RenderChannelThumb(baseNote: Note, channel: Channel, accountViewModel: Accou Row() { Text( text = it, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 3, overflow = TextOverflow.Ellipsis, fontSize = 14.sp @@ -768,7 +768,7 @@ fun Gallery(users: List, accountViewModel: AccountViewModel) { Text( text = remember(users) { " + " + (showCount(users.size - 6)).toString() }, fontSize = 13.sp, - color = MaterialTheme.colors.onSurface + color = MaterialTheme.colorScheme.onSurface ) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt index dcf377cc1..06938aad8 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomHeaderCompose.kt @@ -14,10 +14,10 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Divider -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -218,7 +218,7 @@ private fun ChannelRoomCompose( @Composable private fun ChannelTitleWithLabelInfo(channelName: String, modifier: Modifier) { val label = stringResource(id = R.string.public_chat) - val placeHolderColor = MaterialTheme.colors.placeholderText + val placeHolderColor = MaterialTheme.colorScheme.placeholderText val channelNameAndBoostInfo = remember(channelName) { buildAnnotatedString { withStyle( @@ -530,7 +530,7 @@ private fun SecondRow(channelLastContent: String?, hasNewMessages: MutableState< if (channelLastContent != null) { Text( channelLastContent, - color = MaterialTheme.colors.grayText, + color = MaterialTheme.colorScheme.grayText, maxLines = 1, overflow = TextOverflow.Ellipsis, style = LocalTextStyle.current.copy(textDirection = TextDirection.Content), @@ -539,7 +539,7 @@ private fun SecondRow(channelLastContent: String?, hasNewMessages: MutableState< } else { Text( stringResource(R.string.referenced_event_not_found), - color = MaterialTheme.colors.grayText, + color = MaterialTheme.colorScheme.grayText, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = modifier @@ -573,7 +573,7 @@ private fun TimeAgo(channelLastTime: Long?) { } Text( text = timeAgo, - color = MaterialTheme.colors.grayText, + color = MaterialTheme.colorScheme.grayText, maxLines = 1 ) } @@ -586,7 +586,7 @@ fun NewItemsBubble() { .width(10.dp) .height(10.dp) .clip(shape = CircleShape) - .background(MaterialTheme.colors.primary), + .background(MaterialTheme.colorScheme.primary), contentAlignment = Alignment.Center ) { Text( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt index 9499f2eb8..dee028edd 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt @@ -15,10 +15,10 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -232,9 +232,9 @@ fun NormalChatNote( } } - val loggedInColors = MaterialTheme.colors.mediumImportanceLink - val otherColors = MaterialTheme.colors.subtleBorder - val defaultBackground = MaterialTheme.colors.background + val loggedInColors = MaterialTheme.colorScheme.mediumImportanceLink + val otherColors = MaterialTheme.colorScheme.subtleBorder + val defaultBackground = MaterialTheme.colorScheme.background val backgroundBubbleColor = remember { if (accountViewModel.isLoggedUser(note.author)) { @@ -572,13 +572,13 @@ private fun StatusRow( Column(modifier = ReactionRowHeightChat) { Row(verticalAlignment = Alignment.CenterVertically, modifier = ReactionRowHeightChat) { - LikeReaction(baseNote, MaterialTheme.colors.placeholderText, accountViewModel, nav) + LikeReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav) Spacer(modifier = StdHorzSpacer) - ZapReaction(baseNote, MaterialTheme.colors.placeholderText, accountViewModel, nav = nav) + ZapReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav = nav) Spacer(modifier = DoubleHorzSpacer) ReplyReaction( baseNote = baseNote, - grayTint = MaterialTheme.colors.placeholderText, + grayTint = MaterialTheme.colorScheme.placeholderText, accountViewModel = accountViewModel, showCounter = false, iconSize = Size15dp @@ -599,7 +599,7 @@ fun IncognitoBadge(baseNote: Note) { modifier = Modifier .padding(top = 1.dp) .size(14.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } else if (baseNote.event is PrivateDmEvent) { Icon( @@ -608,7 +608,7 @@ fun IncognitoBadge(baseNote: Note) { modifier = Modifier .padding(top = 1.dp) .size(14.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } @@ -625,7 +625,7 @@ fun ChatTimeAgo(baseNote: Note) { Text( text = time, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, fontSize = Font12SP, maxLines = 1 ) @@ -824,7 +824,7 @@ private fun DisplayMessageUsername( maxLines = 1, tags = userTags, fontWeight = FontWeight.Bold, - overrideColor = MaterialTheme.colors.onBackground, // we do not want clickable names in purple here. + overrideColor = MaterialTheme.colorScheme.onBackground, // we do not want clickable names in purple here. route = route, nav = nav ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/Icons.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/Icons.kt index 48bbe5e01..a5d9dada7 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/Icons.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/Icons.kt @@ -1,8 +1,6 @@ package com.vitorpamplona.amethyst.ui.note import androidx.compose.foundation.layout.size -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Bolt @@ -20,6 +18,8 @@ import androidx.compose.material.icons.filled.VolumeOff import androidx.compose.material.icons.filled.VolumeUp import androidx.compose.material.icons.outlined.BarChart import androidx.compose.material.icons.outlined.PlayCircle +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -61,7 +61,7 @@ fun ArrowBackIcon() { Icon( imageVector = Icons.Default.ArrowBack, contentDescription = stringResource(R.string.back), - tint = MaterialTheme.colors.grayText + tint = MaterialTheme.colorScheme.grayText ) } @@ -71,7 +71,7 @@ fun MessageIcon(modifier: Modifier) { painter = painterResource(R.drawable.ic_dm), null, modifier = modifier, - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } @@ -81,7 +81,7 @@ fun DownloadForOfflineIcon(iconSize: Dp) { imageVector = Icons.Default.DownloadForOffline, null, modifier = remember(iconSize) { Modifier.size(iconSize) }, - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } @@ -181,7 +181,7 @@ fun ExpandLessIcon(modifier: Modifier) { imageVector = Icons.Default.ExpandLess, null, modifier = modifier, - tint = MaterialTheme.colors.subtleButton + tint = MaterialTheme.colorScheme.subtleButton ) } @@ -191,7 +191,7 @@ fun ExpandMoreIcon(modifier: Modifier) { imageVector = Icons.Default.ExpandMore, null, modifier = modifier, - tint = MaterialTheme.colors.subtleButton + tint = MaterialTheme.colorScheme.subtleButton ) } @@ -226,7 +226,7 @@ fun PollIcon() { painter = painterResource(R.drawable.ic_poll), null, modifier = Size20Modifier, - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } @@ -236,7 +236,7 @@ fun RegularPostIcon() { painter = painterResource(R.drawable.ic_lists), null, modifier = Size20Modifier, - tint = MaterialTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } @@ -246,7 +246,7 @@ fun CancelIcon() { imageVector = Icons.Default.Cancel, null, modifier = Size30Modifier, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } @@ -255,8 +255,7 @@ fun CloseIcon() { Icon( painter = painterResource(id = R.drawable.ic_close), contentDescription = stringResource(id = R.string.cancel), - modifier = Size20Modifier, - tint = Color.White + modifier = Size20Modifier ) } @@ -265,7 +264,7 @@ fun MutedIcon() { Icon( imageVector = Icons.Default.VolumeOff, contentDescription = stringResource(id = R.string.muted_button), - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, modifier = Size30Modifier ) } @@ -275,7 +274,7 @@ fun MuteIcon() { Icon( imageVector = Icons.Default.VolumeUp, contentDescription = stringResource(id = R.string.mute_button), - tint = MaterialTheme.colors.onBackground, + tint = MaterialTheme.colorScheme.onBackground, modifier = Size30Modifier ) } @@ -354,7 +353,7 @@ fun VerticalDotsIcon() { imageVector = Icons.Default.MoreVert, null, modifier = Size18Modifier, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MessageSetCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MessageSetCompose.kt index f2f0d857a..937acc83d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MessageSetCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MessageSetCompose.kt @@ -10,8 +10,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -43,9 +43,9 @@ fun MessageSetCompose(messageSetCard: MessageSetCard, routeForLastRead: String, val scope = rememberCoroutineScope() - val defaultBackgroundColor = MaterialTheme.colors.background + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } - val newItemColor = MaterialTheme.colors.newItemBackgroundColor + val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor LaunchedEffect(key1 = messageSetCard) { launch(Dispatchers.IO) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt index 1b8f0adac..51117d9f6 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt @@ -17,9 +17,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.LaunchedEffect @@ -91,9 +91,9 @@ fun MultiSetCompose(multiSetCard: MultiSetCard, routeForLastRead: String, showHi val scope = rememberCoroutineScope() - val defaultBackgroundColor = MaterialTheme.colors.background + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } - val newItemColor = MaterialTheme.colors.newItemBackgroundColor + val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor LaunchedEffect(key1 = multiSetCard) { launch(Dispatchers.IO) { @@ -441,7 +441,7 @@ fun CrossfadeToDisplayAmount(amount: String) { modifier = amountBoxModifier, contentAlignment = Alignment.BottomCenter ) { - val backgroundColor = MaterialTheme.colors.overPictureBackground + val backgroundColor = MaterialTheme.colorScheme.overPictureBackground Box( modifier = remember { Modifier @@ -453,7 +453,7 @@ fun CrossfadeToDisplayAmount(amount: String) { Text( text = amount, fontWeight = FontWeight.Bold, - color = MaterialTheme.colors.bitcoinColor, + color = MaterialTheme.colorScheme.bitcoinColor, fontSize = commentTextSize, modifier = bottomPadding1dp ) @@ -541,7 +541,7 @@ fun WatchUserMetadataAndFollowsAndRenderUserProfilePicture( robot = author.pubkeyHex, model = baseUserPicture, contentDescription = stringResource(id = R.string.profile_image), - modifier = MaterialTheme.colors.profile35dpModifier, + modifier = MaterialTheme.colorScheme.profile35dpModifier, contentScale = ContentScale.Crop, loadProfilePicture = automaticallyShowProfilePicture ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt index 7ac6bbbeb..783b93ff5 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt @@ -6,13 +6,13 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.OpenInNew +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -172,7 +172,7 @@ fun DisplayUsersNpub(npub: String) { Text( text = npub, fontSize = 14.sp, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, overflow = TextOverflow.Ellipsis ) @@ -205,7 +205,7 @@ fun DisplayStatus( painter = painterResource(id = R.drawable.tunestr), null, modifier = Size15Modifier.padding(end = Size5dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) else -> {} } @@ -213,7 +213,7 @@ fun DisplayStatus( Text( text = content, fontSize = Font14SP, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, overflow = TextOverflow.Ellipsis ) @@ -229,7 +229,7 @@ fun DisplayStatus( imageVector = Icons.Default.OpenInNew, null, modifier = Size15Modifier, - tint = MaterialTheme.colors.lessImportantLink + tint = MaterialTheme.colorScheme.lessImportantLink ) } } else if (nostrATag != null) { @@ -249,7 +249,7 @@ fun DisplayStatus( imageVector = Icons.Default.OpenInNew, null, modifier = Size15Modifier, - tint = MaterialTheme.colors.lessImportantLink + tint = MaterialTheme.colorScheme.lessImportantLink ) } } @@ -271,7 +271,7 @@ fun DisplayStatus( imageVector = Icons.Default.OpenInNew, null, modifier = Size15Modifier, - tint = MaterialTheme.colors.lessImportantLink + tint = MaterialTheme.colorScheme.lessImportantLink ) } } @@ -298,7 +298,7 @@ private fun DisplayNIP05( Text( text = remember(nip05) { AnnotatedString(user) }, fontSize = Font14SP, - color = MaterialTheme.colors.nip05, + color = MaterialTheme.colorScheme.nip05, maxLines = 1, overflow = TextOverflow.Ellipsis ) @@ -309,7 +309,7 @@ private fun DisplayNIP05( ClickableText( text = remember(nip05) { AnnotatedString(domain) }, onClick = { runCatching { uri.openUri("https://$domain") } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.nip05, fontSize = Font14SP), + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.nip05, fontSize = Font14SP), maxLines = 1, overflow = TextOverflow.Visible ) @@ -349,7 +349,7 @@ fun DisplayNip05ProfileStatus(user: User, accountViewModel: AccountViewModel) { if (user != "_") { Text( text = remember { AnnotatedString(user + "@") }, - color = MaterialTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, modifier = Modifier.padding(top = 1.dp, bottom = 1.dp, start = 5.dp), maxLines = 1, overflow = TextOverflow.Ellipsis @@ -360,7 +360,7 @@ fun DisplayNip05ProfileStatus(user: User, accountViewModel: AccountViewModel) { ClickableText( text = AnnotatedString(domain), onClick = { nip05.let { runCatching { uri.openUri("https://${it.split("@")[1]}") } } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary), + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary), modifier = Modifier.padding(top = 1.dp, bottom = 1.dp, start = domainPadStart), maxLines = 1, overflow = TextOverflow.Ellipsis diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index c116ae8ec..755daba5e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -28,19 +28,19 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CutCornerShape import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.darkColors import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.ArrowForwardIos import androidx.compose.material.icons.outlined.Bolt -import androidx.compose.material.lightColors +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -624,7 +624,7 @@ fun LongCommunityHeader( Modifier.weight(1f) ) { Row(verticalAlignment = Alignment.CenterVertically) { - val defaultBackground = MaterialTheme.colors.background + val defaultBackground = MaterialTheme.colorScheme.background val background = remember { mutableStateOf(defaultBackground) } @@ -783,9 +783,9 @@ private fun ShortCommunityActionOptions( nav: (String) -> Unit ) { Spacer(modifier = StdHorzSpacer) - LikeReaction(baseNote = note, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav = nav) + LikeReaction(baseNote = note, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav = nav) Spacer(modifier = StdHorzSpacer) - ZapReaction(baseNote = note, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav = nav) + ZapReaction(baseNote = note, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav = nav) WatchAddressableNoteFollows(note, accountViewModel) { isFollowing -> if (!isFollowing) { @@ -835,8 +835,8 @@ private fun CheckNewAndRenderNote( showPopup: () -> Unit, nav: (String) -> Unit ) { - val newItemColor = MaterialTheme.colors.newItemBackgroundColor - val defaultBackgroundColor = MaterialTheme.colors.background + val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } LaunchedEffect(key1 = routeForLastRead, key2 = parentBackgroundColor?.value) { @@ -1112,7 +1112,7 @@ fun DisplayZapSplits(noteEvent: EventInterface, accountViewModel: AccountViewMod ClickableText( text = AnnotatedString(it.lnAddressOrPubKeyHex), onClick = { }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } else { UserPicture(userHex = it.lnAddressOrPubKeyHex, size = 25.dp, accountViewModel = accountViewModel, nav = nav) @@ -1334,7 +1334,7 @@ fun RenderTextEvent( if (makeItShort && isAuthorTheLoggedUser) { Text( text = eventContent, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 2, overflow = TextOverflow.Ellipsis ) @@ -1378,7 +1378,7 @@ fun RenderPoll( if (makeItShort && accountViewModel.isLoggedUser(note.author)) { Text( text = eventContent, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 2, overflow = TextOverflow.Ellipsis ) @@ -1494,12 +1494,12 @@ fun RenderAppDefinition( modifier = Modifier .border( 3.dp, - MaterialTheme.colors.background, + MaterialTheme.colorScheme.background, CircleShape ) .clip(shape = CircleShape) .fillMaxSize() - .background(MaterialTheme.colors.background) + .background(MaterialTheme.colorScheme.background) .combinedClickable( onClick = { zoomImageDialogOpen = true }, onLongClick = { @@ -1543,12 +1543,12 @@ fun RenderAppDefinition( val website = remember(it) { it.website } if (!website.isNullOrEmpty()) { Row(verticalAlignment = Alignment.CenterVertically) { - LinkIcon(Size16Modifier, MaterialTheme.colors.placeholderText) + LinkIcon(Size16Modifier, MaterialTheme.colorScheme.placeholderText) ClickableText( text = AnnotatedString(website.removePrefix("https://")), onClick = { website.let { runCatching { uri.openUri(it) } } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary), + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary), modifier = Modifier.padding(top = 1.dp, bottom = 1.dp, start = 5.dp) ) } @@ -1559,7 +1559,7 @@ fun RenderAppDefinition( modifier = Modifier.padding(top = 5.dp, bottom = 5.dp) ) { val tags = remember(note) { note.event?.tags()?.toImmutableListOfLists() ?: EmptyTagList } - val bgColor = MaterialTheme.colors.background + val bgColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(bgColor) } @@ -1637,7 +1637,7 @@ private fun RenderPrivateMessage( if (makeItShort && isAuthorTheLoggedUser) { Text( text = eventContent!!, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 2, overflow = TextOverflow.Ellipsis ) @@ -2034,7 +2034,7 @@ fun RenderPostApproval( note.replyTo?.forEach { NoteCompose( it, - modifier = MaterialTheme.colors.replyModifier, + modifier = MaterialTheme.colorScheme.replyModifier, unPackReply = false, makeItShort = true, isQuotedNote = true, @@ -2239,10 +2239,9 @@ fun RemoveButton(onClick: () -> Unit) { modifier = Modifier.padding(start = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 0.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.remove), color = Color.White) @@ -2264,10 +2263,9 @@ fun AddButton( } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray - ), + colors = ButtonDefaults.buttonColors( + containerColor = if (isActive) MaterialTheme.colorScheme.primary else Color.Gray + ), contentPadding = PaddingValues(vertical = 0.dp, horizontal = 16.dp) ) { Text(text = stringResource(text), color = Color.White, textAlign = TextAlign.Center) @@ -2311,7 +2309,7 @@ fun RenderPinListEvent( FlowRow(modifier = Modifier.padding(top = 5.dp)) { pinsToShow.forEach { pin -> Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = CenterVertically) { - PinIcon(modifier = Size15Modifier, tint = MaterialTheme.colors.onBackground.copy(0.32f)) + PinIcon(modifier = Size15Modifier, tint = MaterialTheme.colorScheme.onBackground.copy(0.32f)) Spacer(modifier = Modifier.width(5.dp)) @@ -2434,7 +2432,7 @@ private fun RenderReport( .clip(shape = QuoteBorder) .border( 1.dp, - MaterialTheme.colors.subtleBorder, + MaterialTheme.colorScheme.subtleBorder, QuoteBorder ), unPackReply = false, @@ -2478,7 +2476,7 @@ private fun ReplyRow( showVideo = false, showBottomDiviser = false, sendToChannel = true, - modifier = MaterialTheme.colors.replyModifier.padding(10.dp), + modifier = MaterialTheme.colorScheme.replyModifier.padding(10.dp), accountViewModel = accountViewModel, nav = nav ) @@ -2511,7 +2509,7 @@ private fun ReplyNoteComposition( val replyBackgroundColor = remember { mutableStateOf(backgroundColor.value) } - val defaultReplyBackground = MaterialTheme.colors.replyBackground + val defaultReplyBackground = MaterialTheme.colorScheme.replyBackground LaunchedEffect(key1 = backgroundColor.value, key2 = defaultReplyBackground) { launch(Dispatchers.Default) { @@ -2526,7 +2524,7 @@ private fun ReplyNoteComposition( NoteCompose( baseNote = replyingDirectlyTo, isQuotedNote = true, - modifier = MaterialTheme.colors.replyModifier, + modifier = MaterialTheme.colorScheme.replyModifier, unPackReply = false, makeItShort = true, parentBackgroundColor = replyBackgroundColor, @@ -2613,7 +2611,7 @@ fun DisplayLocation(geohash: String, nav: (String) -> Unit) { text = AnnotatedString(cityName), onClick = { nav("Geohash/$geohash") }, style = LocalTextStyle.current.copy( - color = MaterialTheme.colors.primary.copy( + color = MaterialTheme.colorScheme.primary.copy( alpha = 0.52f ), fontSize = Font14SP, @@ -2644,7 +2642,7 @@ fun FirstUserInfoRow( } } - val textColor = if (isRepost) MaterialTheme.colors.grayText else Color.Unspecified + val textColor = if (isRepost) MaterialTheme.colorScheme.grayText else Color.Unspecified if (showAuthorPicture) { NoteAuthorPicture(baseNote, nav, accountViewModel, Size25dp) @@ -2673,7 +2671,7 @@ private fun BoostedMark() { Text( stringResource(id = R.string.boosted), fontWeight = FontWeight.Bold, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, modifier = HalfStartPadding ) @@ -2716,7 +2714,7 @@ fun TimeAgo(time: Long) { Text( text = timeStr, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) } @@ -2824,7 +2822,7 @@ private fun ChannelNotePicture(baseChannel: Channel, loadProfilePicture: Boolean it.channel.profilePicture() }.distinctUntilChanged().observeAsState() - val backgroundColor = MaterialTheme.colors.background + val backgroundColor = MaterialTheme.colorScheme.background val modifier = remember { Modifier @@ -2868,7 +2866,7 @@ private fun RepostNoteAuthorPicture( } Box(Size18Modifier.align(Alignment.BottomStart).padding(1.dp)) { - RepostedIcon(modifier = Size18Modifier, MaterialTheme.colors.placeholderText) + RepostedIcon(modifier = Size18Modifier, MaterialTheme.colorScheme.placeholderText) } Box(Size35Modifier.align(Alignment.BottomEnd)) { @@ -2971,7 +2969,7 @@ private fun LoadAndDisplayPost(postAddress: ATag, accountViewModel: AccountViewM nav(it) } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary) + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary) ) } } @@ -3073,7 +3071,7 @@ private fun DisplayTagList(firstTag: String, nav: (String) -> Unit) { text = displayTag, onClick = { nav(route) }, style = LocalTextStyle.current.copy( - color = MaterialTheme.colors.primary.copy( + color = MaterialTheme.colorScheme.primary.copy( alpha = 0.52f ) ), @@ -3094,7 +3092,7 @@ private fun DisplayCommunity(note: Note, nav: (String) -> Unit) { text = displayTag, onClick = { nav(route) }, style = LocalTextStyle.current.copy( - color = MaterialTheme.colors.primary.copy( + color = MaterialTheme.colorScheme.primary.copy( alpha = 0.52f ) ), @@ -3136,7 +3134,7 @@ fun DisplayUncitedHashtags( text = remember { AnnotatedString("#$hashtag ") }, onClick = { nav("Hashtag/$hashtag") }, style = LocalTextStyle.current.copy( - color = MaterialTheme.colors.primary.copy( + color = MaterialTheme.colorScheme.primary.copy( alpha = 0.52f ) ) @@ -3156,7 +3154,7 @@ fun DisplayPoW( Text( powStr, - color = MaterialTheme.colors.lessImportantLink, + color = MaterialTheme.colorScheme.lessImportantLink, fontSize = Font14SP, fontWeight = FontWeight.Bold, maxLines = 1 @@ -3184,7 +3182,7 @@ fun DisplayReward( text = AnnotatedString("#bounty"), onClick = { nav("Hashtag/bounty") }, style = LocalTextStyle.current.copy( - color = MaterialTheme.colors.primary.copy( + color = MaterialTheme.colorScheme.primary.copy( alpha = 0.52f ) ) @@ -3240,19 +3238,19 @@ private fun RenderPledgeAmount( if (hasPledge) { ZappedIcon(modifier = Size20Modifier) } else { - ZapIcon(modifier = Size20Modifier, MaterialTheme.colors.placeholderText) + ZapIcon(modifier = Size20Modifier, MaterialTheme.colorScheme.placeholderText) } Text( text = reward, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) } @Composable fun BadgeDisplay(baseNote: Note) { - val background = MaterialTheme.colors.background + val background = MaterialTheme.colorScheme.background val badgeData = baseNote.event as? BadgeDefinitionEvent ?: return val image = remember { badgeData.thumb()?.ifBlank { null } ?: badgeData.image() } @@ -3268,9 +3266,9 @@ fun BadgeDisplay(baseNote: Note) { val backgroundColor = it.drawable.toBitmap(200, 200).copy(Bitmap.Config.ARGB_8888, false).get(0, 199) val colorFromImage = Color(backgroundColor) val textBackground = if (colorFromImage.luminance() > 0.5) { - lightColors().onBackground + lightColorScheme().onBackground } else { - darkColors().onBackground + darkColorScheme().onBackground } launch(Dispatchers.Main) { @@ -3286,7 +3284,7 @@ fun BadgeDisplay(baseNote: Note) { .clip(shape = CutCornerShape(20, 20, 20, 20)) .border( 5.dp, - MaterialTheme.colors.mediumImportanceLink, + MaterialTheme.colorScheme.mediumImportanceLink, CutCornerShape(20) ) .background(backgroundFromImage.first) @@ -3329,7 +3327,7 @@ private fun RenderBadge( name?.let { Text( text = it, - style = MaterialTheme.typography.body1, + style = MaterialTheme.typography.bodyLarge, textAlign = TextAlign.Center, modifier = Modifier .fillMaxWidth() @@ -3341,7 +3339,7 @@ private fun RenderBadge( description?.let { Text( text = it, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, textAlign = TextAlign.Center, modifier = Modifier .fillMaxWidth() @@ -3512,7 +3510,7 @@ fun AudioTrackHeader(noteEvent: AudioTrackEvent, note: Note, accountViewModel: A it.first.role?.let { Text( text = it.capitalize(Locale.ROOT), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) } @@ -3553,7 +3551,7 @@ fun AudioHeader(noteEvent: AudioHeaderEvent, note: Note, accountViewModel: Accou val waveform = remember { noteEvent.wavefrom()?.toImmutableList()?.ifEmpty { null } } val content = remember { noteEvent.content().ifBlank { null } } - val defaultBackground = MaterialTheme.colors.background + val defaultBackground = MaterialTheme.colorScheme.background val background = remember { mutableStateOf(defaultBackground) } val tags = remember(noteEvent) { noteEvent?.tags()?.toImmutableListOfLists() ?: EmptyTagList } @@ -3708,7 +3706,7 @@ fun RenderLiveActivityEventInner(baseNote: Note, accountViewModel: AccountViewMo it.first.role?.let { Text( text = it.capitalize(Locale.ROOT), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) } @@ -3740,7 +3738,7 @@ fun RenderLiveActivityEventInner(baseNote: Note, accountViewModel: AccountViewMo ) { Text( text = stringResource(id = R.string.live_stream_is_offline), - color = MaterialTheme.colors.onBackground, + color = MaterialTheme.colorScheme.onBackground, fontWeight = FontWeight.Bold ) } @@ -3754,7 +3752,7 @@ fun RenderLiveActivityEventInner(baseNote: Note, accountViewModel: AccountViewMo ) { Text( text = stringResource(id = R.string.live_stream_has_ended), - color = MaterialTheme.colors.onBackground, + color = MaterialTheme.colorScheme.onBackground, fontWeight = FontWeight.Bold ) } @@ -3774,7 +3772,7 @@ private fun LongFormHeader(noteEvent: LongTextNoteEvent, note: Note, accountView .clip(shape = QuoteBorder) .border( 1.dp, - MaterialTheme.colors.subtleBorder, + MaterialTheme.colorScheme.subtleBorder, QuoteBorder ) ) { @@ -3804,7 +3802,7 @@ private fun LongFormHeader(noteEvent: LongTextNoteEvent, note: Note, accountView title?.let { Text( text = it, - style = MaterialTheme.typography.body1, + style = MaterialTheme.typography.bodyLarge, modifier = Modifier .fillMaxWidth() .padding(start = 10.dp, end = 10.dp, top = 10.dp) @@ -3814,7 +3812,7 @@ private fun LongFormHeader(noteEvent: LongTextNoteEvent, note: Note, accountView summary?.let { Text( text = it, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, modifier = Modifier .fillMaxWidth() .padding(start = 10.dp, end = 10.dp, bottom = 10.dp), @@ -3840,7 +3838,7 @@ private fun RenderClassifieds(noteEvent: ClassifiedsEvent, note: Note, accountVi .clip(shape = QuoteBorder) .border( 1.dp, - MaterialTheme.colors.subtleBorder, + MaterialTheme.colorScheme.subtleBorder, QuoteBorder ) ) { @@ -3863,7 +3861,7 @@ private fun RenderClassifieds(noteEvent: ClassifiedsEvent, note: Note, accountVi title?.let { Text( text = it, - style = MaterialTheme.typography.body1, + style = MaterialTheme.typography.bodyLarge, maxLines = 1, modifier = Modifier.weight(1f) ) @@ -3883,7 +3881,7 @@ private fun RenderClassifieds(noteEvent: ClassifiedsEvent, note: Note, accountVi Text( text = priceTag, maxLines = 1, - color = MaterialTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, fontWeight = FontWeight.Bold, modifier = remember { Modifier @@ -3900,7 +3898,7 @@ private fun RenderClassifieds(noteEvent: ClassifiedsEvent, note: Note, accountVi summary?.let { Text( text = it, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, modifier = Modifier .weight(1f), color = Color.Gray, @@ -3912,7 +3910,7 @@ private fun RenderClassifieds(noteEvent: ClassifiedsEvent, note: Note, accountVi location?.let { Text( text = it, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, color = Color.Gray, maxLines = 1, overflow = TextOverflow.Ellipsis, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt index cdae0628a..536616507 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.IntrinsicSize +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight @@ -15,16 +16,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.AlertDialog -import androidx.compose.material.Button -import androidx.compose.material.ButtonColors -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Card -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.TextButton import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AlternateEmail import androidx.compose.material.icons.filled.Block @@ -35,6 +26,17 @@ import androidx.compose.material.icons.filled.PersonAdd import androidx.compose.material.icons.filled.PersonRemove import androidx.compose.material.icons.filled.Report import androidx.compose.material.icons.filled.Share +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonColors +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf @@ -65,6 +67,7 @@ import com.vitorpamplona.amethyst.ui.components.SelectTextDialog import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.ReportNoteDialog import com.vitorpamplona.amethyst.ui.theme.WarningColor +import com.vitorpamplona.amethyst.ui.theme.isLight import com.vitorpamplona.amethyst.ui.theme.secondaryButtonBackground import com.vitorpamplona.quartz.events.AudioTrackEvent import com.vitorpamplona.quartz.events.FileHeaderEvent @@ -177,15 +180,15 @@ private fun RenderMainPopup( showReportDialog: MutableState ) { val context = LocalContext.current - val primaryLight = lightenColor(MaterialTheme.colors.primary, 0.1f) + val primaryLight = lightenColor(MaterialTheme.colorScheme.primary, 0.1f) val cardShape = RoundedCornerShape(5.dp) val clipboardManager = LocalClipboardManager.current val scope = rememberCoroutineScope() - val backgroundColor = if (MaterialTheme.colors.isLight) { - MaterialTheme.colors.primary + val backgroundColor = if (MaterialTheme.colorScheme.isLight) { + MaterialTheme.colorScheme.primary } else { - MaterialTheme.colors.secondaryButtonBackground + MaterialTheme.colorScheme.secondaryButtonBackground } val showToast = { stringResource: Int -> @@ -205,7 +208,7 @@ private fun RenderMainPopup( Card( modifier = Modifier.shadow(elevation = 6.dp, shape = cardShape), shape = cardShape, - backgroundColor = backgroundColor + colors = CardDefaults.cardColors(containerColor = backgroundColor) ) { Column(modifier = Modifier.width(IntrinsicSize.Min)) { Row(modifier = Modifier.height(IntrinsicSize.Min)) { @@ -413,7 +416,7 @@ private fun BlockAlertDialog(note: Note, accountViewModel: AccountViewModel, onD buttonIcon = Icons.Default.Block, buttonText = stringResource(R.string.quick_action_block_dialog_btn), buttonColors = ButtonDefaults.buttonColors( - backgroundColor = WarningColor, + containerColor = WarningColor, contentColor = Color.White ), onClickDoOnce = { @@ -503,7 +506,7 @@ fun QuickActionAlertDialog( text = { Text(textContent) }, - buttons = { + confirmButton = { Row( modifier = Modifier .padding(all = 8.dp) @@ -513,7 +516,7 @@ fun QuickActionAlertDialog( TextButton(onClick = onClickDontShowAgain) { Text(stringResource(R.string.quick_action_dont_show_again_button)) } - Button(onClick = onClickDoOnce, colors = buttonColors) { + Button(onClick = onClickDoOnce, colors = buttonColors, contentPadding = PaddingValues(horizontal = 16.dp)) { Row( verticalAlignment = Alignment.CenterVertically ) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt index 8aa87ba15..1f5eb03cb 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt @@ -3,10 +3,10 @@ package com.vitorpamplona.amethyst.ui.note import android.widget.Toast import androidx.compose.foundation.* import androidx.compose.foundation.layout.* -import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Bolt import androidx.compose.material.icons.outlined.Bolt +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.Alignment @@ -128,7 +128,7 @@ private fun OptionNote( val color = if (poolOption.consensusThreadhold) { Color.Green.copy(alpha = 0.32f) } else { - MaterialTheme.colors.mediumImportanceLink + MaterialTheme.colorScheme.mediumImportanceLink } ZapVote( @@ -252,7 +252,7 @@ private fun RenderOptionBeforeVote( .clip(shape = QuoteBorder) .border( 2.dp, - MaterialTheme.colors.primary, + MaterialTheme.colorScheme.primary, QuoteBorder ) ) { @@ -458,7 +458,7 @@ fun ZapVote( imageVector = Icons.Outlined.Bolt, contentDescription = stringResource(id = R.string.zaps), modifier = Modifier.size(20.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } else { Spacer(Modifier.width(3.dp)) @@ -479,7 +479,7 @@ fun ZapVote( Text( text = amountStr, fontSize = Font14SP, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, modifier = modifier ) } @@ -543,7 +543,7 @@ fun FilteredZapAmountChoicePopup( shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index 1384d13a5..8896cb0ca 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -29,16 +29,16 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LinearProgressIndicator -import androidx.compose.material.MaterialTheme -import androidx.compose.material.ProgressIndicatorDefaults -import androidx.compose.material.Text import androidx.compose.material.ripple.rememberRipple +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LinearProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ProgressIndicatorDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.LaunchedEffect @@ -172,7 +172,7 @@ private fun InnerReactionRow( ) { val (value, elapsed) = measureTimedValue { Row(verticalAlignment = CenterVertically) { - ReplyReactionWithDialog(baseNote, MaterialTheme.colors.placeholderText, accountViewModel, nav) + ReplyReactionWithDialog(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav) } } Log.d("Rendering Metrics", "Reaction Reply: ${baseNote.event?.content()?.split("\n")?.getOrNull(0)?.take(15)}.. $elapsed") @@ -186,7 +186,7 @@ private fun InnerReactionRow( Row(verticalAlignment = CenterVertically) { BoostWithDialog( baseNote, - MaterialTheme.colors.placeholderText, + MaterialTheme.colorScheme.placeholderText, accountViewModel, nav ) @@ -201,7 +201,7 @@ private fun InnerReactionRow( ) { val (value, elapsed) = measureTimedValue { Row(verticalAlignment = CenterVertically) { - LikeReaction(baseNote, MaterialTheme.colors.placeholderText, accountViewModel, nav) + LikeReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav) } } Log.d("Rendering Metrics", "Reaction Likes: ${baseNote.event?.content()?.split("\n")?.getOrNull(0)?.take(15)}.. $elapsed") @@ -213,7 +213,7 @@ private fun InnerReactionRow( ) { val (value, elapsed) = measureTimedValue { Row(verticalAlignment = CenterVertically) { - ZapReaction(baseNote, MaterialTheme.colors.placeholderText, accountViewModel, nav = nav) + ZapReaction(baseNote, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav = nav) } } Log.d("Rendering Metrics", "Reaction Zaps: ${baseNote.event?.content()?.split("\n")?.getOrNull(0)?.take(15)}.. $elapsed") @@ -227,8 +227,8 @@ private fun InnerReactionRow( Row(verticalAlignment = CenterVertically) { ViewCountReaction( note = baseNote, - grayTint = MaterialTheme.colors.placeholderText, - viewCountColorFilter = MaterialTheme.colors.placeholderTextColorFilter + grayTint = MaterialTheme.colorScheme.placeholderText, + viewCountColorFilter = MaterialTheme.colorScheme.placeholderTextColorFilter ) } } @@ -285,7 +285,7 @@ fun RenderZapRaiser(baseNote: Note, zapraiserAmount: Long, details: Boolean, acc val color = if (zapraiserStatus.progress > 0.99) { DarkerGreen } else { - MaterialTheme.colors.mediumImportanceLink + MaterialTheme.colorScheme.mediumImportanceLink } LinearProgressIndicator( @@ -310,7 +310,7 @@ fun RenderZapRaiser(baseNote: Note, zapraiserAmount: Long, details: Boolean, acc Text( text = stringResource(id = R.string.sats_to_complete, totalPercentage, zapraiserStatus.left), modifier = NoSoTinyBorders, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, fontSize = Font14SP, maxLines = 1 ) @@ -389,7 +389,7 @@ private fun ReactionDetailGallery( nav: (String) -> Unit, accountViewModel: AccountViewModel ) { - val defaultBackgroundColor = MaterialTheme.colors.background + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } val hasReactions by baseNote.live().hasReactions.observeAsState( @@ -1306,7 +1306,7 @@ private fun BoostTypeChoicePopup(baseNote: Note, iconSize: Dp, accountViewModel: shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(stringResource(R.string.boost), color = Color.White, textAlign = TextAlign.Center) @@ -1318,7 +1318,7 @@ private fun BoostTypeChoicePopup(baseNote: Note, iconSize: Dp, accountViewModel: shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(stringResource(R.string.quote), color = Color.White, textAlign = TextAlign.Center) @@ -1387,10 +1387,9 @@ private fun ActionableReactionButton( onDismiss() }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ) + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ) ) { val thisModifier = remember(reactionType) { Modifier.combinedClickable( @@ -1507,7 +1506,7 @@ fun ZapAmountChoicePopup( shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayCompose.kt index 077b3e6e8..ae9974ca3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayCompose.kt @@ -5,11 +5,11 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue @@ -73,7 +73,7 @@ fun RelayCompose( Text( "${relay.counter} ${stringResource(R.string.posts_received)}", - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, overflow = TextOverflow.Ellipsis ) @@ -117,10 +117,9 @@ fun AddRelayButton(onClick: () -> Unit) { modifier = Modifier.padding(horizontal = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(id = R.string.add), color = Color.White) @@ -133,10 +132,9 @@ fun RemoveRelayButton(onClick: () -> Unit) { modifier = Modifier.padding(horizontal = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.remove), color = Color.White) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListBox.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListBox.kt index 58bac1021..4df1037de 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListBox.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListBox.kt @@ -5,11 +5,11 @@ import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ExpandMore +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.derivedStateOf @@ -88,7 +88,7 @@ private fun ShowMoreRelaysButton(onClick: () -> Unit) { imageVector = Icons.Default.ExpandMore, null, modifier = ShowMoreRelaysButtonIconModifier, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt index dfa129ccb..da119f789 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt @@ -10,12 +10,12 @@ import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ChevronRight import androidx.compose.material.ripple.rememberRipple +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue @@ -102,7 +102,7 @@ fun ChatRelayExpandButton(onClick: () -> Unit) { imageVector = Icons.Default.ChevronRight, null, modifier = Size15Modifier, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } @@ -125,6 +125,7 @@ fun RenderRelay(relay: RelayBriefInfo, accountViewModel: AccountViewModel, nav: val context = LocalContext.current val scope = rememberCoroutineScope() + val interactionSource = remember { MutableInteractionSource() } val ripple = rememberRipple(bounded = false, radius = Size15dp) @@ -182,7 +183,7 @@ fun RenderRelay(relay: RelayBriefInfo, accountViewModel: AccountViewModel, nav: @Composable fun RenderRelayIcon(iconUrl: String, loadProfilePicture: Boolean, size: Dp = Size13dp) { - val backgroundColor = MaterialTheme.colors.background + val backgroundColor = MaterialTheme.colorScheme.background val iconModifier = remember { Modifier diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt index 9d299117b..5c1a168e3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReplyInformation.kt @@ -4,9 +4,9 @@ import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -73,7 +73,7 @@ private fun ReplyInformation( Text( stringResource(R.string.replying_to), fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) repliesToDisplay.forEachIndexed { idx, user -> @@ -84,13 +84,13 @@ private fun ReplyInformation( Text( ", ", fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } else if (idx < repliesToDisplay.size - 1) { Text( stringResource(R.string.and), fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } } else { @@ -98,25 +98,25 @@ private fun ReplyInformation( Text( ", ", fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } else if (idx < repliesToDisplay.size) { Text( stringResource(R.string.and), fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) ClickableText( AnnotatedString("${sortedMentions.size - 2}"), - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.lessImportantLink, fontSize = 13.sp), + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.lessImportantLink, fontSize = 13.sp), onClick = { expanded = true } ) Text( " ${stringResource(R.string.others)}", fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } } @@ -176,7 +176,7 @@ fun ReplyInformationChannel( Text( stringResource(id = R.string.replying_to), fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) mentions.forEachIndexed { idx, user -> @@ -186,13 +186,13 @@ fun ReplyInformationChannel( Text( ", ", fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } else if (idx < mentions.size - 1) { Text( " ${stringResource(id = R.string.and)} ", fontSize = 13.sp, - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } } @@ -213,7 +213,7 @@ private fun ReplyInfoMention( clickablePart = remember(innerUserState) { "$prefix${innerUserState?.user?.toBestDisplayName()}" }, tags = remember(innerUserState) { innerUserState?.user?.info?.latestMetadata?.tags?.toImmutableListOfLists() }, style = LocalTextStyle.current.copy( - color = MaterialTheme.colors.lessImportantLink, + color = MaterialTheme.colorScheme.lessImportantLink, fontSize = 13.sp ), onClick = { onUserTagClick(user) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt index b2705c9cb..13d239407 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth @@ -19,13 +20,13 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -212,7 +213,7 @@ fun UpdateReactionTypeDialog( placeholder = { Text( text = "\uD83D\uDCAF, \uD83C\uDF89, \uD83D\uDC4E", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true, @@ -225,7 +226,7 @@ fun UpdateReactionTypeDialog( onClick = { postViewModel.addChoice() }, shape = ButtonBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(text = stringResource(R.string.add), color = Color.White) @@ -254,11 +255,12 @@ private fun RenderReactionOption( modifier = Modifier.padding(horizontal = 3.dp), shape = ButtonBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ), onClick = { postViewModel.removeChoice(reactionType) - } + }, + contentPadding = PaddingValues(horizontal = 5.dp) ) { if (reactionType.startsWith(":")) { val noStartColon = reactionType.removePrefix(":") @@ -331,7 +333,7 @@ private fun EmojiSelector(accountViewModel: AccountViewModel, nav: (String) -> U @Composable fun EmojiCollectionGallery(emojiCollections: List, accountViewModel: AccountViewModel, nav: (String) -> Unit, onClick: ((EmojiUrl) -> Unit)? = null) { - val color = MaterialTheme.colors.background + val color = MaterialTheme.colorScheme.background val bgColor = remember { mutableStateOf(color) } val listState = rememberLazyListState() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt index 526ab3417..6c2a6a09f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt @@ -27,18 +27,18 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Visibility import androidx.compose.material.icons.outlined.VisibilityOff +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -288,7 +288,7 @@ fun UpdateZapAmountDialog( modifier = Modifier.padding(horizontal = 3.dp), shape = ButtonBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ), onClick = { postViewModel.removeAmount(amountInSats) @@ -330,7 +330,7 @@ fun UpdateZapAmountDialog( placeholder = { Text( text = "100, 1000, 5000", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true, @@ -343,7 +343,7 @@ fun UpdateZapAmountDialog( onClick = { postViewModel.addAmount() }, shape = ButtonBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(text = stringResource(R.string.add), color = Color.White) @@ -418,7 +418,7 @@ fun UpdateZapAmountDialog( painter = painterResource(R.drawable.ic_qrcode), null, modifier = Modifier.size(24.dp), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } } @@ -432,7 +432,7 @@ fun UpdateZapAmountDialog( Text( stringResource(id = R.string.wallet_connect_service_explainer), Modifier.weight(1f), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, fontSize = Font14SP ) } @@ -471,7 +471,7 @@ fun UpdateZapAmountDialog( placeholder = { Text( text = "npub, hex", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true, @@ -493,7 +493,7 @@ fun UpdateZapAmountDialog( placeholder = { Text( text = "wss://relay.server.com", - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) }, @@ -537,7 +537,7 @@ fun UpdateZapAmountDialog( placeholder = { Text( text = stringResource(R.string.wallet_connect_service_secret_placeholder), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, trailingIcon = { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt index 32b53d4ba..19f0f108f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt @@ -4,7 +4,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding -import androidx.compose.material.Divider +import androidx.compose.material3.Divider import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt index 9d5f312c0..3b3879f2f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt @@ -10,12 +10,12 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Divider -import androidx.compose.material.DropdownMenu -import androidx.compose.material.DropdownMenuItem -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.ripple.rememberRipple +import androidx.compose.material3.Divider +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.LaunchedEffect @@ -97,7 +97,7 @@ fun NoteAuthorPicture( @Composable fun DisplayBlankAuthor(size: Dp, modifier: Modifier = Modifier) { - val backgroundColor = MaterialTheme.colors.background + val backgroundColor = MaterialTheme.colorScheme.background val nullModifier = remember { modifier @@ -324,7 +324,7 @@ fun PictureAndFollowingMark( modifier: Modifier, accountViewModel: AccountViewModel ) { - val backgroundColor = MaterialTheme.colors.background + val backgroundColor = MaterialTheme.colorScheme.background val myImageModifier = remember { modifier .size(size) @@ -430,6 +430,9 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi if (!state.isFollowingAuthor) { DropdownMenuItem( + text = { + Text(stringResource(R.string.follow)) + }, onClick = { val author = note.author ?: return@DropdownMenuItem scope.launch(Dispatchers.IO) { @@ -437,63 +440,77 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi onDismiss() } } - ) { - Text(stringResource(R.string.follow)) - } + ) Divider() } DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_text)) + }, onClick = { scope.launch(Dispatchers.IO) { clipboardManager.setText(AnnotatedString(accountViewModel.decrypt(note) ?: "")) onDismiss() } } - ) { - Text(stringResource(R.string.copy_text)) - } + ) DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_user_pubkey)) + }, onClick = { scope.launch(Dispatchers.IO) { clipboardManager.setText(AnnotatedString("nostr:${note.author?.pubkeyNpub()}")) onDismiss() } } - ) { - Text(stringResource(R.string.copy_user_pubkey)) - } - DropdownMenuItem(onClick = { - scope.launch(Dispatchers.IO) { - clipboardManager.setText(AnnotatedString("nostr:" + note.toNEvent())) + ) + DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_note_id)) + }, + onClick = { + scope.launch(Dispatchers.IO) { + clipboardManager.setText(AnnotatedString("nostr:" + note.toNEvent())) + onDismiss() + } + } + ) + DropdownMenuItem( + text = { + Text(stringResource(R.string.quick_action_share)) + }, + onClick = { + val sendIntent = Intent().apply { + action = Intent.ACTION_SEND + type = "text/plain" + putExtra( + Intent.EXTRA_TEXT, + externalLinkForNote(note) + ) + putExtra(Intent.EXTRA_TITLE, actContext.getString(R.string.quick_action_share_browser_link)) + } + + val shareIntent = Intent.createChooser(sendIntent, appContext.getString(R.string.quick_action_share)) + ContextCompat.startActivity(actContext, shareIntent, null) onDismiss() } - }) { - Text(stringResource(R.string.copy_note_id)) - } - DropdownMenuItem(onClick = { - val sendIntent = Intent().apply { - action = Intent.ACTION_SEND - type = "text/plain" - putExtra( - Intent.EXTRA_TEXT, - externalLinkForNote(note) - ) - putExtra(Intent.EXTRA_TITLE, actContext.getString(R.string.quick_action_share_browser_link)) - } - - val shareIntent = Intent.createChooser(sendIntent, appContext.getString(R.string.quick_action_share)) - ContextCompat.startActivity(actContext, shareIntent, null) - onDismiss() - }) { - Text(stringResource(R.string.quick_action_share)) - } + ) Divider() - DropdownMenuItem(onClick = { scope.launch(Dispatchers.IO) { accountViewModel.broadcast(note); onDismiss() } }) { - Text(stringResource(R.string.broadcast)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.broadcast)) + }, + onClick = { + scope.launch(Dispatchers.IO) { accountViewModel.broadcast(note); onDismiss() } + } + ) Divider() if (state.isPrivateBookmarkNote) { DropdownMenuItem( + text = { + Text(stringResource(R.string.remove_from_private_bookmarks)) + }, onClick = { scope.launch(Dispatchers.IO) { if (accountViewModel.loggedInWithExternalSigner()) { @@ -511,11 +528,12 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi } } } - ) { - Text(stringResource(R.string.remove_from_private_bookmarks)) - } + ) } else { DropdownMenuItem( + text = { + Text(stringResource(R.string.add_to_private_bookmarks)) + }, onClick = { scope.launch(Dispatchers.IO) { if (accountViewModel.loggedInWithExternalSigner()) { @@ -533,12 +551,13 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi } } } - ) { - Text(stringResource(R.string.add_to_private_bookmarks)) - } + ) } if (state.isPublicBookmarkNote) { DropdownMenuItem( + text = { + Text(stringResource(R.string.remove_from_public_bookmarks)) + }, onClick = { scope.launch(Dispatchers.IO) { if (accountViewModel.loggedInWithExternalSigner()) { @@ -559,11 +578,12 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi } } } - ) { - Text(stringResource(R.string.remove_from_public_bookmarks)) - } + ) } else { DropdownMenuItem( + text = { + Text(stringResource(R.string.add_to_public_bookmarks)) + }, onClick = { scope.launch(Dispatchers.IO) { if (accountViewModel.loggedInWithExternalSigner()) { @@ -584,35 +604,48 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi } } } - ) { - Text(stringResource(R.string.add_to_public_bookmarks)) - } + ) } Divider() if (state.showSensitiveContent == null || state.showSensitiveContent == true) { - DropdownMenuItem(onClick = { scope.launch(Dispatchers.IO) { accountViewModel.hideSensitiveContent(); onDismiss() } }) { - Text(stringResource(R.string.content_warning_hide_all_sensitive_content)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.content_warning_hide_all_sensitive_content)) + }, + onClick = { scope.launch(Dispatchers.IO) { accountViewModel.hideSensitiveContent(); onDismiss() } } + ) } if (state.showSensitiveContent == null || state.showSensitiveContent == false) { - DropdownMenuItem(onClick = { scope.launch(Dispatchers.IO) { accountViewModel.disableContentWarnings(); onDismiss() } }) { - Text(stringResource(R.string.content_warning_show_all_sensitive_content)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.content_warning_show_all_sensitive_content)) + }, + onClick = { scope.launch(Dispatchers.IO) { accountViewModel.disableContentWarnings(); onDismiss() } } + ) } if (state.showSensitiveContent != null) { - DropdownMenuItem(onClick = { scope.launch(Dispatchers.IO) { accountViewModel.seeContentWarnings(); onDismiss() } }) { - Text(stringResource(R.string.content_warning_see_warnings)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.content_warning_see_warnings)) + }, + onClick = { scope.launch(Dispatchers.IO) { accountViewModel.seeContentWarnings(); onDismiss() } } + ) } Divider() if (state.isLoggedUser) { - DropdownMenuItem(onClick = { scope.launch(Dispatchers.IO) { accountViewModel.delete(note); onDismiss() } }) { - Text(stringResource(R.string.request_deletion)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.request_deletion)) + }, + onClick = { scope.launch(Dispatchers.IO) { accountViewModel.delete(note); onDismiss() } } + ) } else { - DropdownMenuItem(onClick = { reportDialogShowing = true }) { - Text(stringResource(R.string.block_report)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.block_report)) + }, + onClick = { reportDialogShowing = true } + ) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt index 45418fadd..2a7c51e73 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt @@ -6,12 +6,12 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Bolt import androidx.compose.material.icons.filled.ExpandMore +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.collectAsState @@ -87,7 +87,7 @@ fun UserReactionsRow( imageVector = Icons.Default.ExpandMore, null, modifier = Size20Modifier, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt index c723cf10e..ae8f1d948 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt @@ -5,9 +5,9 @@ import android.util.Log import androidx.compose.animation.Crossfade import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue @@ -52,9 +52,7 @@ fun UsernameDisplay(baseUser: User, weight: Modifier = Modifier, showPlayButton: } } - val userMetadata by baseUser.live().metadata.map { - it.user.info - }.observeAsState(baseUser.info) + val userMetadata by baseUser.live().userMetadataInfo.observeAsState(baseUser.info) Crossfade(targetState = userMetadata, modifier = weight) { if (it != null) { @@ -148,7 +146,7 @@ private fun UserAndUsernameDisplay( CreateTextWithEmoji( text = remember { "@$bestUserName" }, tags = tags, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, overflow = TextOverflow.Ellipsis, @@ -173,7 +171,7 @@ fun DrawPlayName(name: String) { @Composable fun DrawPlayNameIcon(onClick: () -> Unit) { IconButton(onClick = onClick, modifier = StdButtonSizeModifier) { - PlayIcon(modifier = StdButtonSizeModifier, tint = MaterialTheme.colors.placeholderText) + PlayIcon(modifier = StdButtonSizeModifier, tint = MaterialTheme.colorScheme.placeholderText) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt index 5acecbbf0..546d80141 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt @@ -5,18 +5,18 @@ import android.content.Intent import android.net.Uri import androidx.compose.foundation.layout.* import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.AlertDialog -import androidx.compose.material.Button -import androidx.compose.material.ButtonColors -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TextButton import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Done +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonColors +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -170,7 +170,7 @@ fun ZapCustomDialog( placeholder = { Text( text = "100, 1000, 5000", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true, @@ -220,7 +220,7 @@ fun ZapCustomDialog( placeholder = { Text( text = stringResource(id = R.string.custom_zaps_add_a_message_example), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, singleLine = true, @@ -239,10 +239,9 @@ fun ZapButton(isActive: Boolean, onPost: () -> Unit) { Button( onClick = { onPost() }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray - ) + colors = ButtonDefaults.buttonColors( + containerColor = if (isActive) MaterialTheme.colorScheme.primary else Color.Gray + ) ) { Text(text = "⚡Zap ", color = Color.White) } @@ -264,7 +263,7 @@ fun ErrorMessageDialog( text = { Text(textContent) }, - buttons = { + confirmButton = { Row( modifier = Modifier .padding(all = 8.dp) @@ -409,10 +408,9 @@ fun PayButton(isActive: Boolean, modifier: Modifier = Modifier, onPost: () -> Un onPost() }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray - ), + colors = ButtonDefaults.buttonColors( + containerColor = if (isActive) MaterialTheme.colorScheme.primary else Color.Gray + ), contentPadding = PaddingValues(0.dp) ) { if (isActive) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt index 3d4319459..f2b34a2d5 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt @@ -6,9 +6,9 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf @@ -261,7 +261,7 @@ fun AboutDisplay(baseAuthor: User) { Text( userAboutMe, - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, overflow = TextOverflow.Ellipsis ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapUserSetCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapUserSetCompose.kt index 4d6acb69e..51e40ec09 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapUserSetCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapUserSetCompose.kt @@ -9,8 +9,8 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -35,9 +35,9 @@ import kotlinx.coroutines.launch @Composable fun ZapUserSetCompose(zapSetCard: ZapUserSetCard, isInnerNote: Boolean = false, routeForLastRead: String, accountViewModel: AccountViewModel, nav: (String) -> Unit) { - val defaultBackgroundColor = MaterialTheme.colors.background + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } - val newItemColor = MaterialTheme.colors.newItemBackgroundColor + val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor LaunchedEffect(key1 = zapSetCard.createdAt()) { launch(Dispatchers.IO) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/QrCodeDrawer.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/QrCodeDrawer.kt index ac9669c6f..31e0cdfed 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/QrCodeDrawer.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/QrCodeDrawer.kt @@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -34,13 +34,13 @@ fun QrCodeDrawer(contents: String, modifier: Modifier = Modifier) { createQrCode(contents = contents) } - val foregroundColor = MaterialTheme.colors.onSurface + val foregroundColor = MaterialTheme.colorScheme.onSurface Box( modifier = modifier .defaultMinSize(48.dp, 48.dp) .aspectRatio(1f) - .background(MaterialTheme.colors.background) + .background(MaterialTheme.colorScheme.background) ) { Canvas(modifier = Modifier.fillMaxSize()) { // Calculate the height and width of each column/row diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/ShowQRDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/ShowQRDialog.kt index 6a03be50f..57832f1f7 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/ShowQRDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/qrcode/ShowQRDialog.kt @@ -12,11 +12,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -51,7 +51,7 @@ fun ShowQRDialog(user: User, loadProfilePicture: Boolean, onScan: (String) -> Un Surface(modifier = Modifier.fillMaxSize()) { Column( modifier = Modifier - .background(MaterialTheme.colors.background) + .background(MaterialTheme.colorScheme.background) .fillMaxSize() ) { Row( @@ -81,8 +81,8 @@ fun ShowQRDialog(user: User, loadProfilePicture: Boolean, onScan: (String) -> Un .width(100.dp) .height(100.dp) .clip(shape = CircleShape) - .border(3.dp, MaterialTheme.colors.background, CircleShape) - .background(MaterialTheme.colors.background), + .border(3.dp, MaterialTheme.colorScheme.background, CircleShape) + .background(MaterialTheme.colorScheme.background), loadProfilePicture = loadProfilePicture ) } @@ -119,7 +119,7 @@ fun ShowQRDialog(user: User, loadProfilePicture: Boolean, onScan: (String) -> Un .height(50.dp), colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ) ) { Text(text = stringResource(R.string.scan_qr)) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedView.kt index e35a1fcb0..0ad831d9c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedView.kt @@ -13,10 +13,9 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.pullrefresh.PullRefreshIndicator -import androidx.compose.material.pullrefresh.pullRefresh -import androidx.compose.material.pullrefresh.rememberPullRefreshState +import androidx.compose.material3.pullrefresh.PullRefreshIndicator +import androidx.compose.material3.pullrefresh.pullRefresh +import androidx.compose.material3.pullrefresh.rememberPullRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -36,7 +35,6 @@ import com.vitorpamplona.amethyst.ui.note.NoteCompose import com.vitorpamplona.amethyst.ui.note.ZapUserSetCompose import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -@OptIn(ExperimentalMaterialApi::class) @Composable fun RefresheableCardView( viewModel: CardFeedViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomFeedView.kt index 2c8f66d92..038099834 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ChatroomFeedView.kt @@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.material.Divider -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt index 9dd16fc50..6a3de2700 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt @@ -16,13 +16,12 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Button -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.OutlinedButton -import androidx.compose.material.Text -import androidx.compose.material.pullrefresh.PullRefreshIndicator -import androidx.compose.material.pullrefresh.pullRefresh -import androidx.compose.material.pullrefresh.rememberPullRefreshState +import androidx.compose.material3.Button +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text +import androidx.compose.material3.pullrefresh.PullRefreshIndicator +import androidx.compose.material3.pullrefresh.pullRefresh +import androidx.compose.material3.pullrefresh.rememberPullRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState @@ -54,7 +53,6 @@ fun RefresheableFeedView( } } -@OptIn(ExperimentalMaterialApi::class) @Composable fun RefresheableView( viewModel: InvalidatableViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt index e3cdcf7fa..df499ff45 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt @@ -6,10 +6,9 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.pullrefresh.PullRefreshIndicator -import androidx.compose.material.pullrefresh.pullRefresh -import androidx.compose.material.pullrefresh.rememberPullRefreshState +import androidx.compose.material3.pullrefresh.PullRefreshIndicator +import androidx.compose.material3.pullrefresh.pullRefresh +import androidx.compose.material3.pullrefresh.rememberPullRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -102,7 +101,6 @@ class RelayFeedViewModel : ViewModel() { } } -@OptIn(ExperimentalMaterialApi::class) @Composable fun RelayFeedView( viewModel: RelayFeedViewModel, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/StringFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/StringFeedView.kt index 5266a3d89..9cf68a8c9 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/StringFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/StringFeedView.kt @@ -9,8 +9,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.OutlinedButton -import androidx.compose.material.Text +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt index 99a4d1ef5..f117decfc 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt @@ -18,18 +18,17 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Divider -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.ProvideTextStyle -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.MoreVert -import androidx.compose.material.pullrefresh.PullRefreshIndicator -import androidx.compose.material.pullrefresh.pullRefresh -import androidx.compose.material.pullrefresh.rememberPullRefreshState +import androidx.compose.material3.Divider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ProvideTextStyle +import androidx.compose.material3.Text +import androidx.compose.material3.pullrefresh.PullRefreshIndicator +import androidx.compose.material3.pullrefresh.pullRefresh +import androidx.compose.material3.pullrefresh.rememberPullRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState @@ -92,7 +91,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -@OptIn(ExperimentalMaterialApi::class) @Composable fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: AccountViewModel, nav: (String) -> Unit) { val feedState by viewModel.feedContent.collectAsState() @@ -132,7 +130,7 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A } withContext(Dispatchers.Main) { - listState.animateScrollToItem(position) + listState.scrollToItem(position) } } } @@ -152,8 +150,8 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A item, modifier = Modifier.drawReplyLevel( item.replyLevel(), - MaterialTheme.colors.placeholderText, - if (item.idHex == noteId) MaterialTheme.colors.lessImportantLink else MaterialTheme.colors.placeholderText + MaterialTheme.colorScheme.placeholderText, + if (item.idHex == noteId) MaterialTheme.colorScheme.lessImportantLink else MaterialTheme.colorScheme.placeholderText ), accountViewModel = accountViewModel, nav = nav @@ -162,7 +160,7 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A } else { Column() { Row() { - val selectedNoteColor = MaterialTheme.colors.selectedNote + val selectedNoteColor = MaterialTheme.colorScheme.selectedNote val background = remember { if (item.idHex == noteId) mutableStateOf(selectedNoteColor) else null } @@ -171,8 +169,8 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A item, modifier = Modifier.drawReplyLevel( item.replyLevel(), - MaterialTheme.colors.placeholderText, - if (item.idHex == noteId) MaterialTheme.colors.lessImportantLink else MaterialTheme.colors.placeholderText + MaterialTheme.colorScheme.placeholderText, + if (item.idHex == noteId) MaterialTheme.colorScheme.lessImportantLink else MaterialTheme.colorScheme.placeholderText ), parentBackgroundColor = background, isBoostedNote = false, @@ -251,7 +249,7 @@ fun NoteMaster( var popupExpanded by remember { mutableStateOf(false) } - val defaultBackgroundColor = MaterialTheme.colors.background + val defaultBackgroundColor = MaterialTheme.colorScheme.background val backgroundColor = remember { mutableStateOf(defaultBackgroundColor) } if (noteEvent == null) { @@ -310,7 +308,7 @@ fun NoteMaster( Text( timeAgo(note.createdAt(), context = context), - color = MaterialTheme.colors.placeholderText, + color = MaterialTheme.colorScheme.placeholderText, maxLines = 1 ) @@ -322,7 +320,7 @@ fun NoteMaster( imageVector = Icons.Default.MoreVert, null, modifier = Modifier.size(15.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) NoteDropDownMenu(baseNote, moreActionsExpanded, accountViewModel) @@ -518,7 +516,7 @@ private fun RenderClassifiedsReaderForThread( title?.let { Text( text = it, - style = MaterialTheme.typography.body1, + style = MaterialTheme.typography.bodyLarge, maxLines = 1, modifier = Modifier.weight(1f) ) @@ -538,7 +536,7 @@ private fun RenderClassifiedsReaderForThread( Text( text = priceTag, maxLines = 1, - color = MaterialTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, fontWeight = FontWeight.Bold, modifier = remember { Modifier @@ -557,7 +555,7 @@ private fun RenderClassifiedsReaderForThread( ) { Text( text = it, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, modifier = Modifier.weight(1f), color = Color.Gray, overflow = TextOverflow.Ellipsis @@ -572,7 +570,7 @@ private fun RenderClassifiedsReaderForThread( ) { Text( text = it, - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, color = Color.Gray, maxLines = 1, overflow = TextOverflow.Ellipsis diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountBackupDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountBackupDialog.kt index 05bde8aa8..c9d580917 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountBackupDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountBackupDialog.kt @@ -17,14 +17,14 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Key +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment @@ -40,7 +40,7 @@ import androidx.compose.ui.window.DialogProperties import androidx.fragment.app.FragmentActivity import com.halilibo.richtext.markdown.Markdown import com.halilibo.richtext.ui.RichTextStyle -import com.halilibo.richtext.ui.material.MaterialRichText +import com.halilibo.richtext.ui.material3.Material3RichText import com.halilibo.richtext.ui.resolveDefaults import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.model.Account @@ -60,7 +60,7 @@ fun AccountBackupDialog(account: Account, onClose: () -> Unit) { Surface(modifier = Modifier.fillMaxSize()) { Column( modifier = Modifier - .background(MaterialTheme.colors.background) + .background(MaterialTheme.colorScheme.background) .fillMaxSize() ) { Row( @@ -80,7 +80,7 @@ fun AccountBackupDialog(account: Account, onClose: () -> Unit) { horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { - MaterialRichText( + Material3RichText( style = RichTextStyle().resolveDefaults() ) { Markdown( @@ -126,17 +126,17 @@ private fun NSecCopyButton( }, shape = ButtonBorder, colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + containerColor = MaterialTheme.colorScheme.primary ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Icon( - tint = MaterialTheme.colors.onPrimary, + tint = MaterialTheme.colorScheme.onPrimary, imageVector = Icons.Default.Key, contentDescription = stringResource(R.string.copies_the_nsec_id_your_password_to_the_clipboard_for_backup), modifier = Modifier.padding(end = 5.dp) ) - Text(stringResource(id = R.string.copy_my_secret_key), color = MaterialTheme.colors.onPrimary) + Text(stringResource(id = R.string.copy_my_secret_key), color = MaterialTheme.colorScheme.onPrimary) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 72f658dac..1f655684c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -37,6 +37,7 @@ import com.vitorpamplona.amethyst.ui.screen.CombinedZap import com.vitorpamplona.quartz.encoders.ATag import com.vitorpamplona.quartz.encoders.HexKey import com.vitorpamplona.quartz.encoders.Nip19 +import com.vitorpamplona.quartz.events.ChatroomKey import com.vitorpamplona.quartz.events.Event import com.vitorpamplona.quartz.events.GiftWrapEvent import com.vitorpamplona.quartz.events.ImmutableListOfLists @@ -739,6 +740,14 @@ class AccountViewModel(val account: Account) : ViewModel(), Dao { } } + fun createChatRoomFor(user: User, then: (Int) -> Unit) { + viewModelScope.launch(Dispatchers.IO) { + val withKey = ChatroomKey(persistentSetOf(user.pubkeyHex)) + account.userProfile().createChatroom(withKey) + then(withKey.hashCode()) + } + } + class Factory(val account: Account) : ViewModelProvider.Factory { override fun create(modelClass: Class): AccountViewModel { return AccountViewModel(account) as AccountViewModel diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt index a8040c539..becede4ac 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt @@ -6,10 +6,10 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Tab -import androidx.compose.material.TabRow -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Tab +import androidx.compose.material3.TabRow +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -54,7 +54,8 @@ fun BookmarkListScreen(accountViewModel: AccountViewModel, nav: (String) -> Unit val coroutineScope = rememberCoroutineScope() TabRow( - backgroundColor = MaterialTheme.colors.background, + containerColor = MaterialTheme.colorScheme.background, + contentColor = MaterialTheme.colorScheme.onBackground, selectedTabIndex = pagerState.currentPage, modifier = TabRowHeight ) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt index bda0d3dc9..83aeaf9f0 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt @@ -5,6 +5,7 @@ import androidx.compose.animation.animateContentSize import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsFocusedAsState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues @@ -21,25 +22,26 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.DropdownMenu -import androidx.compose.material.DropdownMenuItem -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.TextFieldColors -import androidx.compose.material.TextFieldDefaults -import androidx.compose.material.TextFieldDefaults.indicatorLine +import androidx.compose.foundation.text.selection.LocalTextSelectionColors import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Cancel import androidx.compose.material.icons.filled.EditNote import androidx.compose.material.icons.filled.Share +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextFieldColors +import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf @@ -48,6 +50,7 @@ import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -346,7 +349,7 @@ fun DisplayReplyingToNote( modifier = Modifier .padding(end = 5.dp) .size(30.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } @@ -381,7 +384,7 @@ fun EditFieldRow( placeholder = { Text( text = stringResource(R.string.reply_here), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content), @@ -397,7 +400,7 @@ fun EditFieldRow( leadingIcon = { UploadFromGallery( isUploading = channelScreenModel.isUploadingImage, - tint = MaterialTheme.colors.placeholderText, + tint = MaterialTheme.colorScheme.placeholderText, modifier = EditFieldLeadingIconModifier ) { val fileServer = if (isPrivate) { @@ -420,7 +423,7 @@ fun EditFieldRow( channelScreenModel.upload(it, "", false, fileServer, context) } }, - colors = TextFieldDefaults.textFieldColors( + colors = TextFieldDefaults.colors( focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent ) @@ -428,6 +431,7 @@ fun EditFieldRow( } } +@OptIn(ExperimentalMaterial3Api::class) @Composable fun MyTextField( value: TextFieldValue, @@ -440,6 +444,9 @@ fun MyTextField( placeholder: @Composable (() -> Unit)? = null, leadingIcon: @Composable (() -> Unit)? = null, trailingIcon: @Composable (() -> Unit)? = null, + prefix: @Composable (() -> Unit)? = null, + suffix: @Composable (() -> Unit)? = null, + supportingText: @Composable (() -> Unit)? = null, isError: Boolean = false, visualTransformation: VisualTransformation = VisualTransformation.None, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, @@ -448,22 +455,30 @@ fun MyTextField( maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, minLines: Int = 1, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, - shape: Shape = TextFieldDefaults.TextFieldShape, - colors: TextFieldColors = TextFieldDefaults.textFieldColors() + shape: Shape = TextFieldDefaults.shape, + colors: TextFieldColors = TextFieldDefaults.colors() ) { - // If color is not provided via the text style, use content color as a default + // COPIED FROM TEXT FIELD + // The only change is the contentPadding below + val textColor = textStyle.color.takeOrElse { - colors.textColor(enabled).value + val focused by interactionSource.collectIsFocusedAsState() + + val targetValue = when { + !enabled -> MaterialTheme.colorScheme.placeholderText + isError -> MaterialTheme.colorScheme.onSurface + focused -> MaterialTheme.colorScheme.onSurface + else -> MaterialTheme.colorScheme.onSurface + } + + rememberUpdatedState(targetValue).value } val mergedTextStyle = textStyle.merge(TextStyle(color = textColor)) - @OptIn(ExperimentalMaterialApi::class) - ( + CompositionLocalProvider(LocalTextSelectionColors provides LocalTextSelectionColors.current) { BasicTextField( value = value, modifier = modifier - .background(colors.backgroundColor(enabled).value, shape) - .indicatorLine(enabled, isError, interactionSource, colors) .defaultMinSize( minWidth = TextFieldDefaults.MinWidth, minHeight = 36.dp @@ -472,7 +487,7 @@ fun MyTextField( enabled = enabled, readOnly = readOnly, textStyle = mergedTextStyle, - cursorBrush = SolidColor(colors.cursorColor(isError).value), + cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), visualTransformation = visualTransformation, keyboardOptions = keyboardOptions, keyboardActions = keyboardActions, @@ -481,8 +496,7 @@ fun MyTextField( maxLines = maxLines, minLines = minLines, decorationBox = @Composable { innerTextField -> - // places leading icon, text field with label and placeholder, trailing icon - TextFieldDefaults.TextFieldDecorationBox( + TextFieldDefaults.DecorationBox( value = value.text, visualTransformation = visualTransformation, innerTextField = innerTextField, @@ -490,21 +504,25 @@ fun MyTextField( label = label, leadingIcon = leadingIcon, trailingIcon = trailingIcon, + prefix = prefix, + suffix = suffix, + supportingText = supportingText, + shape = shape, singleLine = singleLine, enabled = enabled, isError = isError, interactionSource = interactionSource, colors = colors, - contentPadding = TextFieldDefaults.textFieldWithoutLabelPadding( - top = 12.dp, - bottom = 12.dp, + contentPadding = TextFieldDefaults.contentPaddingWithoutLabel( start = 10.dp, - end = 10.dp + top = 12.dp, + end = 10.dp, + bottom = 12.dp ) ) } ) - ) + } } @Composable @@ -766,7 +784,7 @@ fun LongChannelHeader( Modifier.weight(1f) ) { Row(verticalAlignment = Alignment.CenterVertically) { - val defaultBackground = MaterialTheme.colors.background + val defaultBackground = MaterialTheme.colorScheme.background val background = remember { mutableStateOf(defaultBackground) } @@ -912,12 +930,10 @@ private fun ShortChannelActionOptions( ) { LoadNote(baseNoteHex = channel.idHex, accountViewModel) { it?.let { - var popupExpanded by remember { mutableStateOf(false) } - Spacer(modifier = StdHorzSpacer) - LikeReaction(baseNote = it, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav) + LikeReaction(baseNote = it, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav) Spacer(modifier = StdHorzSpacer) - ZapReaction(baseNote = it, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav = nav) + ZapReaction(baseNote = it, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav = nav) Spacer(modifier = StdHorzSpacer) } } @@ -990,9 +1006,9 @@ private fun LiveChannelActionOptions( Spacer(modifier = StdHorzSpacer) } - LikeReaction(baseNote = it, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav) + LikeReaction(baseNote = it, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav) Spacer(modifier = StdHorzSpacer) - ZapReaction(baseNote = it, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel, nav = nav) + ZapReaction(baseNote = it, grayTint = MaterialTheme.colorScheme.onSurface, accountViewModel = accountViewModel, nav = nav) } } @@ -1072,10 +1088,9 @@ private fun NoteCopyButton( .width(50.dp), onClick = { popupExpanded = true }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.placeholderText - ) + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.placeholderText + ) ) { Icon( tint = Color.White, @@ -1089,9 +1104,12 @@ private fun NoteCopyButton( ) { val clipboardManager = LocalClipboardManager.current - DropdownMenuItem(onClick = { clipboardManager.setText(AnnotatedString("nostr:" + note.idNote())); popupExpanded = false }) { - Text(stringResource(R.string.copy_channel_id_note_to_the_clipboard)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_channel_id_note_to_the_clipboard)) + }, + onClick = { clipboardManager.setText(AnnotatedString("nostr:" + note.idNote())); popupExpanded = false } + ) } } } @@ -1112,10 +1130,9 @@ private fun EditButton(accountViewModel: AccountViewModel, channel: PublicChatCh .width(50.dp), onClick = { wantsToPost = true }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ) + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ) ) { Icon( tint = Color.White, @@ -1137,10 +1154,9 @@ fun JoinChatButton(accountViewModel: AccountViewModel, channel: Channel, nav: (S } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.join), color = Color.White) @@ -1159,10 +1175,9 @@ fun LeaveChatButton(accountViewModel: AccountViewModel, channel: Channel, nav: ( } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.leave), color = Color.White) @@ -1181,10 +1196,9 @@ fun JoinCommunityButton(accountViewModel: AccountViewModel, note: AddressableNot } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.join), color = Color.White) @@ -1203,10 +1217,9 @@ fun LeaveCommunityButton(accountViewModel: AccountViewModel, note: AddressableNo } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.leave), color = Color.White) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomListScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomListScreen.kt index 0051e737c..1ab24c005 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomListScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomListScreen.kt @@ -10,16 +10,16 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState -import androidx.compose.material.DropdownMenu -import androidx.compose.material.DropdownMenuItem -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Tab -import androidx.compose.material.TabRow -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Tab +import androidx.compose.material3.TabRow +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.Immutable @@ -96,7 +96,8 @@ fun ChatroomListScreen( ) { Box(Modifier.fillMaxWidth()) { TabRow( - backgroundColor = MaterialTheme.colors.background, + containerColor = MaterialTheme.colorScheme.background, + contentColor = MaterialTheme.colorScheme.onBackground, selectedTabIndex = pagerState.currentPage, modifier = TabRowHeight ) { @@ -123,7 +124,7 @@ fun ChatroomListScreen( Icon( imageVector = Icons.Default.MoreVert, contentDescription = null, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) ChatroomTabMenu( @@ -173,24 +174,33 @@ fun ChatroomTabMenu( onMarkNewAsRead: () -> Unit ) { DropdownMenu(expanded = expanded, onDismissRequest = onDismiss) { - DropdownMenuItem(onClick = { - onMarkKnownAsRead() - onDismiss() - }) { - Text(stringResource(R.string.mark_all_known_as_read)) - } - DropdownMenuItem(onClick = { - onMarkNewAsRead() - onDismiss() - }) { - Text(stringResource(R.string.mark_all_new_as_read)) - } - DropdownMenuItem(onClick = { - onMarkKnownAsRead() - onMarkNewAsRead() - onDismiss() - }) { - Text(stringResource(R.string.mark_all_as_read)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.mark_all_known_as_read)) + }, + onClick = { + onMarkKnownAsRead() + onDismiss() + } + ) + DropdownMenuItem( + text = { + Text(stringResource(R.string.mark_all_new_as_read)) + }, + onClick = { + onMarkNewAsRead() + onDismiss() + } + ) + DropdownMenuItem( + text = { + Text(stringResource(R.string.mark_all_as_read)) + }, + onClick = { + onMarkKnownAsRead() + onMarkNewAsRead() + onDismiss() + } + ) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt index 0ac3bf90d..7264426ac 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt @@ -19,19 +19,20 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.EditNote +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -329,6 +330,7 @@ fun ChatroomScreen( } } +@OptIn(ExperimentalMaterial3Api::class) @Composable fun PrivateMessageEditFieldRow( channelScreenModel: NewPostViewModel, @@ -356,10 +358,9 @@ fun PrivateMessageEditFieldRow( placeholder = { Text( text = stringResource(R.string.reply_here), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, - textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content), trailingIcon = { PostButton( onPost = { @@ -373,7 +374,7 @@ fun PrivateMessageEditFieldRow( Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 6.dp)) { UploadFromGallery( isUploading = channelScreenModel.isUploadingImage, - tint = MaterialTheme.colors.placeholderText, + tint = MaterialTheme.colorScheme.placeholderText, modifier = Modifier .size(30.dp) .padding(start = 2.dp) @@ -433,7 +434,7 @@ fun PrivateMessageEditFieldRow( modifier = Modifier .padding(top = 2.dp) .size(18.dp), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } else { Icon( @@ -442,13 +443,13 @@ fun PrivateMessageEditFieldRow( modifier = Modifier .padding(top = 2.dp) .size(18.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } } }, - colors = TextFieldDefaults.textFieldColors( + colors = TextFieldDefaults.colors( focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent ) @@ -598,10 +599,9 @@ private fun EditRoomSubjectButton(room: ChatroomKey, accountViewModel: AccountVi .width(50.dp), onClick = { wantsToPost = true }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ) + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ) ) { Icon( tint = Color.White, @@ -672,7 +672,7 @@ fun NewSubjectView(onClose: () -> Unit, accountViewModel: AccountViewModel, room placeholder = { Text( text = stringResource(R.string.messages_new_message_subject_caption), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -693,7 +693,7 @@ fun NewSubjectView(onClose: () -> Unit, accountViewModel: AccountViewModel, room placeholder = { Text( text = stringResource(R.string.messages_new_subject_message_placeholder), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ConnectOrbotDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ConnectOrbotDialog.kt index ceee975b6..d2abb8c28 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ConnectOrbotDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ConnectOrbotDialog.kt @@ -9,12 +9,12 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.rememberCoroutineScope @@ -31,7 +31,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import com.halilibo.richtext.markdown.Markdown -import com.halilibo.richtext.ui.material.MaterialRichText +import com.halilibo.richtext.ui.material3.Material3RichText import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.ui.actions.CloseButton import com.vitorpamplona.amethyst.ui.theme.ButtonBorder @@ -90,13 +90,13 @@ fun ConnectOrbotDialog(onClose: () -> Unit, onPost: () -> Unit, portNumber: Muta stringStyle = RichTextDefaults.stringStyle?.copy( linkStyle = SpanStyle( textDecoration = TextDecoration.Underline, - color = MaterialTheme.colors.primary + color = MaterialTheme.colorScheme.primary ) ) ) Row() { - MaterialRichText( + Material3RichText( style = myMarkDownStyle ) { Markdown( @@ -122,7 +122,7 @@ fun ConnectOrbotDialog(onClose: () -> Unit, onPost: () -> Unit, portNumber: Muta placeholder = { Text( text = "9050", - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) } ) @@ -143,10 +143,9 @@ fun UseOrbotButton(onPost: () -> Unit = {}, isActive: Boolean, modifier: Modifie } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray - ) + colors = ButtonDefaults.buttonColors( + containerColor = if (isActive) MaterialTheme.colorScheme.primary else Color.Gray + ) ) { Text(text = stringResource(R.string.use_orbot), color = Color.White) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DiscoverScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DiscoverScreen.kt index a9febcdca..50e2abecb 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DiscoverScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DiscoverScreen.kt @@ -14,10 +14,10 @@ import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PagerState -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Tab -import androidx.compose.material.TabRow -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Tab +import androidx.compose.material3.TabRow +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -120,7 +120,8 @@ private fun DiscoverPages( nav: (String) -> Unit ) { TabRow( - backgroundColor = MaterialTheme.colors.background, + containerColor = MaterialTheme.colorScheme.background, + contentColor = MaterialTheme.colorScheme.onBackground, selectedTabIndex = pagerState.currentPage, modifier = TabRowHeight ) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt index 36bec3b1d..0dc73aa73 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt @@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.Divider -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt index edd2cfe21..569b1a028 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt @@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.Divider -import androidx.compose.material.Text +import androidx.compose.material3.Divider +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.derivedStateOf diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt index 3faa5a440..4c9d2c5b3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt @@ -13,15 +13,15 @@ import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Checkbox -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.ScrollableTabRow -import androidx.compose.material.Tab -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Checkbox +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.ScrollableTabRow +import androidx.compose.material3.Tab +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -59,6 +59,7 @@ import com.vitorpamplona.amethyst.ui.screen.RefreshingFeedUserFeedView import com.vitorpamplona.amethyst.ui.screen.StringFeedView import com.vitorpamplona.amethyst.ui.screen.UserFeedViewModel import com.vitorpamplona.amethyst.ui.theme.ButtonBorder +import com.vitorpamplona.amethyst.ui.theme.DividerThickness import com.vitorpamplona.amethyst.ui.theme.HorzPadding import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.StdPadding @@ -145,10 +146,14 @@ fun HiddenUsersScreen( } ScrollableTabRow( - backgroundColor = MaterialTheme.colors.background, + containerColor = MaterialTheme.colorScheme.background, + contentColor = MaterialTheme.colorScheme.onBackground, edgePadding = 8.dp, selectedTabIndex = pagerState.currentPage, - modifier = TabRowHeight + modifier = TabRowHeight, + divider = { + Divider(thickness = DividerThickness) + } ) { Tab( selected = pagerState.currentPage == 0, @@ -222,7 +227,7 @@ private fun AddMuteWordTextField(accountViewModel: AccountViewModel) { placeholder = { Text( text = stringResource(R.string.hide_new_word_label), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, keyboardOptions = KeyboardOptions.Default.copy( @@ -366,10 +371,9 @@ fun HideWordButton(onClick: () -> Unit) { modifier = Modifier.padding(horizontal = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.block_only), color = Color.White) @@ -382,10 +386,9 @@ fun ShowWordButton(text: Int = R.string.unblock, onClick: () -> Unit) { modifier = Modifier.padding(start = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(text), color = Color.White, textAlign = TextAlign.Center) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt index de8e18134..5ea399e65 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt @@ -7,10 +7,10 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PagerState -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Tab -import androidx.compose.material.TabRow -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Tab +import androidx.compose.material3.TabRow +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.Immutable @@ -103,9 +103,10 @@ private fun HomePages( nav: (String) -> Unit ) { TabRow( - backgroundColor = MaterialTheme.colors.background, - selectedTabIndex = pagerState.currentPage, - modifier = TabRowHeight + containerColor = MaterialTheme.colorScheme.background, + contentColor = MaterialTheme.colorScheme.onBackground, + modifier = TabRowHeight, + selectedTabIndex = pagerState.currentPage ) { val coroutineScope = rememberCoroutineScope() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoadRedirectScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoadRedirectScreen.kt index 7687ea956..15b1b408c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoadRedirectScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoadRedirectScreen.kt @@ -5,7 +5,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt index 4b1fa1697..13f17c98e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt @@ -3,18 +3,23 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn import android.content.res.Configuration import androidx.activity.compose.BackHandler import androidx.compose.animation.AnimatedContent -import androidx.compose.animation.Crossfade -import androidx.compose.animation.ExperimentalAnimationApi -import androidx.compose.animation.core.tween import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically import androidx.compose.animation.togetherWith -import androidx.compose.animation.with import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.statusBarsPadding -import androidx.compose.material.* +import androidx.compose.material3.* +import androidx.compose.material3.DrawerValue +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.ModalNavigationDrawer +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SheetValue +import androidx.compose.material3.rememberDrawerState +import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -26,13 +31,14 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.unit.dp @@ -65,7 +71,7 @@ import com.vitorpamplona.amethyst.ui.screen.ThemeViewModel import kotlinx.coroutines.launch import kotlin.math.abs -@OptIn(ExperimentalMaterialApi::class, ExperimentalAnimationApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun MainScreen( accountViewModel: AccountViewModel, @@ -73,21 +79,32 @@ fun MainScreen( themeViewModel: ThemeViewModel ) { val scope = rememberCoroutineScope() - val scaffoldState = rememberScaffoldState(rememberDrawerState(DrawerValue.Closed)) + var openBottomSheet by rememberSaveable { mutableStateOf(false) } + + val drawerState = rememberDrawerState(DrawerValue.Closed) val sheetState = rememberModalBottomSheetState( - initialValue = ModalBottomSheetValue.Hidden, - confirmValueChange = { it != ModalBottomSheetValue.HalfExpanded }, - skipHalfExpanded = true + skipPartiallyExpanded = true, + confirmValueChange = { it != SheetValue.PartiallyExpanded } ) + val openSheetFunction = remember { + { + scope.launch { + openBottomSheet = true + sheetState.show() + } + Unit + } + } + val navController = rememberNavController() val navState = navController.currentBackStackEntryAsState() val orientation = LocalConfiguration.current.orientation - val currentDrawerState = scaffoldState.drawerState.currentValue + val currentDrawerState = drawerState.currentValue LaunchedEffect(key1 = orientation) { if (orientation == Configuration.ORIENTATION_LANDSCAPE && currentDrawerState == DrawerValue.Closed) { - scaffoldState.drawerState.close() + drawerState.close() } } @@ -167,42 +184,50 @@ fun MainScreen( val navBottomRow = remember(navController) { { route: Route, selected: Boolean -> - if (!selected) { - navController.navigate(route.base) { - popUpTo(Route.Home.route) - launchSingleTop = true - } - } else { - // deals with scroll to top here to avoid passing as parameter - // and having to deal with all recompositions with scroll to top true - when (route.base) { - Route.Home.base -> { - homeFeedViewModel.sendToTop() - repliesFeedViewModel.sendToTop() + scope.launch { + if (!selected) { + navController.navigate(route.base) { + popUpTo(Route.Home.route) + launchSingleTop = true } - Route.Video.base -> { - videoFeedViewModel.sendToTop() - } - Route.Discover.base -> { - discoveryLiveFeedViewModel.sendToTop() - discoveryCommunityFeedViewModel.sendToTop() - discoveryChatFeedViewModel.sendToTop() - } - Route.Notification.base -> { - notifFeedViewModel.invalidateDataAndSendToTop() - } - } + } else { + // deals with scroll to top here to avoid passing as parameter + // and having to deal with all recompositions with scroll to top true + when (route.base) { + Route.Home.base -> { + homeFeedViewModel.sendToTop() + repliesFeedViewModel.sendToTop() + } - navController.navigate(route.route) { - popUpTo(route.route) - launchSingleTop = true + Route.Video.base -> { + videoFeedViewModel.sendToTop() + } + + Route.Discover.base -> { + discoveryLiveFeedViewModel.sendToTop() + discoveryCommunityFeedViewModel.sendToTop() + discoveryChatFeedViewModel.sendToTop() + } + + Route.Notification.base -> { + notifFeedViewModel.invalidateDataAndSendToTop() + } + } + + navController.navigate(route.route) { + popUpTo(route.route) + launchSingleTop = true + } } } + + Unit } } val bottomBarHeightPx = with(LocalDensity.current) { 50.dp.roundToPx().toFloat() } val bottomBarOffsetHeightPx = remember { mutableStateOf(0f) } + val shouldShow = remember { mutableStateOf(true) } val nestedScrollConnection = remember { object : NestedScrollConnection { @@ -221,107 +246,112 @@ fun MainScreen( } } + shouldShow.value = abs(bottomBarOffsetHeightPx.value) < bottomBarHeightPx / 2.0f + return Offset.Zero } } } - val shouldShow = remember { - derivedStateOf { - abs(bottomBarOffsetHeightPx.value) < bottomBarHeightPx / 2.0f - } - } - WatchNavStateToUpdateBarVisibility(navState, bottomBarOffsetHeightPx) - ModalBottomSheetLayout( - sheetState = sheetState, - sheetContent = { - AccountSwitchBottomSheet(accountViewModel = accountViewModel, accountStateViewModel = accountStateViewModel) - } - ) { - Scaffold( - modifier = Modifier - .background(MaterialTheme.colors.primaryVariant) - .statusBarsPadding() - .nestedScroll(nestedScrollConnection), - bottomBar = { - AnimatedContent( - targetState = shouldShow.value, - transitionSpec = { - slideInVertically { height -> height } togetherWith - slideOutVertically { height -> height } - } - ) { isVisible -> - if (isVisible) { - AppBottomBar(accountViewModel, navState, navBottomRow) - } - } - }, - topBar = { - AnimatedContent( - targetState = shouldShow.value, - transitionSpec = { - slideInVertically { height -> 0 } togetherWith - slideOutVertically { height -> 0 } - } - ) { isVisible -> - if (isVisible) { - AppTopBar( - followLists, - navState, - scaffoldState, - accountViewModel, - nav = nav, - navPopBack - ) - } - } - }, - drawerContent = { - DrawerContent(nav, scaffoldState, sheetState, accountViewModel) - BackHandler(enabled = scaffoldState.drawerState.isOpen) { - scope.launch { scaffoldState.drawerState.close() } - } - }, - floatingActionButton = { - Crossfade( - targetState = shouldShow.value, - animationSpec = tween(durationMillis = 100) - ) { state -> - if (state) { - FloatingButtons( - navState, - accountViewModel, - accountStateViewModel, - nav, - navBottomRow - ) - } - } - }, - scaffoldState = scaffoldState - ) { - Column( - modifier = Modifier - .padding(bottom = it.calculateBottomPadding()) - ) { - AppNavigation( - homeFeedViewModel = homeFeedViewModel, - repliesFeedViewModel = repliesFeedViewModel, - knownFeedViewModel = knownFeedViewModel, - newFeedViewModel = newFeedViewModel, - videoFeedViewModel = videoFeedViewModel, - discoveryLiveFeedViewModel = discoveryLiveFeedViewModel, - discoveryCommunityFeedViewModel = discoveryCommunityFeedViewModel, - discoveryChatFeedViewModel = discoveryChatFeedViewModel, - notifFeedViewModel = notifFeedViewModel, - userReactionsStatsModel = userReactionsStatsModel, - navController = navController, - accountViewModel = accountViewModel, - themeViewModel = themeViewModel - ) + ModalNavigationDrawer( + drawerState = drawerState, + drawerContent = { + DrawerContent(nav, drawerState, openSheetFunction, accountViewModel) + BackHandler(enabled = drawerState.isOpen) { + scope.launch { drawerState.close() } } + }, + content = { + Scaffold( + modifier = Modifier + .background(MaterialTheme.colorScheme.secondary) + .statusBarsPadding() + .nestedScroll(nestedScrollConnection), + bottomBar = { + AnimatedContent( + targetState = shouldShow.value, + transitionSpec = { + slideInVertically { height -> height } togetherWith + slideOutVertically { height -> height } + } + ) { isVisible -> + if (isVisible) { + AppBottomBar(accountViewModel, navState, navBottomRow) + } + } + }, + topBar = { + AnimatedContent( + targetState = shouldShow.value, + transitionSpec = { + slideInVertically { height -> 0 } togetherWith + slideOutVertically { height -> 0 } + } + ) { isVisible -> + if (isVisible) { + AppTopBar( + followLists, + navState, + drawerState, + accountViewModel, + nav = nav, + navPopBack + ) + } + } + }, + floatingActionButton = { + FloatingButtons( + navState, + accountViewModel, + accountStateViewModel, + nav, + navBottomRow + ) + } + ) { + Column( + modifier = Modifier + .padding( + top = it.calculateTopPadding(), + bottom = it.calculateBottomPadding() + ) + ) { + AppNavigation( + homeFeedViewModel = homeFeedViewModel, + repliesFeedViewModel = repliesFeedViewModel, + knownFeedViewModel = knownFeedViewModel, + newFeedViewModel = newFeedViewModel, + videoFeedViewModel = videoFeedViewModel, + discoveryLiveFeedViewModel = discoveryLiveFeedViewModel, + discoveryCommunityFeedViewModel = discoveryCommunityFeedViewModel, + discoveryChatFeedViewModel = discoveryChatFeedViewModel, + notifFeedViewModel = notifFeedViewModel, + userReactionsStatsModel = userReactionsStatsModel, + navController = navController, + accountViewModel = accountViewModel, + themeViewModel = themeViewModel + ) + } + } + } + ) + + // Sheet content + if (openBottomSheet) { + ModalBottomSheet( + onDismissRequest = { + scope.launch { sheetState.hide() }.invokeOnCompletion { + if (!sheetState.isVisible) { + openBottomSheet = false + } + } + }, + sheetState = sheetState + ) { + AccountSwitchBottomSheet(accountViewModel = accountViewModel, accountStateViewModel = accountStateViewModel) } } } @@ -356,22 +386,19 @@ fun FloatingButtons( navScrollToTop: (Route, Boolean) -> Unit ) { val accountState by accountStateViewModel.accountContent.collectAsState() - val context = LocalContext.current - Crossfade(targetState = accountState, animationSpec = tween(durationMillis = 100)) { state -> - when (state) { - is AccountState.LoggedInViewOnly -> { - if (accountViewModel.loggedInWithExternalSigner()) { - WritePermissionButtons(navEntryState, accountViewModel, nav, navScrollToTop) - } - } - is AccountState.LoggedOff -> { - // Does nothing. - } - is AccountState.LoggedIn -> { + when (accountState) { + is AccountState.LoggedInViewOnly -> { + if (accountViewModel.loggedInWithExternalSigner()) { WritePermissionButtons(navEntryState, accountViewModel, nav, navScrollToTop) } } + is AccountState.LoggedOff -> { + // Does nothing. + } + is AccountState.LoggedIn -> { + WritePermissionButtons(navEntryState, accountViewModel, nav, navScrollToTop) + } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt index d6a644ad1..23963c187 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt @@ -7,8 +7,8 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -195,7 +195,7 @@ fun SummaryBar(model: UserReactionsViewModel) { .clickable(onClick = { showChart = !showChart }) ) { ProvideChartStyle( - chartStyle = MaterialTheme.colors.chartStyle + chartStyle = MaterialTheme.colorScheme.chartStyle ) { ObserveAndShowChart(model, lineChartCount, lineChartZaps) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt index 8988acaf5..46f2db189 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt @@ -13,12 +13,12 @@ import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ContentCopy import androidx.compose.material.icons.filled.EditNote import androidx.compose.material.icons.filled.Link import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.Alignment @@ -41,6 +41,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp @@ -92,6 +93,7 @@ import com.vitorpamplona.amethyst.ui.screen.RelayFeedViewModel import com.vitorpamplona.amethyst.ui.screen.UserFeedViewModel import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange import com.vitorpamplona.amethyst.ui.theme.ButtonBorder +import com.vitorpamplona.amethyst.ui.theme.DividerThickness import com.vitorpamplona.amethyst.ui.theme.Size16Modifier import com.vitorpamplona.amethyst.ui.theme.Size35dp import com.vitorpamplona.amethyst.ui.theme.placeholderText @@ -99,7 +101,6 @@ import com.vitorpamplona.quartz.encoders.ATag import com.vitorpamplona.quartz.events.AppDefinitionEvent import com.vitorpamplona.quartz.events.BadgeDefinitionEvent import com.vitorpamplona.quartz.events.BadgeProfilesEvent -import com.vitorpamplona.quartz.events.ChatroomKey import com.vitorpamplona.quartz.events.EmptyTagList import com.vitorpamplona.quartz.events.GitHubIdentity import com.vitorpamplona.quartz.events.IdentityClaim @@ -111,7 +112,6 @@ import com.vitorpamplona.quartz.events.TelegramIdentity import com.vitorpamplona.quartz.events.TwitterIdentity import com.vitorpamplona.quartz.events.toImmutableListOfLists import kotlinx.collections.immutable.ImmutableList -import kotlinx.collections.immutable.persistentSetOf import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -299,7 +299,7 @@ private fun RenderSurface( ) { Surface( modifier = Modifier.fillMaxWidth(), - color = MaterialTheme.colors.background + color = MaterialTheme.colorScheme.background ) { var columnSize by remember { mutableStateOf(IntSize.Zero) } var tabsSize by remember { mutableStateOf(IntSize.Zero) } @@ -389,10 +389,14 @@ private fun RenderScreen( Column { ProfileHeader(baseUser, appRecommendations, nav, accountViewModel) ScrollableTabRow( - backgroundColor = MaterialTheme.colors.background, + containerColor = MaterialTheme.colorScheme.background, + contentColor = MaterialTheme.colorScheme.onBackground, selectedTabIndex = pagerState.currentPage, edgePadding = 8.dp, - modifier = tabRowModifier + modifier = tabRowModifier, + divider = { + Divider(thickness = DividerThickness) + } ) { CreateAndRenderTabs(baseUser, pagerState) } @@ -630,12 +634,12 @@ private fun ProfileHeader( shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.background + containerColor = MaterialTheme.colorScheme.background ), contentPadding = PaddingValues(0.dp) ) { Icon( - tint = MaterialTheme.colors.placeholderText, + tint = MaterialTheme.colorScheme.placeholderText, imageVector = Icons.Default.MoreVert, contentDescription = stringResource(R.string.more_options) ) @@ -662,7 +666,7 @@ private fun ProfileHeader( size = 100.dp, modifier = Modifier.border( 3.dp, - MaterialTheme.colors.background, + MaterialTheme.colorScheme.background, CircleShape ), onClick = { @@ -874,7 +878,7 @@ private fun DrawAdditionalInfo( } } - (user.bestDisplayName() ?: user.bestUsername())?.let { + user.toBestDisplayName().let { Row(verticalAlignment = Alignment.Bottom, modifier = Modifier.padding(top = 7.dp)) { CreateTextWithEmoji( text = it, @@ -885,26 +889,11 @@ private fun DrawAdditionalInfo( } } - if (user.bestDisplayName() != null) { - user.bestUsername()?.let { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.padding(top = 1.dp, bottom = 1.dp) - ) { - CreateTextWithEmoji( - text = "@$it", - tags = tags, - color = MaterialTheme.colors.placeholderText - ) - } - } - } - Row(verticalAlignment = Alignment.CenterVertically) { Text( text = user.pubkeyDisplayHex(), modifier = Modifier.padding(top = 1.dp, bottom = 1.dp), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) IconButton( @@ -917,7 +906,7 @@ private fun DrawAdditionalInfo( imageVector = Icons.Default.ContentCopy, null, modifier = Modifier.size(15.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } @@ -945,7 +934,7 @@ private fun DrawAdditionalInfo( painter = painterResource(R.drawable.ic_qrcode), null, modifier = Modifier.size(15.dp), - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) } } @@ -958,7 +947,7 @@ private fun DrawAdditionalInfo( if (!website.isNullOrEmpty()) { Row(verticalAlignment = Alignment.CenterVertically) { Icon( - tint = MaterialTheme.colors.placeholderText, + tint = MaterialTheme.colorScheme.placeholderText, imageVector = Icons.Default.Link, contentDescription = stringResource(R.string.website), modifier = Modifier.size(16.dp) @@ -977,7 +966,7 @@ private fun DrawAdditionalInfo( } } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary), + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary), modifier = Modifier.padding(top = 1.dp, bottom = 1.dp, start = 5.dp) ) } @@ -1001,7 +990,7 @@ private fun DrawAdditionalInfo( ClickableText( text = AnnotatedString(identity.identity), onClick = { runCatching { uri.openUri(identity.toProofUrl()) } }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary), + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary), modifier = Modifier .padding(top = 1.dp, bottom = 1.dp, start = 5.dp) .weight(1f) @@ -1014,7 +1003,7 @@ private fun DrawAdditionalInfo( Row( modifier = Modifier.padding(top = 5.dp, bottom = 5.dp) ) { - val defaultBackground = MaterialTheme.colors.background + val defaultBackground = MaterialTheme.colorScheme.background val background = remember { mutableStateOf(defaultBackground) } @@ -1050,7 +1039,7 @@ fun DisplayLNAddress( ClickableText( text = AnnotatedString(lud16), onClick = { zapExpanded = !zapExpanded }, - style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary), + style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary), modifier = Modifier .padding(top = 1.dp, bottom = 1.dp, start = 5.dp) .weight(1f) @@ -1338,7 +1327,7 @@ private fun WatchAndRenderBadgeImage( } } - val bgColor = MaterialTheme.colors.background + val bgColor = MaterialTheme.colorScheme.background if (image == null) { RobohashAsyncImage( @@ -1648,16 +1637,16 @@ private fun MessageButton(user: User, accountViewModel: AccountViewModel, nav: ( .width(50.dp), onClick = { scope.launch(Dispatchers.IO) { - val withKey = ChatroomKey(persistentSetOf(user.pubkeyHex)) - accountViewModel.account.userProfile().createChatroom(withKey) - nav("Room/${withKey.hashCode()}") + accountViewModel.createChatRoomFor(user) { + nav("Room/$it") + } } }, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.placeholderText - ) + contentPadding = PaddingValues(0.dp), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.placeholderText + ) ) { Icon( painter = painterResource(R.drawable.ic_dm), @@ -1678,16 +1667,27 @@ private fun EditButton(account: Account) { NewUserMetadataView({ wantsToEdit = false }, account) } + InnerEditButton { wantsToEdit = true } +} + +@Preview +@Composable +private fun InnerEditButtonPreview() { + InnerEditButton {} +} + +@Composable +private fun InnerEditButton(onClick: () -> Unit) { Button( modifier = Modifier .padding(horizontal = 3.dp) .width(50.dp), - onClick = { wantsToEdit = true }, + onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ) + contentPadding = PaddingValues(0.dp), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ) ) { Icon( tint = Color.White, @@ -1703,10 +1703,9 @@ fun UnfollowButton(onClick: () -> Unit) { modifier = Modifier.padding(horizontal = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.unfollow), color = Color.White) @@ -1719,10 +1718,9 @@ fun FollowButton(text: Int = R.string.follow, onClick: () -> Unit) { modifier = Modifier.padding(start = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(text), color = Color.White, textAlign = TextAlign.Center) @@ -1735,10 +1733,9 @@ fun ShowUserButton(onClick: () -> Unit) { modifier = Modifier.padding(start = 3.dp), onClick = onClick, shape = ButtonBorder, - colors = ButtonDefaults - .buttonColors( - backgroundColor = MaterialTheme.colors.primary - ), + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary + ), contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) ) { Text(text = stringResource(R.string.unblock), color = Color.White) @@ -1753,62 +1750,82 @@ fun UserProfileDropDownMenu(user: User, popupExpanded: Boolean, onDismiss: () -> ) { val clipboardManager = LocalClipboardManager.current - DropdownMenuItem(onClick = { clipboardManager.setText(AnnotatedString(user.pubkeyNpub())); onDismiss() }) { - Text(stringResource(R.string.copy_user_id)) - } + DropdownMenuItem( + text = { + Text(stringResource(R.string.copy_user_id)) + }, + onClick = { clipboardManager.setText(AnnotatedString(user.pubkeyNpub())); onDismiss() } + ) if (accountViewModel.userProfile() != user) { Divider() if (accountViewModel.account.isHidden(user)) { DropdownMenuItem( + text = { + Text(stringResource(R.string.unblock_user)) + }, onClick = { accountViewModel.show(user) onDismiss() } - ) { - Text(stringResource(R.string.unblock_user)) - } + ) } else { DropdownMenuItem( + text = { + Text(stringResource(id = R.string.block_hide_user)) + }, onClick = { accountViewModel.hide(user) onDismiss() } - ) { - Text(stringResource(id = R.string.block_hide_user)) - } + ) } Divider() - DropdownMenuItem(onClick = { - accountViewModel.report(user, ReportEvent.ReportType.SPAM) - onDismiss() - }) { - Text(stringResource(id = R.string.report_spam_scam)) - } - DropdownMenuItem(onClick = { - accountViewModel.report(user, ReportEvent.ReportType.PROFANITY) - onDismiss() - }) { - Text(stringResource(R.string.report_hateful_speech)) - } - DropdownMenuItem(onClick = { - accountViewModel.report(user, ReportEvent.ReportType.IMPERSONATION) - onDismiss() - }) { - Text(stringResource(id = R.string.report_impersonation)) - } - DropdownMenuItem(onClick = { - accountViewModel.report(user, ReportEvent.ReportType.NUDITY) - onDismiss() - }) { - Text(stringResource(R.string.report_nudity_porn)) - } - DropdownMenuItem(onClick = { - accountViewModel.report(user, ReportEvent.ReportType.ILLEGAL) - onDismiss() - }) { - Text(stringResource(id = R.string.report_illegal_behaviour)) - } + DropdownMenuItem( + text = { + Text(stringResource(id = R.string.report_spam_scam)) + }, + onClick = { + accountViewModel.report(user, ReportEvent.ReportType.SPAM) + onDismiss() + } + ) + DropdownMenuItem( + text = { + Text(stringResource(R.string.report_hateful_speech)) + }, + onClick = { + accountViewModel.report(user, ReportEvent.ReportType.PROFANITY) + onDismiss() + } + ) + DropdownMenuItem( + text = { + Text(stringResource(id = R.string.report_impersonation)) + }, + onClick = { + accountViewModel.report(user, ReportEvent.ReportType.IMPERSONATION) + onDismiss() + } + ) + DropdownMenuItem( + text = { + Text(stringResource(R.string.report_nudity_porn)) + }, + onClick = { + accountViewModel.report(user, ReportEvent.ReportType.NUDITY) + onDismiss() + } + ) + DropdownMenuItem( + text = { + Text(stringResource(id = R.string.report_illegal_behaviour)) + }, + onClick = { + accountViewModel.report(user, ReportEvent.ReportType.ILLEGAL) + onDismiss() + } + ) } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt index 8ddb6fa20..591bc3e28 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt @@ -8,19 +8,21 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Block import androidx.compose.material.icons.filled.Report +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -46,6 +48,7 @@ import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +@OptIn(ExperimentalMaterial3Api::class) @Composable fun ReportNoteDialog(note: Note, accountViewModel: AccountViewModel, onDismiss: () -> Unit) { val reportTypes = listOf( @@ -73,8 +76,9 @@ fun ReportNoteDialog(note: Note, accountViewModel: AccountViewModel, onDismiss: ArrowBackIcon() } }, - backgroundColor = MaterialTheme.colors.surface, - elevation = 0.dp + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.surface + ) ) } ) { pad -> @@ -103,7 +107,7 @@ fun ReportNoteDialog(note: Note, accountViewModel: AccountViewModel, onDismiss: ) SpacerH16() - Divider(color = MaterialTheme.colors.onSurface, thickness = 0.25.dp) + Divider(color = MaterialTheme.colorScheme.onSurface, thickness = 0.25.dp) SpacerH16() SectionHeader(text = stringResource(R.string.report_dialog_report_btn)) @@ -157,7 +161,7 @@ private fun SpacerH16() = Spacer(modifier = Modifier.height(16.dp)) private fun SectionHeader(text: String) = Text( text = text, fontWeight = FontWeight.Bold, - color = MaterialTheme.colors.onSurface, + color = MaterialTheme.colorScheme.onSurface, fontSize = 18.sp ) @@ -165,7 +169,7 @@ private fun SectionHeader(text: String) = Text( private fun ActionButton(text: String, icon: ImageVector, enabled: Boolean = true, onClick: () -> Unit) = Button( onClick = onClick, enabled = enabled, - colors = ButtonDefaults.buttonColors(backgroundColor = WarningColor), + colors = ButtonDefaults.buttonColors(containerColor = WarningColor), modifier = Modifier.fillMaxWidth() ) { Row( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SearchScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SearchScreen.kt index bde8aaa86..63b877ab2 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SearchScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SearchScreen.kt @@ -16,12 +16,13 @@ import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Divider -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.TextField -import androidx.compose.material.TextFieldDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -270,6 +271,7 @@ private fun SearchBar( } } +@OptIn(ExperimentalMaterial3Api::class) @Composable private fun SearchTextField( searchBarViewModel: SearchBarViewModel, @@ -301,7 +303,7 @@ private fun SearchTextField( placeholder = { Text( text = stringResource(R.string.npub_hex_username), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, trailingIcon = { @@ -317,7 +319,7 @@ private fun SearchTextField( } }, singleLine = true, - colors = TextFieldDefaults.textFieldColors( + colors = TextFieldDefaults.colors( focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SettingsScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SettingsScreen.kt index df5118c0d..d73d9d66b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SettingsScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/SettingsScreen.kt @@ -12,13 +12,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.DropdownMenuItem -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.ExposedDropdownMenuBox -import androidx.compose.material.ExposedDropdownMenuDefaults -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.TextField +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ExposedDropdownMenuBox +import androidx.compose.material3.ExposedDropdownMenuDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue @@ -284,7 +284,7 @@ fun SettingsRow( ) Text( text = stringResource(description), - style = MaterialTheme.typography.caption, + style = MaterialTheme.typography.bodySmall, color = Color.Gray, maxLines = 2, overflow = TextOverflow.Ellipsis @@ -303,7 +303,7 @@ fun SettingsRow( } } -@OptIn(ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun DropDownSettings( selectedItem: MutableState, @@ -340,13 +340,14 @@ fun DropDownSettings( ) { listItems.forEach { selectedOption -> DropdownMenuItem( + text = { + Text(text = selectedOption) + }, onClick = { selectedItem.value = selectedOption expanded = false } - ) { - Text(text = selectedOption) - } + ) } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt index 184d0c780..bbad07242 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt @@ -20,11 +20,11 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.VerticalPager import androidx.compose.foundation.pager.rememberPagerState -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -401,7 +401,7 @@ private fun VideoUserOptionAction( imageVector = Icons.Default.MoreVert, null, modifier = remember { Modifier.size(20.dp) }, - tint = MaterialTheme.colors.placeholderText + tint = MaterialTheme.colorScheme.placeholderText ) NoteDropDownMenu( @@ -445,17 +445,17 @@ fun ReactionsColumn(baseNote: Note, accountViewModel: AccountViewModel, nav: (St Spacer(modifier = Modifier.height(8.dp)) Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(bottom = 75.dp, end = 20.dp)) { - ReplyReaction(baseNote, grayTint = MaterialTheme.colors.onBackground, accountViewModel, iconSize = 40.dp) { + ReplyReaction(baseNote, grayTint = MaterialTheme.colorScheme.onBackground, accountViewModel, iconSize = 40.dp) { routeFor( baseNote, accountViewModel.userProfile() )?.let { nav(it) } } - BoostReaction(baseNote, grayTint = MaterialTheme.colors.onBackground, accountViewModel, iconSize = 40.dp) { + BoostReaction(baseNote, grayTint = MaterialTheme.colorScheme.onBackground, accountViewModel, iconSize = 40.dp) { wantsToQuote = baseNote } - LikeReaction(baseNote, grayTint = MaterialTheme.colors.onBackground, accountViewModel, nav, iconSize = 40.dp, heartSize = Size35dp, 28.sp) - ZapReaction(baseNote, grayTint = MaterialTheme.colors.onBackground, accountViewModel, iconSize = 40.dp, animationSize = Size35dp, nav = nav) - ViewCountReaction(baseNote, grayTint = MaterialTheme.colors.onBackground, barChartSize = 39.dp, viewCountColorFilter = MaterialTheme.colors.onBackgroundColorFilter) + LikeReaction(baseNote, grayTint = MaterialTheme.colorScheme.onBackground, accountViewModel, nav, iconSize = 40.dp, heartSize = Size35dp, 28.sp) + ZapReaction(baseNote, grayTint = MaterialTheme.colorScheme.onBackground, accountViewModel, iconSize = 40.dp, animationSize = Size35dp, nav = nav) + ViewCountReaction(baseNote, grayTint = MaterialTheme.colorScheme.onBackground, barChartSize = 39.dp, viewCountColorFilter = MaterialTheme.colorScheme.onBackgroundColorFilter) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt index 77c5d6c1b..61647802a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt @@ -13,10 +13,10 @@ import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Visibility import androidx.compose.material.icons.outlined.VisibilityOff +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi @@ -186,7 +186,7 @@ fun LoginPage( placeholder = { Text( text = stringResource(R.string.nsec_npub_hex_private_key), - color = MaterialTheme.colors.placeholderText + color = MaterialTheme.colorScheme.placeholderText ) }, trailingIcon = { @@ -219,7 +219,7 @@ fun LoginPage( painter = painterResource(R.drawable.ic_qrcode), null, modifier = Modifier.size(24.dp), - tint = MaterialTheme.colors.primary + tint = MaterialTheme.colorScheme.primary ) } }, @@ -237,8 +237,8 @@ fun LoginPage( if (errorMessage.isNotBlank()) { Text( text = errorMessage, - color = MaterialTheme.colors.error, - style = MaterialTheme.typography.caption + color = MaterialTheme.colorScheme.error, + style = MaterialTheme.typography.bodySmall ) } @@ -252,10 +252,10 @@ fun LoginPage( ) val regularText = - SpanStyle(color = MaterialTheme.colors.onBackground) + SpanStyle(color = MaterialTheme.colorScheme.onBackground) val clickableTextStyle = - SpanStyle(color = MaterialTheme.colors.primary) + SpanStyle(color = MaterialTheme.colorScheme.primary) val annotatedTermsString = buildAnnotatedString { withStyle(regularText) { @@ -284,8 +284,8 @@ fun LoginPage( if (termsAcceptanceIsRequired.isNotBlank()) { Text( text = termsAcceptanceIsRequired, - color = MaterialTheme.colors.error, - style = MaterialTheme.typography.caption + color = MaterialTheme.colorScheme.error, + style = MaterialTheme.typography.bodySmall ) } } @@ -341,10 +341,12 @@ fun LoginPage( }, shape = RoundedCornerShape(Size35dp), modifier = Modifier - .fillMaxWidth() .height(50.dp) ) { - Text(text = stringResource(R.string.login)) + Text( + text = stringResource(R.string.login), + modifier = Modifier.padding(horizontal = 40.dp) + ) } } @@ -386,10 +388,12 @@ fun LoginPage( }, shape = RoundedCornerShape(Size35dp), modifier = Modifier - .fillMaxWidth() .height(50.dp) ) { - Text(text = stringResource(R.string.login_with_external_signer)) + Text( + text = stringResource(R.string.login_with_external_signer), + modifier = Modifier.padding(horizontal = 40.dp) + ) } } } @@ -412,7 +416,7 @@ fun LoginPage( style = TextStyle( fontSize = Font14SP, textDecoration = TextDecoration.Underline, - color = MaterialTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, textAlign = TextAlign.Center ) ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Color.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Color.kt index 538442536..d51d13d20 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Color.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Color.kt @@ -11,6 +11,9 @@ val Teal200 = Color(0xFF03DAC5) val BitcoinOrange = Color(0xFFF7931A) val RoyalBlue = Color(0xFF4169E1) +val BitcoinDark = Color(0xFFF7931A) +val BitcoinLight = Color(0xFFB66605) + val Following = Color(0xFF03DAC5) val FollowsFollow = Color.Yellow val NIP05Verified = Color.Blue diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt index f3068ebce..ac5f5feba 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt @@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Shapes +import androidx.compose.material3.Shapes import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.unit.dp @@ -23,7 +23,7 @@ val Shapes = Shapes( val RippleRadius45dp = 45.dp // Ripple should be +10.dp over the component size val BottomTopHeight = Modifier.height(50.dp) -val TabRowHeight = Modifier.height(40.dp) +val TabRowHeight = Modifier val SmallBorder = RoundedCornerShape(7.dp) val QuoteBorder = RoundedCornerShape(15.dp) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt index f300b21d9..44d24b53f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt @@ -8,10 +8,10 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Colors -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors +import androidx.compose.material3.ColorScheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.runtime.livedata.observeAsState @@ -33,23 +33,20 @@ import com.patrykandpatrick.vico.compose.style.ChartStyle import com.patrykandpatrick.vico.core.DefaultColors import com.vitorpamplona.amethyst.ui.screen.ThemeViewModel -private val DarkColorPalette = darkColors( +private val DarkColorPalette = darkColorScheme( primary = Purple200, - primaryVariant = Purple700, secondary = Teal200, - secondaryVariant = Purple200 + // secondary = Purple700, + tertiary = Teal200 ) -private val LightColorPalette = lightColors( +private val LightColorPalette = lightColorScheme( primary = Purple500, - primaryVariant = Purple700, secondary = Teal200, - secondaryVariant = Purple500 + // secondary = Purple700, + tertiary = Teal200 ) -private val BitcoinDark = Color(0xFFF7931A) -private val BitcoinLight = Color(0xFFB66605) - private val DarkNewItemBackground = DarkColorPalette.primary.copy(0.12f) private val LightNewItemBackground = LightColorPalette.primary.copy(0.12f) @@ -237,81 +234,84 @@ val MarkDownStyleOnLight = RichTextDefaults.copy( ) ) -val Colors.newItemBackgroundColor: Color +val ColorScheme.isLight: Boolean + get() = primary == Purple500 + +val ColorScheme.newItemBackgroundColor: Color get() = if (isLight) LightNewItemBackground else DarkNewItemBackground -val Colors.replyBackground: Color +val ColorScheme.replyBackground: Color get() = if (isLight) LightReplyItemBackground else DarkReplyItemBackground -val Colors.selectedNote: Color +val ColorScheme.selectedNote: Color get() = if (isLight) LightSelectedNote else DarkSelectedNote -val Colors.secondaryButtonBackground: Color +val ColorScheme.secondaryButtonBackground: Color get() = if (isLight) LightButtonBackground else DarkButtonBackground -val Colors.lessImportantLink: Color +val ColorScheme.lessImportantLink: Color get() = if (isLight) LightLessImportantLink else DarkLessImportantLink -val Colors.zapraiserBackground: Color +val ColorScheme.zapraiserBackground: Color get() = if (isLight) LightZapraiserBackground else DarkZapraiserBackground -val Colors.mediumImportanceLink: Color +val ColorScheme.mediumImportanceLink: Color get() = if (isLight) LightMediumImportantLink else DarkMediumImportantLink -val Colors.veryImportantLink: Color +val ColorScheme.veryImportantLink: Color get() = if (isLight) LightVeryImportantLink else DarkVeryImportantLink -val Colors.placeholderText: Color +val ColorScheme.placeholderText: Color get() = if (isLight) LightPlaceholderText else DarkPlaceholderText -val Colors.nip05: Color +val ColorScheme.nip05: Color get() = if (isLight) Nip05EmailColorLight else Nip05EmailColorDark -val Colors.placeholderTextColorFilter: ColorFilter +val ColorScheme.placeholderTextColorFilter: ColorFilter get() = if (isLight) LightPlaceholderTextColorFilter else DarkPlaceholderTextColorFilter -val Colors.onBackgroundColorFilter: ColorFilter +val ColorScheme.onBackgroundColorFilter: ColorFilter get() = if (isLight) LightOnBackgroundColorFilter else DarkOnBackgroundColorFilter -val Colors.grayText: Color +val ColorScheme.grayText: Color get() = if (isLight) LightGrayText else DarkGrayText -val Colors.subtleBorder: Color +val ColorScheme.subtleBorder: Color get() = if (isLight) LightSubtleBorder else DarkSubtleBorder -val Colors.subtleButton: Color +val ColorScheme.subtleButton: Color get() = if (isLight) LightSubtleButton else DarkSubtleButton -val Colors.overPictureBackground: Color +val ColorScheme.overPictureBackground: Color get() = if (isLight) LightOverPictureBackground else DarkOverPictureBackground -val Colors.bitcoinColor: Color +val ColorScheme.bitcoinColor: Color get() = if (isLight) BitcoinLight else BitcoinDark -val Colors.warningColor: Color +val ColorScheme.warningColor: Color get() = if (isLight) LightWarningColor else DarkWarningColor -val Colors.allGoodColor: Color +val ColorScheme.allGoodColor: Color get() = if (isLight) LightAllGoodColor else DarkAllGoodColor -val Colors.markdownStyle: RichTextStyle +val ColorScheme.markdownStyle: RichTextStyle get() = if (isLight) MarkDownStyleOnLight else MarkDownStyleOnDark -val Colors.repostProfileBorder: Modifier +val ColorScheme.repostProfileBorder: Modifier get() = if (isLight) RepostPictureBorderLight else RepostPictureBorderDark -val Colors.imageModifier: Modifier +val ColorScheme.imageModifier: Modifier get() = if (isLight) LightImageModifier else DarkImageModifier -val Colors.profile35dpModifier: Modifier +val ColorScheme.profile35dpModifier: Modifier get() = if (isLight) LightProfile35dpModifier else DarkProfile35dpModifier -val Colors.replyModifier: Modifier +val ColorScheme.replyModifier: Modifier get() = if (isLight) LightReplyBorderModifier else DarkReplyBorderModifier -val Colors.innerPostModifier: Modifier +val ColorScheme.innerPostModifier: Modifier get() = if (isLight) LightInnerPostBorderModifier else DarkInnerPostBorderModifier -val Colors.chartStyle: ChartStyle +val ColorScheme.chartStyle: ChartStyle get() { val defaultColors = if (isLight) DefaultColors.Light else DefaultColors.Dark return ChartStyle.fromColors( @@ -338,7 +338,7 @@ fun AmethystTheme(themeViewModel: ThemeViewModel, content: @Composable () -> Uni val colors = if (darkTheme) DarkColorPalette else LightColorPalette MaterialTheme( - colors = colors, + colorScheme = colors, typography = Typography, shapes = Shapes, content = content diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt index 828320955..5de4113af 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Type.kt @@ -1,6 +1,6 @@ package com.vitorpamplona.amethyst.ui.theme -import androidx.compose.material.Typography +import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight @@ -11,7 +11,7 @@ import com.halilibo.richtext.ui.HeadingStyle // Set of Material typography styles to start with val Typography = Typography( - body1 = TextStyle( + bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp diff --git a/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt b/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt index fdba993e6..d3330e5e3 100644 --- a/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt +++ b/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt @@ -4,15 +4,15 @@ import android.content.res.Resources import androidx.compose.animation.Crossfade import androidx.compose.foundation.layout.* import androidx.compose.foundation.text.ClickableText -import androidx.compose.material.Divider -import androidx.compose.material.DropdownMenu -import androidx.compose.material.DropdownMenuItem -import androidx.compose.material.Icon -import androidx.compose.material.LocalTextStyle -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Check +import androidx.compose.material3.Divider +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.Icon +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState @@ -139,7 +139,7 @@ private fun TranslationMessage( .padding(top = 5.dp) ) { val clickableTextStyle = - SpanStyle(color = MaterialTheme.colors.lessImportantLink) + SpanStyle(color = MaterialTheme.colorScheme.lessImportantLink) val annotatedTranslationString = buildAnnotatedString { withStyle(clickableTextStyle) { @@ -165,7 +165,7 @@ private fun TranslationMessage( ClickableText( text = annotatedTranslationString, style = LocalTextStyle.current.copy( - color = MaterialTheme.colors.onSurface.copy( + color = MaterialTheme.colorScheme.onSurface.copy( alpha = 0.32f ) ), @@ -187,113 +187,125 @@ private fun TranslationMessage( expanded = langSettingsPopupExpanded, onDismissRequest = { langSettingsPopupExpanded = false } ) { - DropdownMenuItem(onClick = { - scope.launch(Dispatchers.IO) { - accountViewModel.dontTranslateFrom(source) - langSettingsPopupExpanded = false - } - }) { - if (source in accountViewModel.account.dontTranslateFrom) { - Icon( - imageVector = Icons.Default.Check, - contentDescription = null, - modifier = Modifier.size(24.dp) - ) - } else { - Spacer(modifier = Modifier.size(24.dp)) - } + DropdownMenuItem( + text = { + if (source in accountViewModel.account.dontTranslateFrom) { + Icon( + imageVector = Icons.Default.Check, + contentDescription = null, + modifier = Modifier.size(24.dp) + ) + } else { + Spacer(modifier = Modifier.size(24.dp)) + } - Spacer(modifier = Modifier.size(10.dp)) + Spacer(modifier = Modifier.size(10.dp)) - Text( - stringResource( - R.string.translations_never_translate_from_lang, - Locale(source).displayName + Text( + stringResource( + R.string.translations_never_translate_from_lang, + Locale(source).displayName + ) ) - ) - } + }, + onClick = { + scope.launch(Dispatchers.IO) { + accountViewModel.dontTranslateFrom(source) + langSettingsPopupExpanded = false + } + } + ) Divider() - DropdownMenuItem(onClick = { - scope.launch(Dispatchers.IO) { - accountViewModel.prefer(source, target, source) - langSettingsPopupExpanded = false - } - }) { - if (accountViewModel.account.preferenceBetween(source, target) == source) { - Icon( - imageVector = Icons.Default.Check, - contentDescription = null, - modifier = Modifier.size(24.dp) - ) - } else { - Spacer(modifier = Modifier.size(24.dp)) - } + DropdownMenuItem( + text = { + if (accountViewModel.account.preferenceBetween(source, target) == source) { + Icon( + imageVector = Icons.Default.Check, + contentDescription = null, + modifier = Modifier.size(24.dp) + ) + } else { + Spacer(modifier = Modifier.size(24.dp)) + } - Spacer(modifier = Modifier.size(10.dp)) + Spacer(modifier = Modifier.size(10.dp)) - Text( - stringResource( - R.string.translations_show_in_lang_first, - Locale(source).displayName + Text( + stringResource( + R.string.translations_show_in_lang_first, + Locale(source).displayName + ) ) - ) - } - DropdownMenuItem(onClick = { - scope.launch(Dispatchers.IO) { - accountViewModel.prefer(source, target, target) - langSettingsPopupExpanded = false + }, + onClick = { + scope.launch(Dispatchers.IO) { + accountViewModel.prefer(source, target, source) + langSettingsPopupExpanded = false + } } - }) { - if (accountViewModel.account.preferenceBetween(source, target) == target) { - Icon( - imageVector = Icons.Default.Check, - contentDescription = null, - modifier = Modifier.size(24.dp) + ) + DropdownMenuItem( + text = { + if (accountViewModel.account.preferenceBetween(source, target) == target) { + Icon( + imageVector = Icons.Default.Check, + contentDescription = null, + modifier = Modifier.size(24.dp) + ) + } else { + Spacer(modifier = Modifier.size(24.dp)) + } + + Spacer(modifier = Modifier.size(10.dp)) + + Text( + stringResource( + R.string.translations_show_in_lang_first, + Locale(target).displayName + ) ) - } else { - Spacer(modifier = Modifier.size(24.dp)) + }, + onClick = { + scope.launch(Dispatchers.IO) { + accountViewModel.prefer(source, target, target) + langSettingsPopupExpanded = false + } } - - Spacer(modifier = Modifier.size(10.dp)) - - Text( - stringResource( - R.string.translations_show_in_lang_first, - Locale(target).displayName - ) - ) - } + ) Divider() val languageList = ConfigurationCompat.getLocales(Resources.getSystem().configuration) for (i in 0 until languageList.size()) { languageList.get(i)?.let { lang -> - DropdownMenuItem(onClick = { - scope.launch(Dispatchers.IO) { - accountViewModel.translateTo(lang) - langSettingsPopupExpanded = false - } - }) { - if (lang.language in accountViewModel.account.translateTo) { - Icon( - imageVector = Icons.Default.Check, - contentDescription = null, - modifier = Modifier.size(24.dp) - ) - } else { - Spacer(modifier = Modifier.size(24.dp)) - } + DropdownMenuItem( + text = { + if (lang.language in accountViewModel.account.translateTo) { + Icon( + imageVector = Icons.Default.Check, + contentDescription = null, + modifier = Modifier.size(24.dp) + ) + } else { + Spacer(modifier = Modifier.size(24.dp)) + } - Spacer(modifier = Modifier.size(10.dp)) + Spacer(modifier = Modifier.size(10.dp)) - Text( - stringResource( - R.string.translations_always_translate_to_lang, - lang.displayName + Text( + stringResource( + R.string.translations_always_translate_to_lang, + lang.displayName + ) ) - ) - } + }, + onClick = { + scope.launch(Dispatchers.IO) { + accountViewModel.translateTo(lang) + langSettingsPopupExpanded = false + } + } + ) } } } diff --git a/build.gradle b/build.gradle index e91051a8c..4fdcae5fb 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,7 @@ buildscript { exoplayer_version = '1.1.1' media3_version = '1.1.1' core_ktx_version = '1.12.0' + material3_version = '1.1.2' } dependencies { classpath 'com.google.gms:google-services:4.4.0'