-
-
Notifications
You must be signed in to change notification settings - Fork 16
Graphing Improvements #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| // Function template chips | ||
| Text( | ||
| text = "Quick Templates:", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not translatable, i.e. stringResource(R.string.quick_templates)
| val templates = listOf( | ||
| "sin(x)" to "sin(x)", | ||
| "x^2" to "x^2", | ||
| "sin(cos(x))" to "sin(cos(x))", | ||
| "sqrt(x^2+1)" to "sqrt(x^2+1)", | ||
| "e^(-x^2)" to "exp(-x^2)", | ||
| "ln(abs(x))" to "ln(abs(x))", | ||
| "tan(x/2)" to "tan(x/2)", | ||
| "cbrt(x)" to "cbrt(x)", | ||
| "cot(x)" to "cot(x)", | ||
| "1/x" to "1/x" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| val templates = listOf( | |
| "sin(x)" to "sin(x)", | |
| "x^2" to "x^2", | |
| "sin(cos(x))" to "sin(cos(x))", | |
| "sqrt(x^2+1)" to "sqrt(x^2+1)", | |
| "e^(-x^2)" to "exp(-x^2)", | |
| "ln(abs(x))" to "ln(abs(x))", | |
| "tan(x/2)" to "tan(x/2)", | |
| "cbrt(x)" to "cbrt(x)", | |
| "cot(x)" to "cot(x)", | |
| "1/x" to "1/x" | |
| ) | |
| val templates = remember { | |
| listOf( | |
| "sin(x)" to "sin(x)", | |
| "x^2" to "x^2", | |
| "sin(cos(x))" to "sin(cos(x))", | |
| "sqrt(x^2+1)" to "sqrt(x^2+1)", | |
| "e^(-x^2)" to "exp(-x^2)", | |
| "ln(abs(x))" to "ln(abs(x))", | |
| "tan(x/2)" to "tan(x/2)", | |
| "cbrt(x)" to "cbrt(x)", | |
| "cot(x)" to "cot(x)", | |
| "1/x" to "1/x" | |
| ) | |
| } |
we should either make them remember or put them outside of the compose code, i.e. above the method declaration
| "1/x" to "1/x" | ||
| ) | ||
|
|
||
| templates.forEach { (label, template) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could use a LazyRow here instead of a Row with Modifier.scrollabe?
| IconButton(onClick = { showCheatSheet = true }) { | ||
| Icon( | ||
| imageVector = Icons.Rounded.Help, | ||
| contentDescription = "Syntax help", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not translatable
| ), | ||
| supportingText = { | ||
| Text( | ||
| text = "Supports nested functions like sin(cos(x))", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that hint is really necessary, perhaps it'd be better to put this into the SyntaxCheatSheetDialog?
(and also make it translatable)
| "+" to "Addition", | ||
| "-" to "Subtraction", | ||
| "*" to "Multiplication", | ||
| "/" to "Division", | ||
| "^" to "Exponentiation (x^2)", | ||
| "%" to "Modulo (remainder)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not translatable
| "+" to "Addition", | ||
| "-" to "Subtraction", | ||
| "*" to "Multiplication", | ||
| "/" to "Division", | ||
| "^" to "Exponentiation (x^2)", | ||
| "%" to "Modulo (remainder)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually use % as percentage (e.g. 10% is the same as 0.1) and not as modulo in CalcYou, might be worth adding a mod function that can be used instead.
| onClick = onDismiss, | ||
| modifier = Modifier.align(Alignment.End) | ||
| ) { | ||
| Text(text = "Close") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Text(text = "Close") | |
| Text(text = stringResource(android.R.string.ok)) |
| fontWeight = FontWeight.Bold, | ||
| color = MaterialTheme.colorScheme.secondary | ||
| ) | ||
| items.forEach { (syntax, description) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a LazyColumn could be used instead here as well for lazy rendering. Won't make much of a difference here, but for larger data amounts it definitely improves performance
| private fun gcd(a: Long, b: Long): Long { | ||
| var x = abs(a) | ||
| var y = abs(b) | ||
| while (y != 0L) { | ||
| val temp = y | ||
| y = x % y | ||
| x = temp | ||
| } | ||
| return x | ||
| } | ||
|
|
||
| private fun lcm(a: Long, b: Long): Long { | ||
| return if (a == 0L || b == 0L) 0L else abs(a * b) / gcd(a, b) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put this into MathUtil.kt
Bnyro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this really looks like a bunch of great improvements! <3
I hope you're doing well, as I haven't heard from you in a while. I'd definitely love to see you back in our development team :)
Added new functions:
Added a cheat sheet to quickly look up available function syntax
Allow hiding functions
Visibility improvements (thicker lines for functions and axis) and a Legend showing currently visible functions