react-native-navigation 7.47.0 → 7.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/lib/android/app/build.gradle +2 -1
  2. package/lib/android/app/src/main/java/com/reactnativenavigation/FeatureToggles.kt +2 -0
  3. package/lib/android/app/src/main/java/com/reactnativenavigation/options/BottomTabsOptions.java +21 -1
  4. package/lib/android/app/src/main/java/com/reactnativenavigation/options/LayoutDirection.java +6 -1
  5. package/lib/android/app/src/main/java/com/reactnativenavigation/options/params/BottomTabsLayoutStyle.kt +20 -0
  6. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/ColorUtils.java +4 -0
  7. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +12 -2
  8. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenter.kt +129 -11
  9. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +2 -1
  10. package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabs.java +6 -6
  11. package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainer.kt +83 -5
  12. package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabsLayout.java +58 -6
  13. package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/ShadowLayout.kt +4 -8
  14. package/lib/dist/src/interfaces/Options.d.ts +46 -3
  15. package/lib/ios/RNNSideMenu/MMDrawerController/MMDrawerController.h +22 -0
  16. package/lib/ios/RNNSideMenu/MMDrawerController/MMDrawerController.m +782 -161
  17. package/lib/ios/RNNSideMenuPresenter.m +27 -0
  18. package/lib/ios/RNNSideMenuSideOptions.h +6 -0
  19. package/lib/ios/RNNSideMenuSideOptions.m +13 -1
  20. package/lib/src/interfaces/Options.ts +46 -3
  21. package/package.json +1 -1
@@ -1,18 +1,34 @@
1
1
  package com.reactnativenavigation.views.bottomtabs;
2
2
 
3
+ import static android.view.Gravity.CENTER_HORIZONTAL;
4
+ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
5
+ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
6
+
3
7
  import android.content.Context;
8
+ import android.graphics.Color;
4
9
  import android.view.Gravity;
5
10
  import android.view.View;
6
11
  import android.view.ViewGroup;
12
+ import android.widget.LinearLayout;
7
13
 
8
14
  import androidx.coordinatorlayout.widget.CoordinatorLayout;
9
15
 
10
- import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
11
- import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
16
+ import com.reactnativenavigation.RNNFeatureToggles;
17
+ import com.reactnativenavigation.RNNToggles;
18
+
19
+ import eightbitlab.com.blurview.BlurTarget;
12
20
 
