Przeglądaj źródła

1.修改Esign Template控件位置调整视图。

Pen Li 8 lat temu
rodzic
commit
a3006b576f

BIN
Ants Contract/AntsContract.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 94 - 11
Ants Contract/AntsContract/AntsContract/Base.lproj/Main.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" colorMatched="YES" initialViewController="UmP-Fl-ZUI">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16A323" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" colorMatched="YES" initialViewController="UmP-Fl-ZUI">
     <device id="ipad9_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -85,6 +85,15 @@
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
+                            <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="bur-yb-Jpu">
+                                <rect key="frame" x="50" y="850" width="150" height="84"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="25"/>
+                                <state key="normal" title="Debug"/>
+                                <connections>
+                                    <action selector="debugBtnClick:" destination="BYZ-38-t0r" eventType="touchUpInside" id="miM-ag-9gQ"/>
+                                </connections>
+                            </button>
                             <view hidden="YES" contentMode="scaleToFill" misplaced="YES" id="WlE-9f-0pQ">
                                 <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
@@ -138,6 +147,7 @@
                         <outlet property="btnNewCustomer" destination="VoO-EQ-M9h" id="U9J-M1-26G"/>
                         <outlet property="coverBG" destination="74h-ia-SzF" id="3El-ao-Ke2"/>
                         <outlet property="coverView" destination="WlE-9f-0pQ" id="WdQ-tM-RPW"/>
+                        <outlet property="debugBtn" destination="bur-yb-Jpu" id="38c-aM-rKK"/>
                         <outlet property="ibSignin" destination="A9f-vj-ZDF" id="nwF-qz-pqH"/>
                         <outlet property="imageBG" destination="V7m-G1-ogb" id="yvL-Se-ZpI"/>
                         <outlet property="labelDocNumber" destination="KcS-q7-9pm" id="fNU-5d-StP"/>
@@ -391,11 +401,11 @@
                                         <rect key="frame" x="0.0" y="28" width="360" height="44"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="v4l-du-pTm" id="JkA-pY-NIV">
-                                            <rect key="frame" x="0.0" y="0.0" width="360" height="43.5"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="360" height="44"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Ofv-pg-h2w">
-                                                    <rect key="frame" x="15" y="0.0" width="330" height="43.5"/>
+                                                    <rect key="frame" x="15" y="0.0" width="330" height="43"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -517,7 +527,7 @@
                                         <rect key="frame" x="0.0" y="28" width="768" height="128"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KmC-hR-Rfo" id="twt-7p-gUd">
-                                            <rect key="frame" x="0.0" y="0.0" width="768" height="127.5"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="768" height="128"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="GE2016121201" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="eH3-OQ-M6Q">
@@ -831,18 +841,18 @@
                                         <rect key="frame" x="0.0" y="28" width="540" height="44"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="K5M-kB-Cox" id="8bB-hy-1xQ">
-                                            <rect key="frame" x="0.0" y="0.0" width="540" height="43.5"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="540" height="43"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="93T-5h-JKV">
-                                                    <rect key="frame" x="15" y="5" width="33.5" height="20.5"/>
+                                                    <rect key="frame" x="15" y="5" width="34" height="21"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="mtf-OD-AFL">
-                                                    <rect key="frame" x="15" y="25.5" width="44" height="14.5"/>
+                                                    <rect key="frame" x="15" y="26" width="44" height="14"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="12"/>
                                                     <nil key="textColor"/>
@@ -1139,7 +1149,7 @@
                                         <rect key="frame" x="0.0" y="28" width="768" height="44"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bC4-0A-Qjh" id="rna-0d-wd1">
-                                            <rect key="frame" x="0.0" y="0.0" width="768" height="43.5"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="768" height="44"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="GE2016121201" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5Tt-7m-QFz">
@@ -1230,12 +1240,80 @@
                             </button>
                             <view contentMode="scaleToFill" misplaced="YES" id="w7G-eF-IRC">
                                 <rect key="frame" x="26" y="696" width="717" height="308"/>
