diff --git a/android/README.md b/android/README.md index c3005e6..e911d99 100644 --- a/android/README.md +++ b/android/README.md @@ -344,20 +344,6 @@ The cuprated graph is built with Rust 1.98 here, the same floor as `ci.yml` (`rust-version = "1.98"`). Job timeout is **90** minutes on `android-release.yml` and **120** on `android-ci.yml`. -## App shell - -Three top-level destinations, one persistent bottom tab bar -(`ui/components/BottomTabBar.kt`): **Chats** (default), **Wallet**, and **Node & -Settings**. Sub-screens (chat, invite share, add contact, rotate, profile, saved -wallets) keep a chevron back button and hide the bar. The rare and destructive -actions — rotate identity, delete message history, saved wallets — are behind the -`⋮` overflow and a typed confirmation, not on the home screen. - -Colours, radii and type live in `ui/Theme.kt` as `OwColors` / `OwRadius` / -`OwSize`; new UI takes tokens from there instead of `MaterialTheme` defaults. -Monospace is reserved for pubkeys, truncated onion locators, seeds, `host:port` -and block heights — never for a sentence. - ## Layout ``` @@ -377,33 +363,25 @@ android/ build.gradle.kts src/main/AndroidManifest.xml src/main/java/com/siriusdevops/onionwire/ - MainActivity.kt # app shell: bottom tabs + NavHost + MainActivity.kt # NavHost WireViewModel.kt # UI-side Wire handle; wallet-child poller crypto/ # Keystore-wrapped store passphrase keepalive/ # NodeHost, KeepAliveService, policy, lifetime wallet/ # ChainStorage, WalletChildBinaries ui/ # Compose screens (M3) - components/ # design system: OwButton, OwSegmentedControl, - # OwAlertBanner, OwCard, OwTopBar, OwBottomTabBar, - # OwConfirmDialog, OwQrCode, Identicon WalletScreen.kt - WalletManagerScreen.kt WalletChildStatusText.kt ChatScreen.kt - RosterScreen.kt # Chats tab: identity bar + roster - SettingsScreen.kt # Node & Settings tab - ProfileScreen.kt - InviteScreens.kt # share (QR + text) and paste-a-contact + RosterScreen.kt + InviteScreens.kt InviteAddFlow.kt OutboxDetail.kt MessageDelivery.kt UnlockScreen.kt UnlockSubmit.kt - SeedBackupGate.kt RotateScreen.kt - Insets.kt # systemBars ∪ ime, minus the tab-bar inset - Theme.kt # design tokens: palette, radii, sizes, typography - src/main/res/drawable/ic_ow_*.xml # single-colour design-system icons + Insets.kt + Theme.kt src/test/ # JVM: envelope, store, invite, outbox, keepalive, wallet line, refresh loop src/androidTest/ # device-only: AndroidKeyStore src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt b/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt index 772f733..0cd7f57 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt @@ -8,61 +8,37 @@ import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.result.contract.ActivityResultContracts -import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import androidx.core.view.WindowCompat import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel -import androidx.navigation.NavHostController import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable -import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navArgument import com.siriusdevops.onionwire.ui.ChatScreen -import com.siriusdevops.onionwire.ui.LocalBottomBarPresent -import com.siriusdevops.onionwire.ui.OnionWireTheme import com.siriusdevops.onionwire.ui.PasteInviteScreen import com.siriusdevops.onionwire.ui.ProfileScreen import com.siriusdevops.onionwire.ui.RosterScreen import com.siriusdevops.onionwire.ui.RotateScreen -import com.siriusdevops.onionwire.ui.SettingsScreen import com.siriusdevops.onionwire.ui.ShareInviteScreen import com.siriusdevops.onionwire.ui.UnlockScreen import com.siriusdevops.onionwire.ui.WalletManagerScreen import com.siriusdevops.onionwire.ui.WalletScreen -import com.siriusdevops.onionwire.ui.components.OwBottomTabBar -import com.siriusdevops.onionwire.ui.components.OwTab +import com.siriusdevops.onionwire.ui.OnionWireTheme import kotlinx.coroutines.launch class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() - // The shell paints the canvas to the bottom of the screen behind the tab - // bar; the system's translucent three-button scrim would draw a second, - // lighter band over it (edge-to-edge guidance, SDK 29+). - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - window.isNavigationBarContrastEnforced = false - } - // enableEdgeToEdge() from ComponentActivity sets the icon appearance from - // the system theme; the app is dark-only, so the bars are always dark with - // light icons. Re-assert it here in case the theme changes under us. - WindowCompat.getInsetsController(window, window.decorView).apply { - isAppearanceLightStatusBars = false - isAppearanceLightNavigationBars = false - } setContent { OnionWireTheme { Surface( @@ -85,7 +61,7 @@ private fun AppRoot(vm: WireViewModel = viewModel()) { // Asked in context: the notification is the keep-alive's only visible // trace, so the prompt lands when the node becomes reachable rather than at // first launch. Denial is not fatal — the service runs either way and the - // settings screen says the notice is hidden. + // roster says the notice is hidden. val askNotifications = rememberLauncherForActivityResult( ActivityResultContracts.RequestPermission(), ) { vm.onNotificationPermissionChanged() } @@ -111,165 +87,86 @@ private fun AppRoot(vm: WireViewModel = viewModel()) { } } -/** Top-level destinations. Everything else is a sub-screen with a chevron. */ -private object Routes { - const val Chats = "chats" - const val Wallet = "wallet" - const val Settings = "settings" - const val Share = "share" - const val Paste = "paste" - const val Rotate = "rotate" - const val Profile = "profile" - const val Wallets = "wallets" - const val Chat = "chat/{pk}" - - fun tabOf(route: String?): OwTab? = when (route) { - Chats -> OwTab.Chats - Wallet -> OwTab.Wallet - Settings -> OwTab.Settings - else -> null - } - - fun routeOf(tab: OwTab): String = when (tab) { - OwTab.Chats -> Chats - OwTab.Wallet -> Wallet - OwTab.Settings -> Settings - } -} - -/** - * The app shell. - * - * A `Scaffold` whose only job is the persistent bottom tab bar: it owns the - * navigation-bar inset, the screens keep owning their own top bars and system - * insets (see `screenContentInsets`), and `LocalBottomBarPresent` tells those - * screens not to pad for the bar a second time. - * - * Selecting a tab pops back to the start destination and restores that tab's - * saved state, so a chat left open behind the Wallet tab is still there when the - * user comes back — the standard bottom-nav contract. - */ @Composable private fun ReadyGraph(vm: WireViewModel, ready: Phase.Ready, keepAliveNote: String?) { val nav = rememberNavController() val friends by vm.friends.collectAsStateWithLifecycle() val scope = rememberCoroutineScope() - val entry by nav.currentBackStackEntryAsState() - val tab = Routes.tabOf(entry?.destination?.route) - Scaffold( - // Each screen's Scaffold applies its own bars; zeroing this one keeps the - // status bar from being padded twice and leaves the only inset this - // level owns — the tab bar's height — in `pad`. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = MaterialTheme.colorScheme.background, - bottomBar = { - if (tab != null) { - OwBottomTabBar(selected = tab, onSelect = { nav.selectTab(it) }) - } - }, - ) { pad -> - CompositionLocalProvider(LocalBottomBarPresent provides (tab != null)) { - NavHost( - navController = nav, - startDestination = Routes.Chats, - modifier = Modifier.padding(bottom = pad.calculateBottomPadding()), - ) { - composable(Routes.Chats) { - RosterScreen( - fingerprint = ready.fingerprint, - friends = friends, - invite = vm::invite, - onOpenChat = { nav.navigate("chat/${it.pubkeyHex}") }, - onShare = { nav.navigate(Routes.Share) }, - onPaste = { nav.navigate(Routes.Paste) }, - onRotate = { nav.navigate(Routes.Rotate) }, - onWipe = { scope.launch { vm.wipeMessages() } }, - onOpenProfile = { nav.navigate(Routes.Profile) }, - onLock = vm::lock, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - ) - } + NavHost(navController = nav, startDestination = "roster") { + composable("roster") { + RosterScreen( + fingerprint = ready.fingerprint, + onion = ready.onion, + sdkVersion = ready.sdkVersion, + friends = friends, + keepAliveNote = keepAliveNote, + onOpenChat = { nav.navigate("chat/${it.pubkeyHex}") }, + onShare = { nav.navigate("share") }, + onPaste = { nav.navigate("paste") }, + onRotate = { nav.navigate("rotate") }, + onWipe = { scope.launch { vm.wipeMessages() } }, + onOpenProfile = { nav.navigate("profile") }, + onLock = vm::lock, + onOpenWallet = { nav.navigate("wallet") }, + ) + } - composable(Routes.Wallet) { - WalletScreen( - vm = vm, - onBack = { nav.popBackStack() }, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - ) - } + composable("share") { + ShareInviteScreen(ownerInvite = vm::invite, onBack = { nav.popBackStack() }) + } - composable(Routes.Settings) { - SettingsScreen( - sdkVersion = ready.sdkVersion, - keepAliveNote = keepAliveNote, - onOpenProfile = { nav.navigate(Routes.Profile) }, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - onRotate = { nav.navigate(Routes.Rotate) }, - onWipe = { scope.launch { vm.wipeMessages() } }, - onLock = vm::lock, - ) - } + composable("paste") { + PasteInviteScreen( + onDecode = vm::decode, + onAdd = vm::addFriend, + onBack = { nav.popBackStack() }, + ) + } - composable(Routes.Share) { - ShareInviteScreen(ownerInvite = vm::invite, onBack = { nav.popBackStack() }) - } + composable("rotate") { + RotateScreen( + currentOnion = ready.onion, + onRotate = { + val out = vm.rotateOnion() + out.notified.toInt() to out.friends.toInt() + }, + onBack = { nav.popBackStack() }, + ) + } - composable(Routes.Paste) { - PasteInviteScreen( - onDecode = vm::decode, - onAdd = vm::addFriend, - onBack = { nav.popBackStack() }, - ) - } + composable("wallet") { + WalletScreen( + vm = vm, + onBack = { nav.popBackStack() }, + onOpenWallets = { nav.navigate("wallets") }, + ) + } - composable(Routes.Rotate) { - RotateScreen( - currentOnion = ready.onion, - onRotate = { - val out = vm.rotateOnion() - out.notified.toInt() to out.friends.toInt() - }, - onBack = { nav.popBackStack() }, - ) - } + composable("wallets") { + WalletManagerScreen(vm = vm, onBack = { nav.popBackStack() }) + } - composable(Routes.Wallets) { - WalletManagerScreen(vm = vm, onBack = { nav.popBackStack() }) - } + composable("profile") { + ProfileScreen(vm = vm, onBack = { nav.popBackStack() }) + } - composable(Routes.Profile) { - ProfileScreen(vm = vm, onBack = { nav.popBackStack() }) - } - - composable( - route = Routes.Chat, - arguments = listOf(navArgument("pk") { type = NavType.StringType }), - ) { chatEntry -> - val pk = chatEntry.arguments?.getString("pk").orEmpty() - val friend = friends.firstOrNull { it.pubkeyHex == pk } - ChatScreen( - vm = vm, - peer = pk, - title = friend?.petname?.takeIf { it.isNotBlank() } - ?: friend?.fingerprint - ?: pk.take(16), - fingerprint = friend?.fingerprint ?: pk.take(16), - onion = friend?.onion.orEmpty(), - onBack = { nav.popBackStack() }, - ) - } - } + composable( + route = "chat/{pk}", + arguments = listOf(navArgument("pk") { type = NavType.StringType }), + ) { entry -> + val pk = entry.arguments?.getString("pk").orEmpty() + val friend = friends.firstOrNull { it.pubkeyHex == pk } + ChatScreen( + vm = vm, + peer = pk, + title = friend?.petname?.takeIf { it.isNotBlank() } + ?: friend?.fingerprint + ?: pk.take(16), + fingerprint = friend?.fingerprint ?: pk.take(16), + onion = friend?.onion.orEmpty(), + onBack = { nav.popBackStack() }, + ) } } } - -private fun NavHostController.selectTab(target: OwTab) { - val route = Routes.routeOf(target) - if (currentDestination?.route == route) return - navigate(route) { - popUpTo(graph.startDestinationId) { saveState = true } - launchSingleTop = true - restoreState = true - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt index a5369b4..499b6f8 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.IconButton @@ -50,9 +51,6 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwIconButton import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.siriusdevops.onionwire.WireViewModel import uniffi.onionwire_sdk.SendState @@ -61,7 +59,7 @@ import uniffi.onionwire_sdk.SendState @Composable fun ChatScreen( vm: WireViewModel, - /** The peer's public key, hex — the key the open chat's poller runs for. */ + /** The peer's ed25519 pubkey hex — the key the open chat's poller runs for. */ peer: String, title: String, fingerprint: String, @@ -186,11 +184,7 @@ fun ChatScreen( } }, navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) + IconButton(onClick = onBack) { Text("<") } }, colors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.background, @@ -388,8 +382,7 @@ fun ChatScreen( // Always drawn, never swapped out for a spinner: a button that // changes size under the thumb — or disappears — is how "I hit // send and nothing happened" gets reported. - OwButton( - text = "Send", + Button( enabled = draft.isNotBlank() && pending == null, onClick = send, modifier = Modifier.testTag("chat-send"), diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt index 88a7629..fd7802d 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt @@ -8,18 +8,8 @@ import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.union import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.runtime.Composable -import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.Modifier -/** - * True while a screen is rendered inside the shell that owns the bottom tab bar. - * - * The tab bar applies the navigation-bar inset itself, so a screen inside the - * shell must not pad for it a second time — that is the difference between the - * list ending just above the tabs and the list floating 48dp above them. - */ -val LocalBottomBarPresent = staticCompositionLocalOf { false } - /** * The bottom + horizontal window insets one screen's content root must apply * itself. @@ -35,9 +25,7 @@ val LocalBottomBarPresent = staticCompositionLocalOf { false } * * The IME's bottom inset already covers the navigation bar, so the two are * unioned (per-side `max`), never summed: keyboard height while typing, - * navigation-bar height otherwise, and no double padding in between. Inside the - * tab shell the vertical bar inset is dropped entirely — see - * [LocalBottomBarPresent]. + * navigation-bar height otherwise, and no double padding in between. * * The `Top` side is deliberately excluded — a `Scaffold`'s `pad.top` is the app * bar's own measured height, and the app bar carries its own status-bar inset @@ -50,15 +38,8 @@ val LocalBottomBarPresent = staticCompositionLocalOf { false } * composable reads — call it from a composable (every call site is one). */ @Composable -fun Modifier.screenContentInsets(): Modifier { - val sides = if (LocalBottomBarPresent.current) { - WindowInsetsSides.Horizontal - } else { - WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom - } - return windowInsetsPadding( - WindowInsets.systemBars.only(sides) - .union(WindowInsets.ime) +fun Modifier.screenContentInsets(): Modifier = + windowInsetsPadding( + WindowInsets.systemBars.union(WindowInsets.ime) .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom), - ) -} + ) \ No newline at end of file diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt index a519bb7..4d67f52 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt @@ -1,9 +1,6 @@ package com.siriusdevops.onionwire.ui import android.content.ClipData -import android.content.ClipDescription -import android.os.Build -import android.os.PersistableBundle import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -14,13 +11,20 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +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.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.getValue @@ -28,37 +32,15 @@ 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 import androidx.compose.ui.platform.ClipEntry import androidx.compose.ui.platform.LocalClipboard -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwAlertBanner -import com.siriusdevops.onionwire.ui.components.OwAlertVariant -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwQrCode -import com.siriusdevops.onionwire.ui.components.OwTopBar import kotlinx.coroutines.launch import uniffi.onionwire_sdk.FriendInfo import uniffi.onionwire_sdk.InviteInfo -/** - * Your invite, as a code and as text. - * - * The invite is the one artifact that leaves the device on purpose, so this - * screen is deliberately plain about what it is: one person, one trusted channel, - * nothing published. Both the QR and the text are here because a person pointing - * a camera at a screen and a person pasting into a chat client are different - * people, and neither is wrong. - */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { var invite by remember { mutableStateOf(null) } @@ -74,11 +56,18 @@ fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { } Scaffold( - topBar = { OwTopBar(title = "Your invite", onBack = onBack) }, + topBar = { + TopAppBar( + title = { Text("Your invite") }, + navigationIcon = { IconButton(onClick = onBack) { Text("<") } }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), + ) + }, // The root applies systemBars + IME itself (see `screenContentInsets`), // so Scaffold must not also pad for the navigation bar. contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, ) { pad -> Column( Modifier @@ -86,123 +75,70 @@ fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { .fillMaxSize() .screenContentInsets() .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), + .padding(16.dp), ) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Not published anywhere", - description = "Hand this to one person over a channel you already " + - "trust. There is no directory and no lookup — that is the point.", + Text( + "Hand this to one person, over a channel you already trust. " + + "It is not published anywhere and cannot be looked up.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) - Spacer(Modifier.height(16.dp)) + Spacer(Modifier.height(12.dp)) when { - error != null -> OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not read your invite", - description = error, + error != null -> Text( + error!!, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, ) - invite == null -> Row( - Modifier.fillMaxWidth().padding(vertical = 32.dp), - horizontalArrangement = Arrangement.Center, - ) { CircularProgressIndicator(color = OwColors.Accent) } + invite == null -> CircularProgressIndicator() else -> { - val payload = invite!! - Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) { - OwQrCode(payload = payload, size = 220.dp) - } - Spacer(Modifier.height(16.dp)) - // Four lines, ellipsised: the payload is ~1 KB, and a card - // that grows to fill the screen pushes Copy and Done out of - // reach — the copyable text is a fallback for the QR, not - // the main event. `Copy invite` always carries the whole - // string. - OwCard(Modifier.fillMaxWidth(), padding = 12.dp) { + Card( + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { Text( - payload, - style = MonoStyle.copy(color = OwColors.TextSecondary), - textAlign = TextAlign.Start, - maxLines = 4, - overflow = TextOverflow.Ellipsis, + invite!!, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(12.dp), ) } Spacer(Modifier.height(12.dp)) - Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { - OwButton( - text = if (copied) "Copied" else "Copy invite", - onClick = { - scope.launch { - val clip = ClipData.newPlainText("onionwire invite", payload) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - clip.description.extras = PersistableBundle().apply { - putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) - } - } - clipboard.setClipEntry(ClipEntry(clip)) - copied = true - } - }, - leadingIconRes = R.drawable.ic_ow_copy, - ) - OwButton( - text = "Done", - variant = OwButtonVariant.Outline, - onClick = onBack, - ) + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Button(onClick = { + scope.launch { + clipboard.setClipEntry( + ClipEntry(ClipData.newPlainText("onionwire invite", invite!!)), + ) + copied = true + } + }) { Text(if (copied) "Copied" else "Copy") } } - Spacer(Modifier.height(24.dp)) - OwCard(Modifier.fillMaxWidth()) { - Text( - "What is in it", - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, - ) - Spacer(Modifier.height(8.dp)) - InviteField("k", "ed25519 identity pubkey — who you are") - InviteField("o", "current onion locator — where you are now") - InviteField("spk", "x25519 signed prekey — session start material") - InviteField("sig", "signature over k‖o‖spk — reject if it fails") - Spacer(Modifier.height(10.dp)) - OwDivider() - Spacer(Modifier.height(10.dp)) - Text( - "The onion in here goes stale when you rotate. The key does " + - "not. If you re-share later, the same k updates their entry — " + - "it never creates a second friend.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - Spacer(Modifier.height(24.dp)) + Spacer(Modifier.height(20.dp)) + Text("What is in it", style = MaterialTheme.typography.titleSmall) + Spacer(Modifier.height(6.dp)) + Mono("k ed25519 identity pubkey — who you are") + Mono("o current onion locator — where you are now") + Mono("spk x25519 signed prekey — session start material") + Mono("sig signature over k‖o‖spk — reject if it fails") + Spacer(Modifier.height(12.dp)) + Text( + "The onion in here goes stale when you rotate. The key does not. " + + "If you re-share later, the same k updates their entry — it never " + + "creates a second friend.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) } } } } } -@Composable -private fun InviteField(key: String, meaning: String) { - Row(Modifier.padding(vertical = 2.dp), verticalAlignment = Alignment.CenterVertically) { - Text( - key, - style = MonoStyle.copy(color = OwColors.Accent), - modifier = Modifier.padding(end = 10.dp), - ) - Label(meaning) - } -} - -/** - * Paste someone else's invite. - * - * Verification is a separate, explicit step from adding: the preview shows who - * they are and where they are reachable *before* anything is written to the - * roster, because a mistyped or swapped invite is the one thing a human can - * still catch. - */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun PasteInviteScreen( onDecode: suspend (String) -> InviteInfo, @@ -219,12 +155,19 @@ fun PasteInviteScreen( val adding = flow.adding Scaffold( - topBar = { OwTopBar(title = "Add contact", onBack = onBack) }, + topBar = { + TopAppBar( + title = { Text("Add a friend") }, + navigationIcon = { IconButton(onClick = onBack) { Text("<") } }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), + ) + }, // Same inset handoff as the chat composer: with the keyboard up, the // Verify / Approve buttons under the invite field must still be // reachable by scrolling, not by dismissing the keyboard. contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, ) { pad -> Column( Modifier @@ -232,83 +175,90 @@ fun PasteInviteScreen( .fillMaxSize() .screenContentInsets() .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), + .padding(16.dp), ) { - Spacer(Modifier.height(8.dp)) OutlinedTextField( value = raw, onValueChange = { raw = it flow.clear() }, - label = { Text("onionwire:v2:…") }, + label = { Text("onionwire:v1:…") }, minLines = 4, - shape = RoundedCornerShape(OwRadius.Control), modifier = Modifier.fillMaxWidth(), ) Spacer(Modifier.height(12.dp)) - Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { - OwButton( - text = "Verify", + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Button( enabled = raw.isNotBlank() && !verifying && !adding, onClick = { scope.launch { flow.verify(raw) } }, - ) + ) { Text("Verify") } if (added != null) { - OwButton(text = "Done", variant = OwButtonVariant.Outline, onClick = onBack) + TextButton(onClick = onBack) { Text("Done") } } } Spacer(Modifier.height(16.dp)) error?.let { - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "That invite was not accepted", - description = "$it — unsigned or tampered invites are rejected " + - "here, before anything is stored.", + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + ) + Spacer(Modifier.height(8.dp)) + Text( + "Unsigned or tampered invites are rejected here, before anything is stored.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) - Spacer(Modifier.height(12.dp)) } preview?.let { p -> - OwCard(Modifier.fillMaxWidth()) { - Label("THEY ARE") - Spacer(Modifier.height(2.dp)) - Mono(shortId(p.pubkeyHex, head = 12, tail = 8)) - Spacer(Modifier.height(6.dp)) - Text( - "Compare this fingerprint with them over a second channel " + - "before you trust it.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(10.dp)) - OwDivider() - Spacer(Modifier.height(10.dp)) - Label("REACHABLE AT") - Spacer(Modifier.height(2.dp)) - Mono(shortOnion(p.onion)) + Card( + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + modifier = Modifier.fillMaxWidth(), + ) { + Column(Modifier.padding(12.dp)) { + Label("THEY ARE") + Mono(p.pubkeyHex) + Spacer(Modifier.height(8.dp)) + Text( + "fingerprint ${p.pubkeyHex.take(16)}… — compare this with them " + + "over a second channel before you trust it.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + Spacer(Modifier.height(8.dp)) + Label("REACHABLE AT") + Mono(p.onion) + } } Spacer(Modifier.height(12.dp)) - OwButton( - text = "Approve & add", + Button( enabled = !adding && added == null, onClick = { scope.launch { flow.add(raw) } }, - leadingIconRes = R.drawable.ic_ow_add, - ) + ) { Text("Approve & add") } } added?.let { f -> Spacer(Modifier.height(16.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Added ${f.petname ?: shortId(f.fingerprint)}", - description = "If that key was already in your roster, only the " + - "locator was updated. One key is always one friend.", + Text( + "Added ${f.petname ?: f.fingerprint}", + style = MaterialTheme.typography.titleSmall, + color = MaterialTheme.colorScheme.primary, + ) + Spacer(Modifier.height(4.dp)) + Text( + "If that key was already in your roster, only the locator was updated. " + + "One key is always one friend.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) } - Spacer(Modifier.height(24.dp)) } } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt index a0e3243..b3b41c3 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api @@ -32,9 +33,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwIconButton import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.siriusdevops.onionwire.WireViewModel import kotlinx.coroutines.launch @@ -102,11 +100,7 @@ fun ProfileScreen( TopAppBar( title = { Text("Profile") }, navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) + TextButton(onClick = onBack) { Text("Back") } }, colors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.background, @@ -240,8 +234,7 @@ fun ProfileScreen( .padding(12.dp), horizontalArrangement = Arrangement.End, ) { - OwButton( - text = if (busy) "Saving…" else "Save", + Button( onClick = { addressError = null saveError = null @@ -254,7 +247,7 @@ fun ProfileScreen( } if (problem != null) { addressError = problem - return@OwButton + return@Button } scope.launch { busy = true @@ -301,7 +294,9 @@ fun ProfileScreen( }, enabled = !busy && profileSaveEnabled(loaded, form), modifier = Modifier.testTag("profile-save"), - ) + ) { + Text(if (busy) "Saving…" else "Save") + } } status?.let { diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt index edfae7a..b1575ca 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt @@ -1,14 +1,8 @@ package com.siriusdevops.onionwire.ui -import android.content.ClipData -import android.content.ClipDescription -import android.os.Build -import android.os.PersistableBundle -import android.widget.Toast import androidx.compose.foundation.background import androidx.compose.foundation.clickable 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.Spacer @@ -18,71 +12,38 @@ 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.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold 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.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.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.platform.ClipEntry -import androidx.compose.ui.platform.Clipboard -import androidx.compose.ui.platform.LocalClipboard -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Identicon -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonRow -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwConfirmDialog -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwIcon -import com.siriusdevops.onionwire.ui.components.OwIconButton -import com.siriusdevops.onionwire.ui.components.OwOverflowMenu -import com.siriusdevops.onionwire.ui.components.OwStatusDot -import com.siriusdevops.onionwire.ui.components.OwTopBar -import com.siriusdevops.onionwire.ui.components.TorStatusPill -import kotlinx.coroutines.launch import uniffi.onionwire_sdk.FriendInfo -/** - * Home: your identity, and the roster. - * - * Three things changed from the alpha build and they are deliberate: - * - * - The identity block is one compact bar. The old expandable card, the version - * and key-type footnote and the keep-alive paragraph are gone from here: the - * technical lines moved to Node & Settings, and reachability is a status row - * there too. A home screen does not explain the transport before it shows the - * people. - * - The five text-link actions are gone. Invite and Add are the two first-class - * actions (in the empty state, and in the bar); the rare and destructive ones - * live behind the overflow menu. - * - The empty state says what to do next, with the two buttons that do it. - * - * Behaviour is unchanged: every callback here is the ViewModel call the old - * screen made — this screen only decides where the entry points sit. - */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun RosterScreen( fingerprint: String, + onion: String, + sdkVersion: String, friends: List, - invite: suspend () -> String, + keepAliveNote: String?, onOpenChat: (FriendInfo) -> Unit, onShare: () -> Unit, onPaste: () -> Unit, @@ -90,290 +51,245 @@ fun RosterScreen( onWipe: () -> Unit, onOpenProfile: () -> Unit, onLock: () -> Unit, - onOpenWallets: () -> Unit, + onOpenWallet: () -> Unit, ) { - val context = LocalContext.current - val clipboard = LocalClipboard.current - val scope = rememberCoroutineScope() - var confirmDeleteAll by remember { mutableStateOf(false) } + var confirmWipe by remember { mutableStateOf(false) } + // Closed by default; `rememberSaveable` so a rotation keeps whatever the + // user chose instead of snapping back to (or away from) the summary. + // Nothing about this is worth persisting to the store. + var identityExpanded by rememberSaveable { mutableStateOf(false) } Scaffold( // The content root below consumes systemBars ∪ ime itself (see - // `screenContentInsets`), and the tab bar above this screen consumes the - // navigation-bar inset; zeroing the Scaffold's own insets is what keeps - // the list from being padded twice. + // `screenContentInsets`); zeroing the Scaffold's own insets keeps the + // navigation bar from being applied twice and lets the wipe-confirm + // strip sit above the keyboard instead of under it. contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, topBar = { - OwTopBar( - title = "OnionWire", - status = { TorStatusPill() }, + TopAppBar( + title = { Text("OnionWire") }, actions = { - OwIconButton( - iconRes = R.drawable.ic_ow_lock, - contentDescription = "Lock and stop the node", - onClick = onLock, - ) - OwOverflowMenu( - onOpenProfile = onOpenProfile, - onOpenWallets = onOpenWallets, - onRotate = onRotate, - onWipe = { confirmDeleteAll = true }, - ) + TextButton(onClick = onOpenProfile) { Text("Profile") } + TextButton(onClick = onLock) { Text("Lock") } }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), ) }, ) { pad -> Column(Modifier.padding(pad).fillMaxSize().screenContentInsets()) { - IdentityBar( - fingerprint = fingerprint, - onCopyInvite = { - scope.launch { - runCatching { invite() } - .onSuccess { payload -> - copyInvite(clipboard, payload) - Toast.makeText(context, "Invite address copied", Toast.LENGTH_SHORT).show() - } - .onFailure { - Toast.makeText(context, "Could not read the invite", Toast.LENGTH_SHORT).show() - } + + Card( + modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Column(Modifier.padding(12.dp)) { + // The disclosure header. Collapsed, this one line *is* the + // identity block: the label, the abbreviated fingerprint, + // and a chevron saying there is more behind it. + Row( + modifier = Modifier + .fillMaxWidth() + .clickable { identityExpanded = !identityExpanded }, + verticalAlignment = Alignment.CenterVertically, + ) { + Label("YOU (stable forever)") + if (!identityExpanded) { + Spacer(Modifier.width(8.dp)) + Mono(shortId(fingerprint)) + } + Spacer(Modifier.weight(1f)) + Text( + if (identityExpanded) "▾" else "▸", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) } - }, - onShare = onShare, - ) - - Spacer(Modifier.height(12.dp)) - - if (friends.isEmpty()) { - EmptyRoster( - modifier = Modifier.weight(1f), - onPaste = onPaste, - onShare = onShare, - ) - } else { - LazyColumn(Modifier.weight(1f).fillMaxWidth()) { - items(friends, key = { it.pubkeyHex }) { f -> - FriendRow(f) { onOpenChat(f) } - OwDivider(Modifier.padding(horizontal = 16.dp)) + if (identityExpanded) { + Mono(fingerprint) + Spacer(Modifier.height(10.dp)) + Label("ONION (locator — rotates)") + Mono(onion) + } + Spacer(Modifier.height(10.dp)) + Text( + "sdk $sdkVersion · identity = ed25519 pubkey", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + if (keepAliveNote != null) { + Spacer(Modifier.height(10.dp)) + Text( + keepAliveNote, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.primary, + ) } } } - } - } - if (confirmDeleteAll) { - OwConfirmDialog( - title = "Delete all message history?", - body = "Every message body on this device is deleted. Your identity, " + - "your friends and the pending queue are untouched.", - confirmationWord = "DELETE", - confirmLabel = "Delete history", - destructive = true, - onConfirm = { - confirmDeleteAll = false - onWipe() - }, - onDismiss = { confirmDeleteAll = false }, - ) - } -} - -/** - * Your identity, as one bar: identicon, label, truncated pubkey, then the two - * actions a person actually performs here — copy the invite, show it as a code. - */ -@Composable -private fun IdentityBar( - fingerprint: String, - onCopyInvite: () -> Unit, - onShare: () -> Unit, -) { - OwCard( - modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), - padding = 12.dp, - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - Identicon(seed = fingerprint, size = 40.dp) - Spacer(Modifier.width(12.dp)) - Column(Modifier.weight(1f)) { - Label("Your identity") - Spacer(Modifier.height(2.dp)) - Mono(shortId(fingerprint)) + Spacer(Modifier.height(8.dp)) + Row( + modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp), + horizontalArrangement = Arrangement.SpaceEvenly, + ) { + TextButton(onClick = onShare) { Text("Invite") } + TextButton(onClick = onPaste) { Text("Add") } + TextButton(onClick = onRotate) { Text("Rotate") } + TextButton(onClick = onOpenWallet) { Text("Wallet") } + TextButton(onClick = { confirmWipe = true }) { Text("Wipe chat") } } - OwIconButton( - iconRes = R.drawable.ic_ow_copy, - contentDescription = "Copy invite address", - onClick = onCopyInvite, - ) - Spacer(Modifier.width(8.dp)) - OwIconButton( - iconRes = R.drawable.ic_ow_qr, - contentDescription = "Show your invite", - onClick = onShare, - ) - } - } -} -/** - * The empty roster. - * - * The honest sentence stays: invites are not discoverable, nothing is published. - * The two buttons are the two ways out of this state, in the order that helps — - * paste a peer's invite, or hand yours out. - */ -@Composable -private fun EmptyRoster( - modifier: Modifier = Modifier, - onPaste: () -> Unit, - onShare: () -> Unit, -) { - Column( - modifier = modifier.fillMaxWidth().padding(horizontal = 24.dp), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Box( - Modifier - .width(64.dp) - .height(64.dp) - .clip(CircleShape) - .background(OwColors.Surface), - contentAlignment = Alignment.Center, - ) { - // Muted on purpose: the empty state is an invitation, not an alarm. - // The accent stays reserved for the one primary action below it. - OwIcon( - iconRes = R.drawable.ic_ow_shield, - contentDescription = null, - tint = OwColors.TextSecondary, - size = 30.dp, - ) - } - Spacer(Modifier.height(16.dp)) - Text( - "No contacts yet", - style = MaterialTheme.typography.titleMedium.copy(fontSize = 18.sp, lineHeight = 24.sp), - color = OwColors.TextPrimary, - ) - Spacer(Modifier.height(8.dp)) - Text( - "Share your invite over a channel you already trust, or paste a peer's " + - "invite to start an end-to-end encrypted chat. Invites are not " + - "discoverable — nothing is published.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - textAlign = TextAlign.Center, - modifier = Modifier.widthIn(max = 280.dp), - ) - Spacer(Modifier.height(20.dp)) - OwButtonRow(Modifier.widthIn(max = 320.dp)) { - OwButton( - text = "Add contact", - onClick = onPaste, - variant = OwButtonVariant.Primary, - modifier = Modifier.weight(1f), - leadingIconRes = R.drawable.ic_ow_add, - ) - OwButton( - text = "Share my invite", - onClick = onShare, - variant = OwButtonVariant.Secondary, - modifier = Modifier.weight(1f), - ) + if (confirmWipe) { + ConfirmStrip( + text = "Delete every message body? Identity and friends stay.", + confirm = "WIPE", + onConfirm = { confirmWipe = false; onWipe() }, + onCancel = { confirmWipe = false }, + ) + } + + HorizontalDivider(Modifier.padding(vertical = 8.dp)) + + if (friends.isEmpty()) { + Column( + Modifier.fillMaxSize().padding(24.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text("No friends yet", style = MaterialTheme.typography.titleMedium) + Spacer(Modifier.height(8.dp)) + Text( + "Share your invite over a channel you already trust, or paste " + + "someone else's. Invites are not discoverable — nothing is published.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } else { + // weight(1f), not fillMaxSize(): the list must yield height to + // its siblings (the action row and the wipe-confirm strip above + // it) when the IME shrinks the window, instead of claiming all + // of it and pushing them off the bottom. + LazyColumn(Modifier.weight(1f).fillMaxWidth()) { + items(friends, key = { it.pubkeyHex }) { f -> + FriendRow(f) { onOpenChat(f) } + HorizontalDivider() + } + } + } } } } @Composable private fun FriendRow(f: FriendInfo, onClick: () -> Unit) { - Row( + Column( Modifier .fillMaxWidth() .clickable(onClick = onClick) + .background(MaterialTheme.colorScheme.background) .padding(horizontal = 16.dp, vertical = 12.dp), - verticalAlignment = Alignment.CenterVertically, ) { - Column(Modifier.weight(1f)) { - Row(verticalAlignment = Alignment.CenterVertically) { + Row(verticalAlignment = Alignment.CenterVertically) { + Text( + f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint, + style = MaterialTheme.typography.titleSmall, + ) + if (!f.lastConnectOk) { + Spacer(Modifier.height(0.dp)) Text( - f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint, - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, + " locator stale", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.error, ) - if (!f.lastConnectOk) { - Spacer(Modifier.width(8.dp)) - OwStatusDot(OwColors.Warning) - Spacer(Modifier.width(6.dp)) - Text( - "locator stale", - style = MaterialTheme.typography.labelSmall, - color = OwColors.Warning, - ) - } } - Spacer(Modifier.height(3.dp)) - Text( - shortId(f.fingerprint), - style = MonoStyle, - color = OwColors.TextSecondary, - ) - Text( - shortOnion(f.onion), - style = MonoStyle.copy(color = OwColors.TextMuted), - ) } - Text("›", style = MaterialTheme.typography.titleMedium, color = OwColors.TextMuted) + Spacer(Modifier.height(2.dp)) + Text( + f.fingerprint, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.primary, + ) + Text( + f.onion, + style = MaterialTheme.typography.labelSmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) } } -/** - * Clipboard handling for the invite. - * - * The invite is a locator plus a prekey: it is a secret-ish string that opens a - * conversation with you, so the clip is marked sensitive (API 33+) — it will not - * be previewed on the lock screen or indexed by the clipboard UI. Nothing here - * is logged, persisted, or drawn anywhere but the share sheet. - */ -private suspend fun copyInvite(clipboard: Clipboard, text: String) { - val clip = ClipData.newPlainText("onionwire invite", text) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - clip.description.extras = PersistableBundle().apply { - putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) - } - } - clipboard.setClipEntry(ClipEntry(clip)) -} - /** * The compact stand-in for a long identity string: `head` characters, an - * ellipsis, then `tail` characters. Pure, so the roster's line and its unit test - * agree on what "short" means. + * ellipsis, then `tail` characters. Pure, so the roster's collapsed line and + * its unit test agree on what "short" means. * * A string no longer than the abbreviation is returned unchanged — the * abbreviation must never grow a value, and a short value must never come back - * mangled. Kotlin strings are UTF-16, but these IDs are hex, so `take`/`takeLast` - * cannot split a surrogate pair here. + * mangled. Kotlin strings are UTF-16, but these IDs are hex, so `take`/ + * `takeLast` cannot split a surrogate pair here. */ fun shortId(id: String, head: Int = 6, tail: Int = 4): String { if (id.length < head + tail + 1) return id return id.take(head) + "…" + id.takeLast(tail) } -/** - * A v3 onion locator shortened for a roster row, with the `.onion` suffix kept - * visible: `abcdefghij…uvwxyz.onion`. - * - * The suffix is the part that tells a reader this is an onion address at all, so - * it is never the part that gets truncated. The full value lives on the profile - * and invite screens, and a v3 locator is never soft-wrapped — a wrapped address - * cannot be copied reliably. - */ -fun shortOnion(onion: String, head: Int = 10, tail: Int = 6): String { - val suffix = ".onion" - if (onion.isEmpty()) return onion - if (!onion.endsWith(suffix)) return onion - val body = onion.removeSuffix(suffix) - if (body.length <= head + tail + 1) return onion - return body.take(head) + "…" + body.takeLast(tail) + suffix +@Composable +fun Label(text: String) { + Text( + text, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) +} + +@Composable +fun Mono(text: String) { + Text( + text, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.onSurface, + ) +} + +@Composable +fun ConfirmStrip( + text: String, + confirm: String, + onConfirm: () -> Unit, + onCancel: () -> Unit, +) { + var typed by remember { mutableStateOf("") } + Card( + modifier = Modifier.fillMaxWidth().padding(12.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Column(Modifier.padding(12.dp)) { + Text(text, style = MaterialTheme.typography.bodySmall) + Spacer(Modifier.height(8.dp)) + androidx.compose.material3.OutlinedTextField( + value = typed, + onValueChange = { typed = it }, + singleLine = true, + label = { Text("Type $confirm") }, + modifier = Modifier.fillMaxWidth(), + ) + Spacer(Modifier.height(8.dp)) + Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth()) { + TextButton(onClick = onCancel) { Text("Cancel") } + TextButton( + onClick = onConfirm, + enabled = typed.trim().equals(confirm, ignoreCase = true), + ) { Text("Confirm") } + } + } + } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt index b84dd11..b1f99b5 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.IconButton @@ -28,12 +29,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwIconButton /** * Rotating publishes a brand new onion service and hard-cuts the old one. @@ -59,13 +54,7 @@ fun RotateScreen( topBar = { TopAppBar( title = { Text("Rotate onion") }, - navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) - }, + navigationIcon = { IconButton(onClick = onBack) { Text("<") } }, colors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.background, ), @@ -110,13 +99,11 @@ fun RotateScreen( ) Spacer(Modifier.height(12.dp)) Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - OwButton( - text = "Rotate", - variant = OwButtonVariant.Destructive, + Button( enabled = typed.trim().equals("ROTATE", ignoreCase = true) && !busy, onClick = { busy = true; error = null }, - ) + ) { Text("Rotate") } if (busy) CircularProgressIndicator() } } @@ -154,11 +141,7 @@ fun RotateScreen( color = MaterialTheme.colorScheme.onSurfaceVariant, ) Spacer(Modifier.height(16.dp)) - OwButton( - text = "Share the new invite", - variant = OwButtonVariant.Secondary, - onClick = onBack, - ) + Button(onClick = onBack) { Text("Back — share the new invite") } } } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt deleted file mode 100644 index c5e5c68..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt +++ /dev/null @@ -1,215 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -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.foundation.layout.width -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -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.graphics.Color -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwConfirmDialog -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwIconButton -import com.siriusdevops.onionwire.ui.components.OwSectionTitle -import com.siriusdevops.onionwire.ui.components.OwTopBar -import com.siriusdevops.onionwire.ui.components.TorStatusPill - -/** - * The third tab: everything that is not a conversation or a balance. - * - * This is where the alpha build's honest-but-noisy bits went — the SDK line, the - * keep-alive paragraph, the identity rotation and the history wipe. They are not - * hidden; they are one tap away instead of on the screen a person opens twenty - * times a day. No behaviour lives here: every callback is a ViewModel call the - * old roster made. - */ -@Composable -fun SettingsScreen( - sdkVersion: String, - keepAliveNote: String?, - onOpenProfile: () -> Unit, - onOpenWallets: () -> Unit, - onRotate: () -> Unit, - onWipe: () -> Unit, - onLock: () -> Unit, -) { - var confirmDeleteAll by remember { mutableStateOf(false) } - - Scaffold( - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - topBar = { - OwTopBar( - title = "Node & Settings", - status = { TorStatusPill() }, - actions = { - OwIconButton( - iconRes = R.drawable.ic_ow_lock, - contentDescription = "Lock and stop the node", - onClick = onLock, - ) - }, - ) - }, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), - ) { - Spacer(Modifier.height(8.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("ACCOUNT") - Spacer(Modifier.height(4.dp)) - SettingsRow( - title = "Your profile", - subtitle = "Name, bio and Monero address", - onClick = onOpenProfile, - ) - OwDivider() - SettingsRow( - title = "Saved wallets", - subtitle = "Open a wallet file, or check its backup", - onClick = onOpenWallets, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("REACHABILITY") - Spacer(Modifier.height(6.dp)) - Text( - keepAliveNote ?: "Checking how this app is kept reachable…", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("SECURITY & DATA") - Spacer(Modifier.height(4.dp)) - SettingsRow( - title = "Rotate identity", - subtitle = "New onion address. Offline contacts must re-scan your invite.", - onClick = onRotate, - ) - OwDivider() - SettingsRow( - title = "Delete message history", - subtitle = "Removes every message body on this device. Identity and contacts stay.", - danger = true, - onClick = { confirmDeleteAll = true }, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - OwSectionTitle("About") - Spacer(Modifier.height(8.dp)) - Row(verticalAlignment = Alignment.CenterVertically) { - Label("IDENTITY") - Spacer(Modifier.width(10.dp)) - Mono("ed25519") - } - Spacer(Modifier.height(4.dp)) - Row(verticalAlignment = Alignment.CenterVertically) { - Label("SDK") - Spacer(Modifier.width(10.dp)) - Mono(sdkVersion) - } - Spacer(Modifier.height(10.dp)) - Text( - "Tor and the chain node run in-process. The wallet is an RPC the app " + - "owns and starts itself.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - - Spacer(Modifier.height(24.dp)) - } - } - - if (confirmDeleteAll) { - OwConfirmDialog( - title = "Delete all message history?", - body = "Every message body on this device is deleted. Your identity, " + - "your friends and the pending queue are untouched.", - confirmationWord = "DELETE", - confirmLabel = "Delete history", - destructive = true, - onConfirm = { - confirmDeleteAll = false - onWipe() - }, - onDismiss = { confirmDeleteAll = false }, - ) - } -} - -@Composable -private fun SettingsRow( - title: String, - subtitle: String, - onClick: () -> Unit, - danger: Boolean = false, -) { - Row( - Modifier - .fillMaxWidth() - .clickable(onClick = onClick) - .padding(vertical = 12.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Column(Modifier.weight(1f)) { - Text( - title, - style = MaterialTheme.typography.titleSmall, - color = if (danger) OwColors.Danger else OwColors.TextPrimary, - ) - Spacer(Modifier.height(2.dp)) - Text( - subtitle, - style = MaterialTheme.typography.bodySmall, - color = if (danger) Color(0xCCFF5C5C) else OwColors.TextSecondary, - ) - } - Spacer(Modifier.width(12.dp)) - Text( - "›", - style = MaterialTheme.typography.titleMedium, - color = if (danger) OwColors.Danger else OwColors.TextMuted, - ) - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt index 7133a98..b04565b 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt @@ -1,149 +1,34 @@ package com.siriusdevops.onionwire.ui import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Typography import androidx.compose.material3.darkColorScheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -/** - * OnionWire design tokens. - * - * One canvas, two surfaces, one accent. The palette is deliberately small: - * every screen used to invent its own pill and its own grey, which is what made - * the alpha build read as a debug harness. - * - * Typography rule — the reason this file carries a [MonoStyle]: monospace is - * reserved for cryptographic material and numbers (pubkeys, truncated onion - * locators, seeds, `host:port`, block heights). Chrome is sans. A screen that - * sets `fontFamily = FontFamily.Monospace` on a sentence is a bug. - */ -object OwColors { - /** App canvas. */ - val Canvas = Color(0xFF0A0C0E) +private val OnionViolet = Color(0xFF7C4DFF) +private val WireCyan = Color(0xFF38F2C7) +private val DeepVoid = Color(0xFF0B0B10) +private val PanelVoid = Color(0xFF15151C) - /** Cards and elevated surfaces. */ - val Surface = Color(0xFF12161A) - - /** Inputs, secondary buttons, segmented-control track. */ - val SurfaceInteractive = Color(0xFF1C2228) - - /** The one border. 1dp, never a gradient. */ - val Border = Color(0xFF262E36) - - /** Primary brand / accent. Text on top of it is [Canvas], semibold. */ - val Accent = Color(0xFF2EE59D) - - val TextPrimary = Color(0xFFF3F5F7) - val TextSecondary = Color(0xFF9BA3AE) - val TextMuted = Color(0xFF5E6773) - - /** Success / connected is the accent — there is no second green. */ - val Success = Accent - - /** Warning / syncing. Text, 12% tint, 30% border. */ - val Warning = Color(0xFFF5A623) - val WarningTint = Color(0x1FF5A623) - val WarningBorder = Color(0x4DF5A623) - - /** Danger / error / destructive. */ - val Danger = Color(0xFFFF5C5C) - val DangerTint = Color(0x1FFF5C5C) - val DangerBorder = Color(0x4DFF5C5C) - - /** Info banner — the accent at banner tints, no third hue. */ - val InfoTint = Color(0x142EE59D) - val InfoBorder = Color(0x3D2EE59D) -} - -/** Geometry. Buttons and inputs are 12dp squircles, never 999dp pills. */ -object OwRadius { - /** Cards and the identity bar. */ - val Card = 16.dp - - /** Buttons, inputs, icon surfaces, segmented control. */ - val Control = 12.dp - - /** Small status badges and address chips only. */ - val Pill = 999.dp -} - -/** Fixed sizes from the spec. */ -object OwSize { - val Button = 48.dp - val ButtonCompact = 44.dp - val IconButton = 36.dp - val TabBar = 64.dp - val TabBarBorder = 1.dp - val ProgressTrack = 6.dp -} - -/** The only monospace style in the app. */ -val MonoStyle: TextStyle = TextStyle( - fontFamily = FontFamily.Monospace, - fontSize = 13.sp, - lineHeight = 18.sp, - color = OwColors.TextPrimary, -) - -private val OnionWireTypography = Typography( - // Chrome: system sans. No display face, no bundled grotesque. - displaySmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Bold, fontSize = 28.sp, lineHeight = 34.sp), - headlineSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 22.sp, lineHeight = 28.sp), - titleLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 20.sp, lineHeight = 26.sp), - titleMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 16.sp, lineHeight = 22.sp), - titleSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 15.sp, lineHeight = 20.sp), - bodyLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 16.sp, lineHeight = 24.sp), - bodyMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 14.sp, lineHeight = 20.sp), - bodySmall = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 13.sp, lineHeight = 18.sp), - labelLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 14.sp, lineHeight = 18.sp), - labelMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 12.sp, lineHeight = 16.sp), - labelSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 14.sp, letterSpacing = 0.6.sp), -) - -/** - * The scheme Material components (text fields, dialogs, dividers) still read - * from. New UI should take tokens from [OwColors] directly; `surfaceVariant` - * and `onSurfaceVariant` are mapped so untouched Material defaults do not fall - * back to purple. - */ private val OnionWireColors = darkColorScheme( - primary = OwColors.Accent, - onPrimary = OwColors.Canvas, - primaryContainer = OwColors.SurfaceInteractive, - onPrimaryContainer = OwColors.TextPrimary, - secondary = OwColors.SurfaceInteractive, - onSecondary = OwColors.TextPrimary, - tertiary = OwColors.TextSecondary, - onTertiary = OwColors.Canvas, - background = OwColors.Canvas, - onBackground = OwColors.TextPrimary, - surface = OwColors.Canvas, - onSurface = OwColors.TextPrimary, - surfaceVariant = OwColors.Surface, - onSurfaceVariant = OwColors.TextSecondary, - surfaceContainer = OwColors.Surface, - surfaceContainerHigh = OwColors.SurfaceInteractive, - surfaceContainerLow = OwColors.Surface, - outline = OwColors.Border, - outlineVariant = OwColors.Border, - error = OwColors.Danger, - onError = OwColors.Canvas, - errorContainer = OwColors.DangerTint, - onErrorContainer = OwColors.Danger, - scrim = Color(0xCC000000), + primary = WireCyan, + onPrimary = DeepVoid, + primaryContainer = OnionViolet, + onPrimaryContainer = Color.White, + secondary = OnionViolet, + onSecondary = Color.White, + background = DeepVoid, + onBackground = Color(0xFFE6E6F0), + surface = DeepVoid, + onSurface = Color(0xFFE6E6F0), + surfaceVariant = PanelVoid, + onSurfaceVariant = Color(0xFFB9B9CC), + outline = Color(0xFF3A3A4A), + error = Color(0xFFFF6B6B), + onError = DeepVoid, ) @Composable fun OnionWireTheme(content: @Composable () -> Unit) { - MaterialTheme( - colorScheme = OnionWireColors, - typography = OnionWireTypography, - content = content, - ) + MaterialTheme(colorScheme = OnionWireColors, content = content) } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt deleted file mode 100644 index a7cbb3f..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt +++ /dev/null @@ -1,103 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -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.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.RoundedCornerShape -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** Banner severity. Three states, matching the status colours exactly. */ -enum class OwAlertVariant { Warning, Error, Info } - -/** - * A contextual banner: status icon, one-line title, one- or two-line body. - * - * Replaces the raw red and grey paragraphs that used to trail the wallet and - * invite screens. A state the app is *in* (no wallet open, node experimental) is - * an info or warning banner; only a real failure gets [OwAlertVariant.Error]. - */ -@Composable -fun OwAlertBanner( - variant: OwAlertVariant, - title: String, - description: String? = null, - modifier: Modifier = Modifier, - action: (@Composable () -> Unit)? = null, -) { - val text: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.Warning - OwAlertVariant.Error -> OwColors.Danger - OwAlertVariant.Info -> OwColors.TextPrimary - } - val tint: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.WarningTint - OwAlertVariant.Error -> OwColors.DangerTint - OwAlertVariant.Info -> OwColors.InfoTint - } - val border: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.WarningBorder - OwAlertVariant.Error -> OwColors.DangerBorder - OwAlertVariant.Info -> OwColors.InfoBorder - } - val iconRes = when (variant) { - OwAlertVariant.Warning -> R.drawable.ic_ow_warning - OwAlertVariant.Error -> R.drawable.ic_ow_warning - OwAlertVariant.Info -> R.drawable.ic_ow_info - } - val iconTint = when (variant) { - OwAlertVariant.Info -> OwColors.Accent - else -> text - } - - Row( - modifier = modifier - .fillMaxWidth() - .clip(RoundedCornerShape(OwRadius.Control)) - .background(tint) - .border(1.dp, border, RoundedCornerShape(OwRadius.Control)) - .padding(horizontal = 14.dp, vertical = 12.dp), - horizontalArrangement = Arrangement.Start, - ) { - Icon( - painter = painterResource(iconRes), - contentDescription = null, - tint = iconTint, - modifier = Modifier.padding(top = 1.dp).size(18.dp), - ) - Spacer(Modifier.width(10.dp)) - Column(Modifier.weight(1f)) { - Text(title, style = MaterialTheme.typography.titleSmall, color = text) - if (!description.isNullOrBlank()) { - Spacer(Modifier.height(3.dp)) - Text( - description, - style = MaterialTheme.typography.bodySmall, - color = if (variant == OwAlertVariant.Info) OwColors.TextSecondary else text, - ) - } - if (action != null) { - Spacer(Modifier.height(10.dp)) - action() - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt deleted file mode 100644 index 3c3e1c7..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -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.statusBarsPadding -import androidx.compose.foundation.layout.width -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 -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors - -/** - * The app's one top bar. - * - * Deliberately not `TopAppBar`: that component is a fixed height single line, and - * this header carries a second row (the `● Tor active` pill). A custom column - * also keeps the status-bar inset inside the bar's own background instead of - * padding the screen underneath it. - * - * On a sub-screen the navigation slot is a chevron icon button, never the word - * "Back". - */ -@Composable -fun OwTopBar( - title: String, - modifier: Modifier = Modifier, - onBack: (() -> Unit)? = null, - status: (@Composable () -> Unit)? = null, - actions: @Composable RowScope.() -> Unit = {}, -) { - Column( - modifier = modifier - .fillMaxWidth() - .background(OwColors.Canvas) - .statusBarsPadding() - .padding(start = 16.dp, end = 16.dp, top = 10.dp, bottom = 10.dp), - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - if (onBack != null) { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - tint = OwColors.TextPrimary, - background = OwColors.SurfaceInteractive, - ) - Spacer(Modifier.width(12.dp)) - } - Text( - title, - style = MaterialTheme.typography.titleLarge, - fontWeight = FontWeight.Bold, - color = OwColors.TextPrimary, - modifier = Modifier.weight(1f), - ) - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically, - content = actions, - ) - } - if (status != null) { - Spacer(Modifier.height(8.dp)) - status() - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt deleted file mode 100644 index f0127a0..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt +++ /dev/null @@ -1,127 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.annotation.DrawableRes -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -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.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.navigationBarsPadding -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.Icon -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 -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.role -import androidx.compose.ui.semantics.selected -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwSize - -/** - * The three top-level destinations. - * - * Chats is home. The node lives inside Wallet (that is where its card already - * is), so the third tab is the security/settings surface: identity, saved - * wallets, rotation, wipe, and — behind progressive disclosure — the SDK line - * that used to sit under the roster. - */ -enum class OwTab(val label: String, @param:DrawableRes val icon: Int) { - Chats("Chats", R.drawable.ic_ow_chat), - Wallet("Wallet", R.drawable.ic_ow_wallet), - // Tab labels stay short: the destination is Node & Settings (that is the - // screen title), but a 10sp label in a third of the bar has no room for it. - Settings("Settings", R.drawable.ic_ow_sliders), -} - -/** - * Persistent bottom navigation. - * - * 64dp of canvas with a single 1dp top border — no elevation shadow, no - * translucent scrim. The navigation-bar inset is applied here, so screens inside - * the shell must not also pad for it (see `LocalBottomBarPresent`). - */ -@Composable -fun OwBottomTabBar( - selected: OwTab, - onSelect: (OwTab) -> Unit, - modifier: Modifier = Modifier, -) { - Column( - modifier = modifier - .fillMaxWidth() - .background(OwColors.Canvas), - ) { - OwDivider() - Row( - modifier = Modifier - .fillMaxWidth() - .navigationBarsPadding() - .height(OwSize.TabBar), - horizontalArrangement = Arrangement.SpaceEvenly, - verticalAlignment = Alignment.CenterVertically, - ) { - OwTab.entries.forEach { tab -> - TabItem( - tab = tab, - selected = tab == selected, - onClick = { onSelect(tab) }, - modifier = Modifier.weight(1f), - ) - } - } - } -} - -@Composable -private fun TabItem( - tab: OwTab, - selected: Boolean, - onClick: () -> Unit, - modifier: Modifier = Modifier, -) { - val tint: Color = if (selected) OwColors.Accent else OwColors.TextMuted - Column( - modifier = modifier - .fillMaxWidth() - .clickable(onClick = onClick) - .semantics { - role = Role.Tab - this.selected = selected - } - .padding(vertical = 8.dp), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center, - ) { - Box(contentAlignment = Alignment.Center) { - Icon( - painter = painterResource(tab.icon), - contentDescription = null, - tint = tint, - modifier = Modifier.size(22.dp), - ) - } - Spacer(Modifier.height(4.dp)) - Text( - tab.label, - style = MaterialTheme.typography.labelSmall, - fontSize = 10.sp, - fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Medium, - color = tint, - ) - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt deleted file mode 100644 index 7ff42b6..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt +++ /dev/null @@ -1,145 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -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.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius -import com.siriusdevops.onionwire.ui.OwSize - -/** - * The four button tiers. There is no fifth: a screen that needs something - * quieter than [Outline] uses a text action, not a new shape. - */ -enum class OwButtonVariant { - /** Solid accent, canvas-coloured semibold text. One per screen region. */ - Primary, - - /** Solid interactive surface, no border. */ - Secondary, - - /** Transparent with the one border. */ - Outline, - - /** Tinted crimson with a crimson border. Destructive actions only. */ - Destructive, -} - -/** - * The app's button. - * - * Heights and radii come from the spec, not from Material's 40dp default: a - * 48dp target is comfortable and consistent, and a 12dp squircle replaces the - * 999dp pill that made every alpha action look identical. - */ -@Composable -fun OwButton( - text: String, - onClick: () -> Unit, - modifier: Modifier = Modifier, - variant: OwButtonVariant = OwButtonVariant.Primary, - enabled: Boolean = true, - leadingIconRes: Int? = null, - content: (@Composable androidx.compose.foundation.layout.RowScope.() -> Unit)? = null, -) { - val height = when (variant) { - OwButtonVariant.Outline -> OwSize.ButtonCompact - else -> OwSize.Button - } - val container = when (variant) { - OwButtonVariant.Primary -> OwColors.Accent - OwButtonVariant.Secondary -> OwColors.SurfaceInteractive - OwButtonVariant.Outline -> Color.Transparent - OwButtonVariant.Destructive -> OwColors.DangerTint - } - val contentColor = when (variant) { - OwButtonVariant.Primary -> OwColors.Canvas - OwButtonVariant.Secondary -> OwColors.TextPrimary - OwButtonVariant.Outline -> OwColors.TextPrimary - OwButtonVariant.Destructive -> OwColors.Danger - } - val weight = if (variant == OwButtonVariant.Primary) FontWeight.SemiBold else FontWeight.Medium - // A local val, not the parameter: a parameter captured by the Button's - // content lambda cannot be smart-cast, and the nullable-call error reads as - // a Compose problem when it is only a Kotlin capture rule. - val customContent = content - - Button( - onClick = onClick, - enabled = enabled, - modifier = modifier.height(height), - shape = RoundedCornerShape(OwRadius.Control), - border = when (variant) { - OwButtonVariant.Outline -> BorderStroke(1.dp, OwColors.Border) - OwButtonVariant.Destructive -> BorderStroke(1.dp, OwColors.DangerBorder) - else -> null - }, - colors = ButtonDefaults.buttonColors( - containerColor = container, - contentColor = contentColor, - disabledContainerColor = when (variant) { - OwButtonVariant.Outline -> Color.Transparent - OwButtonVariant.Primary -> OwColors.SurfaceInteractive - OwButtonVariant.Secondary -> OwColors.Surface - OwButtonVariant.Destructive -> OwColors.Surface - }, - disabledContentColor = OwColors.TextMuted, - ), - elevation = ButtonDefaults.buttonElevation(defaultElevation = 0.dp, pressedElevation = 0.dp), - contentPadding = ButtonDefaults.ContentPadding, - ) { - if (customContent != null) { - customContent() - } else { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center, - ) { - if (leadingIconRes != null) { - Icon( - painter = painterResource(leadingIconRes), - contentDescription = null, - modifier = Modifier.size(18.dp), - ) - Spacer(Modifier.width(8.dp)) - } - Text(text, style = MaterialTheme.typography.labelLarge, fontWeight = weight) - } - } - } -} - -/** - * Two buttons sharing a row: the primary action takes the space, the secondary - * one takes what it needs. Used by the identity bar and the empty state. - */ -@Composable -fun OwButtonRow( - modifier: Modifier = Modifier, - content: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit, -) { - Row( - modifier = modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(12.dp), - verticalAlignment = Alignment.CenterVertically, - content = content, - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt deleted file mode 100644 index cb8d1ea..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.layout.Arrangement -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.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.AlertDialog -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * A typed-confirmation dialog for an irreversible action. - * - * The typed word is not theatre: "Rotate identity" cuts every friend who is - * offline off the current locator, and "Wipe all chats" deletes every message - * body. Both are one stray tap away from a menu, so the dialog asks for the - * word the user is about to lose. - * - * [confirmationWord] is echoed in the field label; the confirm button stays - * disabled until it is typed (case-insensitively) — same contract the old inline - * confirm strip had, now with a real scrim behind it. - */ -@Composable -fun OwConfirmDialog( - title: String, - body: String, - confirmationWord: String, - confirmLabel: String, - destructive: Boolean, - onConfirm: () -> Unit, - onDismiss: () -> Unit, -) { - var typed by remember { mutableStateOf("") } - val armed = typed.trim().equals(confirmationWord, ignoreCase = true) - - AlertDialog( - onDismissRequest = onDismiss, - shape = RoundedCornerShape(OwRadius.Card), - containerColor = OwColors.Surface, - titleContentColor = OwColors.TextPrimary, - textContentColor = OwColors.TextSecondary, - title = { Text(title, style = MaterialTheme.typography.titleMedium) }, - text = { - Column { - Text(body, style = MaterialTheme.typography.bodyMedium) - Spacer(Modifier.height(14.dp)) - OutlinedTextField( - value = typed, - onValueChange = { typed = it }, - singleLine = true, - label = { Text("Type $confirmationWord") }, - modifier = Modifier.fillMaxWidth(), - ) - } - }, - confirmButton = { - Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth()) { - TextButton(onClick = onDismiss) { - Text("Cancel", color = OwColors.TextSecondary) - } - TextButton( - onClick = onConfirm, - enabled = armed, - ) { - Text( - confirmLabel, - color = when { - !armed -> OwColors.TextMuted - destructive -> OwColors.Danger - else -> OwColors.Accent - }, - ) - } - } - }, - modifier = Modifier.padding(horizontal = 8.dp), - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt deleted file mode 100644 index f467049..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.layout.Box -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * The `⋮` overflow on the messenger and settings bars. - * - * Serious and rare actions live here instead of on the home screen: rotating the - * identity cuts every offline friend off the current locator, and deleting the - * message history is irreversible. Neither belongs next to "Invite". - * - * The menu is a component rather than inline code so the destructive verbs have - * exactly one home — a new screen that wants the overflow gets the same list, - * not a second copy with different wording. - */ -@Composable -fun OwOverflowMenu( - onOpenProfile: () -> Unit, - onOpenWallets: () -> Unit, - onRotate: () -> Unit, - onWipe: () -> Unit, - modifier: Modifier = Modifier, -) { - var open by remember { mutableStateOf(false) } - - Box(modifier) { - OwIconButton( - iconRes = R.drawable.ic_ow_more_vert, - contentDescription = "More actions", - onClick = { open = true }, - ) - DropdownMenu( - expanded = open, - onDismissRequest = { open = false }, - containerColor = OwColors.SurfaceInteractive, - shape = androidx.compose.foundation.shape.RoundedCornerShape(OwRadius.Control), - ) { - DropdownMenuItem( - text = { Text("Your profile", color = OwColors.TextPrimary) }, - onClick = { open = false; onOpenProfile() }, - ) - DropdownMenuItem( - text = { Text("Saved wallets", color = OwColors.TextPrimary) }, - onClick = { open = false; onOpenWallets() }, - ) - DropdownMenuItem( - text = { Text("Rotate identity", color = OwColors.TextPrimary) }, - onClick = { open = false; onRotate() }, - ) - DropdownMenuItem( - text = { Text("Delete message history", color = OwColors.Danger) }, - onClick = { open = false; onWipe() }, - ) - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt deleted file mode 100644 index 9e3fb3d..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.Canvas -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.geometry.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import com.google.zxing.BarcodeFormat -import com.google.zxing.EncodeHintType -import com.google.zxing.qrcode.QRCodeWriter -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * Renders [payload] as a QR code. - * - * The invite is a locator plus a prekey — long, and it has to survive a person - * pointing a phone at a screen, so the modules are drawn at full contrast on a - * light plate rather than tinted to match the dark theme. - * - * A payload zxing cannot encode (too long for version 40) renders as an empty - * plate; callers always show the copyable text as well, so a failed encode is - * degraded, not fatal. - */ -@Composable -fun OwQrCode( - payload: String, - modifier: Modifier = Modifier, - size: Dp = 200.dp, -) { - val matrix = remember(payload) { - runCatching { - QRCodeWriter().encode( - payload, - BarcodeFormat.QR_CODE, - 0, - 0, - mapOf(EncodeHintType.MARGIN to 0), - ) - }.getOrNull() - } - Box( - modifier = modifier - .size(size) - .clip(RoundedCornerShape(OwRadius.Control)) - .background(OwColors.TextPrimary), - contentAlignment = Alignment.Center, - ) { - if (matrix != null) { - Canvas(Modifier.size(size)) { - val cells = matrix.width.toFloat() - val cellW = this.size.width / cells - val cellH = this.size.height / matrix.height.toFloat() - for (y in 0 until matrix.height) { - for (x in 0 until matrix.width) { - if (matrix.get(x, y)) { - drawRect( - color = Color(0xFF0A0C0E), - topLeft = Offset(x * cellW, y * cellH), - size = Size(cellW + 0.5f, cellH + 0.5f), - ) - } - } - } - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt deleted file mode 100644 index 11be548..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.animation.animateColorAsState -import androidx.compose.animation.core.tween -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.role -import androidx.compose.ui.semantics.selected -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * Horizontal segmented control: one track, [OwColors.SurfaceInteractive], 4dp of - * inside padding, 12dp radius. - * - * This replaces the stacks of full-width pill buttons that made "Pruned / Full / - * Testnet" read as three unrelated actions rather than one choice with three - * values. The selected segment is an accent fill with canvas text. - */ -@Composable -fun OwSegmentedControl( - options: List, - selectedIndex: Int, - onSelect: (Int) -> Unit, - modifier: Modifier = Modifier, - enabled: Boolean = true, -) { - Row( - modifier = modifier - .fillMaxWidth() - .clip(RoundedCornerShape(OwRadius.Control)) - .background(OwColors.SurfaceInteractive) - .padding(4.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - options.forEachIndexed { index, label -> - val selected = index == selectedIndex - val container by animateColorAsState( - targetValue = if (selected) OwColors.Accent else OwColors.SurfaceInteractive, - animationSpec = tween(durationMillis = 160), - label = "segment-container", - ) - val textColor by animateColorAsState( - targetValue = when { - selected -> OwColors.Canvas - enabled -> OwColors.TextSecondary - else -> OwColors.TextMuted - }, - animationSpec = tween(durationMillis = 160), - label = "segment-text", - ) - Box( - modifier = Modifier - .weight(1f) - .height(36.dp) - .clip(RoundedCornerShape(9.dp)) - .background(container) - .clickable(enabled = enabled && !selected) { onSelect(index) } - .semantics { - role = Role.Tab - this.selected = selected - }, - contentAlignment = Alignment.Center, - ) { - Text( - label, - style = MaterialTheme.typography.labelLarge, - fontSize = 13.sp, - fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Medium, - color = textColor, - ) - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt deleted file mode 100644 index 57bdfde..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt +++ /dev/null @@ -1,260 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.Canvas -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.Row -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.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Icon -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 -import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.geometry.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.semantics.contentDescription -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.ui.MonoStyle -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius -import com.siriusdevops.onionwire.ui.OwSize - -/** - * A section card: [OwColors.Surface], 16dp radius, one 1dp border, 16dp of - * padding. Every non-list block on every screen is one of these. - */ -@Composable -fun OwCard( - modifier: Modifier = Modifier, - padding: Dp = 16.dp, - content: @Composable ColumnScope.() -> Unit, -) { - Column( - modifier = modifier - .clip(RoundedCornerShape(OwRadius.Card)) - .background(OwColors.Surface) - .border(1.dp, OwColors.Border, RoundedCornerShape(OwRadius.Card)) - .padding(padding), - content = content, - ) -} - -/** Small tracked label, secondary colour. Never monospace. */ -@Composable -fun Label(text: String, modifier: Modifier = Modifier) { - Text( - text, - modifier = modifier, - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) -} - -/** - * Cryptographic material and numbers only: pubkeys, truncated locators, seeds, - * `host:port`, block heights. Never a sentence. - */ -@Composable -fun Mono(text: String, modifier: Modifier = Modifier, color: Color = OwColors.TextPrimary) { - Text(text, modifier = modifier, style = MonoStyle.copy(color = color)) -} - -/** Section heading inside a card. */ -@Composable -fun OwSectionTitle(text: String, modifier: Modifier = Modifier) { - Text( - text, - modifier = modifier, - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextPrimary, - ) -} - -/** A 7dp status dot. Colour is the caller's statement, not decoration. */ -@Composable -fun OwStatusDot(color: Color, modifier: Modifier = Modifier) { - Box(modifier.size(7.dp).clip(CircleShape).background(color)) -} - -/** Small status badge — the one place a 999dp radius is correct. */ -@Composable -fun OwPill( - text: String, - modifier: Modifier = Modifier, - textColor: Color = OwColors.TextSecondary, - container: Color = OwColors.SurfaceInteractive, - borderColor: Color? = null, - dotColor: Color? = null, -) { - Row( - modifier = modifier - .clip(RoundedCornerShape(OwRadius.Pill)) - .background(container) - .then( - if (borderColor != null) { - Modifier.border(1.dp, borderColor, RoundedCornerShape(OwRadius.Pill)) - } else { - Modifier - }, - ) - .padding(horizontal = 10.dp, vertical = 4.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(6.dp), - ) { - if (dotColor != null) OwStatusDot(dotColor) - Text(text, style = MaterialTheme.typography.labelSmall, color = textColor, fontSize = 11.sp) - } -} - -/** - * The header status pill: `● Tor active`. - * - * Shown while the app is in `Phase.Ready`, which is exactly when the node (and - * therefore Arti) is up. It says nothing about reachability after the app - * leaves the foreground — the keep-alive state is a separate row on the - * settings screen, because that is the honest place for it. - */ -@Composable -fun TorStatusPill(modifier: Modifier = Modifier) { - OwPill( - text = "Tor active", - modifier = modifier, - textColor = OwColors.Accent, - container = OwColors.InfoTint, - borderColor = OwColors.InfoBorder, - dotColor = OwColors.Accent, - ) -} - -/** - * A 36x36 icon button on an interactive surface. Used for Lock, back chevrons - * and the overflow trigger. - */ -@Composable -fun OwIconButton( - iconRes: Int, - contentDescription: String, - onClick: () -> Unit, - modifier: Modifier = Modifier, - tint: Color = OwColors.TextPrimary, - background: Color = OwColors.SurfaceInteractive, - size: Dp = OwSize.IconButton, -) { - Box( - modifier = modifier - .size(size) - .clip(RoundedCornerShape(OwRadius.Control)) - .background(background) - .clickable(onClick = onClick) - .semantics { this.contentDescription = contentDescription }, - contentAlignment = Alignment.Center, - ) { - Icon( - painter = painterResource(iconRes), - contentDescription = null, - tint = tint, - modifier = Modifier.size(18.dp), - ) - } -} - -/** - * A deterministic 5x5 identicon derived from the identity fingerprint. - * - * Not a security feature: it is a stable visual handle so "your identity" is - * recognisable at a glance without reading 64 hex characters. It renders the - * seed it was given — it never invents a value, and two devices showing the - * same fingerprint show the same picture. - */ -@Composable -fun Identicon(seed: String, modifier: Modifier = Modifier, size: Dp = 40.dp) { - val palette = listOf(OwColors.Accent, OwColors.TextSecondary, OwColors.TextMuted) - val cells = identiconCells(seed) - Box( - modifier = modifier - .size(size) - .clip(CircleShape) - .background(OwColors.SurfaceInteractive), - contentAlignment = Alignment.Center, - ) { - Canvas(Modifier.size(size * 0.62f)) { - val cell = this.size.minDimension / 5f - val pad = (this.size.minDimension - cell * 5f) / 2f - cells.forEach { (x, y, tone) -> - drawRect( - color = palette[tone % palette.size], - topLeft = Offset(pad + x * cell, pad + y * cell), - size = Size(cell, cell), - ) - } - } - } -} - -/** - * The left half of a 5-wide grid plus its mirror, as (column, row, tone) - * triples. Pure and cheap: the same seed always yields the same picture. - */ -internal fun identiconCells(seed: String): List> { - if (seed.isEmpty()) return emptyList() - val bytes = seed.map { it.code }.toIntArray() - var i = 0 - val out = mutableListOf>() - for (row in 0 until 5) { - for (col in 0 until 3) { - val v = bytes[i % bytes.size] - i++ - // A cell exists when the byte says so; tone varies the shade. - if (v % 3 != 0) { - val tone = (v / 3) % 3 - out += Triple(col, row, tone) - val mirrored = 4 - col - if (mirrored != col) out += Triple(mirrored, row, tone) - } - } - } - return out -} - -/** The one hairline rule. */ -@Composable -fun OwDivider(modifier: Modifier = Modifier, color: Color = OwColors.Border) { - Box(modifier.fillMaxWidth().height(1.dp).background(color)) -} - -/** Border stroke helper so screens never hardcode the token twice. */ -val OwCardBorder: BorderStroke = BorderStroke(1.dp, OwColors.Border) - -/** Convenience for the many `Icon(painterResource(...))` call sites. */ -@Composable -fun OwIcon( - iconRes: Int, - contentDescription: String?, - tint: Color = OwColors.TextPrimary, - size: Dp = 20.dp, -) { - Icon( - painter = painterResource(iconRes), - contentDescription = contentDescription, - tint = tint, - modifier = Modifier.size(size), - ) -} diff --git a/android/app/src/main/res/drawable/ic_ow_add.xml b/android/app/src/main/res/drawable/ic_ow_add.xml deleted file mode 100644 index 3f91af8..0000000 --- a/android/app/src/main/res/drawable/ic_ow_add.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_chat.xml b/android/app/src/main/res/drawable/ic_ow_chat.xml deleted file mode 100644 index e673602..0000000 --- a/android/app/src/main/res/drawable/ic_ow_chat.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_chevron_left.xml b/android/app/src/main/res/drawable/ic_ow_chevron_left.xml deleted file mode 100644 index b235eaa..0000000 --- a/android/app/src/main/res/drawable/ic_ow_chevron_left.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_copy.xml b/android/app/src/main/res/drawable/ic_ow_copy.xml deleted file mode 100644 index d52c3fb..0000000 --- a/android/app/src/main/res/drawable/ic_ow_copy.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_info.xml b/android/app/src/main/res/drawable/ic_ow_info.xml deleted file mode 100644 index 2a5d106..0000000 --- a/android/app/src/main/res/drawable/ic_ow_info.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_lock.xml b/android/app/src/main/res/drawable/ic_ow_lock.xml deleted file mode 100644 index fce7ee1..0000000 --- a/android/app/src/main/res/drawable/ic_ow_lock.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_more_vert.xml b/android/app/src/main/res/drawable/ic_ow_more_vert.xml deleted file mode 100644 index bcd27db..0000000 --- a/android/app/src/main/res/drawable/ic_ow_more_vert.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_person.xml b/android/app/src/main/res/drawable/ic_ow_person.xml deleted file mode 100644 index 7bc0b35..0000000 --- a/android/app/src/main/res/drawable/ic_ow_person.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_qr.xml b/android/app/src/main/res/drawable/ic_ow_qr.xml deleted file mode 100644 index 7e43c96..0000000 --- a/android/app/src/main/res/drawable/ic_ow_qr.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_share.xml b/android/app/src/main/res/drawable/ic_ow_share.xml deleted file mode 100644 index dc49c02..0000000 --- a/android/app/src/main/res/drawable/ic_ow_share.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_shield.xml b/android/app/src/main/res/drawable/ic_ow_shield.xml deleted file mode 100644 index 2aab4a8..0000000 --- a/android/app/src/main/res/drawable/ic_ow_shield.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_sliders.xml b/android/app/src/main/res/drawable/ic_ow_sliders.xml deleted file mode 100644 index d16a838..0000000 --- a/android/app/src/main/res/drawable/ic_ow_sliders.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_wallet.xml b/android/app/src/main/res/drawable/ic_ow_wallet.xml deleted file mode 100644 index ed74045..0000000 --- a/android/app/src/main/res/drawable/ic_ow_wallet.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_warning.xml b/android/app/src/main/res/drawable/ic_ow_warning.xml deleted file mode 100644 index 234711a..0000000 --- a/android/app/src/main/res/drawable/ic_ow_warning.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt deleted file mode 100644 index 0fa45bf..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * `shortOnion`, the roster's locator abbreviation, on the JVM. - * - * A v3 onion locator must never be soft-wrapped or reduced to a middle slice - * that hides `.onion`: the suffix is what tells a reader this is an onion - * address at all, and the full value is available on the profile and invite - * screens. Pure logic, no Robolectric — same shape as `RosterIdTest`. - */ -class RosterOnionTest { - - private val v3 = - "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwxyz234567.onion" - - @Test - fun a_v3_locator_keeps_its_suffix() { - val short = shortOnion(v3) - assertEquals(true, short.endsWith(".onion")) - assertEquals(v3.take(10), short.substringBefore("\u2026")) - assertEquals(v3.removeSuffix(".onion").takeLast(6), short.removeSuffix(".onion").substringAfter("\u2026")) - } - - @Test - fun the_suffix_is_never_the_part_that_is_cut() { - // Even with an aggressive abbreviation the reader still sees `….onion`. - val body = v3.removeSuffix(".onion") - val short = shortOnion(v3, head = 3, tail = 2) - assertEquals(body.take(3) + "\u2026" + body.takeLast(2) + ".onion", short) - } - - @Test - fun a_short_value_is_returned_unchanged() { - assertEquals("abc.onion", shortOnion("abc.onion")) - assertEquals("", shortOnion("")) - } - - @Test - fun a_value_with_no_suffix_is_not_mangled() { - assertEquals("not-an-onion", shortOnion("not-an-onion")) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt deleted file mode 100644 index 38d6424..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The identicon is a rendering of the identity fingerprint, so it has to be a - * function of that value and nothing else: same fingerprint, same picture, on - * every device and every launch. Pure (a list of cells), no Compose runtime. - */ -class IdenticonTest { - - private val fingerprint = - "9f2c41ab77de03b5c8e1f0a6d4b39c2e5a7f81c0d3e6b492af17c5d80e3b6a49" - - @Test - fun the_same_seed_always_produces_the_same_cells() { - assertEquals(identiconCells(fingerprint), identiconCells(fingerprint)) - } - - @Test - fun the_picture_is_mirrored_about_the_middle_column() { - val cells = identiconCells(fingerprint) - val columns = cells.map { it.first } - cells.forEach { (col, row, tone) -> - assertTrue( - "column $col row $row is not mirrored", - cells.any { it.first == 4 - col && it.second == row && it.third == tone }, - ) - } - assertTrue(columns.all { it in 0..4 }) - } - - @Test - fun a_different_seed_produces_a_different_picture() { - val other = fingerprint.reversed() - assertTrue(identiconCells(fingerprint) != identiconCells(other)) - } - - @Test - fun an_empty_seed_draws_nothing() { - assertEquals(emptyList>(), identiconCells("")) - } -}