21
+ /**
22
+ * Implementation note: The space-view and its containing linear-layout is a trick meant to force
23
+ * a bottom margin layout which isn't based on a `MarginLayoutParams.bottomMargin`. That's because
24
+ * it is not always honored by the CoordinatorLayout. This appears to be an ok work-around (which
25
+ * BTW actually would have been an idiomatic solution in ComposeUI).
26
+ */
13
27
  public class BottomTabsLayout extends CoordinatorLayout {
14
28
 
15
29
  private BottomTabsContainer bottomTabsContainer;
30
+ private View spaceView;
31
+ private BlurTarget blurSurface;
16
32
 
17
33
  public BottomTabsLayout(Context context) {
18
34
  super(context);
@@ -21,16 +37,52 @@ public class BottomTabsLayout extends CoordinatorLayout {
21
37
  @Override
22
38
  public void addView(View child, int index, ViewGroup.LayoutParams params) {
23
39
  if (bottomTabsContainer != null && child != bottomTabsContainer) {
24
- super.addView(child, getChildCount() - 1, params);
40
+ if (RNNFeatureToggles.isEnabled(RNNToggles.TAB_BAR_TRANSLUCENCE)) {
41
+ // As loosely explained in BlurView's README, the blur *view* and blur *target* must
42
+ // reside in different sub-sections of the view-hierarchy
43
+ lazyInitBlurSurface();
44
+ blurSurface.addView(child, -1, params);
45
+ } else {
46
+ super.addView(child, getChildCount() - 1, params);
47
+ }
25
48
  } else {
26
49
  super.addView(child, 0, params);
27
50
  }
51
+
52
+ if (bottomTabsContainer != null && blurSurface != null) {
53
+ bottomTabsContainer.setBlurSurface(blurSurface);
54
+ }
28
55
  }
29
56
 
30
57
  public void addBottomTabsContainer(BottomTabsContainer bottomTabsContainer) {
31
- CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
32
- lp.gravity = Gravity.BOTTOM;
33
- addView(bottomTabsContainer, lp);
58
+ View spaceView = new View(getContext());
59
+ spaceView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, 0));
60
+
61
+ LinearLayout surface = new LinearLayout(getContext());
62
+ surface.setOrientation(LinearLayout.VERTICAL);
63
+ surface.setGravity(CENTER_HORIZONTAL);
64
+ surface.setBackgroundColor(Color.TRANSPARENT);
65
+ surface.addView(bottomTabsContainer, new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
66
+ surface.addView(spaceView);
67
+
68
+ // Note: Width should always be WRAP_CONTENT so we could delegate the width-related decision
69
+ // making to the bottom-tabs view hierarchy itself (i.e. based on user properties).
70
+ CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
71
+ lp.gravity = Gravity.BOTTOM | CENTER_HORIZONTAL;
72
+ addView(surface, -1, lp);
73
+
34
74
  this.bottomTabsContainer = bottomTabsContainer;
75
+ this.spaceView = spaceView;
76
+ }
77
+
78
+ public void setBottomMargin(int bottomMargin) {
79
+ ((MarginLayoutParams) spaceView.getLayoutParams()).bottomMargin = bottomMargin;
80
+ }
81
+
82
+ private void lazyInitBlurSurface() {
83
+ if (blurSurface == null) {
84
+ blurSurface = new BlurTarget(getContext());
85
+ super.addView(blurSurface, super.getChildCount() - 1, new CoordinatorLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
86
+ }
35
87
  }
36
88
  }
@@ -13,7 +13,7 @@ private const val MAX_ANGLE = 360.0f
13
13
  private const val MIN_RADIUS = 0.1f
14
14
  private const val MIN_ANGLE = 0.0f
15
15
 
16
- open class ShadowLayout constructor(context: Context) : FrameLayout(context) {
16
+ open class ShadowLayout(context: Context) : FrameLayout(context) {
17
17
  private val paint: Paint = Paint(ANTI_ALIAS_FLAG).apply {
18
18
  isDither = true
19
19
  isFilterBitmap = true
@@ -43,7 +43,7 @@ open class ShadowLayout constructor(context: Context) : FrameLayout(context) {
43
43
  var isShadowed: Boolean = false
44
44
  set(isShadowed) {
45
45
  field = isShadowed
46
- this.updatePadding()
46
+ updatePadding()
47
47
  postInvalidate()
48
48
  }
49
49
 
@@ -108,11 +108,8 @@ open class ShadowLayout constructor(context: Context) : FrameLayout(context) {
108
108
  if (isShadowed) {
109
109
  if (invalidateShadow) {
110
110
  if (bounds.width() != 0 && bounds.height() != 0) {
111
- bitmap = Bitmap.createBitmap(
112
- bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888
113
- )
114
- bitmap?.let {
115
- mainCanvas.setBitmap(bitmap)
111
+ bitmap = Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888).also {
112
+ mainCanvas.setBitmap(it)
116
113
  invalidateShadow = false
117
114
 
118
115
  super.dispatchDraw(mainCanvas)
@@ -135,5 +132,4 @@ open class ShadowLayout constructor(context: Context) : FrameLayout(context) {
135
132
 
136
133
  super.dispatchDraw(canvas)
137
134
  }
138
-
139
135
  }
@@ -773,7 +773,9 @@ export interface OptionsBottomTabs {
773
773
  */
774
774
  drawBehind?: boolean;
775
775
  /**
776
- * Set a background color for the bottom tabs
776
+ * Set a background color for the bottom tabs.<br/>
777
+ * On Android - also applicable when translucence is applied, but a semi-transparent
778
+ * color should be used (e.g. `rgba(255, 0, 0, 0.25)`).
777
779
  */
778
780
  backgroundColor?: Color;
779
781
  /**
@@ -789,10 +791,42 @@ export interface OptionsBottomTabs {
789
791
  */
790
792
  barStyle?: 'default' | 'black';
791
793
  /**
792
- * Allows the Bottom Tabs to be translucent (blurred)
793
- * #### (iOS specific)
794
+ * Control the way the bottom tabs are laid out.
795
+ * - `stretch`: Fill the entire width of the screen.
796
+ * - `compact`: Occupy the minimum width needed to hold tab buttons. Recommended for
797
+ * usage in conjunction with `drawBehind: true`.
798
+ *
799
+ * #### (Android specific)
800
+ * @default 'stretch'
801
+ */
802
+ layoutStyle?: 'stretch' | 'compact';
803
+ /**
804
+ * Specify a corner-radius (in dip) in order to apply round corners to the tabs container.<br/>
805
+ * Mainly suitable when used in conjunction with `layoutStyle: 'compact'`
806
+ * #### (Android specific)
807
+ */
808
+ cornerRadius?: AndroidDensityNumber;
809
+ /**
810
+ * Bottom-margin to set in order to apply a "hover" effect.
811
+ * Works best when used in conjunction with `layoutStyle: 'compact'` and `drawBehind: true`.
812
+ * #### (Android specific)
813
+ */
814
+ bottomMargin?: AndroidDensityNumber;
815
+ /**
816
+ * Allows the bottom tabs to be translucent (blurred). Doesn't necessarily play
817
+ * nice with shadow effects on Android.
818
+ * #### Android: experimental, turn on using native toggle `TAB_BAR_TRANSLUCENCE`.
794
819
  */
795
820
  translucent?: boolean;
821
+ /**
822
+ * Set a custom radius to be used in the blur effect. Higher is blurrier, but
823
+ * also more CPU-intensive.<br/>
824
+ * Note: The blurring is performed following a bitmap downscale of x4.0, so
825
+ * ultimately the actual radius is (4*blurRadius).
826
+ * #### (Android specific)
827
+ * @defaultValue 1.0
828
+ */
829
+ blurRadius?: AndroidDensityNumber;
796
830
  /**
797
831
  * Hide the top line of the Tab Bar
798
832
  * #### (iOS specific)
@@ -986,10 +1020,19 @@ export interface SideMenuSide {
986
1020
  height?: number;
987
1021
  /**
988
1022
  * Stretch sideMenu contents when opened past the width
1023
+ *
1024
+ * **Not applicable when `openMode` is `aboveContent`**
1025
+ *
989
1026
  * #### (iOS specific)
990
1027
  * @default true
991
1028
  */
992
1029
  shouldStretchDrawer?: boolean;
1030
+ /**
1031
+ * Configure the opening mode of the side menu
1032
+ * #### (iOS specific)
1033
+ * @default 'pushContent'
1034
+ */
1035
+ openMode?: 'pushContent' | 'aboveContent';
993
1036
  }
994
1037
  export interface OptionsSideMenu {
995
1038
  /**
@@ -127,6 +127,14 @@ typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController *dra
127
127
 
128
128
  @interface MMDrawerController : UIViewController
129
129
 
130
+ /**
131
+ Enum defining how the drawer opens
132
+ */
133
+ typedef NS_ENUM(NSInteger, MMDrawerOpenMode) {
134
+ MMDrawerOpenModePushContent = 0, // Original behavior - pushes content aside
135
+ MMDrawerOpenModeAboveContent = 1, // Overlay behavior - opens above content
136
+ };
137
+
130
138
  ///---------------------------------------
131
139
  /// @name Accessing Drawer Container View Controller Properties
132
140
  ///---------------------------------------
@@ -213,6 +221,18 @@ typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController *dra
213
221
  @property(nonatomic, assign) BOOL shouldStretchLeftDrawer;
214
222
  @property(nonatomic, assign) BOOL shouldStretchRightDrawer;
215
223
 
224
+ /**
225
+ * Specifies how the drawer should open relative to the center content.
226
+ *
227
+ * Possible values:
228
+ * - MMDrawerOpenModePushContent: The drawer will push the center content aside when opening (traditional behavior).
229
+ * - MMDrawerOpenModeAboveContent: The drawer will open above the center content with a semi-transparent overlay.
230
+ *
231
+ * By default, this value is set to MMDrawerOpenModePushContent.
232
+ */
233
+ @property(nonatomic, assign) MMDrawerOpenMode leftDrawerOpenMode;
234
+ @property(nonatomic, assign) MMDrawerOpenMode rightDrawerOpenMode;
235
+
216
236
  /**
217
237
  The current open side of the drawer.
218
238
 
@@ -600,4 +620,6 @@ typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController *dra
600
620
  (BOOL (^)(MMDrawerController *drawerController, UIGestureRecognizer *gesture,
601
621
  UITouch *touch))gestureShouldRecognizeTouchBlock;
602
622
 
623
+ - (void)side:(MMDrawerSide)drawerSide openMode:(MMDrawerOpenMode)openMode;
624
+
603
625
  @end