-                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                                 <subviews>
-                                    <stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" id="861-cb-EzK">
-                                        <rect key="frame" x="354" y="140" width="94" height="29"/>
+                                    <stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100000" id="861-cb-EzK">
+                                        <rect key="frame" x="147" y="56" width="94" height="29"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <connections>
+                                            <action selector="xStepperClick:" destination="IrJ-nO-Jqx" eventType="valueChanged" id="29M-XX-8zW"/>
+                                        </connections>
+                                    </stepper>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="X:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="36D-hz-mdm">
+                                        <rect key="frame" x="85" y="60" width="42" height="21"/>
                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <nil key="textColor"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                    <stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100000" id="kVq-yL-saL">
+                                        <rect key="frame" x="147" y="140" width="94" height="29"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <connections>
+                                            <action selector="wStepperClick:" destination="IrJ-nO-Jqx" eventType="valueChanged" id="yie-ft-cnp"/>
+                                        </connections>
+                                    </stepper>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="W:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1lA-wP-7Wy">
+                                        <rect key="frame" x="85" y="148" width="42" height="21"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <nil key="textColor"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                    <stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100000" id="iko-Xx-Khd">
+                                        <rect key="frame" x="500" y="56" width="94" height="29"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                        <connections>
+                                            <action selector="yStepperClick:" destination="IrJ-nO-Jqx" eventType="valueChanged" id="PLY-KM-dBk"/>
+                                        </connections>
+                                    </stepper>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Y:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="2bv-uD-Gfj">
+                                        <rect key="frame" x="442" y="60" width="42" height="21"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <nil key="textColor"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                    <stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100000" id="DTJ-6C-VP7">
+                                        <rect key="frame" x="500" y="144" width="94" height="29"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                        <connections>
+                                            <action selector="hStepperClick:" destination="IrJ-nO-Jqx" eventType="valueChanged" id="CAt-mf-dob"/>
+                                        </connections>
                                     </stepper>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="H:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="eK8-TQ-bhT">
+                                        <rect key="frame" x="450" y="148" width="42" height="21"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <nil key="textColor"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                    <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="w4q-z3-jFI">
+                                        <rect key="frame" x="322" y="56" width="46" height="30"/>
+                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
+                                        <state key="normal" title="Top"/>
+                                        <connections>
+                                            <action selector="topBtnClick:" destination="IrJ-nO-Jqx" eventType="touchUpInside" id="YrK-Jq-inA"/>
+                                        </connections>
+                                    </button>
+                                    <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="xPF-6R-x3J">
+                                        <rect key="frame" x="316" y="139" width="59" height="30"/>
+                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
+                                        <state key="normal" title="Bottom"/>
+                                        <connections>
+                                            <action selector="bottomBtnClick:" destination="IrJ-nO-Jqx" eventType="touchUpInside" id="NWZ-LQ-YIg"/>
+                                        </connections>
+                                    </button>
                                 </subviews>
                                 <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
                             </view>
@@ -1256,9 +1334,14 @@
                     </navigationItem>
                     <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
                     <connections>
+                        <outlet property="hStepper" destination="DTJ-6C-VP7" id="G8b-ar-HWN"/>
                         <outlet property="ibSave" destination="lAX-gb-VMT" id="KOn-7l-p52"/>
                         <outlet property="left_button" destination="YRy-cf-b04" id="3xH-Ve-tNp"/>
+                        <outlet property="positionControlBackground" destination="w7G-eF-IRC" id="ttu-7I-E79"/>
                         <outlet property="right_button" destination="tuM-sI-7IN" id="sVX-vn-m7h"/>
+                        <outlet property="wStepper" destination="kVq-yL-saL" id="46E-go-Kzf"/>
+                        <outlet property="xStepper" destination="861-cb-EzK" id="CUx-Ci-i5R"/>
+                        <outlet property="yStepper" destination="iko-Xx-Khd" id="suz-B6-D4P"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="83E-Gv-ZLo" userLabel="First Responder" sceneMemberID="firstResponder"/>

+ 1 - 1
Ants Contract/Granite Expo eSign/Granite Expo eSign.xcodeproj/xcuserdata/macmini1.xcuserdatad/xcschemes/eSign.xcscheme

@@ -42,7 +42,7 @@
       </AdditionalOptions>
    </TestAction>
    <LaunchAction
-      buildConfiguration = "Release"
+      buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"

+ 2 - 4
Ants Contract/Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.h

@@ -7,10 +7,8 @@
 //
 
 #import <UIKit/UIKit.h>
