8 #import <UIKit/UIKit.h> 9 #import <WebKit/WebKit.h> 27 WKWebView *webTitleView;
37 - (instancetype)initWithNibName:(nullable NSString *)nibNameOrNilz
38 bundle:(nullable NSBundle *)nibBundleOrNilz
40 self = [
super initWithNibName:nibNameOrNilz bundle:nibBundleOrNilz];
50 self.title =
@"Capture Web Snippet";
53 +
self.navigationController.navigationBar.frame.size.height;
56 UIImage *backgrdImage = [UIImage imageNamed:@"blueHydrangea.png"];
57 CGSize photoSize = [backgrdImage size];
58 CGRect totalFrame =
self.view.frame;
60 float resizeRatio = photoSize.height / totalFrame.size.height;
61 UIImage *resizedImage = [UIImage imageWithCGImage:[backgrdImage CGImage]
62 scale:backgrdImage.scale * resizeRatio
63 orientation:(backgrdImage.imageOrientation) ];
64 UIImageView *backgrd = [[UIImageView alloc] initWithImage:resizedImage];
65 [
self.view addSubview:backgrd];
68 float toDriveuttonWidth = 72.0;
69 CGRect toDriveFrame = CGRectMake(
overallSize.width - (toDriveuttonWidth+ 6.0),
navbarBottomEdge + 10.0, toDriveuttonWidth, toDriveuttonWidth);
70 UIButton *toDriveButton = [[UIButton alloc] initWithFrame:toDriveFrame];
71 [toDriveButton setTitle:@"Drive" forState:UIControlStateNormal];
72 [toDriveButton addTarget:self action:@selector(pushToCreateEntryOnDrive) forControlEvents:UIControlEventTouchUpInside];
73 [toDriveButton addGradientFace];
74 [
self.view addSubview:toDriveButton];
78 float snippetTitleFrameHeight = 48.0;
79 CGRect snippetTitleFrame = CGRectMake(8.0,
82 snippetTitleFrameHeight);
85 float snippetIngredientsFrameTop = snippetTitleFrameTop + snippetTitleFrameHeight + 4.0;
86 float remainingHeight =
overallSize.height - snippetIngredientsFrameTop;
87 float snippetIngredientsFrameHeight = remainingHeight/2 - 4.0;
88 CGRect snippetIngredientsFrame = CGRectMake(8.0,
89 snippetIngredientsFrameTop,
91 snippetIngredientsFrameHeight);
94 float snippetInstructionFrameTop = snippetIngredientsFrameTop + snippetIngredientsFrameHeight + 4.0;
95 float snippetInstructionFrameHeight =
overallSize.height - snippetInstructionFrameTop - 4.0;
96 CGRect snippetInstructionFrame = CGRectMake(8.0,
97 snippetInstructionFrameTop,
99 snippetInstructionFrameHeight);
103 [
self.view addSubview:webTitleView];
104 [
self.view addSubview:webIngredientsView];
105 [
self.view addSubview:webInstructionView];
115 - (WKWebView *) viewDidLoadSnippet:(NSString *)input inFrame:(CGRect)snippetFrame
117 WKWebView *
webView = [[WKWebView alloc] initWithFrame:snippetFrame];
118 webView.navigationDelegate =
self;
124 input =
@"<body bgcolor=\"orange\
"><center><h1><b>Error</b></h1></center></body>";
126 [webView loadHTMLString:input baseURL:nil];
127 [webView setOpaque:YES];
128 [webView setBackgroundColor:[UIColor whiteColor]];
129 webView.layer.cornerRadius = 8;
130 webView.layer.borderColor = [[UIColor blackColor] CGColor];
131 webView.layer.borderWidth = 3.0;
135 - (void) loadWebView:(WKWebView *)webview with:(NSString *)htmlload
137 [webview loadHTMLString:htmlload baseURL:nil];
139 - (void) pushToCreateEntryOnDrive
144 if (nil != _showTextTitle) {
145 driveMenuItem.
titleTextStr = [driveMenuItem.titleTextStr stringByAppendingString:_showTextTitle];
148 [
self.navigationController pushViewController:driveMenuItem animated:YES];
151 - (void) popPushController:(UIViewController *)rebuildVC
153 NSString *rebuildClassStr = NSStringFromClass([rebuildVC
class]);
154 NSLog(
@"V7GoogDriveMenuItemViewController.popPushController: class %@",
156 if ([rebuildClassStr isEqualToString:
@"V7GoogDriveMenuItemViewControlle"]) {
157 UIViewController *popped = [
self.navigationController popViewControllerAnimated:NO];
158 NSLog(
@"CameraSnapViewController.popPushController: %@", NSStringFromClass([popped
class]));
160 NSLog(
@"W7WebSnippetViewController.popPushController: rebuild-vc");
165 - (NSString *) embelishHtmlReturn:(NSString *)htmlbody
167 NSString *styleMU =
@"<style> body {background-color: #BBFFDD; }, li { background-color: #FFFF00; border: none; color: black; padding: 5px 9px; text-align: left; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; }, ul { list-style-type: circle; } </style> ";
168 NSString *metaMU =
@"<meta name=\"viewport\
" content=\"width=device-width, initial-scale=1.0\">";
169 NSString *ret = [NSString stringWithFormat:@" %@ %@ %@ ", metaMU, styleMU, htmlbody];
241 - (void)textViewDidChange:(UITextView *)textView
243 NSLog(
@"W7WebSnippetViewController.textViewDidChange: Called");
WKWebView * webInstructionView
WKWebView * viewDidLoadSnippet:inFrame:(NSString *input, [inFrame] CGRect snippetFrame)
WKWebView * webIngredientsView
void pushToCreateEntryOnDrive()