-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBPBHarmfulStateViewController.m
126 lines (99 loc) · 4.06 KB
/
BPBHarmfulStateViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//
// BPBHarmfulStateViewController.m
// Origins
//
// Created by billy bray on 5/7/14.
// Copyright (c) 2014 Spartan Systems. All rights reserved.
//
#import "BPBHarmfulStateViewController.h"
#import <Social/Social.h>
@interface BPBHarmfulStateViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *productImageView;
@property (weak, nonatomic) IBOutlet UILabel *productNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *storeNameLabel;
@property (weak, nonatomic) IBOutlet UITextView *productDescriptionTextView;
@property (weak, nonatomic) IBOutlet UIView *originFirstAlertView;
@property (weak, nonatomic) IBOutlet UIView *originShareAlertView;
@end
@implementation BPBHarmfulStateViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.storeNameLabel.text = self.storeName;
self.productImageView.image = self.productImage;
self.productNameLabel.text = self.productName;
self.productDescriptionTextView.text = self.productDescription;
}
-(void)scannerSwipeRight:(UIGestureRecognizer*)g
{
[self.navigationController popToViewController:self.mvc animated:YES];
}
- (IBAction)flagItem:(id)sender
{
[self.mvc addStore:self.storeName withImpact:self.impact andProduct:self.productBarcode andLocation:self.storeLocation];
// Add the product
[self.mvc addProduct:self.productName withImpact:self.impact andProductBarCode:self.productBarcode andImage:self.productImage withDescription:self.productDescription];
// Present option to share
[self replaceFirstTagView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)shareAlertButton:(id)sender
{
SLComposeViewController *twitterController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[twitterController dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(@"Posted....");
[self.navigationController popToViewController:self.mvc animated:YES];
}
break;
}};
[twitterController setInitialText:[NSString stringWithFormat:@"I flagged an Origin Confirmed envirnonmentally harmful product @%@ Please stock Origin Made Alternatives.", self.storeName]];
[twitterController setCompletionHandler:completionHandler];
[self.navigationController presentViewController:twitterController animated:YES completion:nil];
}
}
-(void)replaceFirstTagView
{
// Remove the first view with tagging
[UIView transitionWithView:self.view
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[self.originFirstAlertView setHidden:YES];
}
completion:nil];
// Add new view for thank you
[UIView transitionWithView:self.view
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[self.originShareAlertView setHidden:NO];
}
completion:^(BOOL finished){
// TODO
}];
}
@end