Today's Menu  Portugal
journal and plan nutrition
Instance Methods | Properties | List of all members
W7WebSnippetViewController Class Reference

#import <W7WebSnippetViewController.h>

Inheritance diagram for W7WebSnippetViewController:
Inheritance graph
[legend]
Collaboration diagram for W7WebSnippetViewController:
Collaboration graph
[legend]

Instance Methods

(instancetype) - initWithNibName:bundle:
 
(void) - viewDidLoad [implementation]
 
(WKWebView *) - viewDidLoadSnippet:inFrame: [implementation]
 
(void) - loadWebView:with: [implementation]
 
(void) - pushToCreateEntryOnDrive [implementation]
 
(void) - popPushController: [implementation]
 
(NSString *) - embelishHtmlReturn: [implementation]
 
(void) - textViewDidChange: [implementation]
 

Properties

NSString * showTextTitle
 
NSString * showTextIngredients
 
NSString * showTextInstruction
 
NSString * showHtmlTitle
 
NSString * showHtmlIngredients
 
NSString * showHtmlInstruction
 

Detailed Description

Definition at line 14 of file W7WebSnippetViewController.h.

Method Documentation

◆ embelishHtmlReturn:()

- (NSString *) embelishHtmlReturn: (NSString *)  htmlbody
implementation

Definition at line 165 of file W7WebSnippetViewController.m.

165  :(NSString *)htmlbody
166 {
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];
170 
171  return ret;
172 }

◆ initWithNibName:bundle:()

- (instancetype) initWithNibName: (nullable NSString *)  nibNameOrNil
bundle: (nullable NSBundle *)  nibBundleOrNil 

Definition at line 37 of file W7WebSnippetViewController.m.

37  :(nullable NSString *)nibNameOrNilz
38  bundle:(nullable NSBundle *)nibBundleOrNilz
39 {
40  self = [super initWithNibName:nibNameOrNilz bundle:nibBundleOrNilz];
41  if (self) {
42  ;
43  }
44  return self;
45 }

◆ loadWebView:with:()

- (void) loadWebView: (WKWebView *)  webview
with: (NSString *)  htmlload 
implementation

Definition at line 135 of file W7WebSnippetViewController.m.

135  :(WKWebView *)webview with:(NSString *)htmlload
136 {
137  [webview loadHTMLString:htmlload baseURL:nil];
138 }

◆ popPushController:()

- (void) popPushController: (UIViewController *)  rebuildVC
implementation

Definition at line 151 of file W7WebSnippetViewController.m.

151  :(UIViewController *)rebuildVC
152 {
153  NSString *rebuildClassStr = NSStringFromClass([rebuildVC class]);
154  NSLog(@"V7GoogDriveMenuItemViewController.popPushController: class %@",
155  rebuildClassStr);
156  if ([rebuildClassStr isEqualToString:@"V7GoogDriveMenuItemViewControlle"]) {
157  UIViewController *popped = [self.navigationController popViewControllerAnimated:NO];
158  NSLog(@"CameraSnapViewController.popPushController: %@", NSStringFromClass([popped class]));
159 
160  NSLog(@"W7WebSnippetViewController.popPushController: rebuild-vc");
161  [self pushToCreateEntryOnDrive];
162  }
163 }

◆ pushToCreateEntryOnDrive()

- (void) pushToCreateEntryOnDrive
implementation

Definition at line 139 of file W7WebSnippetViewController.m.

140 {
141  V7GoogDriveMenuItemViewController *driveMenuItem =
142  [[V7GoogDriveMenuItemViewController alloc] initWithNibName:nil bundle:nil];
143  driveMenuItem.delegate = self;
144  if (nil != _showTextTitle) {
145  driveMenuItem.titleTextStr = [driveMenuItem.titleTextStr stringByAppendingString:_showTextTitle];
146  }
147 
148  [self.navigationController pushViewController:driveMenuItem animated:YES];
149 }
id< V7GoogDriveMenuViewProtocol > delegate

◆ textViewDidChange:()

- (void) textViewDidChange: (UITextView *)  textView
implementation

Definition at line 241 of file W7WebSnippetViewController.m.

241  :(UITextView *)textView
242 {
243  NSLog(@"W7WebSnippetViewController.textViewDidChange: Called");
244 // CGFloat fixedWidth = textView.frame.size.width;
245 // CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
246 // CGRect newFrame = textView.frame;
247 // newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
248 // textView.frame = newFrame;
249 }