-typedef NS_ENUM(NSInteger, PDFEditAction) {
-    PDFEditActionNew = 0,
-    PDFEditActionModify = 1
-};
+#import "DocumentPageViewController.h"
+
 @interface DocumentTemplateViewController : UIViewController<UIPageViewControllerDelegate , UIPageViewControllerDataSource>
 @property (weak, nonatomic) IBOutlet UIButton *left_button;
 @property (weak, nonatomic) IBOutlet UIButton *right_button;

+ 124 - 2
Ants Contract/Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.m

@@ -30,14 +30,25 @@
 #import "TextDrawable.h"
 #import "ImageDrawable.h"
 #import "RectDrawable.h"
-@interface DocumentTemplateViewController ()
+@interface DocumentTemplateViewController () <TemplateUpdateControlFrame>
+
+@property (strong, nonatomic) IBOutlet UIView *positionControlBackground;
+@property (strong, nonatomic) IBOutlet UIStepper *xStepper;
+@property (strong, nonatomic) IBOutlet UIStepper *yStepper;
+@property (strong, nonatomic) IBOutlet UIStepper *wStepper;
+@property (strong, nonatomic) IBOutlet UIStepper *hStepper;
+
+
+@property (nonatomic,weak) UIView *focusView;
+@property (nonatomic,strong) UIColor *focusViewNormalColor;
+
+@property (nonatomic,strong) TemplateViewController *currentPageViewController;
 
 @end
 
 @implementation DocumentTemplateViewController
 
 
