Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ No ads. No tracking. No internet permission. Just a calculator.

- ✅ Clean, minimal calculator with retro circular keys
- ✅ Live results — see the answer as you type
- ✅ Scientific keys behind a slide-up handle — sin, cos, tan (and inverses), ln, log, √, powers, π, e, factorial, DEG/RAD
- ✅ Scrollable expression display — no more truncated numbers
- ✅ Calculation history saved locally with Room database
- ✅ Unit Converter — Length, Weight, Area, Volume, Temperature, Time, Speed, Pressure
Expand All @@ -53,10 +54,11 @@ No ads. No tracking. No internet permission. Just a calculator.
## Screenshots

<p align="center">
<img src="screenshots/Numio1.jpg" width="200" />
<img src="screenshots/Numio2.jpg" width="200" />
<img src="screenshots/Numio3.jpg" width="200" />
<img src="screenshots/Numio4.jpg" width="200" />
<img src="screenshots/Numio1.jpg" width="160" />
<img src="screenshots/Numio2.jpg" width="160" />
<img src="screenshots/Numio3.jpg" width="160" />
<img src="screenshots/Numio4.jpg" width="160" />
<img src="screenshots/Numio5.jpg" width="160" />
</p>

## Download
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId = "com.rr.numio"
minSdk = 24
targetSdk = 36
versionCode = 9
versionName = "1.0.8"
versionCode = 10
versionName = "1.1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
191 changes: 182 additions & 9 deletions app/src/main/java/com/rr/numio/ui.CalculatorScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import androidx.compose.material.icons.filled.History
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.foundation.gestures.detectVerticalDragGestures
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.foundation.gestures.detectTapGestures
Expand Down Expand Up @@ -49,6 +57,7 @@ private val NumioSurface = Color(0xFF3A3733)
private val NumioRed = Color(0xFFE8452F)
private val NumioTextMuted = Color(0xFF9C9578)
private val NumioTextOnDark = Color(0xFFF2EFE9)
private val NumioSciSurface = Color(0xFF2A2825)

