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

Add support for setting bottom margin

Open Polarisation opened this issue 4 years ago • 9 comments
trafficstars

See #15

This allows a bottom margin to be set. This can be used to place the snackbar above navigational elements such as a tab bar at the bottom of the screen.

  • [x] iOS support
  • [x] Android support
  • [x] Type declarations for new option
  • [x] Documentation for new option
  • [x] Added example for new option in example codebase

Screenshot 2021-06-21 at 17 42 42

Polarisation avatar Jun 07 '21 05:06 Polarisation

Thank you for this work @Polarisation! The code looks great, I'll just need to find some time to test before officially merging. It may be a few weeks, but I will get to it.

Because you reached out via email about being able to include this in your own app, I just wanted to offer that you CAN use this immediately -- you just need to use your fork in your app instead of this library directly. You can find articles about this online, here's one for example that seems useful: https://blaipratdesaba.com/how-to-use-an-npm-node-module-that-has-been-forked-b7dd522fdd08. Hope it helps, cheers!

cooperka avatar Jun 10 '21 05:06 cooperka

@cooperka Thanks that's helpful. Keen to stay aligned on the main package but may use the fork short term 👍

Polarisation avatar Jun 11 '21 07:06 Polarisation

Made a few further tweaks:

  • In a bottom margin is set, the animation will now fade in/out, rather than slide up/down.
  • Removed the marginLeft and marginRight options as I couldn't find an implementation which works reliably. (it's also not important for my use case, which is to raise the snackbar above a bottom tab bar)
  • I upgraded com.google.android.material to the latest (1.3.0) to support the fade animation. After doing this, I also needed to add an explicit androidx.swiperefreshlayout dependency.

Polarisation avatar Jun 21 '21 09:06 Polarisation

Want this feature to be merged. Kind of a necessary one. Thank you!

sugata98 avatar Jul 10 '21 11:07 sugata98

Definitely is a really nice to have feature!

JuanpaG94 avatar Jul 15 '21 11:07 JuanpaG94

Update: Rebased on latest main with dependency upgrades; works great on Android! Now to spend a few more hours setting up xcode... I should have this ready to merge tomorrow.

cooperka avatar Jul 16 '21 05:07 cooperka

Facebook's support for upgrading RN modules is truly despicable... I'll need to start a new module from scratch and re-apply this library's code on top of it.

For anyone wanting to use this feature right away, you can: just point to the code at cooperka/react-native-snackbar, branch feature/margins where I've committed the compiled lib directory. There's NO reason you can't use this feature RIGHT NOW in your app.

I will merge this PR after I'm able to test on iOS. It will take several more days before I have time to keep going. Thanks again for the great submission @Polarisation, I have no concerns that it works, I just need to be able to verify before shipping new code.

cooperka avatar Jul 17 '21 02:07 cooperka

I integrated my fork into an app with the following edits to package.json:

"dependencies": {
  "react-native-snackbar": "https://github.com/Polarisation/react-native-snackbar.git#feature/margins"
},
"scripts": {
  "build-snackbar": "cd ./node_modules/react-native-snackbar && yarn install && rm -rf node_modules example",
  "postinstall": "yarn build-snackbar"
},

Probably easier to use the compiled branch @cooperka prepared above, but just thought I'd share this snippet, it might be helpful for anyone submitting Pull Requests in future.

Polarisation avatar Jul 19 '21 09:07 Polarisation

merge

pe-johndpope avatar May 19 '22 12:05 pe-johndpope

Can we merge this now?

Sumit2202 avatar Oct 13 '22 18:10 Sumit2202

  • In a bottom margin is set, the animation will now fade in/out, rather than slide up/down.
  • Removed the marginLeft and marginRight options as I couldn't find an implementation which works reliably. (it's also not important for my use case, which is to raise the snackbar above a bottom tab bar)

Hi @cooperka (https://github.com/cooperka), any way we can have all margins setable as you tried before? or perhaps a custamizable styling of the box? I am unsure how difficult it is to build this. My wish is to have the snackbar floating at the bottom but not touching any side . So basically I would love to have it like this example found in MUI docs:


Screenshot 2022-11-03 at 16 52 12

Is what I'm asking possible with this library?
 Thanks for the efforts.

lydialawli avatar Nov 03 '22 16:11 lydialawli

still untested by me on iOS, but has a lot of love from the community! thanks again @Polarisation.

released as v2.6.0 🎉

cooperka avatar May 09 '23 15:05 cooperka