changed git call from https to git readonly
[atutor.git] / mods / atsocial_iphone_app / InAppSettingsKit / Views / IASKPSTitleValueSpecifierViewCell.m
1 //
2 //  IASKPSTitleValueSpecifierViewCell.m
3 //  http://www.inappsettingskit.com
4 //
5 //  Copyright (c) 2010:
6 //  Luc Vandal, Edovia Inc., http://www.edovia.com
7 //  Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
8 //  All rights reserved.
9 // 
10 //  It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz, 
11 //  as the original authors of this code. You can give credit in a blog post, a tweet or on 
12 //  a info page of your app. Also, the original authors appreciate letting them know if you use this code.
13 //
14 //  This code is licensed under the BSD license that is available at: http://www.opensource.org/licenses/bsd-license.php
15 //
16
17 #import "IASKPSTitleValueSpecifierViewCell.h"
18 #import "IASKSettingsReader.h"
19
20
21 @implementation IASKPSTitleValueSpecifierViewCell
22
23 - (void)layoutSubviews {
24         // left align the value if the title is empty
25         if (!self.textLabel.text.length) {
26                 self.textLabel.text = self.detailTextLabel.text;
27                 self.detailTextLabel.text = nil;
28                 if ([self.reuseIdentifier isEqualToString:kIASKPSMultiValueSpecifier]) {
29                         self.textLabel.font = [UIFont systemFontOfSize:[UIFont labelFontSize]];
30                         self.textLabel.textColor = self.detailTextLabel.textColor;
31                 }
32         }
33         [super layoutSubviews];
34         
35         CGSize viewSize =  [self.textLabel superview].frame.size;
36         
37         // set the left title label frame
38         CGFloat labelWidth = [self.textLabel sizeThatFits:CGSizeZero].width;
39         CGFloat minValueWidth = (self.detailTextLabel.text.length) ? kIASKMinValueWidth + kIASKSpacing : 0;
40         labelWidth = MIN(labelWidth, viewSize.width - minValueWidth - kIASKPaddingLeft -kIASKPaddingRight);
41         CGRect labelFrame = CGRectMake(kIASKPaddingLeft, 0, labelWidth, viewSize.height -2);
42         self.textLabel.frame = labelFrame;
43         
44         // set the right value label frame
45         if (self.detailTextLabel.text.length) {
46                 CGRect valueFrame = CGRectMake(kIASKPaddingLeft + labelWidth + kIASKSpacing,
47                                                                            0,
48                                                                            viewSize.width - (kIASKPaddingLeft + labelWidth + kIASKSpacing) - kIASKPaddingRight,
49                                                                            viewSize.height -2);
50                 self.detailTextLabel.frame = valueFrame;
51         }
52 }
53
54 @end