Merge branch 'feature/redesign' into feature/desktop

This commit is contained in:
2026-10-14 00:21:38 +03:00
Unverified
47 changed files with 1272 additions and 125 deletions
+1 -3
View File
@@ -1,8 +1,6 @@
<component name="ArtifactManager">
<artifact type="jar" name="shared">
<output-path>$PROJECT_DIR$/utils/shared/build/libs</output-path>
<root id="archive" name="shared.jar">
<element id="module-output" name="FromChat.utils.shared.androidMain" />
</root>
<root id="archive" name="shared.jar" />
</artifact>
</component>
+1 -3
View File
@@ -1,8 +1,6 @@
<component name="ArtifactManager">
<artifact type="jar" name="shared-jvm">
<output-path>$PROJECT_DIR$/utils/shared/build/libs</output-path>
<root id="archive" name="shared-jvm.jar">
<element id="module-output" name="FromChat.utils.shared.jvmMain" />
</root>
<root id="archive" name="shared-jvm.jar" />
</artifact>
</component>
+1 -1
View File
@@ -2,6 +2,6 @@
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="externalSystemId" value="Gradle" />
<option name="version" value="2.4.20" />
<option name="version" value="2.4.21" />
</component>
</project>
+68
View File
@@ -0,0 +1,68 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Android" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
<module name="FromChat.app.android" />
<option name="ANDROID_RUN_CONFIGURATION_SCHEMA_VERSION" value="1" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="DEPLOY_AS_INSTANT" value="false" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="ALL_USERS" value="false" />
<option name="ALWAYS_INSTALL_WITH_PM" value="false" />
<option name="ALLOW_ASSUME_VERIFIED" value="false" />
<option name="CLEAR_APP_STORAGE" value="false" />
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="RESTORE_ENABLED" value="false" />
<option name="RESTORE_FILE" value="" />
<option name="RESTORE_FRESH_INSTALL_ONLY" value="false" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
</Hybrid>
<Java>
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
</Java>
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
</Native>
<Profilers>
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Java/Kotlin Method Trace" />
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY" value="" />
<option name="ACTIVITY_CLASS" value="" />
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
<option name="SKIP_ACTIVITY_VALIDATION" value="false" />
<method v="2">
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
+27
View File
@@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Desktop" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:desktop:run" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<ExternalSystemDebugDisabled>false</ExternalSystemDebugDisabled>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<GradleProfilingDisabled>false</GradleProfilingDisabled>
<GradleCoverageDisabled>false</GradleCoverageDisabled>
<method v="2" />
</configuration>
</component>
+1 -1
View File
@@ -1 +1 @@
100% бесплатный и открытый мессенджер.
FromChat - 100% бесплатный и открытый мессенджер.
@@ -1,6 +1,8 @@
package ru.fromchat.ui.components
import android.annotation.SuppressLint
import android.os.Build
import android.os.VibrationEffect
import android.view.HapticFeedbackConstants
import androidx.activity.BackEventCompat
import androidx.activity.compose.PredictiveBackHandler
@@ -44,15 +46,40 @@ actual fun rememberHapticFeedbackInternal(): (Int) -> Unit {
val view = LocalView.current
return remember(view) {
{ ordinal ->
val constant = when (ordinal) {
HapticFeedbackEvent.ProfileOpened.ordinal -> HapticFeedbackConstants.CLOCK_TICK
HapticFeedbackEvent.ProfileClosed.ordinal -> HapticFeedbackConstants.CLOCK_TICK
HapticFeedbackEvent.MessageSent.ordinal -> HapticFeedbackConstants.CONFIRM
HapticFeedbackEvent.ContextMenuOpened.ordinal -> HapticFeedbackConstants.CONFIRM
HapticFeedbackEvent.SelectionModeEntered.ordinal -> HapticFeedbackConstants.CONFIRM
else -> HapticFeedbackConstants.CLOCK_TICK
// Two-stage premium switch feel: SwitchPress → light tick, SwitchToggle →
// heavier commit click. On API 26+ we use the predefined-effect overload
// (VibrationEffect.EFFECT_TICK / EFFECT_CLICK) which routes to the system
// without VIBRATE permission and has built-in device fallback. On API 24-25
// we fall back to the legacy int constants.
when (ordinal) {
HapticFeedbackEvent.SwitchPress.ordinal -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.performHapticFeedback(0, VibrationEffect.EFFECT_TICK)
} else {
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
}
}
HapticFeedbackEvent.SwitchToggle.ordinal -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.performHapticFeedback(0, VibrationEffect.EFFECT_CLICK)
} else {
view.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
}
}
else -> {
val constant = when (ordinal) {
HapticFeedbackEvent.ProfileOpened.ordinal -> HapticFeedbackConstants.CLOCK_TICK
HapticFeedbackEvent.ProfileClosed.ordinal -> HapticFeedbackConstants.CLOCK_TICK
HapticFeedbackEvent.MessageSent.ordinal -> HapticFeedbackConstants.CONFIRM
HapticFeedbackEvent.ContextMenuOpened.ordinal -> HapticFeedbackConstants.CONFIRM
HapticFeedbackEvent.SelectionModeEntered.ordinal -> HapticFeedbackConstants.CONFIRM
else -> HapticFeedbackConstants.CLOCK_TICK
}
view.performHapticFeedback(constant)
}
}
view.performHapticFeedback(constant)
}
}
}
@@ -0,0 +1,5 @@
package ru.fromchat.ui.main.settings
// On Android, Compose MP's android renderer cannot load .svg
// painter resources and throws.
actual fun svgDrawablesSupported(): Boolean = false
@@ -341,6 +341,12 @@
<string name="settings_category_appearance">Оформление</string>
<string name="settings_category_appearance_d">Тема и Material You</string>
<string name="appearance_nav_bar_style">Стиль панели навигации</string>
<string name="appearance_nav_bar_style_d">Как выглядит нижняя панель навигации</string>
<string name="appearance_nav_bar_traditional">Классическая</string>
<string name="appearance_nav_bar_floating">Плавающая</string>
<string name="appearance_nav_bar_show_titles">Показывать названия вкладок</string>
<string name="appearance_nav_bar_show_titles_d">Показывать подпись выбранной вкладки</string>
<string name="settings_category_server_tools">Сервер и инструменты</string>
<string name="settings_category_server_tools_d">Смена сервера, отладка API</string>
<string name="settings_category_notifications">Уведомления</string>
@@ -373,6 +373,12 @@
<!-- Settings categories -->
<string name="settings_category_appearance">Appearance</string>
<string name="settings_category_appearance_d">Theme and Material You</string>
<string name="appearance_nav_bar_style">Navigation bar style</string>
<string name="appearance_nav_bar_style_d">How the bottom navigation bar looks</string>
<string name="appearance_nav_bar_traditional">Traditional</string>
<string name="appearance_nav_bar_floating">Floating</string>
<string name="appearance_nav_bar_show_titles">Show tab titles</string>
<string name="appearance_nav_bar_show_titles_d">Reveal the label of the selected tab</string>
<string name="settings_category_server_tools">Server and tools</string>
<string name="settings_category_server_tools_d">Change server, debug API</string>
<string name="settings_category_notifications">Notifications</string>
@@ -30,6 +30,8 @@ object Settings {
private const val LAST_SERVER_INSTANCE_ID_KEY = "last_server_instance_id"
private const val LAST_ACKNOWLEDGED_APP_VERSION_KEY = "last_acknowledged_app_version"
private const val RELEASE_NOTES_PERMANENTLY_HIDDEN_KEY = "release_notes_permanently_hidden"
private const val NAV_BAR_STYLE_KEY = "nav_bar_style"
private const val NAV_BAR_SHOW_TITLE_KEY = "nav_bar_show_title"
private val settings = PlatformSettings()
private val deviceSessionsJson = Json { ignoreUnknownKeys = true }
@@ -83,6 +85,20 @@ object Settings {
get() = runBlocking { Theme.entries[settings.getInt(THEME_KEY, Theme.AsSystem.ordinal)] }
set(value) = runIO { settings.putInt(THEME_KEY, value.ordinal) }
var navBarStyle: NavBarStyle
get() = runBlocking {
NavBarStyle.entries[settings.getInt(NAV_BAR_STYLE_KEY, NavBarStyle.Floating.ordinal)]
}
set(value) = runIO { settings.putInt(NAV_BAR_STYLE_KEY, value.ordinal) }
/**
* When true, compact (single-pane) detail screens use the Pixel top app bar
* with an app "seed" chip instead of the stock collapsing app bar.
*/
var navBarShowTitle: Boolean
get() = runBlocking { settings.getBoolean(NAV_BAR_SHOW_TITLE_KEY, true) }
set(value) = runIO { settings.putBoolean(NAV_BAR_SHOW_TITLE_KEY, value) }
/**
* When true, Enter sends the message and Shift+Enter inserts a newline.
* When false, Enter inserts a newline (previous composer behavior).
@@ -204,3 +220,12 @@ object Settings {
get() = runBlocking { settings.getBoolean(RELEASE_NOTES_PERMANENTLY_HIDDEN_KEY, false) }
set(value) = runIO { settings.putBoolean(RELEASE_NOTES_PERMANENTLY_HIDDEN_KEY, value) }
}
/** Main-screen bottom navigation bar style. */
enum class NavBarStyle {
/** Standard [androidx.compose.material3.NavigationBar] with icon + text labels. */
Traditional,
/** Floating, fully-rounded pill bar (drag-to-swap, colorful haze). */
Floating,
}
@@ -98,6 +98,7 @@ import ru.fromchat.ui.chat.panels.dm.navigateToDmChat
import ru.fromchat.ui.chat.panels.publicchat.PublicChatNav
import ru.fromchat.ui.chat.panels.publicchat.navigateToPublicChat
import ru.fromchat.ui.chat.utils.appRootAttachmentDropTarget
import ru.fromchat.ui.components.provideSwitchHaptics
import ru.fromchat.ui.main.ConversationListDetailShell
import ru.fromchat.ui.main.DesktopChatsDetailNavHost
import ru.fromchat.ui.main.DesktopContactsDetailNavHost
@@ -142,6 +143,10 @@ private fun standaloneProfileUserId(entry: NavBackStackEntry?): Int? {
return entry.savedStateHandle.get<String>("userId")?.toIntOrNull()?.takeIf { it > 0 }
}
/**
* Root NavHost transitions — scale+fade for the primary
* flow (welcome ↔ auth ↔ chat).
*/
private val rootNavTween = tween<Float>(durationMillis = 250, easing = FastOutSlowInEasing)
private fun rootNavEnterTransition(): EnterTransition =
@@ -356,6 +361,7 @@ fun App(
}
FromChatTheme {
provideSwitchHaptics {
SharedTransitionLayout {
val navController = rememberNavController()
val chatsDetailNavController = rememberNavController()
@@ -778,6 +784,7 @@ fun App(
}
}
}
}
}
}
@@ -0,0 +1,36 @@
package ru.fromchat.ui
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.ui.graphics.Shape
/**
* Central spring / motion tokens shared by the expressive components and
* transitions. Keeping them in one place keeps the whole app feeling
* consistent.
*/
/** Emphasized transitions — modal dialogs, large reveals. Slightly bouncy. */
val EmphasizedSpring = spring<Float>(
dampingRatio = Spring.DampingRatioMediumBouncy,
stiffness = Spring.StiffnessLow,
)
/** Standard interaction spring — press feedback, chip expansion. Snappy. */
val StandardSpring = spring<Float>(
dampingRatio = 0.85f,
stiffness = Spring.StiffnessMedium,
)
/**
* The app-bar title slide spring — slightly slower than standard so the
* word-by-word reflow reads as a deliberate motion rather than a snap.
*/
val TitleSpring = spring<Float>(
dampingRatio = 0.82f,
stiffness = 240f,
)
/** Full / CTA shape (nav pill, primary buttons) — fully rounded. */
val FullCtaShape: Shape = CircleShape
@@ -2,15 +2,19 @@ package ru.fromchat.ui
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import ru.fromchat.config.NavBarStyle
import ru.fromchat.config.Settings
import ru.fromchat.ui.components.googleSansMaterialTypography
import ru.fromchat.ui.components.googleSansFlexTypography
enum class Theme {
AsSystem,
@@ -26,6 +30,26 @@ var theme by mutableStateOf(
runCatching { Settings.theme }.getOrNull() ?: Theme.AsSystem
)
var navBarStyle by mutableStateOf(
runCatching { Settings.navBarStyle }.getOrNull() ?: NavBarStyle.Floating
)
var navBarShowTitle by mutableStateOf(
runCatching { Settings.navBarShowTitle }.getOrNull() ?: true
)
/**
* Expressive shape scale used by the redesigned UI (cards, nav pill, CTAs).
* Independent of the color scheme, so it is shared across platforms.
*/
val expressiveShapes = Shapes(
extraSmall = RoundedCornerShape(8.dp),
small = RoundedCornerShape(8.dp),
medium = RoundedCornerShape(12.dp),
large = RoundedCornerShape(16.dp),
extraLarge = RoundedCornerShape(28.dp),
)
@Composable
expect fun getColorScheme(darkTheme: Boolean, dynamicColor: Boolean): ColorScheme
@@ -122,7 +146,8 @@ fun FromChatTheme(
MaterialTheme(
colorScheme = colorScheme,
typography = googleSansMaterialTypography(),
typography = googleSansFlexTypography(),
shapes = expressiveShapes,
content = content
)
}
@@ -0,0 +1,73 @@
package ru.fromchat.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.pr0gramm3r101.components.ListItem
import com.pr0gramm3r101.components.ListItemContextMenuScope
import com.pr0gramm3r101.components.ListItemPosition
import tech.annexflow.constraintlayout.compose.ConstraintLayoutScope
/**
* A [ListItem] with the "expressive" settings-card look: a soft colored icon
* chip (40dp tile, full-round corners) behind a 26dp glyph, on a
* `surfaceBright` card. Everything else (press scaling, dividers, group
* clipping, context menus) is inherited from the base [ListItem].
*
* @param icon The icon to draw inside the chip.
* @param iconPreset The background + foreground (glyph) colors for the chip.
*/
@Composable
fun ExpressiveListItem(
icon: ImageVector,
iconPreset: IconPreset = ExpressiveTints.Purple,
headline: String,
supportingText: String? = null,
modifier: Modifier = Modifier,
trailingContent: (@Composable ConstraintLayoutScope.() -> Unit)? = null,
enabled: Boolean = true,
divider: Boolean = false,
position: ListItemPosition = ListItemPosition.MIDDLE,
groupItemCount: Int? = null,
onClick: (() -> Unit)? = null,
onContextMenuOpen: (() -> Unit)? = null,
contextMenu: (ListItemContextMenuScope.() -> Unit)? = null,
) {
ListItem(
modifier = modifier,
headline = headline,
supportingText = supportingText,
leadingContent = {
Box(
modifier = Modifier
.size(40.dp)
.background(iconPreset.background, shape = CircleShape),
contentAlignment = Alignment.Center,
) {
Icon(
imageVector = icon,
contentDescription = null,
tint = iconPreset.foreground,
modifier = Modifier.size(26.dp),
)
}
},
trailingContent = trailingContent,
containerColor = MaterialTheme.colorScheme.surfaceBright,
enabled = enabled,
divider = divider,
position = position,
groupItemCount = groupItemCount,
onClick = onClick,
onContextMenuOpen = onContextMenuOpen,
contextMenu = contextMenu,
)
}
@@ -0,0 +1,43 @@
package ru.fromchat.ui.components
import androidx.compose.ui.graphics.Color
/**
* A paired icon-tile color preset for the expressive list items / nav bar: a
* "background" fill behind a matching "foreground" (glyph) color. Each preset is
* a self-contained, reusable chip color extracted from the reference design.
*/
class IconPreset(
val background: Color,
val foreground: Color,
)
/**
* The fixed set of [IconPreset]s used by the settings list and the floating nav
* bar. Values are pulled directly from the Vaffuru reference (bg / fg pairs).
*/
object ExpressiveTints {
/** Light lavender chip, deep-violet glyph. */
val Purple = IconPreset(Color(0xFFB89CD1), Color(0xFF5229A4))
/** Deep violet chip, magenta glyph. */
val Rose = IconPreset(Color(0xFFD492BF), Color(0xFF8C0052))
/** Gold chip, brown glyph. */
val Yellow = IconPreset(Color(0xFFD29E0A), Color(0xFF693801))
/** Warm terracotta chip, dark-brown glyph. */
val Orange = IconPreset(Color(0xFFD39B71), Color(0xFF783707))
/** Green chip, deep-green glyph. */
val Green = IconPreset(Color(0xFF70B576), Color(0xFF00512B))
/** Sky-blue chip, deep-navy glyph. Good fit for "identity / account" items. */
val Blue = IconPreset(Color(0xFFA1C9FF), Color(0xFF04409F))
/** Cyan chip, deep-teal glyph. Good fit for "server / network" items. */
val Cyan = IconPreset(Color(0xFF67D4FF), Color(0xFF004D68))
/** Neutral surface tile (accent / default). */
val NeutralTile: Color = Color(0xFF1C1C1C).copy(alpha = 0.06f)
}
@@ -0,0 +1,270 @@
package ru.fromchat.ui.components
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkHorizontally
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.CircleShape
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.getValue
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.boundsInRoot
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import dev.chrisbanes.haze.HazeState
import kotlin.math.abs
/**
* A single item in a [FloatingNavBar]. When [selected], the item is expanded
* to reveal its [label] and drawn on a tone-container pill (secondaryContainer)
* to highlight it. When not selected, the item is a plain round chip with
* no container color.
*/
@Composable
private fun FloatingNavItem(
icon: ImageVector,
label: String,
selected: Boolean,
showTitle: Boolean,
onClick: () -> Unit,
onPositioned: (LayoutCoordinates) -> Unit,
) {
val contentColor by animateColorAsState(
targetValue = if (selected) {
MaterialTheme.colorScheme.onSecondaryContainer
} else {
MaterialTheme.colorScheme.onSurfaceVariant
},
animationSpec = tween(300),
label = "navItemContentColor",
)
val containerColor by animateColorAsState(
targetValue = if (selected) {
MaterialTheme.colorScheme.secondaryContainer
} else {
Color.Transparent
},
animationSpec = tween(300),
label = "navItemContainerColor",
)
val interactionSource = remember { MutableInteractionSource() }
Surface(
modifier = Modifier
.onGloballyPositioned { onPositioned(it) }
.clip(CircleShape)
.clickable(
interactionSource = interactionSource,
indication = null,
onClick = onClick,
),
shape = CircleShape,
color = containerColor,
) {
Row(
modifier = Modifier.padding(horizontal = 12.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
Icon(
imageVector = icon,
contentDescription = label,
tint = contentColor,
modifier = Modifier.size(22.dp),
)
AnimatedVisibility(
visible = selected && showTitle,
enter = expandHorizontally(animationSpec = tween(300)) + fadeIn(animationSpec = tween(300)),
exit = shrinkHorizontally(animationSpec = tween(300)) + fadeOut(animationSpec = tween(300)),
) {
Text(
text = label,
modifier = Modifier.padding(start = 8.dp),
color = contentColor,
style = MaterialTheme.typography.labelMedium,
maxLines = 1,
softWrap = false,
overflow = TextOverflow.Ellipsis,
)
}
}
}
}
/**
* A floating, fully-rounded (CircleShape) pill navigation bar with:
* * a subtle primary-tinted haze backdrop (the "colorful" blur),
* * an expanded selected-state that reveals the item label on tap,
* * a tonal (secondaryContainer) pill highlight on the selected item,
* * a drag-to-swap gesture (hold + slide across the bar).
*
* The bar is centered horizontally within its parent; the parent is expected to
* handle window-inset padding (status / navigation bars, IME) before calling
* this composable.
*
* @param items The items to render. Exactly one should have `selected = true`.
* @param selectedId The id of the currently selected item (label reveal + pill highlight).
* @param onItemClick Called on tap with the item id.
* @param onSwap Called when a drag-to-swap gesture completes over another item.
* @param hazeState Optional [HazeState]; when present, the pill uses a tinted
* haze backdrop. When null, `containerColor` is used instead.
*/
@Composable
fun FloatingNavBar(
items: List<FloatingNavItemSpec>,
selectedId: String,
showTitles: Boolean = true,
onItemClick: (String) -> Unit,
onSwap: (String) -> Unit = {},
modifier: Modifier = Modifier,
hazeState: HazeState? = null,
containerColor: Color = MaterialTheme.colorScheme.surfaceContainerLow,
tint: Color = MaterialTheme.colorScheme.primary,
) {
val itemCoordinates = remember { mutableStateMapOf<String, LayoutCoordinates>() }
val rootBounds = remember { mutableMapOf<String, Rect>() }
var isDragging by remember { mutableStateOf(false) }
var dragTargetId by remember { mutableStateOf<String?>(null) }
val haptic = LocalHapticFeedback.current
fun updateBounds() {
itemCoordinates.forEach { (id, coords) ->
if (coords.isAttached) {
rootBounds[id] = coords.boundsInRoot()
}
}
}
fun dragNearest(targetX: Float): String? {
return items.minByOrNull { item ->
val rect = rootBounds[item.id]
if (rect != null) {
val centerX = rect.left + rect.width / 2
abs(centerX - targetX)
} else {
Float.MAX_VALUE
}
}?.id
}
fun endDrag() {
val target = dragTargetId
isDragging = false
dragTargetId = null
if (target != null && target != selectedId) {
onSwap(target)
}
}
val surfaceColor = if (hazeState != null) Color.Transparent else containerColor
// Outer Box: fill parent width, center horizontally. Inner Surface: natural
// width capped at 620dp so it reads as a floating pill (not full-width).
Box(
modifier = modifier,
contentAlignment = Alignment.Center,
) {
Surface(
shape = CircleShape,
color = surfaceColor,
shadowElevation = 8.dp,
modifier = Modifier
.widthIn(max = 620.dp)
.zIndex(1f)
.clip(CircleShape)
.then(if (hazeState != null) Modifier.tintedHaze(hazeState, tint = tint) else Modifier),
) {
Row(
modifier = Modifier
.wrapContentWidth(Alignment.Start)
.padding(8.dp)
.pointerInput(Unit) {
detectDragGestures(
onDragStart = { offset ->
isDragging = true
updateBounds()
val container = itemCoordinates.values.firstOrNull()
if (container != null && container.isAttached) {
val rootTouchX = container.localToRoot(offset).x
dragTargetId = dragNearest(rootTouchX)
}
},
onDragEnd = { endDrag() },
onDragCancel = { endDrag() },
onDrag = { change, _ ->
change.consume()
val coords = itemCoordinates.values.firstOrNull()
if (coords != null && coords.isAttached) {
val rootTouchX = coords.localToRoot(change.position).x
val nearest = dragNearest(rootTouchX)
if (nearest != dragTargetId) {
dragTargetId = nearest
if (nearest != null) {
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
}
}
}
},
)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
items.forEach { item ->
if (item.id != items.first().id) {
Spacer(modifier = Modifier.width(4.dp))
}
FloatingNavItem(
icon = item.icon,
label = item.label,
selected = item.id == selectedId,
showTitle = showTitles,
onClick = { onItemClick(item.id) },
onPositioned = { itemCoordinates[item.id] = it },
)
}
}
}
}
}
/** A spec for an item in a [FloatingNavBar]. */
data class FloatingNavItemSpec(
val id: String,
val icon: ImageVector,
val label: String,
)
@@ -0,0 +1,36 @@
package ru.fromchat.ui.components
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import dev.chrisbanes.haze.HazeInput
import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.blur.HazeColorEffect
import dev.chrisbanes.haze.blur.hazeBlur
import dev.chrisbanes.haze.blur.materials.HazeMaterials
private const val DEFAULT_TINT_ALPHA = 0.06f
/**
* Applies [HazeMaterials.thin] with a subtle primary-color [tint] on top,
* producing the "colorful blur" look from the Pixel-styled redesign. Use on
* the nav bar and any panel/chrome surface where we want the blur to pick up
* a little color. Search bars and text fields should **not** use it.
*
* @param hazeState The [HazeState] to blur against (must have matching
* `.hazeSource(hazeState)` ancestors).
* @param tint The color to tint the blurred backdrop with.
* @param alpha How visible the tint is, 0.0 = no tint, 1.0 = full tint.
*/
@Composable
fun Modifier.tintedHaze(
hazeState: HazeState,
tint: Color = MaterialTheme.colorScheme.primary,
alpha: Float = DEFAULT_TINT_ALPHA,
): Modifier = hazeBlur(
input = HazeInput.Backdrop(hazeState),
style = HazeMaterials.thin().then {
colorEffects(listOf(HazeColorEffect.tint(tint.copy(alpha = alpha))))
},
)
@@ -0,0 +1,168 @@
package ru.fromchat.ui.components
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.spring
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
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.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
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.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.delay
import kotlin.time.Duration.Companion.milliseconds
/**
* Word-by-word staggered reveal for the app bar title. Each word fades and
* rises in with a small per-word delay, giving the deliberate "reflow" feel.
* Re-runs whenever [text] changes.
*/
/**
* Word-by-word staggered reveal for the app bar title. Each word fades and
* rises in with a small per-word delay, giving the deliberate "reflow" feel.
* Re-runs whenever [text] changes.
*/
@Composable
fun AnimatedWordTitle(
text: String,
modifier: Modifier = Modifier,
) {
val words = remember(text) { text.split(" ") }
var generation by remember { mutableIntStateOf(0) }
LaunchedEffect(text) {
generation++
}
Row(
modifier = modifier,
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
) {
words.forEachIndexed { index, word ->
var visible by remember { mutableStateOf(false) }
LaunchedEffect(generation) {
visible = false
delay((index * 45).milliseconds)
visible = true
}
val alpha by animateFloatAsState(
targetValue = if (visible) 1f else 0f,
animationSpec = spring(dampingRatio = 0.82f, stiffness = 240f),
label = "pTitleWordAlpha$index",
)
Box(
modifier = Modifier.alpha(alpha),
) {
Text(
text = word,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
if (index < words.lastIndex) {
Spacer(modifier = Modifier.width(8.dp))
}
}
}
}
/**
* A Pixel-style compact top app bar: an app "seed" chip on the leading edge
* (replacing the old back-arrow slot), a word-by-word animated title, and
* optional trailing actions. Intentionally **not** the stock M3 [TopAppBar] —
* the title refills via the staggered [AnimatedWordTitle].
*
* @param title The plain title text (split into words for the reveal).
* @param topPadding Top padding to apply above the bar (status-bar insets, etc).
* @param leadingIcon Icon drawn in the round chip (defaults to a menu icon).
* @param onLeadingAction Invoked when the leading chip is tapped (optional).
* @param trailingActions Trailing action slot.
*/
@Composable
fun PixelTopAppBar(
title: String,
modifier: Modifier = Modifier,
topPadding: Dp = 0.dp,
leadingIcon: ImageVector = Icons.Default.Menu,
leadingTint: Color = MaterialTheme.colorScheme.surfaceBright,
leadingSubTint: Color = MaterialTheme.colorScheme.onSurface,
onLeadingAction: (() -> Unit)? = null,
trailingActions: @Composable RowScope.() -> Unit = {},
containerColor: Color = Color.Transparent,
) {
Surface(
modifier = modifier.fillMaxWidth(),
color = containerColor,
content = {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(top = topPadding),
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp)
.height(64.dp),
verticalAlignment = Alignment.CenterVertically,
) {
if (onLeadingAction != null) {
IconButton(
onClick = onLeadingAction,
modifier = Modifier.size(48.dp),
) {
Box(
modifier = Modifier
.size(40.dp)
.background(leadingTint, shape = CircleShape),
contentAlignment = Alignment.Center,
) {
Icon(
imageVector = leadingIcon,
contentDescription = null,
tint = leadingSubTint,
modifier = Modifier.size(26.dp),
)
}
}
}
AnimatedWordTitle(
text = title,
modifier = Modifier
.weight(1f)
.padding(horizontal = 16.dp),
)
trailingActions()
}
}
},
)
}
@@ -0,0 +1,35 @@
package ru.fromchat.ui.components
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import com.pr0gramm3r101.components.LocalSwitchHaptic
import ru.fromchat.utils.haptic.HapticFeedbackEvent
import ru.fromchat.utils.haptic.rememberHapticFeedback
/**
* Provides the real haptic-firing lambda to every `SwitchListItem` in the subtree.
* Call once at the app root (e.g., inside `@Preview`/`App`/main activity content).
*
* - `SwitchPress` (light tick on touch-down) → `VibrationEffect.EFFECT_TICK` (API 26+)
* or `HapticFeedbackConstants.CLOCK_TICK` (API 24–25) on Android; `UIImpactFeedbackStyleLight`
* on iOS; no-op on Desktop.
* - `SwitchToggle` (heavier commit click when state flips) → `VibrationEffect.EFFECT_CLICK`
* / `HapticFeedbackConstants.CONFIRM` on Android; `UIImpactFeedbackStyleHeavy` on iOS.
*
* The default [LocalSwitchHaptic] is a no-op, so a screen that forgets to call this
* provider still renders correctly — it just doesn't vibrate.
*/
@Composable
fun provideSwitchHaptics(content: @Composable () -> Unit) {
val fire = rememberHapticFeedback()
CompositionLocalProvider(
LocalSwitchHaptic provides { ordinal: Int ->
// Map integer ordinal → enum by position. The enum ordinals are stable
// because we only append at the end (see HapticFeedbackEvent.kt).
val event = HapticFeedbackEvent.entries.getOrNull(ordinal)
if (event != null) fire(event)
},
) {
content()
}
}
@@ -2,48 +2,142 @@ package ru.fromchat.ui.components
import androidx.compose.material3.Typography
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import org.jetbrains.compose.resources.Font
import ru.fromchat.Res
import ru.fromchat.google_sans_bold
import ru.fromchat.google_sans_bold_italic
import ru.fromchat.google_sans_italic
import ru.fromchat.google_sans_medium
import ru.fromchat.google_sans_medium_italic
import ru.fromchat.google_sans_regular
import ru.fromchat.google_sans_semibold
import ru.fromchat.google_sans_semibold_italic
import ru.fromchat.google_sans_rounded_regular
/**
* Typography matching Vaffuru's expressive Material 3 look.
*
* Font: **Google Sans Rounded** (the `zE.ttf` shipped in the Vaffuru APK — OFL,
* weight-class 500, 36k glyphs with full Latin + Cyrillic + Greek coverage).
* Multiple weight instances are registered (300–900) so Compose picks the
* closest available weight per role.
*
* Vaffuru's `s27.java` uses a single FontFamily of `google_sans_rounded_regular`
* with 6 weight slots (300, 400, 500, 600, 700, 900) plus ROND=100 + wght
* variable settings (no-op for a non-variable font, kept for intent).
*/
@Composable
fun googleSansMaterialTypography() = Typography().let {
fun googleSansFlexTypography(): Typography {
val family = FontFamily(
Font(Res.font.google_sans_regular, FontWeight.Normal, FontStyle.Normal),
Font(Res.font.google_sans_italic, FontWeight.Normal, FontStyle.Italic),
Font(Res.font.google_sans_medium, FontWeight.Medium, FontStyle.Normal),
Font(Res.font.google_sans_medium_italic, FontWeight.Medium, FontStyle.Italic),
Font(Res.font.google_sans_semibold, FontWeight.SemiBold, FontStyle.Normal),
Font(Res.font.google_sans_semibold_italic, FontWeight.SemiBold, FontStyle.Italic),
Font(Res.font.google_sans_bold, FontWeight.Bold, FontStyle.Normal),
Font(Res.font.google_sans_bold_italic, FontWeight.Bold, FontStyle.Italic),
Font(Res.font.google_sans_rounded_regular, FontWeight(300)),
Font(Res.font.google_sans_rounded_regular, FontWeight(400)),
Font(Res.font.google_sans_rounded_regular, FontWeight(500)),
Font(Res.font.google_sans_rounded_regular, FontWeight(600)),
Font(Res.font.google_sans_rounded_regular, FontWeight(700)),
Font(Res.font.google_sans_rounded_regular, FontWeight(900)),
)
it.copy(
displayLarge = it.displayLarge.copy(fontFamily = family),
displayMedium = it.displayMedium.copy(fontFamily = family),
displaySmall = it.displaySmall.copy(fontFamily = family),
headlineLarge = it.headlineLarge.copy(fontFamily = family),
headlineMedium = it.headlineMedium.copy(fontFamily = family),
headlineSmall = it.headlineSmall.copy(fontFamily = family),
titleLarge = it.titleLarge.copy(fontFamily = family),
titleMedium = it.titleMedium.copy(fontFamily = family),
titleSmall = it.titleSmall.copy(fontFamily = family),
bodyLarge = it.bodyLarge.copy(fontFamily = family),
bodyMedium = it.bodyMedium.copy(fontFamily = family),
bodySmall = it.bodySmall.copy(fontFamily = family),
labelLarge = it.labelLarge.copy(fontFamily = family),
labelMedium = it.labelMedium.copy(fontFamily = family),
labelSmall = it.labelSmall.copy(fontFamily = family),
return Typography(
displayLarge = TextStyle(
fontFamily = family,
fontSize = 48.sp,
fontWeight = FontWeight(700),
lineHeight = 56.sp,
letterSpacing = 0.sp,
),
displayMedium = TextStyle(
fontFamily = family,
fontSize = 36.sp,
fontWeight = FontWeight(700),
lineHeight = 44.sp,
letterSpacing = 0.sp,
),
displaySmall = TextStyle(
fontFamily = family,
fontSize = 30.sp,
fontWeight = FontWeight(400),
lineHeight = 38.sp,
letterSpacing = 0.sp,
),
headlineLarge = TextStyle(
fontFamily = family,
fontSize = 32.sp,
fontWeight = FontWeight(600),
lineHeight = 40.sp,
letterSpacing = 0.sp,
),
headlineMedium = TextStyle(
fontFamily = family,
fontSize = 28.sp,
fontWeight = FontWeight(600),
lineHeight = 36.sp,
letterSpacing = 0.sp,
),
headlineSmall = TextStyle(
fontFamily = family,
fontSize = 24.sp,
fontWeight = FontWeight(600),
lineHeight = 32.sp,
letterSpacing = 0.sp,
),
titleLarge = TextStyle(
fontFamily = family,
fontSize = 22.sp,
fontWeight = FontWeight(400),
lineHeight = 28.sp,
letterSpacing = 0.sp,
),
titleMedium = TextStyle(
fontFamily = family,
fontSize = 18.sp,
fontWeight = FontWeight(500),
lineHeight = 24.sp,
letterSpacing = 0.15.sp,
),
titleSmall = TextStyle(
fontFamily = family,
fontSize = 14.sp,
fontWeight = FontWeight(500),
lineHeight = 20.sp,
letterSpacing = 0.1.sp,
),
bodyLarge = TextStyle(
fontFamily = family,
fontSize = 16.sp,
fontWeight = FontWeight(400),
lineHeight = 24.sp,
letterSpacing = 0.5.sp,
),
bodyMedium = TextStyle(
fontFamily = family,
fontSize = 14.sp,
fontWeight = FontWeight(400),
lineHeight = 20.sp,
letterSpacing = 0.25.sp,
),
bodySmall = TextStyle(
fontFamily = family,
fontSize = 12.sp,
fontWeight = FontWeight(400),
lineHeight = 16.sp,
letterSpacing = 0.4.sp,
),
labelLarge = TextStyle(
fontFamily = family,
fontSize = 16.sp,
fontWeight = FontWeight(500),
lineHeight = 20.sp,
letterSpacing = 0.1.sp,
),
labelMedium = TextStyle(
fontFamily = family,
fontSize = 14.sp,
fontWeight = FontWeight(500),
lineHeight = 16.sp,
letterSpacing = 0.5.sp,
),
labelSmall = TextStyle(
fontFamily = family,
fontSize = 11.sp,
fontWeight = FontWeight(500),
lineHeight = 16.sp,
letterSpacing = 0.5.sp,
),
)
}
}
@@ -46,7 +46,9 @@ fun NavGraphBuilder.conversationDetailDestinations(
sharedTransitionScope: SharedTransitionScope,
scrollToMessageId: Int?,
) {
composable(PublicChatNav.CHAT_ROUTE) {
composable(
route = PublicChatNav.CHAT_ROUTE,
) {
PublicChatChatRoute(
scrollToMessageId = scrollToMessageId,
navController = navController,
@@ -55,7 +57,9 @@ fun NavGraphBuilder.conversationDetailDestinations(
)
}
composable(PublicChatNav.PROFILE_ROUTE) {
composable(
route = PublicChatNav.PROFILE_ROUTE,
) {
PublicChatProfileRoute(
navController = navController,
sharedTransitionScope = sharedTransitionScope,
@@ -64,16 +64,21 @@ import org.jetbrains.compose.resources.stringResource
import ru.fromchat.Res
import ru.fromchat.api.ApiClient
import ru.fromchat.chats
import ru.fromchat.config.NavBarStyle
import ru.fromchat.contacts
import ru.fromchat.desktop.DesktopMenuCommand
import ru.fromchat.desktop.DesktopMenuCommands
import ru.fromchat.profile
import ru.fromchat.settings
import ru.fromchat.ui.LocalNavController
import ru.fromchat.ui.navBarShowTitle
import ru.fromchat.ui.navBarStyle
import ru.fromchat.ui.chat.rememberChatSurfaceContainerHazeStyle
import ru.fromchat.ui.chat.panels.dm.navigateToDmChat
import ru.fromchat.ui.components.BackHandler
import ru.fromchat.ui.components.FromChatSnackbarHost
import ru.fromchat.ui.components.FloatingNavBar
import ru.fromchat.ui.components.FloatingNavItemSpec
import ru.fromchat.ui.components.LocalPaneHazeState
import ru.fromchat.ui.components.Text
import ru.fromchat.ui.extraStatusBars
@@ -82,6 +87,7 @@ import ru.fromchat.ui.main.chats.ChatContextMenuOverlayHost
import ru.fromchat.ui.main.chats.ChatsSearchScreen
import ru.fromchat.ui.main.chats.ChatsTab
import ru.fromchat.ui.main.settings.SettingsTab
import ru.fromchat.config.Settings as AppSettings
import ru.fromchat.ui.profile.ProfileScreen
const val MAIN_PAGE_CHATS = 0
@@ -263,6 +269,7 @@ fun MainScreen(
val contactsLabel = stringResource(Res.string.contacts)
val settingsLabel = stringResource(Res.string.settings)
val profileLabel = stringResource(Res.string.profile)
val navBarStyle = navBarStyle
BoxWithConstraints(
Modifier.fillMaxSize(),
@@ -342,9 +349,60 @@ fun MainScreen(
bottomChromeHeightDp = measured
}
}
.background(MaterialTheme.colorScheme.surfaceContainer)
.hazeBlur(input = HazeInput.Backdrop(navBarHazeState), style = navBarHazeStyle),
.then(
if (navBarStyle == NavBarStyle.Floating) {
Modifier.padding(
start = 16.dp,
end = 16.dp,
top = 16.dp,
bottom = 16.dp + WindowInsets.navigationBars.only(WindowInsetsSides.Bottom).let {
with(density) { it.getBottom(this).toDp() }
},
)
} else {
Modifier
.background(MaterialTheme.colorScheme.surfaceContainer)
.hazeBlur(input = HazeInput.Backdrop(navBarHazeState), style = navBarHazeStyle)
},
),
) {
if (navBarStyle == NavBarStyle.Floating) {
FloatingNavBar(
modifier = Modifier.fillMaxWidth(),
items =
listOf(
FloatingNavItemSpec(PAGE_CHATS.toString(), Icons.AutoMirrored.Filled.Chat, chatsLabel),
FloatingNavItemSpec(PAGE_CONTACTS.toString(), Icons.Filled.Contacts, contactsLabel),
FloatingNavItemSpec(PAGE_SETTINGS.toString(), Icons.Filled.Settings, settingsLabel),
FloatingNavItemSpec(PAGE_PROFILE.toString(), Icons.Filled.Person, profileLabel),
),
selectedId = selectedPage.toString(),
showTitles = navBarShowTitle,
onItemClick = { id ->
id.toIntOrNull()?.let { page ->
selectMainPage(
page = page,
widthClass = widthClass,
scope = scope,
pagerState = pagerState,
settingsDetailNavController = settingsDetailNavController,
)
}
},
onSwap = { id ->
id.toIntOrNull()?.let { page ->
selectMainPage(
page = page,
widthClass = widthClass,
scope = scope,
pagerState = pagerState,
settingsDetailNavController = settingsDetailNavController,
)
}
},
hazeState = navBarHazeState,
)
} else {
NavigationBar(
modifier = Modifier.fillMaxWidth(),
containerColor = Color.Transparent,
@@ -422,6 +480,7 @@ fun MainScreen(
},
)
}
}
}
}
@@ -30,7 +30,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.pr0gramm3r101.components.Category
import com.pr0gramm3r101.components.ListItem
@@ -77,13 +76,7 @@ fun AboutScreen() {
containerColor = MaterialTheme.colorScheme.background,
topBar = {
SettingsDetailTopBar(
title = {
Text(
stringResource(Res.string.about),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
},
title = stringResource(Res.string.about),
onBack = { navController.navigateUp() },
scrollBehavior = scrollBehavior,
)
@@ -39,7 +39,14 @@ import com.pr0gramm3r101.utils.conditional
import com.pr0gramm3r101.utils.materialYouAvailable
import org.jetbrains.compose.resources.stringResource
import ru.fromchat.Res
import ru.fromchat.appearance_nav_bar_floating
import ru.fromchat.appearance_nav_bar_show_titles
import ru.fromchat.appearance_nav_bar_show_titles_d
import ru.fromchat.appearance_nav_bar_style
import ru.fromchat.appearance_nav_bar_style_d
import ru.fromchat.appearance_nav_bar_traditional
import ru.fromchat.as_system
import ru.fromchat.config.NavBarStyle
import ru.fromchat.config.Settings
import ru.fromchat.dark
import ru.fromchat.enter_to_send
@@ -52,6 +59,8 @@ import ru.fromchat.theme
import ru.fromchat.ui.Theme
import ru.fromchat.ui.components.Text
import ru.fromchat.ui.dynamicThemeEnabled
import ru.fromchat.ui.navBarShowTitle
import ru.fromchat.ui.navBarStyle
import ru.fromchat.ui.theme
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@@ -70,7 +79,7 @@ fun AppearanceScreen(onBack: () -> Unit) {
containerColor = MaterialTheme.colorScheme.background,
topBar = {
SettingsDetailTopBar(
title = { Text(stringResource(Res.string.settings_category_appearance)) },
title = stringResource(Res.string.settings_category_appearance),
onBack = onBack,
scrollBehavior = scrollBehavior,
)
@@ -155,6 +164,52 @@ fun AppearanceScreen(onBack: () -> Unit) {
}
)
}
Category(
Modifier.padding(top = 8.dp),
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
) {
ListItem(
headline = stringResource(Res.string.appearance_nav_bar_style),
supportingText = stringResource(Res.string.appearance_nav_bar_style_d),
leadingContent = { Icon(Icons.Filled.Brush, null) },
divider = true,
bottomContent = {
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
NavBarStyle.entries.forEach { style ->
FilterChip(
onClick = {
Settings.navBarStyle = style
navBarStyle = style
},
selected = navBarStyle == style,
label = {
Text(
text = if (style == NavBarStyle.Traditional) {
stringResource(Res.string.appearance_nav_bar_traditional)
} else {
stringResource(Res.string.appearance_nav_bar_floating)
},
overflow = TextOverflow.Ellipsis
)
}
)
}
}
}
)
SwitchListItem(
headline = stringResource(Res.string.appearance_nav_bar_show_titles),
supportingText = stringResource(Res.string.appearance_nav_bar_show_titles_d),
enabled = navBarStyle == NavBarStyle.Floating,
checked = navBarShowTitle,
onCheckedChange = {
Settings.navBarShowTitle = it
navBarShowTitle = it
},
divider = false
)
}
}
}
}
@@ -145,14 +145,21 @@ internal fun deviceSessionIcon(d: DeviceSessionInfo): ImageVector {
}
}
internal fun deviceSessionLogoResource(d: DeviceSessionInfo): DrawableResource? =
when (resolveDeviceOsName(d)?.lowercase()) {
internal fun deviceSessionLogoResource(d: DeviceSessionInfo): DrawableResource? {
// Android (Compose MP AndroidRenderer) cannot rasterise SVG files and throws
// "Android platform doesn't support SVG format." when a .svg drawable is used
// via painterResource. On Android fall back to the vector [deviceSessionIcon].
if (!svgDrawablesSupported()) return null
return when (resolveDeviceOsName(d)?.lowercase()) {
"windows" -> Res.drawable.os_windows
"macos" -> Res.drawable.os_macos
"linux" -> Res.drawable.os_linux
else -> null
}
}
/** True when the Compose renderer can load .svg drawables (JVM / iOS). */
expect fun svgDrawablesSupported(): Boolean
internal fun resolveDeviceOsName(d: DeviceSessionInfo): String? {
val direct = normalizeDeviceOsName(d.osName)
if (direct != null) return direct
@@ -44,7 +44,6 @@ import ru.fromchat.settings_push_notifications_unavailable
import ru.fromchat.settings_desktop_notifications
import ru.fromchat.settings_desktop_notifications_d
import ru.fromchat.ui.components.FromChatSnackbarHost
import ru.fromchat.ui.components.Text
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -68,7 +67,7 @@ fun NotificationsScreen(onBack: () -> Unit) {
snackbarHost = { FromChatSnackbarHost(hostState = snackbarHostState) },
topBar = {
SettingsDetailTopBar(
title = { Text(stringResource(Res.string.settings_notifications_title)) },
title = stringResource(Res.string.settings_notifications_title),
onBack = onBack,
scrollBehavior = scrollBehavior,
)
@@ -33,6 +33,7 @@ import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.stringResource
import ru.fromchat.Res
import ru.fromchat.back
import ru.fromchat.ui.components.AnimatedWordTitle
import ru.fromchat.ui.extraStatusBars
import ru.fromchat.ui.main.detailPaneShowBackButton
@@ -72,7 +73,7 @@ fun rememberSettingsCollapsingScrollBehavior(): TopAppBarScrollBehavior {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsDetailTopBar(
title: @Composable () -> Unit,
title: String,
onBack: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior? = null,
) {
@@ -86,14 +87,11 @@ fun SettingsDetailTopBar(
}
}
}
// Match Profile / shell (`background`), not AppPanel's default
// `surfaceContainerLowest` — that token reads as a separate pane fill in
// two-pane against the list–detail shell.
val paneColor = MaterialTheme.colorScheme.background
val topBarWindowInsets = settingsDetailWindowInsets()
if (settingsDetailUseCollapsingTopBar()) {
MediumTopAppBar(
title = title,
title = { AnimatedWordTitle(text = title) },
navigationIcon = navigationIcon,
scrollBehavior = scrollBehavior,
windowInsets = topBarWindowInsets,
@@ -105,7 +103,7 @@ fun SettingsDetailTopBar(
} else {
// Desktop / expanded: pinned TopAppBar (not Large/Medium).
TopAppBar(
title = title,
title = { AnimatedWordTitle(text = title) },
navigationIcon = navigationIcon,
windowInsets = topBarWindowInsets,
colors = TopAppBarDefaults.topAppBarColors(
@@ -8,16 +8,15 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.Devices
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.Palette
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.Storage
import androidx.compose.material.icons.outlined.BugReport
import androidx.compose.material.icons.rounded.AccountCircle
import androidx.compose.material.icons.rounded.Devices
import androidx.compose.material.icons.rounded.Info
import androidx.compose.material.icons.rounded.Notifications
import androidx.compose.material.icons.rounded.Palette
import androidx.compose.material.icons.rounded.Person
import androidx.compose.material.icons.rounded.Storage
import androidx.compose.material.icons.rounded.BugReport
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.TopAppBar
@@ -28,7 +27,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.pr0gramm3r101.components.Category
import com.pr0gramm3r101.components.ListItem
import com.pr0gramm3r101.utils.WindowWidthSizeClass
import com.pr0gramm3r101.utils.currentWindowAdaptiveInfo
import com.pr0gramm3r101.utils.verticalScroll
@@ -55,6 +53,8 @@ import ru.fromchat.settings_hub_logs_sub
import ru.fromchat.settings_hub_profile_sub
import ru.fromchat.ui.LocalNavController
import ru.fromchat.ui.components.Text
import ru.fromchat.ui.components.ExpressiveListItem
import ru.fromchat.ui.components.ExpressiveTints
import ru.fromchat.ui.extraStatusBars
import ru.fromchat.ui.main.LocalConversationListDetailActive
import ru.fromchat.ui.main.LocalDesktopSettingsNavController
@@ -111,72 +111,82 @@ fun SettingsTab() {
if (isTwoPane) {
Category(Modifier.padding(top = 16.dp)) {
ListItem(
ExpressiveListItem(
icon = Icons.Rounded.Person,
iconPreset = ExpressiveTints.Blue,
headline = stringResource(Res.string.profile),
supportingText = stringResource(Res.string.settings_hub_profile_sub),
onClick = {
val userId = ApiClient.user?.id?.takeIf { it > 0 } ?: return@ListItem
val userId = ApiClient.user?.id?.takeIf { it > 0 } ?: return@ExpressiveListItem
openDetail("profile/$userId")
},
leadingContent = { Icon(Icons.Filled.Person, null) },
)
}
}
Category(Modifier.padding(top = 16.dp)) {
ListItem(
ExpressiveListItem(
icon = Icons.Rounded.AccountCircle,
iconPreset = ExpressiveTints.Green,
headline = stringResource(Res.string.settings_category_account),
supportingText = stringResource(Res.string.settings_category_account_d),
onClick = { openDetail(SettingsRoutes.Account) },
leadingContent = { Icon(Icons.Filled.AccountCircle, null) },
divider = true
)
ListItem(
ExpressiveListItem(
icon = Icons.Rounded.Devices,
iconPreset = ExpressiveTints.Rose,
headline = stringResource(Res.string.settings_category_devices),
supportingText = stringResource(Res.string.settings_category_devices_d),
onClick = { openDetail(SettingsRoutes.Devices) },
leadingContent = { Icon(Icons.Filled.Devices, null) },
divider = true
)
}
ListItem(
Category(Modifier.padding(top = 8.dp)) {
ExpressiveListItem(
icon = Icons.Rounded.Palette,
iconPreset = ExpressiveTints.Yellow,
headline = stringResource(Res.string.settings_category_appearance),
supportingText = stringResource(Res.string.settings_category_appearance_d),
onClick = { openDetail(SettingsRoutes.Appearance) },
leadingContent = { Icon(Icons.Filled.Palette, null) },
divider = true
)
ListItem(
ExpressiveListItem(
icon = Icons.Rounded.Notifications,
iconPreset = ExpressiveTints.Orange,
headline = stringResource(Res.string.settings_category_notifications),
supportingText = stringResource(Res.string.settings_category_notifications_d),
onClick = { openDetail(SettingsRoutes.Notifications) },
leadingContent = { Icon(Icons.Filled.Notifications, null) },
divider = true
)
}
ListItem(
Category(Modifier.padding(top = 8.dp)) {
ExpressiveListItem(
icon = Icons.Rounded.Storage,
iconPreset = ExpressiveTints.Cyan,
headline = stringResource(Res.string.change_server),
supportingText = stringResource(Res.string.change_server_d),
onClick = { openDetail(SettingsRoutes.ServerConfig) },
leadingContent = { Icon(Icons.Filled.Storage, null) },
divider = true
)
ListItem(
ExpressiveListItem(
icon = Icons.Rounded.Info,
iconPreset = ExpressiveTints.Purple,
headline = stringResource(Res.string.about),
supportingText = stringResource(Res.string.settings_hub_about_sub),
onClick = { openDetail(SettingsRoutes.About) },
leadingContent = { Icon(Icons.Filled.Info, null) },
divider = true
)
ListItem(
ExpressiveListItem(
icon = Icons.Rounded.BugReport,
iconPreset = ExpressiveTints.Rose,
headline = stringResource(Res.string.logs_title),
supportingText = stringResource(Res.string.settings_hub_logs_sub),
onClick = { openDetail(SettingsRoutes.Logs) },
leadingContent = { Icon(Icons.Outlined.BugReport, null) }
)
}
}
@@ -79,7 +79,7 @@ fun AccountScreen(
containerColor = MaterialTheme.colorScheme.background,
topBar = {
SettingsDetailTopBar(
title = { Text(stringResource(Res.string.settings_account_title)) },
title = stringResource(Res.string.settings_account_title),
onBack = onBack,
scrollBehavior = scrollBehavior,
)
@@ -6,4 +6,8 @@ enum class HapticFeedbackEvent {
MessageSent,
ContextMenuOpened,
SelectionModeEntered,
/** Light tick on touch-down of a switch — fires before the state flips. */
SwitchPress,
/** Heavier click at the commit moment — fires exactly when the state flips. */
SwitchToggle,
}
@@ -21,6 +21,8 @@ actual fun rememberHapticFeedbackInternal(): (Int) -> Unit =
HapticFeedbackEvent.MessageSent.ordinal -> UIImpactFeedbackStyle.UIImpactFeedbackStyleMedium
HapticFeedbackEvent.ContextMenuOpened.ordinal -> UIImpactFeedbackStyle.UIImpactFeedbackStyleHeavy
HapticFeedbackEvent.SelectionModeEntered.ordinal -> UIImpactFeedbackStyle.UIImpactFeedbackStyleMedium
HapticFeedbackEvent.SwitchPress.ordinal -> UIImpactFeedbackStyle.UIImpactFeedbackStyleLight
HapticFeedbackEvent.SwitchToggle.ordinal -> UIImpactFeedbackStyle.UIImpactFeedbackStyleHeavy
else -> UIImpactFeedbackStyle.UIImpactFeedbackStyleLight
}
UIImpactFeedbackGenerator(style).impactOccurred()
@@ -0,0 +1,3 @@
package ru.fromchat.ui.main.settings
actual fun svgDrawablesSupported(): Boolean = true
@@ -0,0 +1,3 @@
package ru.fromchat.ui.main.settings
actual fun svgDrawablesSupported(): Boolean = true
+18 -18
View File
@@ -1,19 +1,19 @@
[versions]
agp = "9.4.0"
agp = "9.4.1"
androidx-activityCompose = "1.13.0"
androidx-appcompat = "1.8.0"
androidx-core-ktx = "1.19.0"
androidx-core-ktx = "1.19.1"
androidx-exifinterface = "1.4.2"
coilCompose = "3.6.2"
compose-multiplatform = "1.12.0"
coilCompose = "3.6.3"
compose-multiplatform = "1.12.1"
#noinspection NewerVersionAvailable
constraintlayout = "0.8.0-shaded"
coreSplashscreen = "1.2.0"
firebaseMessaging = "25.1.3"
firebaseMessaging = "26.0.0"
googleServices = "4.5.0"
haze = "2.0.0-beta03"
haze = "2.0.1"
jnaPlatform = "5.19.1"
kotlin = "2.4.20"
kotlin = "2.4.21"
adaptiveAndroid = "1.3.0"
biometric = "1.4.0-alpha07"
gson = "2.14.0"
@@ -22,33 +22,33 @@ kotlinxCoroutinesCore = "1.11.0"
kotlinxIoCore = "0.9.1"
multiplatformCryptoLibsodiumBindings = "0.9.5"
multiplatformSettings = "1.3.0"
serialization = "2.4.20"
serialization = "2.4.21"
serialization-json = "1.11.0"
material = "1.14.0"
activityKtx = "1.13.0"
navigationCompose = "2.9.2"
datastore = "1.2.1"
security-crypto = "1.1.0"
ktor = "3.5.2"
ktor = "3.6.0"
slf4j = "1.7.36"
kotlinxDatetime = "0.8.0"
lifecycleRuntimeKtx = "2.11.0"
composeBom = "2026.09.00"
composeMaterialIconsExtended = "1.7.3"
composeMaterial3 = "1.12.0-alpha03"
composeComponents = "1.12.0"
playServicesBase = "18.10.1"
tweetnaclJava = "1.1.3"
androidxWork = "2.11.2"
composeComponents = "1.12.1"
playServicesBase = "18.11.0"
tweetnaclJava = "1.1.4"
androidxWork = "2.12.0"
cryptography-kotlin = "0.6.0"
krypto = "4.0.10"
sqldelight = "2.3.2"
livekitAndroid = "2.28.2"
sqldelight = "2.4.1"
livekitAndroid = "2.29.0"
livekitAndroidComposeComponents = "2.4.2"
markdownRendererM3 = "0.45.0"
bouncycastle = "1.85.2"
webkit = "1.17.0"
openjfx = "22.0.2"
bouncycastle = "1.86"
webkit = "1.17.1"
openjfx = "27"
[libraries]
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" }
@@ -14,7 +14,9 @@ import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.interaction.Interaction
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
@@ -837,8 +839,29 @@ inline fun SwitchListItem(
groupItemCount: Int? = null,
noinline onContextMenuOpen: (() -> Unit)? = null,
noinline contextMenu: (ListItemContextMenuScope.() -> Unit)? = null,
/**
* Premium two-stage haptic: a light tick on touch-down (before state flips) and a
* heavier click at the commit moment (exactly when state flips). Defaults ON so
* every switch in the app gets the feel automatically; pass `false` to silence.
*
* No-op on platforms that don't support haptics.
*/
hapticFeedback: Boolean = true,
) {
val interactionSource = remember { MutableInteractionSource() }
val (pressHaptic, commitHaptic) = if (enabled && hapticFeedback) {
switchHapticCallbacks()
} else {
val noop: () -> Unit = { }
noop to noop
}
LaunchedEffect(interactionSource) {
interactionSource.interactions.collect { interaction ->
if (interaction is PressInteraction.Press) {
pressHaptic()
}
}
}
ListItem(
modifier = if (enabled) Modifier.clickable(
interactionSource = interactionSource,
@@ -852,7 +875,12 @@ inline fun SwitchListItem(
val (sw) = createRefs()
Switch(
checked = checked,
onCheckedChange = onCheckedChange,
// Fire the heavier click exactly at the commit moment (when state
// actually flips) so the haptic aligns with the visual switch.
onCheckedChange = { newState ->
commitHaptic()
onCheckedChange(newState)
},
interactionSource = interactionSource,
enabled = enabled,
modifier = Modifier.constrainAs(sw) {
@@ -0,0 +1,35 @@
package com.pr0gramm3r101.components
import androidx.compose.runtime.Composable
import androidx.compose.runtime.compositionLocalOf
/**
* CompositionLocal that carries the haptic-firing lambda for `SwitchListItem`.
* Defaults to a no-op so it works on any platform / without a provider.
*
* The app root (in `:app:shared`) calls `provideSwitchHaptics()`, which stores the
* `rememberHapticFeedback()` callback here.
*
* @see SwitchListItem
*/
val LocalSwitchHaptic = compositionLocalOf<(Int) -> Unit> { { _ -> } }
// Ordinals mirror `ru.fromchat.utils.haptic.HapticFeedbackEvent` (see enum).
internal const val HAPTIC_OR_SWITCH_PRESS: Int = 5
internal const val HAPTIC_OR_SWITCH_TOGGLE: Int = 6
/**
* Internal accessor used by the inline [SwitchListItem].
*
* Returns:
* - first element → press haptic (light tick at touch-down)
* - second element → commit haptic (heavier click at state flip)
*
* We pass a plain `Int` so `:utils:shared` has no compile-time dependency on the
* `ru.fromchat.utils.haptic.HapticFeedbackEvent` enum (which lives in `:app:shared`).
*/
@Composable
fun switchHapticCallbacks(): Pair<() -> Unit, () -> Unit> {
val fire = LocalSwitchHaptic.current
return ({ fire(HAPTIC_OR_SWITCH_PRESS) }) to ({ fire(HAPTIC_OR_SWITCH_TOGGLE) })
}