iOS: status bar delegate
This commit is contained in:
parent
0a1dad1b10
commit
a1c67e2b48
@ -24,6 +24,7 @@
|
||||
#import "DoricDriverProtocol.h"
|
||||
#import "DoricNavigatorDelegate.h"
|
||||
#import "DoricNavBarDelegate.h"
|
||||
#import "DoricStatusBarDelegate.h"
|
||||
#import "DoricPerformanceProfile.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@ -34,6 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface DoricContext : NSObject
|
||||
@property(nonatomic, weak) id <DoricNavigatorDelegate> navigator;
|
||||
@property(nonatomic, weak) id <DoricNavBarDelegate> navBar;
|
||||
@property(nonatomic, weak) id <DoricStatusBarDelegate> statusBar;
|
||||
@property(nonatomic, weak) UIViewController *vc;
|
||||
@property(nonatomic, strong) NSString *contextId;
|
||||
@property(nonatomic, strong) id <DoricDriverProtocol> driver;
|
||||
|
@ -25,7 +25,7 @@
|
||||
extern NSString *const DORIC_MASK_RETRY;
|
||||
|
||||
|
||||
@interface DoricViewController : UIViewController <DoricNavigatorDelegate, DoricNavBarDelegate>
|
||||
@interface DoricViewController : UIViewController <DoricNavigatorDelegate, DoricNavBarDelegate, DoricStatusBarDelegate>
|
||||
@property(nonatomic, copy) NSString *source;
|
||||
@property(nonatomic, copy) NSString *alias;
|
||||
@property(nonatomic, copy) NSString *extra;
|
||||
|
@ -163,6 +163,16 @@ - (void)doric_navBar_setCenter:(UIView *)view {
|
||||
self.navigationItem.titleView = view;
|
||||
}
|
||||
|
||||
- (void)doric_statusBar_setHidden:(BOOL)hidden {
|
||||
self.statusBarHidden = hidden;
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
|
||||
- (void)doric_statusBar_setMode:(int)mode {
|
||||
self.statusBarMode = mode;
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
|
||||
- (BOOL)statusBarHidden {
|
||||
return _statusBarHidden;
|
||||
}
|
||||
@ -210,6 +220,7 @@ - (void)loadJSBundle {
|
||||
[self.doricPanel config:result alias:self.alias extra:self.extra];
|
||||
self.doricPanel.doricContext.navigator = self;
|
||||
self.doricPanel.doricContext.navBar = self;
|
||||
self.doricPanel.doricContext.statusBar = self;
|
||||
self.doricPanel.doricContext.vc = self;
|
||||
});
|
||||
};
|
||||
|
@ -28,12 +28,8 @@ - (void)setHidden:(NSDictionary *)param withPromise:(DoricPromise *)promise {
|
||||
__weak typeof(self) _self = self;
|
||||
[self.doricContext dispatchToMainQueue:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (self.doricContext.navBar) {
|
||||
if ([self.doricContext.navBar isKindOfClass:DoricViewController.class]) {
|
||||
DoricViewController *target = ((DoricViewController *) self.doricContext.navBar);
|
||||
target.statusBarHidden = [param optBool:@"hidden"];
|
||||
[target setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
if (self.doricContext.statusBar) {
|
||||
[self.doricContext.statusBar doric_statusBar_setHidden:[param optBool:@"hidden"]];
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -42,12 +38,8 @@ - (void)setMode:(NSDictionary *)param withPromise:(DoricPromise *)promise {
|
||||
__weak typeof(self) _self = self;
|
||||
[self.doricContext dispatchToMainQueue:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (self.doricContext.navBar) {
|
||||
if ([self.doricContext.navBar isKindOfClass:DoricViewController.class]) {
|
||||
DoricViewController *target = ((DoricViewController *) self.doricContext.navBar);
|
||||
target.statusBarMode = [[param optNumber:@"mode"] intValue];
|
||||
[target setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
if (self.doricContext.statusBar) {
|
||||
[self.doricContext.statusBar doric_statusBar_setMode:[[param optNumber:@"mode"] intValue]];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
29
doric-iOS/Pod/Classes/StatusBar/DoricStatusBarDelegate.h
Normal file
29
doric-iOS/Pod/Classes/StatusBar/DoricStatusBarDelegate.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//
|
||||
// Created by jingpeng.wang on 2021/7/27.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@protocol DoricStatusBarDelegate <NSObject>
|
||||
|
||||
- (void)doric_statusBar_setHidden:(BOOL)hidden;
|
||||
|
||||
- (void)doric_statusBar_setMode:(int)mode;
|
||||
|
||||
@end
|
Reference in New Issue
Block a user