Skip to content

Commit

Permalink
添加 splitTopBarTransitionIOS 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
listenzz committed May 30, 2021
1 parent d45b93b commit 9b5c0f7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Garden.setStyle({
titleTextColorLightContent: '#FFFFFF',
titleTextSize: 17,
swipeBackEnabledAndroid: true,
// splitTopBarTransitionIOS: true,
// badgeColor: '#00FFFF',

statusBarColorAndroid: Platform.OS === 'android' && Platform.Version < 23 ? '#4A4A4A' : undefined,
Expand Down
1 change: 1 addition & 0 deletions ios/HybridNavigation/GlobalStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@property (nonatomic, copy) NSString *tabBarItemColorHexString;
@property (nonatomic, copy) NSString *tabBarUnselectedItemColorHexString;
@property (nonatomic, strong, readonly) UIColor *tabBarBackgroundColor;
@property (nonatomic, assign, readonly) BOOL awaysSplitNavigationBarTransition;

- (instancetype)initWithOptions:(NSDictionary *)options;

Expand Down
7 changes: 7 additions & 0 deletions ios/HybridNavigation/GlobalStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ @interface GlobalStyle ()
@property (nonatomic, strong) UIColor *tabBarTintColor;
@property (nonatomic, strong) UIColor *tabBarUnselectedTintColor;

@property (nonatomic, assign, readwrite) BOOL awaysSplitNavigationBarTransition;

@end

@implementation GlobalStyle
Expand Down Expand Up @@ -63,6 +65,11 @@ - (instancetype)initWithOptions:(NSDictionary *)options {
self.barTintColor = [HBDUtils colorWithHexString:topBarColor];
}

NSNumber *splitTopBarTransitionIOS = self.options[@"splitTopBarTransitionIOS"];
if (splitTopBarTransitionIOS) {
self.awaysSplitNavigationBarTransition = [splitTopBarTransitionIOS boolValue];
}

NSString *topBarColorDarkContent = self.options[@"topBarColorDarkContent"];
if (topBarColorDarkContent) {
self.barTintColorDarkContent = [HBDUtils colorWithHexString:topBarColorDarkContent];
Expand Down
5 changes: 5 additions & 0 deletions ios/HybridNavigation/ViewController/HBDNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "HBDReactViewController.h"
#import "HBDPushAnimation.h"
#import "HBDPopAnimation.h"
#import "HBDGarden.h"
#import <React/RCTLog.h>

UIColor* blendColor(UIColor *from, UIColor *to, float percent) {
Expand Down Expand Up @@ -379,6 +380,10 @@ - (void)resetButtonLabelInView:(UIView *)view {
}

- (BOOL)shouldShowFakeBarFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController * _Nonnull)viewController {
if ([HBDGarden globalStyle].awaysSplitNavigationBarTransition) {
return YES;
}

BOOL shouldFake = to == viewController && (![from.hbd_barTintColor.description isEqual:to.hbd_barTintColor.description] || ABS(from.hbd_barAlpha - to.hbd_barAlpha) > 0.1);
return shouldFake;
}
Expand Down
1 change: 1 addition & 0 deletions src/Garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Style {
titleAlignmentAndroid?: TitleAlignment // TopBar 标题的位置,可选项有 `TitleAlignmentLeft` 和 `TitleAlignmentCenter` ,仅对 Android 生效
barButtonItemTextSize?: number // TopBar 按钮字体大小,默认是 15 dp(pt)
swipeBackEnabledAndroid?: boolean // Android 是否开启右滑返回,默认是 false
splitTopBarTransitionIOS?: boolean // iOS 侧滑返回时,是否总是割裂导航栏背景

tabBarColor?: Color // 底部 TabBar 背景颜色,请勿使用带透明度的颜色。
tabBarShadowImage?: ShadowImage // 底部 TabBar 阴影图片。对于 iOS, 只有同时设置了 tabBarColor 才会生效
Expand Down

0 comments on commit 9b5c0f7

Please sign in to comment.