◆ viewDidLoad()

- (void) viewDidLoad
implementation

Definition at line 46 of file W7WebSnippetViewController.m.

46  {
47  [super viewDidLoad];
48  // Do any additional setup after loading the view.
49 
50  self.title = @"Capture Web Snippet";
51 
52  navbarBottomEdge = self.navigationController.navigationBar.frame.origin.y
53  + self.navigationController.navigationBar.frame.size.height;
54 
55  // fetch, scale, and add a subview background image
56  UIImage *backgrdImage = [UIImage imageNamed:@"blueHydrangea.png"];
57  CGSize photoSize = [backgrdImage size];
58  CGRect totalFrame = self.view.frame;
59  overallSize = totalFrame.size;
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];
66  // end - fetch, scale, and add a subview background image
67 
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];
75 
76 
77  float snippetTitleFrameTop = navbarBottomEdge + 20.0 + 80.0;
78  float snippetTitleFrameHeight = 48.0;
79  CGRect snippetTitleFrame = CGRectMake(8.0,
80  snippetTitleFrameTop,
81  overallSize.width - 16.0,
82  snippetTitleFrameHeight);
83  webTitleView = [self viewDidLoadSnippet:_showHtmlTitle inFrame:snippetTitleFrame];
84 
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,
90  overallSize.width - 16.0,
91  snippetIngredientsFrameHeight);
92  webIngredientsView = [self viewDidLoadSnippet:_showHtmlIngredients inFrame:snippetIngredientsFrame];
93 
94  float snippetInstructionFrameTop = snippetIngredientsFrameTop + snippetIngredientsFrameHeight + 4.0;
95  float snippetInstructionFrameHeight = overallSize.height - snippetInstructionFrameTop - 4.0;
96  CGRect snippetInstructionFrame = CGRectMake(8.0,
97  snippetInstructionFrameTop,
98  overallSize.width - 16.0,
99  snippetInstructionFrameHeight);
100  webInstructionView = [self viewDidLoadSnippet:_showHtmlInstruction inFrame:snippetInstructionFrame];
101 
102 
103  [self.view addSubview:webTitleView];
104  [self.view addSubview:webIngredientsView];
105  [self.view addSubview:webInstructionView];
106 
107 }
WKWebView * webInstructionView
CGSize overallSize
WKWebView * webIngredientsView
float navbarBottomEdge

◆ viewDidLoadSnippet:inFrame:()

- (WKWebView *) viewDidLoadSnippet: (NSString *)  input
inFrame: (CGRect)  snippetFrame 
implementation

Definition at line 115 of file W7WebSnippetViewController.m.

115  :(NSString *)input inFrame:(CGRect)snippetFrame
116 {
117  WKWebView *webView = [[WKWebView alloc] initWithFrame:snippetFrame];
118  webView.navigationDelegate = self;
119  webView.UIDelegate = nil;
120 
121  // background-color:#e5ceb3;
122  // background-image:url(\"tiffany_gradient.png\");
123  if (nil==input ) {
124  input = @"<body bgcolor=\"orange\"><center><h1><b>Error</b></h1></center></body>";
125  }
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;
132  webView.clipsToBounds = YES;
133  return webView;
134 }
WKWebView * webView

Property Documentation

◆ showHtmlIngredients

- (NSString*) showHtmlIngredients
readwritenonatomicstrong

Definition at line 20 of file W7WebSnippetViewController.h.

◆ showHtmlInstruction

- (NSString*) showHtmlInstruction
readwritenonatomicstrong

Definition at line 21 of file W7WebSnippetViewController.h.

◆ showHtmlTitle

- (NSString*) showHtmlTitle
readwritenonatomicstrong

Definition at line 19 of file W7WebSnippetViewController.h.

◆ showTextIngredients

- (NSString*) showTextIngredients
readwritenonatomicstrong

Definition at line 17 of file W7WebSnippetViewController.h.

◆ showTextInstruction

- (NSString*) showTextInstruction
readwritenonatomicstrong

Definition at line 18 of file W7WebSnippetViewController.h.

◆ showTextTitle

- (NSString*) showTextTitle
readwritenonatomicstrong

Definition at line 16 of file W7WebSnippetViewController.h.


The documentation for this class was generated from the following files: