commit
Make the app and the website look alike
The website takes the app's Material icons, buttons and text fields, its top bar and drawer, its message cards and its composer. The app takes the site's IBM Plex Sans, its list rows (a star on every row, yellow when on) and its card-style settings.
diff --git a/email/app/src/main/java/gay/doughmination/mail/ui/SettingsScreen.kt b/email/app/src/main/java/gay/doughmination/mail/ui/SettingsScreen.kt
index dbc32cd..67fcea6 100644
--- a/email/app/src/main/java/gay/doughmination/mail/ui/SettingsScreen.kt
+++ b/email/app/src/main/java/gay/doughmination/mail/ui/SettingsScreen.kt
@@ -4,30 +4,36 @@ import android.content.Intent
import android.net.Uri
import android.provider.Settings
import androidx.browser.customtabs.CustomTabsIntent
-import androidx.compose.foundation.clickable
+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.ColumnScope
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
+import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
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.rememberScrollState
+import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.automirrored.outlined.Logout
-import androidx.compose.material.icons.outlined.Description
+import androidx.compose.material.icons.outlined.ChevronRight
import androidx.compose.material.icons.outlined.Notifications
-import androidx.compose.material.icons.outlined.NotificationsActive
-import androidx.compose.material.icons.outlined.NotificationsOff
import androidx.compose.material.icons.outlined.PrivacyTip
import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
-import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
-import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
@@ -38,13 +44,17 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import gay.doughmination.mail.BuildConfig
import gay.doughmination.mail.Push
-@OptIn(ExperimentalMaterial3Api::class)
+/** Laid out like the web's settings page: one card per topic, under a small pink heading. */
+@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@Composable
fun SettingsScreen(vm: MailViewModel) {
val me = vm.me
@@ -65,80 +75,109 @@ fun SettingsScreen(vm: MailViewModel) {
},
snackbarHost = { SnackbarHost(LocalSnackbar.current) },
) { padding ->
- Column(Modifier.padding(padding).fillMaxSize().verticalScroll(rememberScrollState())) {
- Column(Modifier.padding(16.dp)) {
- Text("Your name", style = MaterialTheme.typography.titleMedium)
- Text(
- "Shown on mail you send. Leave it empty to send from the bare address.",
- style = MaterialTheme.typography.bodySmall,
- color = Muted,
- )
- Spacer(Modifier.height(8.dp))
- OutlinedTextField(
- value = name,
- onValueChange = { if (it.length <= 100) name = it },
- singleLine = true,
- modifier = Modifier.fillMaxWidth(),
- )
- Spacer(Modifier.height(8.dp))
- Button(onClick = { vm.saveName(name) }, enabled = name.trim() != me?.name.orEmpty()) { Text("Save") }
+ Column(
+ Modifier.padding(padding).fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 12.dp),
+ verticalArrangement = Arrangement.spacedBy(16.dp),
+ ) {
+ Section("Your name") {
+ Note("People see this as the sender of mail you send. Leave it empty to send from just the address.")
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ OutlinedTextField(
+ value = name,
+ onValueChange = { if (it.length <= 100) name = it },
+ placeholder = { Text("Your name") },
+ singleLine = true,
+ modifier = Modifier.weight(1f),
+ )
+ Spacer(Modifier.width(8.dp))
+ Button(onClick = { vm.saveName(name) }, enabled = name.trim() != me?.name.orEmpty()) { Text("Save") }
+ }
}
- HorizontalDivider()
- Column(Modifier.padding(16.dp)) {
- Text("Your addresses", style = MaterialTheme.typography.titleMedium)
- Spacer(Modifier.height(4.dp))
- for (addr in me?.addresses.orEmpty()) Text(addr, color = Muted)
- if (me?.addresses.isNullOrEmpty()) Text("None yet. Ask an admin to switch on a domain.", color = Muted)
+
+ Section("Your addresses") {
+ Note("You receive and can send from each of these.")
+ for (addr in me?.addresses.orEmpty()) Text("• $addr")
+ if (me?.addresses.isNullOrEmpty()) Text("None yet. Ask an admin to switch on a domain.")
}
- HorizontalDivider()
- if (Push.available(context)) {
- ListItem(
- headlineContent = { Text("Notification settings") },
- supportingContent = { Text("Turn new-mail notifications on or off") },
- leadingContent = { Icon(Icons.Outlined.Notifications, null) },
- modifier = Modifier.clickable {
- context.startActivity(
- Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
- .putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName),
- )
- },
- )
- ListItem(
- headlineContent = { Text("Send a test notification") },
- leadingContent = { Icon(Icons.Outlined.NotificationsActive, null) },
- modifier = Modifier.clickable { vm.testPush() },
- )
- } else {
- ListItem(
- headlineContent = { Text("Notifications") },
- supportingContent = { Text("This build has no Firebase setup, so notifications are off.") },
- leadingContent = { Icon(Icons.Outlined.NotificationsOff, null) },
- )
+
+ Section("Notifications", Icons.Outlined.Notifications) {
+ if (Push.available(context)) {
+ Note("Turn new-mail notifications on or off in Android's settings for the app.")
+ FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ OutlinedButton(onClick = {
+ context.startActivity(
+ Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
+ .putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName),
+ )
+ }) { Text("Notification settings") }
+ OutlinedButton(onClick = vm::testPush) { Text("Send a test") }
+ }
+ } else {
+ Note("This build has no Firebase setup, so notifications are off.")
+ }
}
- HorizontalDivider()
- ListItem(
- headlineContent = { Text("Privacy policy") },
- leadingContent = { Icon(Icons.Outlined.PrivacyTip, null) },
- modifier = Modifier.clickable { openWeb("/privacy") },
- )
- ListItem(
- headlineContent = { Text("Terms of service") },
- leadingContent = { Icon(Icons.Outlined.Description, null) },
- modifier = Modifier.clickable { openWeb("/terms") },
- )
- HorizontalDivider()
- ListItem(
- headlineContent = { Text("Sign out", color = Danger) },
- supportingContent = { me?.let { Text("Signed in as ${it.username}") } },
- leadingContent = { Icon(Icons.AutoMirrored.Outlined.Logout, null, tint = Danger) },
- modifier = Modifier.clickable { vm.signOut() },
- )
+
+ Section("Privacy and terms", Icons.Outlined.PrivacyTip) {
+ Note("What's stored about you and your mail, who can see it, and the rules for using the inbox.")
+ FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ OutlinedButton(onClick = { openWeb("/privacy") }) {
+ Text("Privacy policy")
+ Icon(Icons.Outlined.ChevronRight, null, Modifier.size(ButtonDefaults.IconSize))
+ }
+ OutlinedButton(onClick = { openWeb("/terms") }) {
+ Text("Terms of service")
+ Icon(Icons.Outlined.ChevronRight, null, Modifier.size(ButtonDefaults.IconSize))
+ }
+ }
+ }
+
+ Section("Account") {
+ me?.let { Note("Signed in as ${it.username}.") }
+ OutlinedButton(
+ onClick = { vm.signOut() },
+ colors = ButtonDefaults.outlinedButtonColors(contentColor = Danger),
+ contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
+ ) {
+ Icon(Icons.AutoMirrored.Outlined.Logout, null, Modifier.size(ButtonDefaults.IconSize))
+ Spacer(Modifier.width(ButtonDefaults.IconSpacing))
+ Text("Sign out")
+ }
+ }
+
Text(
"Inbox ${BuildConfig.VERSION_NAME}",
- Modifier.padding(16.dp),
+ Modifier.padding(start = 4.dp, bottom = 24.dp),
style = MaterialTheme.typography.labelSmall,
color = Muted,
)
}
}
}
+
+private val sectionShape = RoundedCornerShape(16.dp)
+
+/** A card like the web's settings sections: dark glass, a hairline border, an eyebrow heading. */
+@Composable
+private fun Section(title: String, icon: ImageVector? = null, content: @Composable ColumnScope.() -> Unit) {
+ Column(
+ Modifier
+ .fillMaxWidth()
+ .clip(sectionShape)
+ .background(Bg.copy(alpha = 0.72f))
+ .border(1.dp, Line, sectionShape)
+ .padding(16.dp),
+ verticalArrangement = Arrangement.spacedBy(10.dp),
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ if (icon != null) {
+ Icon(icon, null, Modifier.size(16.dp), tint = Accent)
+ Spacer(Modifier.width(6.dp))
+ }
+ Text(title.uppercase(), style = Eyebrow)
+ }
+ content()
+ }
+}
+
+@Composable
+private fun Note(text: String) = Text(text, style = MaterialTheme.typography.bodyMedium, color = Muted)
diff --git a/email/app/src/main/java/gay/doughmination/mail/ui/Theme.kt b/email/app/src/main/java/gay/doughmination/mail/ui/Theme.kt
index f701562..b1eefa4 100644
--- a/email/app/src/main/java/gay/doughmination/mail/ui/Theme.kt
+++ b/email/app/src/main/java/gay/doughmination/mail/ui/Theme.kt
@@ -12,9 +12,15 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import gay.doughmination.mail.R
+import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.Font
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.sp
// The site's palette (email/src/web/app.css).
val Accent = Color(0xFFEB459E)
@@ -23,6 +29,49 @@ val Muted = Color(0xFFA49EAB)
val Bg = Color(0xFF0B0A0D)
/** A card on the backdrop, like --raised on the web. */
val Raised = Color.White.copy(alpha = 0.05f)
+/** Hairline borders, like --line on the web. */
+val Line = Color.White.copy(alpha = 0.09f)
+/** A starred thread, like --star on the web. */
+val StarYellow = Color(0xFFF7C948)
+
+/** IBM Plex Sans, as on the web and doughmination.gay (the same files, as TTF). */
+val PlexSans = FontFamily(
+ Font(R.font.ibm_plex_sans_regular, FontWeight.Normal),
+ Font(R.font.ibm_plex_sans_medium, FontWeight.Medium),
+ Font(R.font.ibm_plex_sans_semibold, FontWeight.SemiBold),
+ Font(R.font.ibm_plex_sans_bold, FontWeight.Bold),
+)
+
+private fun TextStyle.plex() = copy(fontFamily = PlexSans)
+
+private val typography = Typography().run {
+ Typography(
+ displayLarge = displayLarge.plex(),
+ displayMedium = displayMedium.plex(),
+ displaySmall = displaySmall.plex(),
+ headlineLarge = headlineLarge.plex(),
+ headlineMedium = headlineMedium.plex(),
+ headlineSmall = headlineSmall.plex(),
+ titleLarge = titleLarge.plex(),
+ titleMedium = titleMedium.plex(),
+ titleSmall = titleSmall.plex(),
+ bodyLarge = bodyLarge.plex(),
+ bodyMedium = bodyMedium.plex(),
+ bodySmall = bodySmall.plex(),
+ labelLarge = labelLarge.plex(),
+ labelMedium = labelMedium.plex(),
+ labelSmall = labelSmall.plex(),
+ )
+}
+
+/** The web's small uppercase accent label (.eyebrow), used for headings. */
+val Eyebrow = TextStyle(
+ fontFamily = PlexSans,
+ fontSize = 11.sp,
+ fontWeight = FontWeight.SemiBold,
+ letterSpacing = 1.5.sp,
+ color = Accent,
+)
private val colors = darkColorScheme(
primary = Accent,
@@ -87,4 +136,5 @@ fun Backdrop(modifier: Modifier = Modifier) {
}
@Composable
-fun InboxTheme(content: @Composable () -> Unit) = MaterialTheme(colorScheme = colors, content = content)
+fun InboxTheme(content: @Composable () -> Unit) =
+ MaterialTheme(colorScheme = colors, typography = typography, content = content)
diff --git a/email/app/src/main/java/gay/doughmination/mail/ui/ThreadListScreen.kt b/email/app/src/main/java/gay/doughmination/mail/ui/ThreadListScreen.kt
index 0a33868..9be58fb 100644
--- a/email/app/src/main/java/gay/doughmination/mail/ui/ThreadListScreen.kt
+++ b/email/app/src/main/java/gay/doughmination/mail/ui/ThreadListScreen.kt
@@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
@@ -89,6 +90,7 @@ import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
import androidx.browser.customtabs.CustomTabsIntent
import android.net.Uri
import gay.doughmination.mail.data.ListFolder
@@ -308,40 +310,53 @@ private fun SwipeRow(vm: MailViewModel, t: ThreadSummary, onHold: (ThreadSummary
private fun ThreadRow(vm: MailViewModel, t: ThreadSummary, opaque: Boolean, onClick: () -> Unit, onLongClick: () -> Unit) {
val unread = t.unread > 0
// The Bin and Starred mix folders; whoever it's from reads best there.
- val who = when (vm.folder) {
- ListFolder.Sent, ListFolder.Drafts ->
- "To: " + (t.to.joinToString(", ") { displayName(it) }.ifEmpty { "(nobody yet)" })
- else -> displayName(t.from)
- }
+ val fromSide = vm.folder != ListFolder.Sent && vm.folder != ListFolder.Drafts
+ val who = if (fromSide) displayName(t.from)
+ else "To: " + (t.to.joinToString(", ") { displayName(it) }.ifEmpty { "(nobody yet)" })
+ // Laid out like the web's rows on a phone, sizes and all.
Row(
Modifier
.fillMaxWidth()
// Opaque only while it's being swiped, so the wallpaper shows through at rest.
.background(if (opaque) Bg else Color.Transparent)
.combinedClickable(onClick = onClick, onLongClick = onLongClick)
- .padding(horizontal = 16.dp, vertical = 12.dp),
+ .padding(start = 16.dp, end = 8.dp, top = 10.dp, bottom = 10.dp),
verticalAlignment = Alignment.Top,
) {
- Avatar(who.removePrefix("To: "))
- Spacer(Modifier.width(12.dp))
+ Avatar(if (fromSide) displayName(t.from) else displayName(t.to.firstOrNull() ?: "?"))
+ Spacer(Modifier.width(14.dp))
Column(Modifier.weight(1f)) {
- Row(verticalAlignment = Alignment.CenterVertically) {
+ Row(Modifier.padding(end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
Text(
- who + if (t.count > 1) " ${t.count}" else "",
- Modifier.weight(1f),
+ who,
+ Modifier.weight(1f, fill = false),
+ fontSize = 15.sp,
fontWeight = if (unread) FontWeight.Bold else FontWeight.Normal,
+ color = if (unread) MaterialTheme.colorScheme.onSurface else Muted,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
+ if (t.count > 1) {
+ Spacer(Modifier.width(6.dp))
+ Text("${t.count}", fontSize = 12.sp, color = Muted)
+ }
+ if (t.hasAttachments) {
+ Spacer(Modifier.width(6.dp))
+ Icon(Icons.Outlined.AttachFile, "Has attachments", Modifier.size(14.dp), tint = Muted)
+ }
+ Spacer(Modifier.weight(1f).widthIn(min = 8.dp))
Text(
fmtTime(t.lastAt),
- style = MaterialTheme.typography.labelMedium,
- color = if (unread) Accent else Muted,
+ fontSize = 12.sp,
+ fontWeight = if (unread) FontWeight.Bold else FontWeight.Normal,
+ color = if (unread) MaterialTheme.colorScheme.onSurface else Muted,
)
}
Text(
t.subject.ifEmpty { "(no subject)" },
- fontWeight = if (unread) FontWeight.SemiBold else FontWeight.Normal,
+ Modifier.padding(end = 8.dp),
+ fontSize = 14.sp,
+ fontWeight = if (unread) FontWeight.Bold else FontWeight.Normal,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
@@ -349,30 +364,39 @@ private fun ThreadRow(vm: MailViewModel, t: ThreadSummary, opaque: Boolean, onCl
Text(
t.snippet,
Modifier.weight(1f),
- style = MaterialTheme.typography.bodyMedium,
+ fontSize = 13.5.sp,
color = Muted,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
- if (t.hasAttachments) Icon(Icons.Outlined.AttachFile, "Has attachments", Modifier.size(16.dp), tint = Muted)
- if (t.starred) Icon(Icons.Filled.Star, "Starred", Modifier.size(16.dp), tint = Accent)
+ // A star on every row, as on the web; the Bin has none.
+ if (vm.folder != ListFolder.Bin) {
+ IconButton(onClick = { vm.toggleStar(t.id, !t.starred) }, Modifier.size(32.dp)) {
+ if (t.starred) Icon(Icons.Filled.Star, "Unstar", Modifier.size(18.dp), tint = StarYellow)
+ else Icon(Icons.Outlined.StarOutline, "Star", Modifier.size(18.dp), tint = Muted)
+ }
+ }
}
}
}
}
-private val avatarColors = listOf(
- Color(0xFFEB459E), Color(0xFF7C5CFF), Color(0xFF2FA4FF), Color(0xFF1FB58F),
- Color(0xFFF5A524), Color(0xFFFF6B5C), Color(0xFFB45CFF), Color(0xFF4CC3D9),
-)
-
-/** A coloured initial, as Gmail does. */
+/** A coloured initial, as the web draws it: the same hue from the same name. */
@Composable
private fun Avatar(name: String) {
val initial = name.trim().firstOrNull { it.isLetterOrDigit() }?.uppercaseChar() ?: '?'
- val color = avatarColors[Math.floorMod(name.lowercase().hashCode(), avatarColors.size)]
- Box(Modifier.size(40.dp).clip(CircleShape).background(color), contentAlignment = Alignment.Center) {
- Text(initial.toString(), color = Color.White, fontWeight = FontWeight.Bold)
+ // The web's hash runs over code points, taking each one's first UTF-16 unit.
+ var hue = 0
+ var i = 0
+ while (i < name.length) {
+ hue = (hue * 31 + name[i].code) % 360
+ i += Character.charCount(name.codePointAt(i))
+ }
+ Box(
+ Modifier.padding(top = 2.dp).size(40.dp).clip(CircleShape).background(Color.hsl(hue.toFloat(), 0.55f, 0.42f)),
+ contentAlignment = Alignment.Center,
+ ) {
+ Text(initial.toString(), color = Color.White, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)
}
}
diff --git a/email/app/src/main/java/gay/doughmination/mail/ui/ThreadScreen.kt b/email/app/src/main/java/gay/doughmination/mail/ui/ThreadScreen.kt
index 2b22d7b..c18a0d7 100644
--- a/email/app/src/main/java/gay/doughmination/mail/ui/ThreadScreen.kt
+++ b/email/app/src/main/java/gay/doughmination/mail/ui/ThreadScreen.kt
@@ -92,7 +92,7 @@ fun ThreadScreen(vm: MailViewModel, screen: Screen.Thread) {
}
} else {
IconButton(onClick = { vm.toggleStar(thread.id, !thread.starred) }) {
- if (thread.starred) Icon(Icons.Filled.Star, "Unstar", tint = Accent)
+ if (thread.starred) Icon(Icons.Filled.Star, "Unstar", tint = StarYellow)
else Icon(Icons.Outlined.StarOutline, "Star")
}
if (thread.messages.any { it.folder == "inbox" }) {
diff --git a/email/app/src/main/res/font/ibm_plex_sans_bold.ttf b/email/app/src/main/res/font/ibm_plex_sans_bold.ttf
new file mode 100644
index 0000000..c864a80
Binary files /dev/null and b/email/app/src/main/res/font/ibm_plex_sans_bold.ttf differ
diff --git a/email/app/src/main/res/font/ibm_plex_sans_medium.ttf b/email/app/src/main/res/font/ibm_plex_sans_medium.ttf
new file mode 100644
index 0000000..94738b8
Binary files /dev/null and b/email/app/src/main/res/font/ibm_plex_sans_medium.ttf differ
diff --git a/email/app/src/main/res/font/ibm_plex_sans_regular.ttf b/email/app/src/main/res/font/ibm_plex_sans_regular.ttf
new file mode 100644
index 0000000..a4f4148
Binary files /dev/null and b/email/app/src/main/res/font/ibm_plex_sans_regular.ttf differ
diff --git a/email/app/src/main/res/font/ibm_plex_sans_semibold.ttf b/email/app/src/main/res/font/ibm_plex_sans_semibold.ttf
new file mode 100644
index 0000000..454f3d4
Binary files /dev/null and b/email/app/src/main/res/font/ibm_plex_sans_semibold.ttf differ