-
 - (IBAction)onLeftButtonClick:(id)sender {
     
     
@@ -232,6 +243,8 @@
     [self.view bringSubviewToFront:self.left_button];
     [self.view bringSubviewToFront:self.right_button];
     // Do any additional setup after loading the view.
+    
+    [self.view bringSubviewToFront:self.positionControlBackground];
 }
 -(void) dealloc
 {
@@ -473,6 +486,18 @@
 
 - (IBAction)onSaveClicked:(id)sender {
     
+    // save contro json
+
+    if (self.currentPageViewController) {
+        
+        TemplateViewController *vc = self.currentPageViewController;
+        NSDictionary *page = [vc updatePageControl];
+        self.controlTemplate[[NSString stringWithFormat:@"page_%lu",(unsigned long)vc.pageIndex]] = page;
+    }
+
+    
+    return;
+    
     [self EndEditing];
     if(self.no_save)
     {
@@ -970,6 +995,9 @@
      
      
      */
+    
+    TemplateViewController.controlUpdateDelegate = self;
+        
     return TemplateViewController;
 }
 
@@ -1232,6 +1260,100 @@
     //    return UIPageViewControllerSpineLocationMid;
 }
 
+#pragma mark - Position Update
+
+
+- (IBAction)topBtnClick:(UIButton *)sender {
+    
+    CGRect frame = self.positionControlBackground.frame;
+    frame.origin.y = 84.f;
+    self.positionControlBackground.frame = frame;
+    self.positionControlBackground.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
+    
+    
+}
+
+- (IBAction)bottomBtnClick:(UIButton *)sender {
+    
+    CGRect vcFrame = self.view.frame;
+    CGRect frame = self.positionControlBackground.frame;
+    frame.origin.y = vcFrame.size.height - 20.f - frame.size.height;
+    self.positionControlBackground.frame = frame;
+    self.positionControlBackground.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
+}
+
+- (IBAction)xStepperClick:(UIStepper *)sender {
+    CGRect frame = self.focusView.frame;
+    frame.origin.x = sender.value;
+    self.focusView.frame = frame;
+}
+
+- (IBAction)yStepperClick:(UIStepper *)sender {
+    CGRect frame = self.focusView.frame;
+    frame.origin.y = sender.value;
+    self.focusView.frame = frame;
+}
+
+- (IBAction)wStepperClick:(UIStepper *)sender {
+    CGRect frame = self.focusView.frame;
+    frame.size.width = sender.value;
+    self.focusView.frame = frame;
+}
+
+- (IBAction)hStepperClick:(UIStepper *)sender {
+    CGRect frame = self.focusView.frame;
+    frame.size.height = sender.value;
+    self.focusView.frame = frame;
+}
+
+
 
+#pragma mark - Control Update Delegate
+
+- (void)focusControlView:(UIView *)view {
+    
+    [self recoveryFocusView];
+    
+    self.focusView = view;
+    if (self.focusView != nil) {
+        
+        CGRect frame = self.focusView.frame;
+        
+        self.xStepper.value = frame.origin.x;
+        self.yStepper.value = frame.origin.y;
+        self.wStepper.value = frame.size.width;
+        self.hStepper.value = frame.size.height;
+        
+        self.focusViewNormalColor = self.focusView.backgroundColor;
+        self.focusView.backgroundColor = [UIColor redColor];
+        
+        if ([self.focusView isKindOfClass:[UIImageView class]]) {
+            UIImageView *iv = (UIImageView *)self.focusView;
+            UIImage *ig = iv.image;
+            if (ig) {
+                [iv setImage:[ig imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
+            }
+        }
+        
+    }
+}
+
+- (void)recoveryFocusView {
+    if (self.focusView) {
+        self.focusView.backgroundColor = self.focusViewNormalColor;
+        
+        if ([self.focusView isKindOfClass:[UIImageView class]]) {
+            UIImageView *iv = (UIImageView *)self.focusView;
+            UIImage *ig = iv.image;
+            if (ig) {
+                [iv setImage:[ig imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+            }
+        }
+    }
+}
+
+- (void)currentShowViewController:(TemplateViewController *)vc {
+    self.currentPageViewController = vc;
+}
 
 @end

+ 13 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.h

@@ -12,6 +12,15 @@
 //#import "EditControlView.h"
 #import "TouchImageView.h"
 
+@class TemplateViewController;
+
+@protocol TemplateUpdateControlFrame <NSObject>
+
+- (void)focusControlView:(UIView *)view;
+- (void)currentShowViewController:(TemplateViewController *) vc;
+
+@end
+
 @interface TemplateViewController : UIViewController<UITextViewDelegate,TouchImageViewDelegate>
 
 @property (strong, nonatomic) IBOutlet PDFPageView *pdfPageView;
@@ -34,5 +43,9 @@
 
 - (void)rotateView;
 
+@property (nonatomic,weak) id<TemplateUpdateControlFrame> controlUpdateDelegate;
+
+
+- (NSDictionary *)updatePageControl;
 
 @end

+ 159 - 4
Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.m

@@ -137,6 +137,10 @@ typedef enum {
         [self initControl];
     }
     [self.parentViewController.view layoutIfNeeded];
+    
+    if (self.controlUpdateDelegate) {
+        [self.controlUpdateDelegate currentShowViewController:self];
+    }
 }
 
 
@@ -507,7 +511,8 @@ typedef enum {
     [tv setFont:[UIFont systemFontOfSize:fontsize]];
     bool isdisable = [template[@"disable"] boolValue];
     
-    tv.editable = !isdisable;
+//    tv.editable = !isdisable;
+    tv.editable = true; // for update frame
     NSString* text= template[@"value"];
     if(text.length==0)
     text=@" ";
@@ -616,7 +621,6 @@ typedef enum {
     label.tag = index+ CONTROL_BASE;
     
     
-    
     //UIColorFromARGB(0x4066ccff);
     
     //    tv.backgroundColor = UIColorFromRGB(TV_BG);//[UIColor lightGrayColor];
@@ -633,6 +637,11 @@ typedef enum {
         [label setBackgroundColor:[UIColor grayColor]];
         
     }
+    
+    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
+    [label addGestureRecognizer:tap];
+    label.userInteractionEnabled = YES;
+    
     [destView addSubview:label];
 }
 
@@ -759,6 +768,9 @@ typedef enum {
             marker.backgroundColor= marker_bg;
         }
         
+        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
+        [marker addGestureRecognizer:tap];
+        
         [destView addSubview:marker];
         
     }
@@ -841,6 +853,11 @@ typedef enum {
         
         // [btn setBackgroundImage:[UIColor grayColor] forState:UIControlStateNormal];
     }
+    
+    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
+    [btn addGestureRecognizer:tap];
+    btn.userInteractionEnabled = YES;
+    
     [destView addSubview:btn];
 }
 #pragma mark UIScrollView delegate
@@ -876,6 +893,10 @@ typedef enum {
 #pragma mark Button Click
 - (void)ControlDatePickerClicked:(UIButton *)sender {
     
+    if (self.controlUpdateDelegate) {
+        [self.controlUpdateDelegate focusControlView:sender];
+        return;
+    }
     
     long index = sender.tag - CONTROL_BASE;
     
@@ -919,6 +940,12 @@ typedef enum {
     [self.navigationController pushViewController:dpvc animated:true];
 }
 - (void)ControlButtonClicked:(UIButton *)sender {
+    
+    if (self.controlUpdateDelegate) {
+        [self.controlUpdateDelegate focusControlView:sender];
+        return;
+    }
+    
     //    DebugLog(@"cart sort button clicked");
     
     NSLog(@"button clicked;");
@@ -927,6 +954,11 @@ typedef enum {
 - (void)CheckButtonClicked:(UIButton *)sender {
     //    DebugLog(@"cart sort button clicked");
     
+    if (self.controlUpdateDelegate) {
+        [self.controlUpdateDelegate focusControlView:sender];
+        return;
+    }
+    
     NSLog(@"check clicked;");
     
     long index = sender.tag - CONTROL_BASE;
@@ -995,7 +1027,8 @@ typedef enum {
                         NSString* s_idx =disable_arr[d];
                         s_idx=[s_idx stringByReplacingOccurrencesOfString:@"control_" withString:@""];
                         int d_idx = [s_idx intValue];
-                        ((UITextView*)[sender.superview viewWithTag:d_idx+CONTROL_BASE]).editable = false;
+//                        ((UITextView*)[sender.superview viewWithTag:d_idx+CONTROL_BASE]).editable = false;
+                        ((UITextView*)[sender.superview viewWithTag:d_idx+CONTROL_BASE]).editable = true; // for update frame
                     }
                     NSArray* enable_arr = action[@"enable"] ;
                     for(int e = 0 ; e<enable_arr.count;e++)
@@ -1345,7 +1378,10 @@ typedef enum {
 }
 - (BOOL)textViewShouldBeginEditing:(UITextView *)textView
 {
-    
+    if (self.controlUpdateDelegate) {
+        [self.controlUpdateDelegate focusControlView:textView];
+        return NO;
+    }
     NSLog(@"textViewShouldBeginEditing");
     
     
@@ -1556,6 +1592,9 @@ typedef enum {
 //touchimageview Delegate
 -(void) signature:(TouchImageView *)touchImageView
 {
+    
+    
+    
     __weak __typeof(self)weakSelf = self;
     
     
@@ -1756,6 +1795,12 @@ typedef enum {
 - (void)TouchImageViewOnTouche:(TouchImageView *)touchImageView
 {
     
+    if (self.controlUpdateDelegate) {
+        [self.controlUpdateDelegate focusControlView:touchImageView];
+        return;
+    }
+
+    
     NSLog(@"signature button clicked;");
     
     //
@@ -2050,6 +2095,116 @@ typedef enum {
     //  [self moveInputBarWithKeyboardHeight:0.0 withDuration:animationDuration];
 }
 
+#pragma mark - Update Control 
+
+- (void)tapRecognizer:(UITapGestureRecognizer *)recognizer {
+    UIView *v = recognizer.view;
+    if (self.controlUpdateDelegate) {
+        [self.controlUpdateDelegate focusControlView:v];
+    }
+}
+
+- (NSDictionary *)updatePageControl {
+    
+    int count = [self.page_controlTemplate[@"count"] intValue];
+    for(int i=0;i<count;i++)
+    {
+        NSMutableDictionary * control = [self.page_controlTemplate [[NSString stringWithFormat:@"control_%d",i]] mutableCopy];
+        if (control == nil) {
+            continue;
+        }
+        
+        int tag = i + CONTROL_BASE;
+        UIView *v = [self.editControlView viewWithTag:tag];
+        if (v == nil) {
+            continue;
+        }
+        
 
+        CGRect frame = [self scaleControl:v.frame from:self.editControlView.bounds.size to:CGSizeMake(768, 960.5)];
+        
+        CGFloat x = frame.origin.x;
+        CGFloat y = frame.origin.y;
+        CGFloat w = frame.size.width;
+        CGFloat h = frame.size.height;
+        
+        [control setValue:@(x) forKey:@"pos_x"];
+        [control setValue:@(y) forKey:@"pos_y"];
+        [control setValue:@(w) forKey:@"width"];
+        [control setValue:@(h) forKey:@"height"];
+        
+        
+        if([control[@"type"] isEqualToString:@"TextView"])
+        {
+            
+        }
+        else if([control[@"type"] isEqualToString:@"Button"])
+        {
+            
+            
+        }
+        else if([control[@"type"] isEqualToString:@"Check"])
+        {
+           NSMutableArray* cadedate = [control[@"cadedate"] mutableCopy];
+            for(int k = 0; k < cadedate.count; k++)
+            {
+                
+                NSMutableArray* item = [cadedate[k] mutableCopy];
+                NSMutableArray* checkmarker = [item[1] mutableCopy];
+                if(checkmarker.count==0)
+                {
+                    continue;
+                } else {
+                    UIView *marker = [v viewWithTag:CHECK_BASE + i * 1000 + k];
+                    if (marker == nil) {
+                        continue;
+                    }
+                    
+                    CGRect marker_frame = [self scaleControl:marker.frame from:self.editControlView.bounds.size to:CGSizeMake(768, 960.5)];
+                    
+                    CGFloat marker_x = marker_frame.origin.x;
+                    CGFloat marker_y = marker_frame.origin.y;
+                    CGFloat marker_w = marker_frame.size.width;
+                    CGFloat marker_h = marker_frame.size.height;
+                    
+                    [checkmarker replaceObjectAtIndex:0 withObject:@(marker_x)];
+                    [checkmarker replaceObjectAtIndex:1 withObject:@(marker_y)];
+                    
+                    [item replaceObjectAtIndex:1 withObject:checkmarker];
+                    
+                    [cadedate replaceObjectAtIndex:k withObject:item];
+                }
+                
+                
+            }
+            [control setObject:cadedate forKey:@"cadedate"];
+            
+        }
+        else if([control[@"type"] isEqualToString:@"Signature"])
+        {
+            
+            
+        }
+        else if([control[@"type"] isEqualToString:@"Image"])
+        {
+            
+            
+        }
+        else if([control[@"type"] isEqualToString:@"Label"])
+        {
+            
+            
+        }
+        else if([control[@"type"] isEqualToString:@"DatePicker"])
+        {
+            
+        }
+        
+        [self.page_controlTemplate setObject:control forKey:[NSString stringWithFormat:@"control_%d",i]];
+    }
+
+    
+    return self.page_controlTemplate;
+}
 
 @end

+ 1 - 1
Ants Contract/Granite Expo eSign/Granite Expo eSign/config.h

@@ -23,7 +23,7 @@
     #define NO_SAVE_VERIFY false
 # endif
 
-#define DEBUG_PDFSIG false
+#define DEBUG_PDFSIG true
 
 #define PDF_DEBUG false
 

+ 1 - 0
Ants Contract/common/RootViewController.h

@@ -25,6 +25,7 @@
 @property (weak, nonatomic) IBOutlet UILabel *labelMode;
 @property (weak, nonatomic) IBOutlet UISwitch *switchMode;
 @property (strong, nonatomic) IBOutlet UILabel *labelDocNumber;
+@property (strong, nonatomic) IBOutlet UIButton *debugBtn;
 
 - (void)dealWithUILogout;
 

+ 20 - 1
Ants Contract/common/RootViewController.m

@@ -19,6 +19,8 @@
 #import "ACNetwork.h"
 #import "PDFUtils.h"
 #import "AddExtDocumentViewController.h"
+#import "config.h"
+#import "DocumentTemplateViewController.h"
 
 @interface RootViewController ()
 
@@ -44,7 +46,7 @@
     NSString* versionNum = [NSString stringWithFormat:@"VeS1.%@.%@",version,build];
     self.labelVer.text = versionNum;
     
-    
+    self.debugBtn.hidden = !DEBUG_PDFSIG;
     
     
      // Do any additional setup after loading the view, typically from a nib.
@@ -704,6 +706,23 @@
 //    [self.navigationController pushViewController:dvc animated:true];
 //}
 
+- (IBAction)debugBtnClick:(UIButton *)sender {
+    
+    DocumentTemplateViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentTemplateViewController" ];
+    
+    dvc.templatePath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop.json" ofType:nil];
+    dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop.pdf" ofType:nil];
+    
+    dvc.docment_id =  @"debug_template";
+    dvc.OnSave=^(NSString* file, NSString* subject)
+    {
+        
+        
+    };
+    
+    [self.navigationController pushViewController:dvc animated:true];
+    
+}
 
 
 @end