@SuppressLint("UnusedBoxWithConstraintsScope")
@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -71,6 +80,9 @@ fun CalculatorScreen(

var easterEggTapCount by remember { mutableIntStateOf(0) }
var lastTapTime by remember { mutableLongStateOf(0L) }
// The scientific keys hide behind a handle; "2nd" swaps sin/cos/tan, ln/log for their inverses.
var panelOpen by rememberSaveable { mutableStateOf(false) }
var second by rememberSaveable { mutableStateOf(false) }

val keys = listOf(
listOf("AC" to KeyType.CLEAR_ALL, "C" to KeyType.BACKSPACE, "()" to KeyType.BRACKET, "%" to KeyType.OP, "÷" to KeyType.OP),
Expand Down Expand Up @@ -170,21 +182,41 @@ fun CalculatorScreen(
.fillMaxWidth()
) {
if (maxWidth > maxHeight) {
val sciRowHeight = (maxHeight * 0.13f).coerceIn(28.dp, 40.dp)
Row(
modifier = Modifier.fillMaxSize(),
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
CalcDisplay(
expression = uiState.expression,
result = uiState.result,
cursor = uiState.cursor,
showCursor = uiState.showCursor,
onTapExpression = { viewModel.moveCursor(it) },
accentLight = accentLight,
// There's room in landscape, so the scientific keys are always shown
Column(
modifier = Modifier
.weight(1f)
.fillMaxHeight()
)
) {
CalcDisplay(
expression = uiState.expression,
result = uiState.result,
cursor = uiState.cursor,
showCursor = uiState.showCursor,
onTapExpression = { viewModel.moveCursor(it) },
accentLight = accentLight,
modifier = Modifier
.weight(1f)
.fillMaxWidth()
)
SciPanel(
second = second,
degrees = uiState.degrees,
accent = accent,
rowHeight = sciRowHeight,
onToggleSecond = { second = !second },
onToggleAngle = { viewModel.toggleAngleMode() },
onKey = { viewModel.onKeyPress(it) },
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp)
)
}
CalcKeypad(
keys = keys,
accent = accent,
Expand All @@ -210,11 +242,35 @@ fun CalculatorScreen(
.weight(1f)
.fillMaxWidth()
)
SciHandle(
open = panelOpen,
accent = accent,
onSetOpen = { panelOpen = it }
)
AnimatedVisibility(
visible = panelOpen,
enter = expandVertically(tween(220)) + fadeIn(tween(220)),
exit = shrinkVertically(tween(180)) + fadeOut(tween(180))
) {
SciPanel(
second = second,
degrees = uiState.degrees,
accent = accent,
rowHeight = 44.dp,
onToggleSecond = { second = !second },
onToggleAngle = { viewModel.toggleAngleMode() },
onKey = { viewModel.onKeyPress(it) },
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 8.dp)
)
}
CalcKeypad(
keys = keys,
accent = accent,
accentLight = NumioYellowLight,
heightShare = 0.65f,
// With the panel open the display gives up space so the keys keep their size
heightShare = if (panelOpen) 0.75f else 0.65f,
onKey = { viewModel.onKeyPress(it) },
modifier = Modifier.fillMaxWidth()
)
Expand Down Expand Up @@ -372,6 +428,123 @@ private fun CircleKey(
}
}

private class SciKeySpec(val label: String, val highlighted: Boolean, val onClick: () -> Unit)

/** The scientific keys: 5 across, 3 rows. "2nd" swaps in the inverse functions for one key press. */
@Composable
private fun SciPanel(
second: Boolean,
degrees: Boolean,
accent: Color,
rowHeight: Dp,
onToggleSecond: () -> Unit,
onToggleAngle: () -> Unit,
onKey: (String) -> Unit,
modifier: Modifier = Modifier
) {
fun plain(label: String) = SciKeySpec(label, false) { onKey(label) }
fun swapped(label: String, inverse: String) = if (second) {
SciKeySpec(inverse, false) {
onKey(inverse)
onToggleSecond()
}
} else {
plain(label)
}

val rows = listOf(
listOf(
SciKeySpec("2nd", second, onToggleSecond),
swapped("sin", "sin⁻¹"),
swapped("cos", "cos⁻¹"),
swapped("tan", "tan⁻¹"),
SciKeySpec(if (degrees) "DEG" else "RAD", false, onToggleAngle)
),
listOf(swapped("ln", "eˣ"), swapped("log", "10ˣ"), plain("√"), plain("x²"), plain("xʸ")),
listOf(plain("π"), plain("e"), plain("!"), plain("1/x"), plain("|x|"))
)
Column(
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = modifier
) {
rows.forEach { row ->
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth()
) {
row.forEach { spec ->
SciKey(
spec = spec,
accent = accent,
labelSize = (rowHeight.value * 0.42f).coerceIn(12f, 19f),
modifier = Modifier.weight(1f).height(rowHeight)
)
}
}
}
}
}

@Composable
private fun SciKey(spec: SciKeySpec, accent: Color, labelSize: Float, modifier: Modifier = Modifier) {
val isMode = spec.label == "2nd" || spec.label == "DEG" || spec.label == "RAD"
val fontScale = LocalDensity.current.fontScale
Box(
modifier = modifier
.clip(RoundedCornerShape(999.dp))
.background(if (spec.highlighted) accent else NumioSciSurface)
.clickable(role = Role.Button, onClick = spec.onClick),
contentAlignment = Alignment.Center
) {
Text(
text = spec.label,
color = if (spec.highlighted) NumioBg else if (isMode) accent else NumioTextOnDark,
// Keep the label the same size at big system fonts, so "sin⁻¹" is never cut off
fontSize = (labelSize / fontScale.coerceAtLeast(1f)).sp,
fontWeight = FontWeight.Medium,
maxLines = 1,
softWrap = false
)
}
}

/** Tap, or swipe up or down, to show or hide the scientific keys. */
@Composable
private fun SciHandle(open: Boolean, accent: Color, onSetOpen: (Boolean) -> Unit) {
val label = if (open) "Hide scientific keys" else "Show scientific keys"
Box(
modifier = Modifier
.fillMaxWidth()
.height(28.dp)
.semantics {
contentDescription = label
role = Role.Button
onClick(label = label) {
onSetOpen(!open)
true
}
}
.pointerInput(open) { detectTapGestures { onSetOpen(!open) } }
.pointerInput(open) {
var total = 0f
detectVerticalDragGestures(
onDragStart = { total = 0f },
onDragEnd = {
if (total < -24f) onSetOpen(true) else if (total > 24f) onSetOpen(false)
}
) { _, delta -> total += delta }
},
contentAlignment = Alignment.Center
) {
Box(
modifier = Modifier
.size(width = 40.dp, height = 4.dp)
.clip(RoundedCornerShape(2.dp))
.background(if (open) accent else NumioTextMuted.copy(alpha = 0.6f))
)
}
}

@Composable
private fun HistoryOverlay(onDismiss: () -> Unit, content: @Composable () -> Unit) {
BackHandler(onBack = onDismiss)
Expand Down
Loading
Loading