Browse Source

Merge branch 'compdfkit_demo_ios' of git.kdan.cc:others/kmpdfkit_demo into compdfkit_demo_ios

chenyu 1 year ago
parent
commit
ad11966c83

+ 2 - 0
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFFreeText/CPDFFreeTextViewController.m

@@ -179,6 +179,8 @@
 
 - (void)commomInitTitle {
     self.titleLabel.text = NSLocalizedString(@"Free Text", nil);
+    self.colorView.colorLabel.text = NSLocalizedString(@"Text Color", nil);
+    
     self.sampleView.selecIndex = CPDFSamplesFreeText;
     self.sampleView.fillColor = [UIColor blueColor];
 }

+ 2 - 0
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFLink/CPDFLinkViewController.m

@@ -245,6 +245,7 @@
     _pageTextField.layer.cornerRadius = 5.0;
     _pageTextField.delegate = self;
     _pageTextField.font = [UIFont systemFontOfSize:18.0];
+    _pageTextField.placeholder = NSLocalizedString(@"Please enter page number", nil);
     [_pageTextField setKeyboardType:UIKeyboardTypeNumberPad];
     [self.scrcollView addSubview:_pageTextField];
     
@@ -260,6 +261,7 @@
     _emailTextField.layer.cornerRadius = 5.0;
     _emailTextField.delegate = self;
     _emailTextField.font = [UIFont systemFontOfSize:18.0];
+    _emailTextField.placeholder = NSLocalizedString(@"Please enter a Email", nil);
     [self.scrcollView addSubview:_emailTextField];
     offstY +=_urlTextField.frame.size.height;
     

+ 33 - 14
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CPDFSignatureViewController.m

@@ -31,6 +31,8 @@
 
 @property (nonatomic, strong) UIButton *createButton;
 
+@property (nonatomic, strong) UIView *headerView;
+
 @end
 
 @implementation CPDFSignatureViewController
@@ -49,19 +51,25 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
+    self.headerView = [[UIView alloc] init];
+    self.headerView.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
+    self.headerView.layer.borderWidth = 1.0;
+    self.headerView.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
+    [self.view addSubview:self.headerView];
+    
     self.titleLabel = [[UILabel alloc] init];
     self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
     self.titleLabel.font = [UIFont systemFontOfSize:20];
     self.titleLabel.text = NSLocalizedString(@"Signature", nil);
     self.titleLabel.textAlignment = NSTextAlignmentCenter;
     self.titleLabel.adjustsFontSizeToFitWidth = YES;
-    [self.view addSubview:self.titleLabel];
+    [self.headerView 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.headerView 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;
@@ -82,7 +90,7 @@
     [self.createButton addTarget:self action:@selector(buttonItemClicked_create:) forControlEvents:UIControlEventTouchUpInside];
     [self.view addSubview:self.createButton];
     
-    self.view.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
+    self.view.backgroundColor = [CPDFColorUtils CAnnotationSampleBackgoundColor];
     [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     [self createGestureRecognizer];
 }
@@ -91,6 +99,7 @@
     [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.headerView.frame = CGRectMake(0, 0, self.view.frame.size.width, 50);
     
     self.emptyLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, (self.view.frame.size.height - 50)/2, 120, 50);
     
@@ -132,7 +141,7 @@
 #pragma mark - Action
 
 - (void)buttonItemClicked_back:(id)sender {
-    [self dismissViewControllerAnimated:NO completion:nil];
+    [self dismissViewControllerAnimated:YES completion:nil];
     if(self.delegate && [self.delegate respondsToSelector:@selector(signatureViewControllerDismiss:)]) {
         [self.delegate signatureViewControllerDismiss:self];
     }
@@ -191,12 +200,26 @@
 #pragma mark - CPDFSignatureViewCellDelegate
 
 - (void)signatureViewCell:(CPDFSignatureViewCell *)signatureViewCell {
-    NSIndexPath *indexSet = [self.tableView indexPathForCell:signatureViewCell];
-    [[CSignatureManager sharedManager] removeSignaturesAtIndexe:indexSet.row];
-    if ([CSignatureManager sharedManager].signatures.count < 1) {
-        [self setEditing:NO animated:YES];
-    }
-    [self.tableView reloadData];
+    
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
+                                                           style:UIAlertActionStyleCancel
+                                                         handler:nil];
+    UIAlertAction *OKAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Sure", nil)
+                                                           style:UIAlertActionStyleDefault
+                                                     handler:^(UIAlertAction * _Nonnull action) {
+        NSIndexPath *indexSet = [self.tableView indexPathForCell:signatureViewCell];
+        [[CSignatureManager sharedManager] removeSignaturesAtIndexe:indexSet.row];
+        if ([CSignatureManager sharedManager].signatures.count < 1) {
+            [self setEditing:NO animated:YES];
+        }
+        [self.tableView reloadData];
+    }];
+    UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Tip", nil)
+                                                                   message:NSLocalizedString(@"Are you sure you want to delete the signature?", nil)
+                                                            preferredStyle:UIAlertControllerStyleAlert];
+    [alert addAction:cancelAction];
+    [alert addAction:OKAction];
+    [self presentViewController:alert animated:YES completion:nil];
 }
 
 #pragma mark - CPDFSignatureEditViewControllerDelegate
@@ -204,10 +227,6 @@
 - (void)signatureEditViewController:(CPDFSignatureEditViewController *)signatureEditViewController image:(UIImage *)image{
     [[CSignatureManager sharedManager] addImageSignature:image];
     [self.tableView reloadData];
-    
-//    CPDFSignatureAnnotation *annotation = [[CPDFSignatureAnnotation alloc] initWithDocument:self.annotManage.pdfListView.document];
-//    [annotation setImage:image];
-//    self.annotManage.pdfListView.addAnnotation = annotation;
 }
 
 @end

+ 1 - 3
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CSignatureManager.m

@@ -36,6 +36,7 @@ static CSignatureManager *_sharedSignManager;
             for (NSString *fileName in fileNames) {
                 [signatures addObject:[folderPath stringByAppendingPathComponent:fileName]];
             }
+            _signatures = signatures;
         } else {
             _signatures = [[NSArray alloc] init];
         }
@@ -104,9 +105,6 @@ static CSignatureManager *_sharedSignManager;
 }
 
 - (void)removeSignaturesAtIndexe:(NSInteger)row {
-//    for (NSString *filePath in [self.signatures objectsAtIndexes:indexes]) {
-//        [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
-//    }
     NSMutableArray *array = [NSMutableArray arrayWithArray:self.signatures];
     [array removeObjectAtIndex:row];
     self.signatures = array;

+ 35 - 14
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFStamp/CPDFStampViewController.m

@@ -67,6 +67,8 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
 
 @property (nonatomic, strong) UIView *modelView;
 
+@property (nonatomic, strong) UIView *headerView;
+
 @end
 
 @implementation CPDFStampViewController
@@ -76,7 +78,13 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
-    self.view.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
+    self.view.backgroundColor = [CPDFColorUtils CAnnotationSampleBackgoundColor];
+    
+    self.headerView = [[UIView alloc] init];
+    self.headerView.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
+    self.headerView.layer.borderWidth = 1.0;
+    self.headerView.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
+    [self.view addSubview:self.headerView];
     
     self.titleLabel = [[UILabel alloc] init];
     self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
@@ -84,13 +92,13 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
     self.titleLabel.textAlignment = NSTextAlignmentCenter;
     self.titleLabel.font = [UIFont systemFontOfSize:20];
     self.titleLabel.adjustsFontSizeToFitWidth = YES;
-    [self.view addSubview:self.titleLabel];
+    [self.headerView 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.headerView addSubview:self.backBtn];
     
     NSArray *segmmentArray = [NSArray arrayWithObjects:NSLocalizedString(@"Standard", nil), NSLocalizedString(@"Customize", nil), nil];
     self.segmentedControl = [[UISegmentedControl alloc] initWithItems:segmmentArray];
@@ -131,8 +139,9 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
 
 - (void)viewWillLayoutSubviews {
     [super viewWillLayoutSubviews];
-    self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
-    self.segmentedControl.frame = CGRectMake(50, 50, self.view.frame.size.width-100, 30);
+    self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 0, 120, 50);
+    self.segmentedControl.frame = CGRectMake(50, 55, self.view.frame.size.width-100, 30);
+    self.headerView.frame = CGRectMake(0, 0, self.view.frame.size.width, 50);
     if (@available(iOS 11.0, *)) {
         self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60 - self.view.safeAreaInsets.right, 5, 50, 50);
         self.createButton.frame = CGRectMake(self.view.frame.size.width - 70 - self.view.safeAreaInsets.right, self.view.bounds.size.height - 200 - self.view.safeAreaInsets.bottom, 50, 50);
@@ -581,15 +590,27 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
 #pragma mark - CCustomizeStampTableViewCellDelegate
 
 - (void)customizeStampTableViewCell:(CCustomizeStampTableViewCell *)customizeStampTableViewCell {
-    NSIndexPath *select = [self.tableView indexPathForCell:customizeStampTableViewCell];
-
-    if (select.section == 0) {
-        [self.stampFileManager removeStampItem:select.row type:PDFStampCustomType_Text];
-    } else if (select.section == 1) {
-        [self.stampFileManager removeStampItem:select.row type:PDFStampCustomType_Image];
-    }
-    
-    [self.tableView reloadData];
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
+                                                           style:UIAlertActionStyleCancel
+                                                         handler:nil];
+    UIAlertAction *OKAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Sure", nil)
+                                                           style:UIAlertActionStyleDefault
+                                                     handler:^(UIAlertAction * _Nonnull action) {
+        NSIndexPath *select = [self.tableView indexPathForCell:customizeStampTableViewCell];
+        if (select.section == 0) {
+            [self.stampFileManager removeStampItem:select.row type:PDFStampCustomType_Text];
+        } else if (select.section == 1) {
+            [self.stampFileManager removeStampItem:select.row type:PDFStampCustomType_Image];
+        }
+        
+        [self.tableView reloadData];
+    }];
+    UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Tip", nil)
+                                                                   message:NSLocalizedString(@"Are you sure you want to delete the stamp?", nil)
+                                                            preferredStyle:UIAlertControllerStyleAlert];
+    [alert addAction:cancelAction];
+    [alert addAction:OKAction];
+    [self presentViewController:alert animated:YES completion:nil];
 }
 
 #pragma mark - CStampTextViewControllerDelegate