-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Imperial system #236
Comments
Hi @PierreBresson, I'd like to give this a shot. Can you please assign this to me? |
Hi @ThomasLatham, thanks having a look, let me know if you have any questions ;) |
Okay, thanks! |
So far I have:
All of this is to have a switch-row in settings that controls some application state for unit preferences. I haven't implemented anything that would apply that state where applicable because I want to make sure that what I have is okay first (and write tests for everything if so). Is there a way that this code can be reviewed without submitting a PR? |
Sounds like a good plan. GitHub doesn't support draft pr I think, so you can just submit the pr as it is, I will have a look and help if needed |
Now that the settings switch and Redux stuff is set up, I'm going to start on the task of having units change throughout the app according to the useMetricUnits state. My plan right now is to keep that change as close to the user as possible, so to speak, so that only the display changes but behind the scenes everything is still in metric regardless of the user's unit preference (if that makes any sense). For example,
could become something like
I don't know if there's a software development term for this kind of approach. This would also mean new features involving units would have to follow the same pattern. I'm definitely open to something more elegant and DRY though, or just better in some aspect that isn't immediately apparent to me. @PierreBresson what are your thoughts on this? |
@ThomasLatham I think the general idea is good. It could be slightly improved by using some kind of converter function, so there would be no need for copying and pasting
If Feel free to use a 3rd party library for the conversion, like this one or another. There is probably a better way of doing this, but it will be okay for now |
Oh okay cool! Do you think |
Correct, I forget a third parameter, which could be an enum, something like |
Okay neat. Thanks for the help! |
Hi @PierreBresson, I've been tinkering away at this when I find the time, and I'm ready to commit changes for implementing preferred units during emission adding, but for some reason 10 unit tests are failing in app/screens/Budget/ducks/tests/BudgetScreen.selectors.test.ts. All the tests therein related to monthly carbon values are failing, with the received value being twice the expected (except in the case of electricity carbon value, where the received value is 3 and the expected is 2). I've manually traced the function calls, but I'm just not seeing where such doubling is happening down the received path -- or halving down the expected path. I'm also unsure how to use a debugger for Jest tests in a React Native project that uses Expo, but I'm looking into it. I stashed my changes such that I'm back to the state the app was in just before I submitted the draft PR for the units toggle, but still the same 10 tests are failing. I probably made some rookie mistake somewhere, but I haven't a clue where. Could you please help me out? |
Hey, |
@ThomasLatham I've fixed the tests on main branch, you can merge main it into your branch, it should work. |
@PierreBresson Thanks for looking into and fixing this so fast. I had a feeling it might have something to do with the Y2k+23 switch haha. Sorry I haven't been doing much with this; getting back making some progress on this feature today! |
Summary
As an english citizen or ex british colony citizen, I want to be able to use the app in the imperial system instead of the international system of units (pounds instead of kilos, miles instead of kilometers...)
Proposed feature
Imperial units everywhere in the app + add in the settings a row with instead of a chevron, a switch, that will enable/disable that feature.
To Do List
Checklist, nice to have, but not mandatory
The text was updated successfully, but these errors were encountered: