Compare commits
35 changed files with 439 additions and 2437 deletions
|
|
@ -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**
|
(`rust-version = "1.98"`). Job timeout is **90** minutes on `android-release.yml` and **120**
|
||||||
on `android-ci.yml`.
|
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
|
## Layout
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
@ -377,33 +363,25 @@ android/
|
||||||
build.gradle.kts
|
build.gradle.kts
|
||||||
src/main/AndroidManifest.xml
|
src/main/AndroidManifest.xml
|
||||||
src/main/java/com/siriusdevops/onionwire/
|
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
|
WireViewModel.kt # UI-side Wire handle; wallet-child poller
|
||||||
crypto/ # Keystore-wrapped store passphrase
|
crypto/ # Keystore-wrapped store passphrase
|
||||||
keepalive/ # NodeHost, KeepAliveService, policy, lifetime
|
keepalive/ # NodeHost, KeepAliveService, policy, lifetime
|
||||||
wallet/ # ChainStorage, WalletChildBinaries
|
wallet/ # ChainStorage, WalletChildBinaries
|
||||||
ui/ # Compose screens (M3)
|
ui/ # Compose screens (M3)
|
||||||
components/ # design system: OwButton, OwSegmentedControl,
|
|
||||||
# OwAlertBanner, OwCard, OwTopBar, OwBottomTabBar,
|
|
||||||
# OwConfirmDialog, OwQrCode, Identicon
|
|
||||||
WalletScreen.kt
|
WalletScreen.kt
|
||||||
WalletManagerScreen.kt
|
|
||||||
WalletChildStatusText.kt
|
WalletChildStatusText.kt
|
||||||
ChatScreen.kt
|
ChatScreen.kt
|
||||||
RosterScreen.kt # Chats tab: identity bar + roster
|
RosterScreen.kt
|
||||||
SettingsScreen.kt # Node & Settings tab
|
InviteScreens.kt
|
||||||
ProfileScreen.kt
|
|
||||||
InviteScreens.kt # share (QR + text) and paste-a-contact
|
|
||||||
InviteAddFlow.kt
|
InviteAddFlow.kt
|
||||||
OutboxDetail.kt
|
OutboxDetail.kt
|
||||||
MessageDelivery.kt
|
MessageDelivery.kt
|
||||||
UnlockScreen.kt
|
UnlockScreen.kt
|
||||||
UnlockSubmit.kt
|
UnlockSubmit.kt
|
||||||
SeedBackupGate.kt
|
|
||||||
RotateScreen.kt
|
RotateScreen.kt
|
||||||
Insets.kt # systemBars ∪ ime, minus the tab-bar inset
|
Insets.kt
|
||||||
Theme.kt # design tokens: palette, radii, sizes, typography
|
Theme.kt
|
||||||
src/main/res/drawable/ic_ow_*.xml # single-colour design-system icons
|
|
||||||
src/test/ # JVM: envelope, store, invite, outbox, keepalive, wallet line, refresh loop
|
src/test/ # JVM: envelope, store, invite, outbox, keepalive, wallet line, refresh loop
|
||||||
src/androidTest/ # device-only: AndroidKeyStore
|
src/androidTest/ # device-only: AndroidKeyStore
|
||||||
src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so
|
src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so
|
||||||
|
|
|
||||||
|
|
@ -8,61 +8,37 @@ import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
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.Surface
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.core.view.WindowCompat
|
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavHostController
|
|
||||||
import androidx.navigation.NavType
|
import androidx.navigation.NavType
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import androidx.navigation.navArgument
|
import androidx.navigation.navArgument
|
||||||
import com.siriusdevops.onionwire.ui.ChatScreen
|
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.PasteInviteScreen
|
||||||
import com.siriusdevops.onionwire.ui.ProfileScreen
|
import com.siriusdevops.onionwire.ui.ProfileScreen
|
||||||
import com.siriusdevops.onionwire.ui.RosterScreen
|
import com.siriusdevops.onionwire.ui.RosterScreen
|
||||||
import com.siriusdevops.onionwire.ui.RotateScreen
|
import com.siriusdevops.onionwire.ui.RotateScreen
|
||||||
import com.siriusdevops.onionwire.ui.SettingsScreen
|
|
||||||
import com.siriusdevops.onionwire.ui.ShareInviteScreen
|
import com.siriusdevops.onionwire.ui.ShareInviteScreen
|
||||||
import com.siriusdevops.onionwire.ui.UnlockScreen
|
import com.siriusdevops.onionwire.ui.UnlockScreen
|
||||||
import com.siriusdevops.onionwire.ui.WalletManagerScreen
|
import com.siriusdevops.onionwire.ui.WalletManagerScreen
|
||||||
import com.siriusdevops.onionwire.ui.WalletScreen
|
import com.siriusdevops.onionwire.ui.WalletScreen
|
||||||
import com.siriusdevops.onionwire.ui.components.OwBottomTabBar
|
import com.siriusdevops.onionwire.ui.OnionWireTheme
|
||||||
import com.siriusdevops.onionwire.ui.components.OwTab
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
enableEdgeToEdge()
|
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 {
|
setContent {
|
||||||
OnionWireTheme {
|
OnionWireTheme {
|
||||||
Surface(
|
Surface(
|
||||||
|
|
@ -85,7 +61,7 @@ private fun AppRoot(vm: WireViewModel = viewModel()) {
|
||||||
// Asked in context: the notification is the keep-alive's only visible
|
// 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
|
// 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
|
// 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(
|
val askNotifications = rememberLauncherForActivityResult(
|
||||||
ActivityResultContracts.RequestPermission(),
|
ActivityResultContracts.RequestPermission(),
|
||||||
) { vm.onNotificationPermissionChanged() }
|
) { 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
|
@Composable
|
||||||
private fun ReadyGraph(vm: WireViewModel, ready: Phase.Ready, keepAliveNote: String?) {
|
private fun ReadyGraph(vm: WireViewModel, ready: Phase.Ready, keepAliveNote: String?) {
|
||||||
val nav = rememberNavController()
|
val nav = rememberNavController()
|
||||||
val friends by vm.friends.collectAsStateWithLifecycle()
|
val friends by vm.friends.collectAsStateWithLifecycle()
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val entry by nav.currentBackStackEntryAsState()
|
|
||||||
val tab = Routes.tabOf(entry?.destination?.route)
|
|
||||||
|
|
||||||
Scaffold(
|
NavHost(navController = nav, startDestination = "roster") {
|
||||||
// Each screen's Scaffold applies its own bars; zeroing this one keeps the
|
composable("roster") {
|
||||||
// status bar from being padded twice and leaves the only inset this
|
RosterScreen(
|
||||||
// level owns — the tab bar's height — in `pad`.
|
fingerprint = ready.fingerprint,
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
onion = ready.onion,
|
||||||
containerColor = MaterialTheme.colorScheme.background,
|
sdkVersion = ready.sdkVersion,
|
||||||
bottomBar = {
|
friends = friends,
|
||||||
if (tab != null) {
|
keepAliveNote = keepAliveNote,
|
||||||
OwBottomTabBar(selected = tab, onSelect = { nav.selectTab(it) })
|
onOpenChat = { nav.navigate("chat/${it.pubkeyHex}") },
|
||||||
}
|
onShare = { nav.navigate("share") },
|
||||||
},
|
onPaste = { nav.navigate("paste") },
|
||||||
) { pad ->
|
onRotate = { nav.navigate("rotate") },
|
||||||
CompositionLocalProvider(LocalBottomBarPresent provides (tab != null)) {
|
onWipe = { scope.launch { vm.wipeMessages() } },
|
||||||
NavHost(
|
onOpenProfile = { nav.navigate("profile") },
|
||||||
navController = nav,
|
onLock = vm::lock,
|
||||||
startDestination = Routes.Chats,
|
onOpenWallet = { nav.navigate("wallet") },
|
||||||
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) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.Wallet) {
|
composable("share") {
|
||||||
WalletScreen(
|
ShareInviteScreen(ownerInvite = vm::invite, onBack = { nav.popBackStack() })
|
||||||
vm = vm,
|
}
|
||||||
onBack = { nav.popBackStack() },
|
|
||||||
onOpenWallets = { nav.navigate(Routes.Wallets) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.Settings) {
|
composable("paste") {
|
||||||
SettingsScreen(
|
PasteInviteScreen(
|
||||||
sdkVersion = ready.sdkVersion,
|
onDecode = vm::decode,
|
||||||
keepAliveNote = keepAliveNote,
|
onAdd = vm::addFriend,
|
||||||
onOpenProfile = { nav.navigate(Routes.Profile) },
|
onBack = { nav.popBackStack() },
|
||||||
onOpenWallets = { nav.navigate(Routes.Wallets) },
|
)
|
||||||
onRotate = { nav.navigate(Routes.Rotate) },
|
}
|
||||||
onWipe = { scope.launch { vm.wipeMessages() } },
|
|
||||||
onLock = vm::lock,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.Share) {
|
composable("rotate") {
|
||||||
ShareInviteScreen(ownerInvite = vm::invite, onBack = { nav.popBackStack() })
|
RotateScreen(
|
||||||
}
|
currentOnion = ready.onion,
|
||||||
|
onRotate = {
|
||||||
|
val out = vm.rotateOnion()
|
||||||
|
out.notified.toInt() to out.friends.toInt()
|
||||||
|
},
|
||||||
|
onBack = { nav.popBackStack() },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
composable(Routes.Paste) {
|
composable("wallet") {
|
||||||
PasteInviteScreen(
|
WalletScreen(
|
||||||
onDecode = vm::decode,
|
vm = vm,
|
||||||
onAdd = vm::addFriend,
|
onBack = { nav.popBackStack() },
|
||||||
onBack = { nav.popBackStack() },
|
onOpenWallets = { nav.navigate("wallets") },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
composable(Routes.Rotate) {
|
composable("wallets") {
|
||||||
RotateScreen(
|
WalletManagerScreen(vm = vm, onBack = { nav.popBackStack() })
|
||||||
currentOnion = ready.onion,
|
}
|
||||||
onRotate = {
|
|
||||||
val out = vm.rotateOnion()
|
|
||||||
out.notified.toInt() to out.friends.toInt()
|
|
||||||
},
|
|
||||||
onBack = { nav.popBackStack() },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.Wallets) {
|
composable("profile") {
|
||||||
WalletManagerScreen(vm = vm, onBack = { nav.popBackStack() })
|
ProfileScreen(vm = vm, onBack = { nav.popBackStack() })
|
||||||
}
|
}
|
||||||
|
|
||||||
composable(Routes.Profile) {
|
composable(
|
||||||
ProfileScreen(vm = vm, onBack = { nav.popBackStack() })
|
route = "chat/{pk}",
|
||||||
}
|
arguments = listOf(navArgument("pk") { type = NavType.StringType }),
|
||||||
|
) { entry ->
|
||||||
composable(
|
val pk = entry.arguments?.getString("pk").orEmpty()
|
||||||
route = Routes.Chat,
|
val friend = friends.firstOrNull { it.pubkeyHex == pk }
|
||||||
arguments = listOf(navArgument("pk") { type = NavType.StringType }),
|
ChatScreen(
|
||||||
) { chatEntry ->
|
vm = vm,
|
||||||
val pk = chatEntry.arguments?.getString("pk").orEmpty()
|
peer = pk,
|
||||||
val friend = friends.firstOrNull { it.pubkeyHex == pk }
|
title = friend?.petname?.takeIf { it.isNotBlank() }
|
||||||
ChatScreen(
|
?: friend?.fingerprint
|
||||||
vm = vm,
|
?: pk.take(16),
|
||||||
peer = pk,
|
fingerprint = friend?.fingerprint ?: pk.take(16),
|
||||||
title = friend?.petname?.takeIf { it.isNotBlank() }
|
onion = friend?.onion.orEmpty(),
|
||||||
?: friend?.fingerprint
|
onBack = { nav.popBackStack() },
|
||||||
?: 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.IconButton
|
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.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||||
import androidx.compose.ui.unit.dp
|
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 androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.siriusdevops.onionwire.WireViewModel
|
import com.siriusdevops.onionwire.WireViewModel
|
||||||
import uniffi.onionwire_sdk.SendState
|
import uniffi.onionwire_sdk.SendState
|
||||||
|
|
@ -61,7 +59,7 @@ import uniffi.onionwire_sdk.SendState
|
||||||
@Composable
|
@Composable
|
||||||
fun ChatScreen(
|
fun ChatScreen(
|
||||||
vm: WireViewModel,
|
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,
|
peer: String,
|
||||||
title: String,
|
title: String,
|
||||||
fingerprint: String,
|
fingerprint: String,
|
||||||
|
|
@ -186,11 +184,7 @@ fun ChatScreen(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
OwIconButton(
|
IconButton(onClick = onBack) { Text("<") }
|
||||||
iconRes = R.drawable.ic_ow_chevron_left,
|
|
||||||
contentDescription = "Back",
|
|
||||||
onClick = onBack,
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
containerColor = MaterialTheme.colorScheme.background,
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
|
|
@ -388,8 +382,7 @@ fun ChatScreen(
|
||||||
// Always drawn, never swapped out for a spinner: a button that
|
// Always drawn, never swapped out for a spinner: a button that
|
||||||
// changes size under the thumb — or disappears — is how "I hit
|
// changes size under the thumb — or disappears — is how "I hit
|
||||||
// send and nothing happened" gets reported.
|
// send and nothing happened" gets reported.
|
||||||
OwButton(
|
Button(
|
||||||
text = "Send",
|
|
||||||
enabled = draft.isNotBlank() && pending == null,
|
enabled = draft.isNotBlank() && pending == null,
|
||||||
onClick = send,
|
onClick = send,
|
||||||
modifier = Modifier.testTag("chat-send"),
|
modifier = Modifier.testTag("chat-send"),
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,8 @@ import androidx.compose.foundation.layout.systemBars
|
||||||
import androidx.compose.foundation.layout.union
|
import androidx.compose.foundation.layout.union
|
||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
|
||||||
import androidx.compose.ui.Modifier
|
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
|
* The bottom + horizontal window insets one screen's content root must apply
|
||||||
* itself.
|
* itself.
|
||||||
|
|
@ -35,9 +25,7 @@ val LocalBottomBarPresent = staticCompositionLocalOf { false }
|
||||||
*
|
*
|
||||||
* The IME's bottom inset already covers the navigation bar, so the two are
|
* The IME's bottom inset already covers the navigation bar, so the two are
|
||||||
* unioned (per-side `max`), never summed: keyboard height while typing,
|
* unioned (per-side `max`), never summed: keyboard height while typing,
|
||||||
* navigation-bar height otherwise, and no double padding in between. Inside the
|
* navigation-bar height otherwise, and no double padding in between.
|
||||||
* tab shell the vertical bar inset is dropped entirely — see
|
|
||||||
* [LocalBottomBarPresent].
|
|
||||||
*
|
*
|
||||||
* The `Top` side is deliberately excluded — a `Scaffold`'s `pad.top` is the app
|
* 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
|
* 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 reads — call it from a composable (every call site is one).
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun Modifier.screenContentInsets(): Modifier {
|
fun Modifier.screenContentInsets(): Modifier =
|
||||||
val sides = if (LocalBottomBarPresent.current) {
|
windowInsetsPadding(
|
||||||
WindowInsetsSides.Horizontal
|
WindowInsets.systemBars.union(WindowInsets.ime)
|
||||||
} else {
|
|
||||||
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
|
|
||||||
}
|
|
||||||
return windowInsetsPadding(
|
|
||||||
WindowInsets.systemBars.only(sides)
|
|
||||||
.union(WindowInsets.ime)
|
|
||||||
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom),
|
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom),
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
package com.siriusdevops.onionwire.ui
|
package com.siriusdevops.onionwire.ui
|
||||||
|
|
||||||
import android.content.ClipData
|
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.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
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.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.foundation.verticalScroll
|
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.CircularProgressIndicator
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
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.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
|
@ -28,37 +32,15 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.ClipEntry
|
import androidx.compose.ui.platform.ClipEntry
|
||||||
import androidx.compose.ui.platform.LocalClipboard
|
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 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 kotlinx.coroutines.launch
|
||||||
import uniffi.onionwire_sdk.FriendInfo
|
import uniffi.onionwire_sdk.FriendInfo
|
||||||
import uniffi.onionwire_sdk.InviteInfo
|
import uniffi.onionwire_sdk.InviteInfo
|
||||||
|
|
||||||
/**
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) {
|
fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) {
|
||||||
var invite by remember { mutableStateOf<String?>(null) }
|
var invite by remember { mutableStateOf<String?>(null) }
|
||||||
|
|
@ -74,11 +56,18 @@ fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Scaffold(
|
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`),
|
// The root applies systemBars + IME itself (see `screenContentInsets`),
|
||||||
// so Scaffold must not also pad for the navigation bar.
|
// so Scaffold must not also pad for the navigation bar.
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||||
containerColor = OwColors.Canvas,
|
|
||||||
) { pad ->
|
) { pad ->
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
|
|
@ -86,123 +75,70 @@ fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) {
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.screenContentInsets()
|
.screenContentInsets()
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(horizontal = 16.dp),
|
.padding(16.dp),
|
||||||
) {
|
) {
|
||||||
Spacer(Modifier.height(8.dp))
|
Text(
|
||||||
OwAlertBanner(
|
"Hand this to one person, over a channel you already trust. " +
|
||||||
variant = OwAlertVariant.Info,
|
"It is not published anywhere and cannot be looked up.",
|
||||||
title = "Not published anywhere",
|
style = MaterialTheme.typography.bodySmall,
|
||||||
description = "Hand this to one person over a channel you already " +
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
"trust. There is no directory and no lookup — that is the point.",
|
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
|
|
||||||
when {
|
when {
|
||||||
error != null -> OwAlertBanner(
|
error != null -> Text(
|
||||||
variant = OwAlertVariant.Error,
|
error!!,
|
||||||
title = "Could not read your invite",
|
style = MaterialTheme.typography.bodySmall,
|
||||||
description = error,
|
color = MaterialTheme.colorScheme.error,
|
||||||
)
|
)
|
||||||
|
|
||||||
invite == null -> Row(
|
invite == null -> CircularProgressIndicator()
|
||||||
Modifier.fillMaxWidth().padding(vertical = 32.dp),
|
|
||||||
horizontalArrangement = Arrangement.Center,
|
|
||||||
) { CircularProgressIndicator(color = OwColors.Accent) }
|
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val payload = invite!!
|
Card(
|
||||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
colors = CardDefaults.cardColors(
|
||||||
OwQrCode(payload = payload, size = 220.dp)
|
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
}
|
),
|
||||||
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) {
|
|
||||||
Text(
|
Text(
|
||||||
payload,
|
invite!!,
|
||||||
style = MonoStyle.copy(color = OwColors.TextSecondary),
|
style = MaterialTheme.typography.bodySmall,
|
||||||
textAlign = TextAlign.Start,
|
modifier = Modifier.padding(12.dp),
|
||||||
maxLines = 4,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
OwButton(
|
Button(onClick = {
|
||||||
text = if (copied) "Copied" else "Copy invite",
|
scope.launch {
|
||||||
onClick = {
|
clipboard.setClipEntry(
|
||||||
scope.launch {
|
ClipEntry(ClipData.newPlainText("onionwire invite", invite!!)),
|
||||||
val clip = ClipData.newPlainText("onionwire invite", payload)
|
)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
copied = true
|
||||||
clip.description.extras = PersistableBundle().apply {
|
}
|
||||||
putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true)
|
}) { Text(if (copied) "Copied" else "Copy") }
|
||||||
}
|
|
||||||
}
|
|
||||||
clipboard.setClipEntry(ClipEntry(clip))
|
|
||||||
copied = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
leadingIconRes = R.drawable.ic_ow_copy,
|
|
||||||
)
|
|
||||||
OwButton(
|
|
||||||
text = "Done",
|
|
||||||
variant = OwButtonVariant.Outline,
|
|
||||||
onClick = onBack,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(20.dp))
|
||||||
OwCard(Modifier.fillMaxWidth()) {
|
Text("What is in it", style = MaterialTheme.typography.titleSmall)
|
||||||
Text(
|
Spacer(Modifier.height(6.dp))
|
||||||
"What is in it",
|
Mono("k ed25519 identity pubkey — who you are")
|
||||||
style = MaterialTheme.typography.titleSmall,
|
Mono("o current onion locator — where you are now")
|
||||||
color = OwColors.TextPrimary,
|
Mono("spk x25519 signed prekey — session start material")
|
||||||
)
|
Mono("sig signature over k‖o‖spk — reject if it fails")
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
InviteField("k", "ed25519 identity pubkey — who you are")
|
Text(
|
||||||
InviteField("o", "current onion locator — where you are now")
|
"The onion in here goes stale when you rotate. The key does not. " +
|
||||||
InviteField("spk", "x25519 signed prekey — session start material")
|
"If you re-share later, the same k updates their entry — it never " +
|
||||||
InviteField("sig", "signature over k‖o‖spk — reject if it fails")
|
"creates a second friend.",
|
||||||
Spacer(Modifier.height(10.dp))
|
style = MaterialTheme.typography.bodySmall,
|
||||||
OwDivider()
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
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.
|
|
||||||
*/
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PasteInviteScreen(
|
fun PasteInviteScreen(
|
||||||
onDecode: suspend (String) -> InviteInfo,
|
onDecode: suspend (String) -> InviteInfo,
|
||||||
|
|
@ -219,12 +155,19 @@ fun PasteInviteScreen(
|
||||||
val adding = flow.adding
|
val adding = flow.adding
|
||||||
|
|
||||||
Scaffold(
|
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
|
// Same inset handoff as the chat composer: with the keyboard up, the
|
||||||
// Verify / Approve buttons under the invite field must still be
|
// Verify / Approve buttons under the invite field must still be
|
||||||
// reachable by scrolling, not by dismissing the keyboard.
|
// reachable by scrolling, not by dismissing the keyboard.
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||||
containerColor = OwColors.Canvas,
|
|
||||||
) { pad ->
|
) { pad ->
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
|
|
@ -232,83 +175,90 @@ fun PasteInviteScreen(
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.screenContentInsets()
|
.screenContentInsets()
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(horizontal = 16.dp),
|
.padding(16.dp),
|
||||||
) {
|
) {
|
||||||
Spacer(Modifier.height(8.dp))
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = raw,
|
value = raw,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
raw = it
|
raw = it
|
||||||
flow.clear()
|
flow.clear()
|
||||||
},
|
},
|
||||||
label = { Text("onionwire:v2:…") },
|
label = { Text("onionwire:v1:…") },
|
||||||
minLines = 4,
|
minLines = 4,
|
||||||
shape = RoundedCornerShape(OwRadius.Control),
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
|
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
OwButton(
|
Button(
|
||||||
text = "Verify",
|
|
||||||
enabled = raw.isNotBlank() && !verifying && !adding,
|
enabled = raw.isNotBlank() && !verifying && !adding,
|
||||||
onClick = { scope.launch { flow.verify(raw) } },
|
onClick = { scope.launch { flow.verify(raw) } },
|
||||||
)
|
) { Text("Verify") }
|
||||||
if (added != null) {
|
if (added != null) {
|
||||||
OwButton(text = "Done", variant = OwButtonVariant.Outline, onClick = onBack)
|
TextButton(onClick = onBack) { Text("Done") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
|
|
||||||
error?.let {
|
error?.let {
|
||||||
OwAlertBanner(
|
Text(
|
||||||
variant = OwAlertVariant.Error,
|
it,
|
||||||
title = "That invite was not accepted",
|
style = MaterialTheme.typography.bodySmall,
|
||||||
description = "$it — unsigned or tampered invites are rejected " +
|
color = MaterialTheme.colorScheme.error,
|
||||||
"here, before anything is stored.",
|
)
|
||||||
|
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 ->
|
preview?.let { p ->
|
||||||
OwCard(Modifier.fillMaxWidth()) {
|
Card(
|
||||||
Label("THEY ARE")
|
colors = CardDefaults.cardColors(
|
||||||
Spacer(Modifier.height(2.dp))
|
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
Mono(shortId(p.pubkeyHex, head = 12, tail = 8))
|
),
|
||||||
Spacer(Modifier.height(6.dp))
|
modifier = Modifier.fillMaxWidth(),
|
||||||
Text(
|
) {
|
||||||
"Compare this fingerprint with them over a second channel " +
|
Column(Modifier.padding(12.dp)) {
|
||||||
"before you trust it.",
|
Label("THEY ARE")
|
||||||
style = MaterialTheme.typography.bodySmall,
|
Mono(p.pubkeyHex)
|
||||||
color = OwColors.TextSecondary,
|
Spacer(Modifier.height(8.dp))
|
||||||
)
|
Text(
|
||||||
Spacer(Modifier.height(10.dp))
|
"fingerprint ${p.pubkeyHex.take(16)}… — compare this with them " +
|
||||||
OwDivider()
|
"over a second channel before you trust it.",
|
||||||
Spacer(Modifier.height(10.dp))
|
style = MaterialTheme.typography.bodySmall,
|
||||||
Label("REACHABLE AT")
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
Spacer(Modifier.height(2.dp))
|
)
|
||||||
Mono(shortOnion(p.onion))
|
Spacer(Modifier.height(8.dp))
|
||||||
|
Label("REACHABLE AT")
|
||||||
|
Mono(p.onion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
OwButton(
|
Button(
|
||||||
text = "Approve & add",
|
|
||||||
enabled = !adding && added == null,
|
enabled = !adding && added == null,
|
||||||
onClick = { scope.launch { flow.add(raw) } },
|
onClick = { scope.launch { flow.add(raw) } },
|
||||||
leadingIconRes = R.drawable.ic_ow_add,
|
) { Text("Approve & add") }
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
added?.let { f ->
|
added?.let { f ->
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
OwAlertBanner(
|
Text(
|
||||||
variant = OwAlertVariant.Info,
|
"Added ${f.petname ?: f.fingerprint}",
|
||||||
title = "Added ${f.petname ?: shortId(f.fingerprint)}",
|
style = MaterialTheme.typography.titleSmall,
|
||||||
description = "If that key was already in your roster, only the " +
|
color = MaterialTheme.colorScheme.primary,
|
||||||
"locator was updated. One key is always one friend.",
|
)
|
||||||
|
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))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
|
@ -32,9 +33,6 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
import androidx.compose.ui.unit.dp
|
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 androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.siriusdevops.onionwire.WireViewModel
|
import com.siriusdevops.onionwire.WireViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -102,11 +100,7 @@ fun ProfileScreen(
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text("Profile") },
|
title = { Text("Profile") },
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
OwIconButton(
|
TextButton(onClick = onBack) { Text("Back") }
|
||||||
iconRes = R.drawable.ic_ow_chevron_left,
|
|
||||||
contentDescription = "Back",
|
|
||||||
onClick = onBack,
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
containerColor = MaterialTheme.colorScheme.background,
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
|
|
@ -240,8 +234,7 @@ fun ProfileScreen(
|
||||||
.padding(12.dp),
|
.padding(12.dp),
|
||||||
horizontalArrangement = Arrangement.End,
|
horizontalArrangement = Arrangement.End,
|
||||||
) {
|
) {
|
||||||
OwButton(
|
Button(
|
||||||
text = if (busy) "Saving…" else "Save",
|
|
||||||
onClick = {
|
onClick = {
|
||||||
addressError = null
|
addressError = null
|
||||||
saveError = null
|
saveError = null
|
||||||
|
|
@ -254,7 +247,7 @@ fun ProfileScreen(
|
||||||
}
|
}
|
||||||
if (problem != null) {
|
if (problem != null) {
|
||||||
addressError = problem
|
addressError = problem
|
||||||
return@OwButton
|
return@Button
|
||||||
}
|
}
|
||||||
scope.launch {
|
scope.launch {
|
||||||
busy = true
|
busy = true
|
||||||
|
|
@ -301,7 +294,9 @@ fun ProfileScreen(
|
||||||
},
|
},
|
||||||
enabled = !busy && profileSaveEnabled(loaded, form),
|
enabled = !busy && profileSaveEnabled(loaded, form),
|
||||||
modifier = Modifier.testTag("profile-save"),
|
modifier = Modifier.testTag("profile-save"),
|
||||||
)
|
) {
|
||||||
|
Text(if (busy) "Saving…" else "Save")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status?.let {
|
status?.let {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
package com.siriusdevops.onionwire.ui
|
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.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
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.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.layout.widthIn
|
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
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.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
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.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
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.unit.dp
|
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
|
import uniffi.onionwire_sdk.FriendInfo
|
||||||
|
|
||||||
/**
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RosterScreen(
|
fun RosterScreen(
|
||||||
fingerprint: String,
|
fingerprint: String,
|
||||||
|
onion: String,
|
||||||
|
sdkVersion: String,
|
||||||
friends: List<FriendInfo>,
|
friends: List<FriendInfo>,
|
||||||
invite: suspend () -> String,
|
keepAliveNote: String?,
|
||||||
onOpenChat: (FriendInfo) -> Unit,
|
onOpenChat: (FriendInfo) -> Unit,
|
||||||
onShare: () -> Unit,
|
onShare: () -> Unit,
|
||||||
onPaste: () -> Unit,
|
onPaste: () -> Unit,
|
||||||
|
|
@ -90,290 +51,245 @@ fun RosterScreen(
|
||||||
onWipe: () -> Unit,
|
onWipe: () -> Unit,
|
||||||
onOpenProfile: () -> Unit,
|
onOpenProfile: () -> Unit,
|
||||||
onLock: () -> Unit,
|
onLock: () -> Unit,
|
||||||
onOpenWallets: () -> Unit,
|
onOpenWallet: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
var confirmWipe by remember { mutableStateOf(false) }
|
||||||
val clipboard = LocalClipboard.current
|
// Closed by default; `rememberSaveable` so a rotation keeps whatever the
|
||||||
val scope = rememberCoroutineScope()
|
// user chose instead of snapping back to (or away from) the summary.
|
||||||
var confirmDeleteAll by remember { mutableStateOf(false) }
|
// Nothing about this is worth persisting to the store.
|
||||||
|
var identityExpanded by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
// The content root below consumes systemBars ∪ ime itself (see
|
// The content root below consumes systemBars ∪ ime itself (see
|
||||||
// `screenContentInsets`), and the tab bar above this screen consumes the
|
// `screenContentInsets`); zeroing the Scaffold's own insets keeps the
|
||||||
// navigation-bar inset; zeroing the Scaffold's own insets is what keeps
|
// navigation bar from being applied twice and lets the wipe-confirm
|
||||||
// the list from being padded twice.
|
// strip sit above the keyboard instead of under it.
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||||
containerColor = OwColors.Canvas,
|
|
||||||
topBar = {
|
topBar = {
|
||||||
OwTopBar(
|
TopAppBar(
|
||||||
title = "OnionWire",
|
title = { Text("OnionWire") },
|
||||||
status = { TorStatusPill() },
|
|
||||||
actions = {
|
actions = {
|
||||||
OwIconButton(
|
TextButton(onClick = onOpenProfile) { Text("Profile") }
|
||||||
iconRes = R.drawable.ic_ow_lock,
|
TextButton(onClick = onLock) { Text("Lock") }
|
||||||
contentDescription = "Lock and stop the node",
|
|
||||||
onClick = onLock,
|
|
||||||
)
|
|
||||||
OwOverflowMenu(
|
|
||||||
onOpenProfile = onOpenProfile,
|
|
||||||
onOpenWallets = onOpenWallets,
|
|
||||||
onRotate = onRotate,
|
|
||||||
onWipe = { confirmDeleteAll = true },
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
) { pad ->
|
) { pad ->
|
||||||
Column(Modifier.padding(pad).fillMaxSize().screenContentInsets()) {
|
Column(Modifier.padding(pad).fillMaxSize().screenContentInsets()) {
|
||||||
IdentityBar(
|
|
||||||
fingerprint = fingerprint,
|
Card(
|
||||||
onCopyInvite = {
|
modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp),
|
||||||
scope.launch {
|
colors = CardDefaults.cardColors(
|
||||||
runCatching { invite() }
|
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
.onSuccess { payload ->
|
),
|
||||||
copyInvite(clipboard, payload)
|
) {
|
||||||
Toast.makeText(context, "Invite address copied", Toast.LENGTH_SHORT).show()
|
Column(Modifier.padding(12.dp)) {
|
||||||
}
|
// The disclosure header. Collapsed, this one line *is* the
|
||||||
.onFailure {
|
// identity block: the label, the abbreviated fingerprint,
|
||||||
Toast.makeText(context, "Could not read the invite", Toast.LENGTH_SHORT).show()
|
// 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,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
if (identityExpanded) {
|
||||||
onShare = onShare,
|
Mono(fingerprint)
|
||||||
)
|
Spacer(Modifier.height(10.dp))
|
||||||
|
Label("ONION (locator — rotates)")
|
||||||
Spacer(Modifier.height(12.dp))
|
Mono(onion)
|
||||||
|
}
|
||||||
if (friends.isEmpty()) {
|
Spacer(Modifier.height(10.dp))
|
||||||
EmptyRoster(
|
Text(
|
||||||
modifier = Modifier.weight(1f),
|
"sdk $sdkVersion · identity = ed25519 pubkey",
|
||||||
onPaste = onPaste,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
onShare = onShare,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
} else {
|
if (keepAliveNote != null) {
|
||||||
LazyColumn(Modifier.weight(1f).fillMaxWidth()) {
|
Spacer(Modifier.height(10.dp))
|
||||||
items(friends, key = { it.pubkeyHex }) { f ->
|
Text(
|
||||||
FriendRow(f) { onOpenChat(f) }
|
keepAliveNote,
|
||||||
OwDivider(Modifier.padding(horizontal = 16.dp))
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (confirmDeleteAll) {
|
Spacer(Modifier.height(8.dp))
|
||||||
OwConfirmDialog(
|
Row(
|
||||||
title = "Delete all message history?",
|
modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp),
|
||||||
body = "Every message body on this device is deleted. Your identity, " +
|
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||||
"your friends and the pending queue are untouched.",
|
) {
|
||||||
confirmationWord = "DELETE",
|
TextButton(onClick = onShare) { Text("Invite") }
|
||||||
confirmLabel = "Delete history",
|
TextButton(onClick = onPaste) { Text("Add") }
|
||||||
destructive = true,
|
TextButton(onClick = onRotate) { Text("Rotate") }
|
||||||
onConfirm = {
|
TextButton(onClick = onOpenWallet) { Text("Wallet") }
|
||||||
confirmDeleteAll = false
|
TextButton(onClick = { confirmWipe = true }) { Text("Wipe chat") }
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (confirmWipe) {
|
||||||
* The empty roster.
|
ConfirmStrip(
|
||||||
*
|
text = "Delete every message body? Identity and friends stay.",
|
||||||
* The honest sentence stays: invites are not discoverable, nothing is published.
|
confirm = "WIPE",
|
||||||
* The two buttons are the two ways out of this state, in the order that helps —
|
onConfirm = { confirmWipe = false; onWipe() },
|
||||||
* paste a peer's invite, or hand yours out.
|
onCancel = { confirmWipe = false },
|
||||||
*/
|
)
|
||||||
@Composable
|
}
|
||||||
private fun EmptyRoster(
|
|
||||||
modifier: Modifier = Modifier,
|
HorizontalDivider(Modifier.padding(vertical = 8.dp))
|
||||||
onPaste: () -> Unit,
|
|
||||||
onShare: () -> Unit,
|
if (friends.isEmpty()) {
|
||||||
) {
|
Column(
|
||||||
Column(
|
Modifier.fillMaxSize().padding(24.dp),
|
||||||
modifier = modifier.fillMaxWidth().padding(horizontal = 24.dp),
|
verticalArrangement = Arrangement.Center,
|
||||||
verticalArrangement = Arrangement.Center,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
) {
|
||||||
) {
|
Text("No friends yet", style = MaterialTheme.typography.titleMedium)
|
||||||
Box(
|
Spacer(Modifier.height(8.dp))
|
||||||
Modifier
|
Text(
|
||||||
.width(64.dp)
|
"Share your invite over a channel you already trust, or paste " +
|
||||||
.height(64.dp)
|
"someone else's. Invites are not discoverable — nothing is published.",
|
||||||
.clip(CircleShape)
|
style = MaterialTheme.typography.bodySmall,
|
||||||
.background(OwColors.Surface),
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
contentAlignment = Alignment.Center,
|
)
|
||||||
) {
|
}
|
||||||
// Muted on purpose: the empty state is an invitation, not an alarm.
|
} else {
|
||||||
// The accent stays reserved for the one primary action below it.
|
// weight(1f), not fillMaxSize(): the list must yield height to
|
||||||
OwIcon(
|
// its siblings (the action row and the wipe-confirm strip above
|
||||||
iconRes = R.drawable.ic_ow_shield,
|
// it) when the IME shrinks the window, instead of claiming all
|
||||||
contentDescription = null,
|
// of it and pushing them off the bottom.
|
||||||
tint = OwColors.TextSecondary,
|
LazyColumn(Modifier.weight(1f).fillMaxWidth()) {
|
||||||
size = 30.dp,
|
items(friends, key = { it.pubkeyHex }) { f ->
|
||||||
)
|
FriendRow(f) { onOpenChat(f) }
|
||||||
}
|
HorizontalDivider()
|
||||||
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),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun FriendRow(f: FriendInfo, onClick: () -> Unit) {
|
private fun FriendRow(f: FriendInfo, onClick: () -> Unit) {
|
||||||
Row(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable(onClick = onClick)
|
.clickable(onClick = onClick)
|
||||||
|
.background(MaterialTheme.colorScheme.background)
|
||||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
.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(
|
Text(
|
||||||
f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint,
|
" locator stale",
|
||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = OwColors.TextPrimary,
|
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
|
* 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
|
* ellipsis, then `tail` characters. Pure, so the roster's collapsed line and
|
||||||
* agree on what "short" means.
|
* its unit test agree on what "short" means.
|
||||||
*
|
*
|
||||||
* A string no longer than the abbreviation is returned unchanged — the
|
* 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
|
* 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`
|
* mangled. Kotlin strings are UTF-16, but these IDs are hex, so `take`/
|
||||||
* cannot split a surrogate pair here.
|
* `takeLast` cannot split a surrogate pair here.
|
||||||
*/
|
*/
|
||||||
fun shortId(id: String, head: Int = 6, tail: Int = 4): String {
|
fun shortId(id: String, head: Int = 6, tail: Int = 4): String {
|
||||||
if (id.length < head + tail + 1) return id
|
if (id.length < head + tail + 1) return id
|
||||||
return id.take(head) + "…" + id.takeLast(tail)
|
return id.take(head) + "…" + id.takeLast(tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Composable
|
||||||
* A v3 onion locator shortened for a roster row, with the `.onion` suffix kept
|
fun Label(text: String) {
|
||||||
* visible: `abcdefghij…uvwxyz.onion`.
|
Text(
|
||||||
*
|
text,
|
||||||
* The suffix is the part that tells a reader this is an onion address at all, so
|
style = MaterialTheme.typography.labelSmall,
|
||||||
* it is never the part that gets truncated. The full value lives on the profile
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
* 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 {
|
@Composable
|
||||||
val suffix = ".onion"
|
fun Mono(text: String) {
|
||||||
if (onion.isEmpty()) return onion
|
Text(
|
||||||
if (!onion.endsWith(suffix)) return onion
|
text,
|
||||||
val body = onion.removeSuffix(suffix)
|
style = MaterialTheme.typography.bodySmall,
|
||||||
if (body.length <= head + tail + 1) return onion
|
fontFamily = FontFamily.Monospace,
|
||||||
return body.take(head) + "…" + body.takeLast(tail) + suffix
|
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") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
|
@ -28,12 +29,6 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
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.
|
* Rotating publishes a brand new onion service and hard-cuts the old one.
|
||||||
|
|
@ -59,13 +54,7 @@ fun RotateScreen(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text("Rotate onion") },
|
title = { Text("Rotate onion") },
|
||||||
navigationIcon = {
|
navigationIcon = { IconButton(onClick = onBack) { Text("<") } },
|
||||||
OwIconButton(
|
|
||||||
iconRes = R.drawable.ic_ow_chevron_left,
|
|
||||||
contentDescription = "Back",
|
|
||||||
onClick = onBack,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
containerColor = MaterialTheme.colorScheme.background,
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
),
|
),
|
||||||
|
|
@ -110,13 +99,11 @@ fun RotateScreen(
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
OwButton(
|
Button(
|
||||||
text = "Rotate",
|
|
||||||
variant = OwButtonVariant.Destructive,
|
|
||||||
enabled = typed.trim().equals("ROTATE", ignoreCase = true) &&
|
enabled = typed.trim().equals("ROTATE", ignoreCase = true) &&
|
||||||
!busy,
|
!busy,
|
||||||
onClick = { busy = true; error = null },
|
onClick = { busy = true; error = null },
|
||||||
)
|
) { Text("Rotate") }
|
||||||
if (busy) CircularProgressIndicator()
|
if (busy) CircularProgressIndicator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -154,11 +141,7 @@ fun RotateScreen(
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
OwButton(
|
Button(onClick = onBack) { Text("Back — share the new invite") }
|
||||||
text = "Share the new invite",
|
|
||||||
variant = OwButtonVariant.Secondary,
|
|
||||||
onClick = onBack,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,149 +1,34 @@
|
||||||
package com.siriusdevops.onionwire.ui
|
package com.siriusdevops.onionwire.ui
|
||||||
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Typography
|
|
||||||
import androidx.compose.material3.darkColorScheme
|
import androidx.compose.material3.darkColorScheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.Color
|
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
|
|
||||||
|
|
||||||
/**
|
private val OnionViolet = Color(0xFF7C4DFF)
|
||||||
* OnionWire design tokens.
|
private val WireCyan = Color(0xFF38F2C7)
|
||||||
*
|
private val DeepVoid = Color(0xFF0B0B10)
|
||||||
* One canvas, two surfaces, one accent. The palette is deliberately small:
|
private val PanelVoid = Color(0xFF15151C)
|
||||||
* 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)
|
|
||||||
|
|
||||||
/** 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(
|
private val OnionWireColors = darkColorScheme(
|
||||||
primary = OwColors.Accent,
|
primary = WireCyan,
|
||||||
onPrimary = OwColors.Canvas,
|
onPrimary = DeepVoid,
|
||||||
primaryContainer = OwColors.SurfaceInteractive,
|
primaryContainer = OnionViolet,
|
||||||
onPrimaryContainer = OwColors.TextPrimary,
|
onPrimaryContainer = Color.White,
|
||||||
secondary = OwColors.SurfaceInteractive,
|
secondary = OnionViolet,
|
||||||
onSecondary = OwColors.TextPrimary,
|
onSecondary = Color.White,
|
||||||
tertiary = OwColors.TextSecondary,
|
background = DeepVoid,
|
||||||
onTertiary = OwColors.Canvas,
|
onBackground = Color(0xFFE6E6F0),
|
||||||
background = OwColors.Canvas,
|
surface = DeepVoid,
|
||||||
onBackground = OwColors.TextPrimary,
|
onSurface = Color(0xFFE6E6F0),
|
||||||
surface = OwColors.Canvas,
|
surfaceVariant = PanelVoid,
|
||||||
onSurface = OwColors.TextPrimary,
|
onSurfaceVariant = Color(0xFFB9B9CC),
|
||||||
surfaceVariant = OwColors.Surface,
|
outline = Color(0xFF3A3A4A),
|
||||||
onSurfaceVariant = OwColors.TextSecondary,
|
error = Color(0xFFFF6B6B),
|
||||||
surfaceContainer = OwColors.Surface,
|
onError = DeepVoid,
|
||||||
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),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun OnionWireTheme(content: @Composable () -> Unit) {
|
fun OnionWireTheme(content: @Composable () -> Unit) {
|
||||||
MaterialTheme(
|
MaterialTheme(colorScheme = OnionWireColors, content = content)
|
||||||
colorScheme = OnionWireColors,
|
|
||||||
typography = OnionWireTypography,
|
|
||||||
content = content,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -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),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -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() },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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<String>,
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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<Triple<Int, Int, Int>> {
|
|
||||||
if (seed.isEmpty()) return emptyList()
|
|
||||||
val bytes = seed.map { it.code }.toIntArray()
|
|
||||||
var i = 0
|
|
||||||
val out = mutableListOf<Triple<Int, Int, Int>>()
|
|
||||||
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),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M10.8,4 H13.2 V10.8 H20 V13.2 H13.2 V20 H10.8 V13.2 H4 V10.8 H10.8 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M4,3 H20 A3,3 0 0 1 23,6 V15 A3,3 0 0 1 20,18 H12 L7,22 V18 H4 A3,3 0 0 1 1,15 V6 A3,3 0 0 1 4,3 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="2"
|
|
||||||
android:strokeLineCap="round"
|
|
||||||
android:strokeLineJoin="round"
|
|
||||||
android:pathData="M14.5,4.5 L7.5,12 L14.5,19.5" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M9,8 H18 A2,2 0 0 1 20,10 V20 A2,2 0 0 1 18,22 H9 A2,2 0 0 1 7,20 V10 A2,2 0 0 1 9,8 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M4,16 H3 A1,1 0 0 1 2,15 V4 A1,1 0 0 1 3,3 H14 A1,1 0 0 1 15,4 V5" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M12,2 A10,10 0 1 1 11.99,2 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M11,10 H13 V17.5 H11 Z M11,6 H13 V8.5 H11 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M7,10 V7 A5,5 0 0 1 17,7 V10" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M5,10 H19 A1,1 0 0 1 20,11 V21 A1,1 0 0 1 19,22 H5 A1,1 0 0 1 4,21 V11 A1,1 0 0 1 5,10 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M12,4 A2,2 0 1 0 12,8 A2,2 0 1 0 12,4 Z M12,10 A2,2 0 1 0 12,14 A2,2 0 1 0 12,10 Z M12,16 A2,2 0 1 0 12,20 A2,2 0 1 0 12,16 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M12,3 A4,4 0 1 1 11.99,3 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M4,21 C4,16.6 7.6,13.5 12,13.5 C16.4,13.5 20,16.6 20,21" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="2"
|
|
||||||
android:pathData="M4,4 H10 V10 H4 Z M14,4 H20 V10 H14 Z M4,14 H10 V20 H4 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M14,14 H17 V17 H14 Z M19,18 H21 V20 H19 Z M14,20 H16.5 V22 H14 Z M19.5,14 H21 V16 H19.5 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M12,3 V15 M12,3 L8,7 M12,3 L16,7" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M5,12 V19 A2,2 0 0 0 7,21 H17 A2,2 0 0 0 19,19 V12" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.6"
|
|
||||||
android:pathData="M12,2 L20,5 V11 C20,16.4 16.6,20.8 12,22 C7.4,20.8 4,16.4 4,11 V5 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.6"
|
|
||||||
android:pathData="M8.5,11.5 L11,14 L15.5,9.5" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M3,6 H7.5 M12.5,6 H21 M3,12 H14.5 M19.5,12 H21 M3,18 H4.5 M9.5,18 H21" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M10,3.5 A2.5,2.5 0 1 0 10,8.5 A2.5,2.5 0 1 0 10,3.5 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M17,9.5 A2.5,2.5 0 1 0 17,14.5 A2.5,2.5 0 1 0 17,9.5 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M7,15.5 A2.5,2.5 0 1 0 7,20.5 A2.5,2.5 0 1 0 7,15.5 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Single colour; tinted at the call site. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:pathData="M4,6 H18 A2,2 0 0 1 20,8 V10 H16 A3,3 0 0 0 16,16 H20 V18 A2,2 0 0 1 18,20 H4 A2,2 0 0 1 2,18 V8 A2,2 0 0 1 4,6 Z" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- OnionWire design-system icon. Outline only: a filled triangle would lose
|
|
||||||
its knock-out once the call site tints the drawable. -->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:strokeLineJoin="round"
|
|
||||||
android:pathData="M12,3 L22,20.5 H2 Z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="#FF000000"
|
|
||||||
android:strokeWidth="1.8"
|
|
||||||
android:strokeLineCap="round"
|
|
||||||
android:pathData="M12,9 V14.5 M12,17 V17.2" />
|
|
||||||
</vector>
|
|
||||||
|
|
@ -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"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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<Triple<Int, Int, Int>>(), identiconCells(""))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue