iOS status bar api implement
This commit is contained in:
parent
c63454869c
commit
73c06373ad
@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
8BCADA7C23CD5B65005EEF96 /* NavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BCADA7B23CD5B64005EEF96 /* NavigationController.m */; };
|
||||
A1E221FB2DCA40D85C4D9520 /* libPods-ExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F233ACD236542275AED3DE0 /* libPods-ExampleTests.a */; };
|
||||
CC537F4B9F59400BA5B4FF8F /* libPods-Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DEE8411A69609CC9C86063CC /* libPods-Example.a */; };
|
||||
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */ = {isa = PBXBuildFile; fileRef = D751D19E97EF4EDD7588FEBE /* DemoVC.m */; };
|
||||
@ -46,6 +47,8 @@
|
||||
3D75F592D76A665674B31A66 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
|
||||
4F233ACD236542275AED3DE0 /* libPods-ExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8231E841CCAF382F85C9F576 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
8BCADA7A23CD5B5F005EEF96 /* NavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NavigationController.h; sourceTree = "<group>"; };
|
||||
8BCADA7B23CD5B64005EEF96 /* NavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationController.m; sourceTree = "<group>"; };
|
||||
B93423722F2E06DC238CDD18 /* Pods-ExampleUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleUITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleUITests/Pods-ExampleUITests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
B93D4DB00FD244178B7CE7C4 /* Pods-ExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
D751D18AD6496F4A9BE1AB45 /* QRScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRScanViewController.h; sourceTree = "<group>"; };
|
||||
@ -157,6 +160,8 @@
|
||||
E2334AEF22E9D2060098A085 /* AppDelegate.m */,
|
||||
E2334AF122E9D2060098A085 /* ViewController.h */,
|
||||
E2334AF222E9D2060098A085 /* ViewController.m */,
|
||||
8BCADA7A23CD5B5F005EEF96 /* NavigationController.h */,
|
||||
8BCADA7B23CD5B64005EEF96 /* NavigationController.m */,
|
||||
E2334AF422E9D2060098A085 /* Main.storyboard */,
|
||||
E2334AF722E9D2070098A085 /* Assets.xcassets */,
|
||||
E2334AFC22E9D2070098A085 /* Info.plist */,
|
||||
@ -436,6 +441,7 @@
|
||||
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */,
|
||||
D751D4FCC0A2322211DE3D55 /* QRScanViewController.m in Sources */,
|
||||
D751DDB012BAF476A252CD93 /* DemoLibrary.m in Sources */,
|
||||
8BCADA7C23CD5B65005EEF96 /* NavigationController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -7,11 +7,12 @@
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "NavigationController.h"
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
@property(nonatomic, strong) UIViewController *rootVC;
|
||||
@property(nonatomic, strong) UINavigationController *navigationController;
|
||||
@property(nonatomic, strong) NavigationController *navigationController;
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
@ -22,9 +23,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.rootVC = [[ViewController alloc] init];
|
||||
|
||||
self.window.rootViewController = self.rootVC;
|
||||
self.navigationController = [[UINavigationController
|
||||
self.navigationController = [[NavigationController
|
||||
alloc] initWithRootViewController:self.rootVC];
|
||||
self.window.rootViewController = self.navigationController;
|
||||
[self.window addSubview:self.navigationController.view];
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
|
@ -50,5 +50,7 @@
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
28
doric-iOS/Example/Example/NavigationController.h
Normal file
28
doric-iOS/Example/Example/NavigationController.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright [2019] [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.
|
||||
*/
|
||||
//
|
||||
// NavigationController.h
|
||||
// Doric
|
||||
//
|
||||
// Created by jingpeng.wang on 2020/1/14.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NavigationController : UINavigationController
|
||||
|
||||
@end
|
||||
|
33
doric-iOS/Example/Example/NavigationController.m
Normal file
33
doric-iOS/Example/Example/NavigationController.m
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright [2019] [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.
|
||||
*/
|
||||
//
|
||||
// NavigationController.m
|
||||
// Doric
|
||||
//
|
||||
// Created by jingpeng.wang on 2020/1/14.
|
||||
//
|
||||
#import "NavigationController.h"
|
||||
|
||||
@implementation NavigationController
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle {
|
||||
return [self.topViewController preferredStatusBarStyle];
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return [self.topViewController prefersStatusBarHidden];
|
||||
}
|
||||
@end
|
@ -6,9 +6,9 @@
|
||||
// Copyright © 2019 pengfei.zhou. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
#import <DoricCore/Doric.h>
|
||||
#import "DemoVC.h"
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "QRScanViewController.h"
|
||||
#import "DemoLibrary.h"
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#import "DoricDraggableNode.h"
|
||||
#import "DoricLibrary.h"
|
||||
#import "DoricNotificationPlugin.h"
|
||||
#import "DoricStatusBarPlugin.h"
|
||||
#import "DoricUtil.h"
|
||||
|
||||
@interface DoricLibraries : NSObject
|
||||
@ -128,6 +129,7 @@ - (void)innerRegister {
|
||||
[self registerNativePlugin:DoricPopoverPlugin.class withName:@"popover"];
|
||||
[self registerNativePlugin:DoricAnimatePlugin.class withName:@"animate"];
|
||||
[self registerNativePlugin:DoricNotificationPlugin.class withName:@"notification"];
|
||||
[self registerNativePlugin:DoricStatusBarPlugin.class withName:@"statusbar"];
|
||||
|
||||
[self registerViewNode:DoricStackNode.class withName:@"Stack"];
|
||||
[self registerViewNode:DoricVLayoutNode.class withName:@"VLayout"];
|
||||
|
@ -20,7 +20,12 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DoricNavigatorDelegate.h"
|
||||
#import "DoricNavBarDelegate.h"
|
||||
#import "DoricPanel.h"
|
||||
|
||||
@interface DoricViewController : UIViewController <DoricNavigatorDelegate, DoricNavBarDelegate>
|
||||
@property(nonatomic, strong) DoricPanel *doricPanel;
|
||||
@property(nonatomic) BOOL statusBarHidden;
|
||||
@property(nonatomic) int statusBarMode;
|
||||
|
||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias extra:(NSString *)extra;
|
||||
@end
|
||||
|
@ -20,13 +20,11 @@
|
||||
#import "DoricViewController.h"
|
||||
#import "DoricAsyncResult.h"
|
||||
#import "DoricJSLoaderManager.h"
|
||||
#import "DoricPanel.h"
|
||||
#import "UIView+Doric.h"
|
||||
#import "DoricExtensions.h"
|
||||
#import "DoricUtil.h"
|
||||
|
||||
@interface DoricViewController ()
|
||||
@property(nonatomic, strong) DoricPanel *doricPanel;
|
||||
@property(nonatomic) BOOL navBarHidden;
|
||||
@property(nonatomic, strong) UIImage *navBarImage;
|
||||
@end
|
||||
@ -113,5 +111,20 @@ - (void)doric_navBar_setRight:(UIView *)view {
|
||||
self.navigationItem.rightBarButtonItem = custom;
|
||||
}
|
||||
|
||||
- (BOOL)statusBarHidden {
|
||||
return _statusBarHidden;
|
||||
}
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle {
|
||||
if (self.statusBarMode == 0) {
|
||||
return UIStatusBarStyleLightContent;
|
||||
} else {
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return self.statusBarHidden;
|
||||
}
|
||||
|
||||
@end
|
||||
|
26
doric-iOS/Pod/Classes/Plugin/DoricStatusBarPlugin.h
Normal file
26
doric-iOS/Pod/Classes/Plugin/DoricStatusBarPlugin.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright [2019] [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 2020/01/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "DoricNativePlugin.h"
|
||||
|
||||
@interface DoricStatusBarPlugin : DoricNativePlugin
|
||||
|
||||
@end
|
61
doric-iOS/Pod/Classes/Plugin/DoricStatusBarPlugin.m
Normal file
61
doric-iOS/Pod/Classes/Plugin/DoricStatusBarPlugin.m
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright [2019] [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 2020/01/11.
|
||||
//
|
||||
|
||||
#import "DoricStatusBarPlugin.h"
|
||||
#import "DoricUtil.h"
|
||||
#import "DoricViewNode.h"
|
||||
#import "DoricExtensions.h"
|
||||
#import "DoricViewController.h"
|
||||
|
||||
@implementation DoricStatusBarPlugin
|
||||
|
||||
- (void)setHidden:(NSDictionary *)param withPromise:(DoricPromise *)promise {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.doricContext.navBar) {
|
||||
if ([self.doricContext.navBar isKindOfClass:DoricViewController.class]) {
|
||||
DoricViewController * target = ((DoricViewController *)self.doricContext.navBar);
|
||||
target.statusBarHidden = [param[@"hidden"] boolValue];
|
||||
[target setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)setMode:(NSDictionary *)param withPromise:(DoricPromise *)promise {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.doricContext.navBar) {
|
||||
if ([self.doricContext.navBar isKindOfClass:DoricViewController.class]) {
|
||||
DoricViewController * target = ((DoricViewController *)self.doricContext.navBar);
|
||||
target.statusBarMode = [param[@"mode"] intValue];
|
||||
[target setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)setColor:(NSDictionary *)param withPromise:(DoricPromise *)promise {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.doricContext.navBar) {
|
||||
UIColor *color = DoricColor(param[@"color"]);
|
||||
[self.doricContext.navBar doric_navBar_setBackgroundColor:color];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user