-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from HDB-Li/1.3.3-b
1.3.3
- Loading branch information
Showing
70 changed files
with
1,855 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// LLHtmlComponent.h | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#import "LLComponent.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface LLHtmlComponent : LLComponent | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// LLHtmlComponent.m | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#import "LLHtmlComponent.h" | ||
#import "LLWindowManager.h" | ||
#import "LLNavigationController.h" | ||
|
||
@implementation LLHtmlComponent | ||
|
||
- (void)componentDidLoad:(NSDictionary<NSString *,id> *)data { | ||
LLHtmlWindow *window = [LLWindowManager htmlWindow]; | ||
if (data[kLLComponentWindowRootViewControllerKey]) { | ||
Class rootViewControllerClass = NSClassFromString(data[kLLComponentWindowRootViewControllerKey]); | ||
if (rootViewControllerClass != nil) { | ||
UIViewController *viewController = [[rootViewControllerClass alloc] init]; | ||
NSDictionary *properties = data[kLLComponentWindowRootViewControllerPropertiesKey]; | ||
for (NSString *key in properties) { | ||
id value = properties[key]; | ||
[viewController setValue:value forKey:key]; | ||
} | ||
LLNavigationController *nav = [[LLNavigationController alloc] initWithRootViewController:viewController]; | ||
window.rootViewController = nav; | ||
} | ||
} | ||
[[LLWindowManager shared] showWindow:window animated:YES]; | ||
} | ||
|
||
@end |
17 changes: 17 additions & 0 deletions
17
LLDebugTool/Core/Component/Html/UserInterface/LLHtmlConfigViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// LLHtmlConfigViewController.h | ||
// LLDebugToolDemo | ||
// | ||
// Created by admin10000 on 2019/10/11. | ||
// Copyright © 2019 li. All rights reserved. | ||
// | ||
|
||
#import "LLTitleViewController.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface LLHtmlConfigViewController : LLTitleViewController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
183 changes: 183 additions & 0 deletions
183
LLDebugTool/Core/Component/Html/UserInterface/LLHtmlConfigViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
// | ||
// LLHtmlConfigViewController.m | ||
// LLDebugToolDemo | ||
// | ||
// Created by admin10000 on 2019/10/11. | ||
// Copyright © 2019 li. All rights reserved. | ||
// | ||
|
||
#import "LLHtmlConfigViewController.h" | ||
#import "LLTitleCellCategoryModel.h" | ||
#import "LLSettingManager.h" | ||
#import "LLFactory.h" | ||
#import "LLMacros.h" | ||
#import "LLConst.h" | ||
#import "UIView+LL_Utils.h" | ||
#import "LLThemeManager.h" | ||
#import "LLToastUtils.h" | ||
#import "LLHtmlViewController.h" | ||
#import "LLHtmlUIWebViewController.h" | ||
#import "LLHtmlWkWebViewController.h" | ||
#import "LLConfig.h" | ||
#import <WebKit/WebKit.h> | ||
|
||
@interface LLHtmlConfigViewController () <UITextFieldDelegate> | ||
|
||
@property (nonatomic, copy) NSString *webViewClass; | ||
|
||
@property (nonatomic, strong) UIView *headerView; | ||
|
||
@property (nonatomic, strong) UITextField *headerTextField; | ||
|
||
@end | ||
|
||
@implementation LLHtmlConfigViewController | ||
|
||
#pragma mark - Life cycle | ||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
[self setUpUI]; | ||
[self loadData]; | ||
} | ||
|
||
- (void)viewWillDisappear:(BOOL)animated { | ||
if ([self.headerTextField isFirstResponder]) { | ||
[self.headerTextField resignFirstResponder]; | ||
} | ||
} | ||
|
||
#pragma mark - Over write | ||
- (void)rightItemClick:(UIButton *)sender { | ||
NSString *urlString = [self currentUrlString]; | ||
if (!urlString) { | ||
[[LLToastUtils shared] toastMessage:@"Empty URL"]; | ||
return; | ||
} | ||
if (![urlString.lowercaseString hasPrefix:@"https://"] && ![urlString.lowercaseString hasPrefix:@"http://"]) { | ||
[[LLToastUtils shared] toastMessage:@"URL must has prefix with https:// or http://"]; | ||
return; | ||
} | ||
Class cls = NSClassFromString(self.webViewClass); | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
if (cls != [UIWebView class] && cls != [WKWebView class]) { | ||
#pragma clang diagnostic pop | ||
[[LLToastUtils shared] toastMessage:@"Invalid webView class"]; | ||
return; | ||
} | ||
|
||
[LLSettingManager shared].lastWebViewUrl = urlString; | ||
|
||
LLHtmlViewController *vc = nil; | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
if (cls == [UIWebView class]) { | ||
#pragma clang diagnostic pop | ||
vc = [[LLHtmlUIWebViewController alloc] init]; | ||
} else { | ||
vc = [[LLHtmlWkWebViewController alloc] init]; | ||
} | ||
vc.webViewClass = self.webViewClass; | ||
vc.urlString = [self currentUrlString]; | ||
[self.navigationController pushViewController:vc animated:YES]; | ||
} | ||
|
||
#pragma mark - UITextFieldDelegate | ||
- (BOOL)textFieldShouldReturn:(UITextField *)textField { | ||
[textField resignFirstResponder]; | ||
return YES; | ||
} | ||
|
||
#pragma mark - Primary | ||
- (void)setUpUI { | ||
self.title = @"WebView Config"; | ||
[self initNavigationItemWithTitle:@"Go" imageName:nil isLeft:NO]; | ||
|
||
self.webViewClass = [LLSettingManager shared].webViewClass ?: NSStringFromClass([WKWebView class]); | ||
|
||
self.tableView.tableHeaderView = self.headerView; | ||
} | ||
|
||
- (void)loadData { | ||
NSMutableArray *settings = [[NSMutableArray alloc] init]; | ||
|
||
// Short Cut | ||
[settings addObject:[self getWebViewStyleModel]]; | ||
LLTitleCellCategoryModel *category0 = [[LLTitleCellCategoryModel alloc] initWithTitle:nil items:settings]; | ||
[settings removeAllObjects]; | ||
|
||
[self.dataArray removeAllObjects]; | ||
[self.dataArray addObjectsFromArray:@[category0]]; | ||
[self.tableView reloadData]; | ||
} | ||
|
||
- (LLTitleCellModel *)getWebViewStyleModel { | ||
LLTitleCellModel *model = [[LLTitleCellModel alloc] initWithTitle:@"Style" detailTitleSelector:self.webViewClass]; | ||
__weak typeof(self) weakSelf = self; | ||
model.block = ^{ | ||
[weakSelf showWebViewClassAlert]; | ||
}; | ||
return model; | ||
} | ||
|
||
- (void)showWebViewClassAlert { | ||
__block NSMutableArray *actions = [[NSMutableArray alloc] init]; | ||
[actions addObject:NSStringFromClass([WKWebView class])]; | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
[actions addObject:NSStringFromClass([UIWebView class])]; | ||
#pragma clang diagnostic pop | ||
__weak typeof(self) weakSelf = self; | ||
[self showActionSheetWithTitle:@"Web View Style" actions:actions currentAction:self.webViewClass completion:^(NSInteger index) { | ||
[weakSelf setNewWebViewClass:actions[index]]; | ||
}]; | ||
} | ||
|
||
- (void)setNewWebViewClass:(NSString *)aClass { | ||
self.webViewClass = aClass; | ||
[LLSettingManager shared].webViewClass = aClass; | ||
[self loadData]; | ||
} | ||
|
||
- (NSString *)currentUrlString { | ||
NSString *text = self.headerTextField.text; | ||
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | ||
if (!text || text.length == 0) { | ||
return nil; | ||
} | ||
return text; | ||
} | ||
|
||
#pragma mark - Getters and setters | ||
- (UIView *)headerView { | ||
if (!_headerView) { | ||
_headerView = [LLFactory getView]; | ||
_headerView.frame = CGRectMake(0, 0, LL_SCREEN_WIDTH, 60); | ||
[_headerView addSubview:self.headerTextField]; | ||
self.headerTextField.frame = CGRectMake(kLLGeneralMargin, kLLGeneralMargin, _headerView.LL_width - kLLGeneralMargin * 2, _headerView.LL_height - kLLGeneralMargin * 2); | ||
} | ||
return _headerView; | ||
} | ||
|
||
- (UITextField *)headerTextField { | ||
if (!_headerTextField) { | ||
_headerTextField = [LLFactory getTextField]; | ||
_headerTextField.tintColor = [LLThemeManager shared].primaryColor; | ||
_headerTextField.backgroundColor = [LLThemeManager shared].backgroundColor; | ||
[_headerTextField LL_setBorderColor:[LLThemeManager shared].primaryColor borderWidth:1]; | ||
[_headerTextField LL_setCornerRadius:5]; | ||
_headerTextField.font = [UIFont systemFontOfSize:14]; | ||
_headerTextField.textColor = [LLThemeManager shared].primaryColor; | ||
_headerTextField.delegate = self; | ||
_headerTextField.clearButtonMode = UITextFieldViewModeWhileEditing; | ||
_headerTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Pleace input url" attributes:@{NSForegroundColorAttributeName : [LLThemeManager shared].placeHolderColor}]; | ||
_headerTextField.text = [LLSettingManager shared].lastWebViewUrl ?: ([LLConfig shared].defaultHtmlUrl ?: @"https://"); | ||
UIView *leftView = [LLFactory getView]; | ||
leftView.frame = CGRectMake(0, 0, 10, 1); | ||
_headerTextField.leftView = leftView; | ||
_headerTextField.leftViewMode = UITextFieldViewModeAlways; | ||
} | ||
return _headerTextField; | ||
} | ||
|
||
@end |
30 changes: 30 additions & 0 deletions
30
LLDebugTool/Core/Component/Html/UserInterface/LLHtmlUIWebViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// LLHtmlUIWebViewController.h | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#import "LLHtmlViewController.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface LLHtmlUIWebViewController : LLHtmlViewController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.