react-native-reusables icon indicating copy to clipboard operation
react-native-reusables copied to clipboard

[ BUG ] ThemeToggle not changing on press

Open Dave-Wagner opened this issue 10 months ago • 14 comments
trafficstars

Describe the bug Using an unmodified (other than running through a tunnel and removing --ios from the Dev script) base starter, the ThemeToggle at the top right does absolutely nothing. If I had to guess it is only paying attention to the system default, in my case dark mode.

To Reproduce Steps to reproduce the behavior:

  1. Run the init from the CLI and create a new Starter Base
  2. Run with 'bun dev' and open in Expo Go
  3. Click on 'MoonStar Icon'
  4. Theme does not toggle
  5. Note: It does work on the web version

Expected behavior I expect the theme to switch between light and dark mode on press

Platform (please complete the following information):

  • Type: Device
  • OS: Android (Expo Go)

Additional context Repo: https://github.com/Dave-Wagner/ebike-adventures

Dave-Wagner avatar Jan 08 '25 00:01 Dave-Wagner

Im having the same issue.

Same issue that was closed two weeks ago: https://github.com/mrzachnugent/react-native-reusables/issues/277

TanushN avatar Jan 13 '25 03:01 TanushN

Do you have "userInterfaceStyle": "automatic" in your app.json?

Otherwise, can you please provide a minimal reproduction repo?

mrzachnugent avatar Jan 13 '25 11:01 mrzachnugent

Yes, as you can see from the minimal reproduction repo I linked to in the original post.

edit: Oops, I hadn't heard a reply for a while so I went ahead and started a new repo with the same name, not using this library. Let me set up a new one following the directions and get back to you.

edit2: https://github.com/Dave-Wagner/starter-base

Dave-Wagner avatar Jan 13 '25 12:01 Dave-Wagner

Unfortunately, I am unable to reproduce the error from https://github.com/Dave-Wagner/starter-base

https://github.com/user-attachments/assets/feb3c835-bbfc-42e6-9866-2f640e4d065c

mrzachnugent avatar Jan 13 '25 14:01 mrzachnugent

I should point out that I am specifically using Expo Go, not the Android emulator, however, even create an EAS build using an APK I have the same problem on device. I am using a Google Pixel 9.

Edit: I just ran it on the Emulator in Windows and it works as expected. Perhaps it has to do with the version of Android on my Pixel 9.

Dave-Wagner avatar Jan 13 '25 14:01 Dave-Wagner

Why complete this issue? It's clearly not resolved. There is clearly an issue,. It should be addressed.

Dave-Wagner avatar Jan 17 '25 22:01 Dave-Wagner

Unfortunately, I am unable to reproduce the error from https://github.com/Dave-Wagner/starter-base

https://github.com/user-attachments/assets/feb3c835-bbfc-42e6-9866-2f640e4d065c

Would you be able to try it on an actual device? I'm wondering if it's only a bug there.

For reference, I have a samsung s23 and have the same issue using Expo Go or the full on development apk. The theme only changes when I change my phone's light/dark mode settings.

TanushN avatar Jan 17 '25 23:01 TanushN

I know that if you just run the project and click 20 times or so, it changes the theme (I'm looking for a solution)

Alessandro-filho avatar Feb 18 '25 15:02 Alessandro-filho

Well, I don't know if it's the best way to do this, but I created an alternative, because from what I noticed the position of the button was preventing the function from being executed, even debugging nothing was executed in the terminal, so I placed the same component on another page and it worked normally, in the gist there are 4 files, only 1 of them I created and the rest I just changed a few things, I hope it helps anyone who has this problem and if you have a better way to solve this problem, update me, please

https://github.com/user-attachments/assets/6f559e28-7590-4c41-b7a5-263a6aecb33b

gist

Alessandro-filho avatar Feb 18 '25 18:02 Alessandro-filho

I took another approach and tried replacing it with a different component and on the web it works fine but on native it doesn't even show up.

Edit: I figured out that I missed setting the color and stroke, oops. So it shows up but is still not clickable.

Screenshot_20250218-183512.png

Screenshot_20250218-183404.png

Dave-Wagner avatar Feb 18 '25 23:02 Dave-Wagner

I am having the same issue. On the web it works fine, but on my actual device running a development built the toggle placed in the header doesn't work. If I put it in the index it works, so this would clearly point to an issue with the stack header

DaveVaval avatar Mar 09 '25 19:03 DaveVaval

I am having the same issue. On the web it works fine, but on my actual device running a development built the toggle placed in the header doesn't work. If I put it in the index it works, so this would clearly point to an issue with the stack header

my solution was to create a customized header

Alessandro-filho avatar Mar 10 '25 16:03 Alessandro-filho

I found solution it is expo bug. Replaced onPress by onPressIn and problem solved. https://github.com/expo/expo/issues/29489

aramis-it avatar Mar 19 '25 01:03 aramis-it

I found solution it is expo bug. Replaced onPress by onPressIn and problem solved. expo/expo#29489

That's cool, thanks for the alternative

isolarenergy23 avatar Mar 19 '25 12:03 isolarenergy23

Closing due to not being a React Native Reusables issue

mrzachnugent avatar Aug 22 '25 17:08 mrzachnugent