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

Snackbars on iPad span the entire screen width

Open iRoachie opened this issue 5 years ago • 5 comments

Hey been using your package for a while.

One concern I have is that Snackbars on iPad are full width compared to on Android where they only take up the required space.

Android: kapture 2018-08-11 at 12 09 00

iOS: kapture 2018-08-11 at 12 10 03

iRoachie avatar Aug 11 '18 16:08 iRoachie

Thanks for the report @iRoachie. I'm guessing this would be a simple fix by setting some sort of max width on iOS. Happy to accept PRs!

cooperka avatar Aug 11 '18 17:08 cooperka

I don't mind doing it all, how would we get the width of the content?

iRoachie avatar Aug 11 '18 17:08 iRoachie

I didn't personally write the iOS implementation but I'm guessing one or both of these lines are what determines the width:

  • https://github.com/cooperka/react-native-snackbar/blob/master@{2018-08-11}/ios/RNSnackBarView.m#L144
  • https://github.com/cooperka/react-native-snackbar/blob/master@{2018-08-11}/ios/RNSnackBarView.m#L72

You might need to dig into the iOS UI APIs a bit to figure out what needs to be tweaked. This guide recommends 568dp as the max width for Snackbars.

Good luck and thank you for offering!

cooperka avatar Aug 12 '18 16:08 cooperka

hello, I see that this thread is old. Skimming through the documentation, I was thinking that it would be better to have an option that allows the developer to adjust the width of the snackbar, rather than having a fixed width. I personally would prefer that the snackbar take up the entire width if the screen no matter the size.

Thinking about it, this shouldn't be difficult to implement. Rather than hard coding a specific width value, you would simply use a custom 'width' option that is added in the .show() method. This will also ensure, I believe, uniformity between both android and IOS versions of the snackbar.

Let me know what you think

TimCatana avatar Apr 06 '22 19:04 TimCatana

thanks @TimCatana, sure I would accept a change like that for iOS!

cooperka avatar Apr 19 '22 21:04 cooperka