-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountryViewController.m
179 lines (162 loc) · 8.81 KB
/
CountryViewController.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//
// CountryVewController.m
// DinerRouge
//
// Created by Adrian Holzer on 24.11.14.
// Copyright (c) 2014 Adrian Holzer. All rights reserved.
//
#import "GAI.h"
#import "InfoViewController.h"
#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"
#import "CountryViewController.h"
#import "BillManager.h"
@implementation CountryViewController
@synthesize q1View, q2View, q3View, q4View, q5View,q2ViewIndicator, q3ViewIndicator, q4ViewIndicator, q5ViewIndicator, country,distributionView,distributionLabel,q2ViewIndicatorLabel, q3ViewIndicatorLabel, q4ViewIndicatorLabel, q5ViewIndicatorLabel;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor=[[BillManager sharedBillManager] maincolor];
// instructionView.text=NSLocalizedString(@"INFO_HOW", nil) ;
//setup nav bar title
UINavigationItem *navigationItem = [super navigationItem];
UILabel *customLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120.0f, 44.0f)];
customLabel.backgroundColor= [UIColor clearColor];
customLabel.textAlignment = NSTextAlignmentCenter;
customLabel.textColor = [[BillManager sharedBillManager] secondarycolor];
navigationItem.titleView = customLabel;
[customLabel setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size:[[BillManager sharedBillManager] largeFont]]];
customLabel.text=[self.country.name uppercaseString];
self.giniLabel.text=[NSString stringWithFormat:@"%.f", [self.country.gini floatValue] ];
self.giniLabel.textColor=[[BillManager sharedBillManager] buttonTextColor];
self.giniLabel.backgroundColor=[[BillManager sharedBillManager] buttoncolor];
// BACK BUTTON START
UIButton *newBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
[newBackButton setImage: [[BillManager sharedBillManager]backBoutonImage] forState:UIControlStateNormal];
[newBackButton addTarget:self.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
newBackButton.frame = CGRectMake(5, 5, 30, 30);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:newBackButton];
[self.giniLabel setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size: 65]];
[self.whatLabel setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size:[[BillManager sharedBillManager] largeFont]]];
[self.giniInfo setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size:[[BillManager sharedBillManager] smallFont]]];
[self.distributionLabel setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size:[[BillManager sharedBillManager] smallFont]]];
[self.inequalityLabel setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size:[[BillManager sharedBillManager] smallFont]]];
[self.incomeInfo setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size:[[BillManager sharedBillManager] smallFont]]];
[self.wealthInfo setFont:[UIFont fontWithName:[[BillManager sharedBillManager] fontNameBold] size:[[BillManager sharedBillManager] smallFont]]];
//check if the q5 exists
NSString* pourcentString=@"1";
float value = [country.q5 intValue];
if (value == 0) {
pourcentString=@"5";
value = [country.q4 intValue];
}if (value == 0) {
pourcentString=@"10";
value = [country.q3 intValue];
}if (value == 0) {
pourcentString=@"20";
value = [country.q2 intValue];
}
self.wealthInfo.textColor=[[BillManager sharedBillManager] secondarycolor];
self.wealthInfo.text=[NSString stringWithFormat: NSLocalizedString(@"WEALTH_INFO", nil), pourcentString,[NSString stringWithFormat:@"%.f",value]] ;
NSString* type = NSLocalizedString(@"WEALTH", nil);
if(self.isIncome){
type = NSLocalizedString(@"INCOME", nil);
}
self.whatLabel.text=NSLocalizedString(@"GINI", nil) ;
self.whatLabel.backgroundColor=[[BillManager sharedBillManager] buttoncolor];
self.whatLabel.textColor=[[BillManager sharedBillManager] buttonTextColor];
self.giniInfo.text=[NSString stringWithFormat: NSLocalizedString(@"INFO_GINI", nil),[NSString stringWithFormat:@"%.f", [self.country.gini floatValue]], [[country inequality:NSLocalizedString(type , nil)] lowercaseString]];
self.giniInfo.textColor=[[BillManager sharedBillManager] secondarycolor];
self.incomeInfo.text=[NSString stringWithFormat: NSLocalizedString(@"INCOME_INFO", nil), [NSString stringWithFormat:@"%.f", [country.q5 floatValue]],[NSString stringWithFormat:@"%.f", [country.q1 floatValue]]] ;
self.incomeInfo.textColor=[[BillManager sharedBillManager] secondarycolor];
self.distributionLabel.text= [[NSString stringWithFormat: NSLocalizedString(@"DISTRIBUTION_LABEL", nil), NSLocalizedString(type, nil), NSLocalizedString(self.country.name, nil)] uppercaseString];
self.distributionLabel.textColor=[[BillManager sharedBillManager] buttonTextColor];
self.distributionView.backgroundColor=[[BillManager sharedBillManager] buttoncolor];
if(self.isIncome){
self.inequalityLabel.text=[country inequality:NSLocalizedString(@"INCOME", nil)];
CGRect frm = q1View.frame;
frm.size.width = q5View.frame.size.width*[country.q5 floatValue]/100;
q1View.frame = frm;
frm = q2View.frame;
frm.size.width = q5View.frame.size.width*[country.q4 floatValue]/100;
frm.origin.x=q1View.frame.origin.x+q1View.frame.size.width;
q2View.frame = frm;
frm = q3View.frame;
frm.size.width = q5View.frame.size.width*[country.q3 floatValue]/100;
frm.origin.x=q2View.frame.origin.x+q2View.frame.size.width;
q3View.frame = frm;
frm = q4View.frame;
frm.size.width = q5View.frame.size.width*[country.q2 floatValue]/100;
frm.origin.x=q3View.frame.origin.x+q3View.frame.size.width;
q4View.frame = frm;
}else{
self.inequalityLabel.text=[country inequality:NSLocalizedString(@"WEALTH", nil)];
CGRect frm = q2View.frame;
frm.size.width = q1View.frame.size.width*[country.q2 floatValue]/100;
q2View.frame = frm;
frm = q3View.frame;
frm.size.width = q1View.frame.size.width*[country.q3 floatValue]/100;
q3View.frame = frm;
frm = q4View.frame;
frm.size.width = q1View.frame.size.width*[country.q4 floatValue]/100;
q4View.frame = frm;
frm = q5View.frame;
frm.size.width = q1View.frame.size.width*[country.q5 floatValue]/100;
q5View.frame = frm;
frm = q2ViewIndicator.frame;
frm.origin.x=q2View.frame.origin.x+q2View.frame.size.width-1;
q2ViewIndicator.frame=frm;
frm = q3ViewIndicator.frame;
frm.origin.x=q3View.frame.origin.x+q3View.frame.size.width-1;
q3ViewIndicator.frame=frm;
frm = q4ViewIndicator.frame;
frm.origin.x=q4View.frame.origin.x+q4View.frame.size.width-1;
q4ViewIndicator.frame=frm;
frm = q5ViewIndicator.frame;
frm.origin.x=q5View.frame.origin.x+q5View.frame.size.width-1;
q5ViewIndicator.frame=frm;
q2ViewIndicatorLabel.text=NSLocalizedString(@"The richest 20%", nil);
q3ViewIndicatorLabel.text=NSLocalizedString(@"The richest 10%", nil);
q4ViewIndicatorLabel.text=NSLocalizedString(@"The richest 5%", nil);
q5ViewIndicatorLabel.text=NSLocalizedString(@"The 1%", nil);
if ([country.q2 intValue] == 0) {
[q2ViewIndicator setHidden:YES];
[q2ViewIndicatorLabel setHidden:YES];
}
if ([country.q3 intValue] == 0) {
[q3ViewIndicator setHidden:YES];
[q3ViewIndicatorLabel setHidden:YES];
}
if ([country.q4 intValue] == 0) {
[q4ViewIndicator setHidden:YES];
[q4ViewIndicatorLabel setHidden:YES];
}
if ([country.q5 intValue] == 0) {
[q5ViewIndicator setHidden:YES];
[q5ViewIndicatorLabel setHidden:YES];
}
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)viewDidAppear:(BOOL)animated{
if ([[BillManager sharedBillManager] styleIsCommunist]) {
[[[GAI sharedInstance] defaultTracker] set:kGAIScreenName value:@"Info Screen-C"];
[[[GAI sharedInstance] defaultTracker] send:[[GAIDictionaryBuilder createAppView] build]];
}else{
[[[GAI sharedInstance] defaultTracker] set:kGAIScreenName value:@"Info Screen-NC"];
[[[GAI sharedInstance] defaultTracker] send:[[GAIDictionaryBuilder createAppView] build]];
}
}
@end