|
@@ -11,16 +11,116 @@
|
|
|
//
|
|
|
|
|
|
#import "CPDFSignatureViewController.h"
|
|
|
+#import "CAnnotStyle.h"
|
|
|
+#import "CPDFSignatureViewCell.h"
|
|
|
|
|
|
-@interface CPDFSignatureViewController ()
|
|
|
+@interface CPDFSignatureViewController () <UITableViewDelegate, UITableViewDataSource>
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIButton *backBtn;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UILabel *titleLabel;
|
|
|
+
|
|
|
+@property (nonatomic, strong) CAnnotStyle *annotStyle;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UITableView *tableView;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIImageView *emptyImageView;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIButton *createButton;
|
|
|
|
|
|
@end
|
|
|
|
|
|
@implementation CPDFSignatureViewController
|
|
|
|
|
|
+#pragma mark - Initializers
|
|
|
+
|
|
|
+- (instancetype)initWithStyle:(CAnnotStyle *)annotStyle {
|
|
|
+ if (self = [super init]) {
|
|
|
+ self.annotStyle = annotStyle;
|
|
|
+ }
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - ViewController Methods
|
|
|
+
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
+ self.titleLabel = [[UILabel alloc] init];
|
|
|
+ self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
|
|
|
+ self.titleLabel.font = [UIFont systemFontOfSize:20];
|
|
|
+ self.titleLabel.text = NSLocalizedString(@"Signature", nil);
|
|
|
+ self.titleLabel.adjustsFontSizeToFitWidth = YES;
|
|
|
+ [self.view addSubview:self.titleLabel];
|
|
|
+
|
|
|
+ self.backBtn = [[UIButton alloc] init];
|
|
|
+ self.backBtn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
|
|
|
+ [self.backBtn setImage:[UIImage imageNamed:@"CPDFAnnotationBaseImageBack" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
|
|
|
+ [self.backBtn addTarget:self action:@selector(buttonItemClicked_back:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:self.backBtn];
|
|
|
+
|
|
|
+ self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, self.view.frame.size.height - 120) style:UITableViewStylePlain];
|
|
|
+ self.tableView.delegate = self;
|
|
|
+ self.tableView.dataSource = self;
|
|
|
+ self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
|
+ self.tableView.rowHeight = 120;
|
|
|
+ [self.view addSubview:self.tableView];
|
|
|
+
|
|
|
+ self.emptyImageView = [[UIImageView alloc] init];
|
|
|
+ self.emptyImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
|
+ self.emptyImageView.image = [UIImage imageNamed:@"CPDFAnnotationBaseImageBack" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
|
|
|
+ [self.view addSubview:self.emptyImageView];
|
|
|
+
|
|
|
+ self.createButton = [[UIButton alloc] init];
|
|
|
+ self.createButton.layer.cornerRadius = 10.0;
|
|
|
+ self.createButton.clipsToBounds = YES;
|
|
|
+ [self.createButton setImage:[UIImage imageNamed:@"CPDFSignatureImageAdd" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
|
|
|
+ [self.createButton setTitle:NSLocalizedString(@"Add Signature", nil) forState:UIControlStateNormal];
|
|
|
+ [self.createButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
|
|
|
+ [self.view addSubview:self.createButton];
|
|
|
+
|
|
|
+ self.view.backgroundColor = [UIColor whiteColor];
|
|
|
+ [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)viewWillLayoutSubviews {
|
|
|
+ [super viewWillLayoutSubviews];
|
|
|
+ self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
|
|
|
+ self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, 50);
|
|
|
+ self.createButton.frame = CGRectMake((self.view.frame.size.width - 120)/2, self.view.frame.size.height - 70, 120, 50);;
|
|
|
+ self.emptyImageView.frame = self.tableView.frame;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
|
|
+ [super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
|
|
|
+ [self updatePreferredContentSizeWithTraitCollection:newCollection];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - Protect Methods
|
|
|
+
|
|
|
+- (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
|
|
|
+ self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 270 : 420);
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - Action
|
|
|
+
|
|
|
+- (void)buttonItemClicked_back:(id)sender {
|
|
|
+ [self dismissViewControllerAnimated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - UITableViewDataSource
|
|
|
+
|
|
|
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
+ return 5;
|
|
|
+}
|
|
|
+
|
|
|
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+ CPDFSignatureViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
|
|
|
+ if (cell == nil) {
|
|
|
+ cell = [[CPDFSignatureViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
|
|
|
+ }
|
|
|
+
|
|
|
+ return cell;
|
|
|
}
|
|
|
|
|
|
@end
|