Ver Fonte

1.修改Esign Templat增加Item设置,及其增删。

Pen Li há 8 anos atrás
pai
commit
ad986d1c83
31 ficheiros alterados com 2580 adições e 162 exclusões
  1. BIN
      Ants Contract/AntsContract.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate
  2. 289 90
      Ants Contract/AntsContract/AntsContract/Base.lproj/Main.storyboard
  3. 106 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign.xcodeproj/project.pbxproj
  4. 7 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.h
  5. 246 2
      Ants Contract/Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.m
  6. 16 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeLabelCell.h
  7. 46 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeLabelCell.m
  8. 18 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeSwitchCell.h
  9. 52 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeSwitchCell.m
  10. 31 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTableDataSourceAndDelegate.h
  11. 303 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTableDataSourceAndDelegate.m
  12. 21 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTextFieldCell.h
  13. 64 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTextFieldCell.m
  14. 18 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateCell.h
  15. 42 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateCell.m
  16. 43 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateCell.xib
  17. 32 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateVC.h
  18. 70 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateVC.m
  19. 43 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateVC.xib
  20. 20 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ItemTableDataSourceAndDelegate.h
  21. 222 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ItemTableDataSourceAndDelegate.m
  22. 20 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageItemCell.h
  23. 50 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageItemCell.m
  24. 15 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageSubItemCell.h
  25. 35 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageSubItemCell.m
  26. 6 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.h
  27. 317 69
      Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.m
  28. 1 1
      Ants Contract/Granite Expo eSign/Granite Expo eSign/config.h
  29. 277 0
      Ants Contract/Granite Expo eSign/attribute_template.json
  30. 136 0
      Ants Contract/Granite Expo eSign/template_example.json
  31. 34 0
      Ants Contract/Granite Expo eSign/template_type.json

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


+ 289 - 90
Ants Contract/AntsContract/AntsContract/Base.lproj/Main.storyboard

@@ -1267,117 +1267,307 @@ textAlignment</string>
                                 </connections>
                             </button>
                             <view contentMode="scaleToFill" misplaced="YES" id="w7G-eF-IRC">
-                                <rect key="frame" x="26" y="696" width="717" height="308"/>
+                                <rect key="frame" x="26" y="667" width="717" height="337"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                                 <subviews>
-                                    <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="187" y="57" 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="79" 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="187" 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="79" 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="543" y="55" 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="429" 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="543" y="139" 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="429" 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"/>
+                                        <rect key="frame" x="335" y="45" 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="clc-xQ-3KH">
+                                        <rect key="frame" x="335" y="153" width="46" height="30"/>
+                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+                                        <state key="normal" title="OK"/>
+                                        <connections>
+                                            <action selector="okBtnClick:" destination="IrJ-nO-Jqx" eventType="touchUpInside" id="PSG-BJ-fVB"/>
+                                        </connections>
+                                    </button>
+                                    <view contentMode="scaleToFill" misplaced="YES" id="3aC-Hd-ZLw">
+                                        <rect key="frame" x="398" y="8" width="310" height="320"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES" flexibleMaxY="YES"/>
+                                        <subviews>
+                                            <tableView clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="0mh-T6-q54">
+                                                <rect key="frame" x="5" y="176" width="300" height="139"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                <prototypes>
+                                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="textfield_cell_identifier" rowHeight="40" id="9Ik-wx-I7e" customClass="AttributeTextFieldCell">
+                                                        <rect key="frame" x="0.0" y="28" width="300" height="40"/>
+                                                        <autoresizingMask key="autoresizingMask"/>
+                                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="9Ik-wx-I7e" id="ZJs-5D-8bY">
+                                                            <rect key="frame" x="0.0" y="0.0" width="300" height="39.5"/>
+                                                            <autoresizingMask key="autoresizingMask"/>
+                                                            <subviews>
+                                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="auj-ke-v6b">
+                                                                    <rect key="frame" x="8" y="8" width="105" height="21"/>
+                                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                                    <nil key="textColor"/>
+                                                                    <nil key="highlightedColor"/>
+                                                                </label>
+                                                                <textField opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="97X-Ic-sbD">
+                                                                    <rect key="frame" x="127" y="4" width="165" height="30"/>
+                                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                                    <nil key="textColor"/>
+                                                                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                                    <textInputTraits key="textInputTraits"/>
+                                                                    <connections>
+                                                                        <outlet property="delegate" destination="9Ik-wx-I7e" id="dnZ-aU-AaG"/>
+                                                                    </connections>
+                                                                </textField>
+                                                            </subviews>
+                                                        </tableViewCellContentView>
+                                                        <connections>
+                                                            <outlet property="name_lb" destination="auj-ke-v6b" id="8Qk-iU-Yqm"/>
+                                                            <outlet property="value_tf" destination="97X-Ic-sbD" id="tbv-3V-nMS"/>
+                                                        </connections>
+                                                    </tableViewCell>
+                                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="label_cell_identifier" rowHeight="40" id="ES2-nV-P7X" customClass="AttributeLabelCell">
+                                                        <rect key="frame" x="0.0" y="68" width="300" height="40"/>
+                                                        <autoresizingMask key="autoresizingMask"/>
+                                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ES2-nV-P7X" id="5cN-ns-rLy">
+                                                            <rect key="frame" x="0.0" y="0.0" width="300" height="39.5"/>
+                                                            <autoresizingMask key="autoresizingMask"/>
+                                                            <subviews>
+                                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Zgm-KO-IDv">
+                                                                    <rect key="frame" x="8" y="8" width="105" height="21"/>
+                                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                                    <nil key="textColor"/>
+                                                                    <nil key="highlightedColor"/>
+                                                                </label>
+                                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="T5j-QE-4gb">
+                                                                    <rect key="frame" x="127" y="8" width="165" height="21"/>
+                                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                                    <nil key="textColor"/>
+                                                                    <nil key="highlightedColor"/>
+                                                                </label>
+                                                            </subviews>
+                                                        </tableViewCellContentView>
+                                                        <connections>
+                                                            <outlet property="name_lb" destination="Zgm-KO-IDv" id="me8-ee-FuW"/>
+                                                            <outlet property="value_lb" destination="T5j-QE-4gb" id="JRa-Jw-CDv"/>
+                                                        </connections>
+                                                    </tableViewCell>
+                                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="switch_cell_identifier" rowHeight="40" id="Hfp-lV-yMb" customClass="AttributeSwitchCell">
+                                                        <rect key="frame" x="0.0" y="108" width="300" height="40"/>
+                                                        <autoresizingMask key="autoresizingMask"/>
+                                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Hfp-lV-yMb" id="A8G-jm-GXE">
+                                                            <rect key="frame" x="0.0" y="0.0" width="300" height="39.5"/>
+                                                            <autoresizingMask key="autoresizingMask"/>
+                                                            <subviews>
+                                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="JNH-uj-UCE">
+                                                                    <rect key="frame" x="8" y="8" width="193" height="21"/>
+                                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                                    <nil key="textColor"/>
+                                                                    <nil key="highlightedColor"/>
+                                                                </label>
+                                                                <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" id="JEK-Qx-uyl">
+                                                                    <rect key="frame" x="245" y="4" width="49" height="31"/>
+                                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                                    <connections>
+                                                                        <action selector="clickedSwitch:" destination="Hfp-lV-yMb" eventType="valueChanged" id="XgO-JO-DCN"/>
+                                                                    </connections>
+                                                                </switch>
+                                                            </subviews>
+                                                        </tableViewCellContentView>
+                                                        <connections>
+                                                            <outlet property="name_lb" destination="JNH-uj-UCE" id="Qsz-bH-gXf"/>
+                                                            <outlet property="value_sw" destination="JEK-Qx-uyl" id="Xb4-J7-egh"/>
+                                                        </connections>
+                                                    </tableViewCell>
+                                                </prototypes>
+                                                <sections/>
+                                            </tableView>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Position &amp; Size" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="6GW-g5-PZw">
+                                                <rect key="frame" x="0.0" y="0.0" width="310" height="29"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
+                                                <color key="backgroundColor" red="0.62487856217616589" green="0.45716323151814503" blue="0.11462453076408766" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                <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="861-cb-EzK">
+                                                <rect key="frame" x="157" y="29" 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="9" y="37" width="59" height="21"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                <nil key="textColor"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="tGg-qJ-1DB">
+                                                <rect key="frame" x="83" y="29" width="72" height="30"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                <nil key="textColor"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
+                                            </textField>
+                                            <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="157" y="66" 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>
+                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="PFg-fR-Jk8">
+                                                <rect key="frame" x="83" y="67" width="72" height="30"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                                <nil key="textColor"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
+                                            </textField>
+                                            <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="9" y="70" width="59" 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="157" y="133" 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>
+                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="M9N-a4-XH5">
+                                                <rect key="frame" x="82" y="133" width="72" height="30"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                                <nil key="textColor"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
+                                            </textField>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Hight:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="eK8-TQ-bhT">
+                                                <rect key="frame" x="8" y="137" width="59" height="21"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                <nil key="textColor"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Width:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1lA-wP-7Wy">
+                                                <rect key="frame" x="9" y="102" width="59" 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="157" y="99" 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>
+                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="KEu-MW-Ik7">
+                                                <rect key="frame" x="83" y="99" width="72" height="30"/>
+                                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                <nil key="textColor"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
+                                            </textField>
+                                        </subviews>
+                                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                    </view>
+                                    <tableView clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="VY6-LU-Lsa">
+                                        <rect key="frame" x="8" y="50" width="310" height="275"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                        <prototypes>
+                                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="item_cell" rowHeight="40" id="Sis-8R-Rqy" customClass="PageItemCell">
+                                                <rect key="frame" x="0.0" y="28" width="310" height="40"/>
+                                                <autoresizingMask key="autoresizingMask"/>
+                                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Sis-8R-Rqy" id="iqu-NN-xx0">
+                                                    <rect key="frame" x="0.0" y="0.0" width="310" height="39.5"/>
+                                                    <autoresizingMask key="autoresizingMask"/>
+                                                    <subviews>
+                                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Mdq-JU-ssw">
+                                                            <rect key="frame" x="10" y="5" width="292" height="30"/>
+                                                            <autoresizingMask key="autoresizingMask" flexibleMaxX="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="WQo-9f-1k4">
+                                                            <rect key="frame" x="0.0" y="0.0" width="310" height="40"/>
+                                                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                            <connections>
+                                                                <action selector="itemClicked:" destination="Sis-8R-Rqy" eventType="touchUpInside" id="mMd-0Z-cRP"/>
+                                                            </connections>
+                                                        </button>
+                                                        <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="alp-xq-Jp8">
+                                                            <rect key="frame" x="279" y="5" width="31" height="30"/>
+                                                            <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                                            <fontDescription key="fontDescription" type="system" pointSize="22"/>
+                                                            <state key="normal" title="+"/>
+                                                            <connections>
+                                                                <action selector="addCheckBtnClick:" destination="Sis-8R-Rqy" eventType="touchUpInside" id="efg-vt-lTD"/>
+                                                            </connections>
+                                                        </button>
+                                                    </subviews>
+                                                </tableViewCellContentView>
+                                                <connections>
+                                                    <outlet property="addCheckBtn" destination="alp-xq-Jp8" id="WWS-mG-aKv"/>
+                                                    <outlet property="title_lb" destination="Mdq-JU-ssw" id="Qwd-2T-Orf"/>
+                                                </connections>
+                                            </tableViewCell>
+                                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="subitem_cell" rowHeight="40" id="sg5-Io-RFc" customClass="PageSubItemCell">
+                                                <rect key="frame" x="0.0" y="68" width="310" height="40"/>
+                                                <autoresizingMask key="autoresizingMask"/>
+                                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="sg5-Io-RFc" id="XEY-QN-oaW">
+                                                    <rect key="frame" x="0.0" y="0.0" width="310" height="39.5"/>
+                                                    <autoresizingMask key="autoresizingMask"/>
+                                                    <subviews>
+                                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="J6C-LZ-uuu">
+                                                            <rect key="frame" x="30" y="5" width="266" height="30"/>
+                                                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                            <nil key="textColor"/>
+                                                            <nil key="highlightedColor"/>
+                                                        </label>
+                                                    </subviews>
+                                                </tableViewCellContentView>
+                                                <connections>
+                                                    <outlet property="title_lb" destination="J6C-LZ-uuu" id="SUq-8A-O0r"/>
+                                                </connections>
+                                            </tableViewCell>
+                                        </prototypes>
+                                    </tableView>
                                     <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"/>
+                                        <rect key="frame" x="329" y="268" 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>
-                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="tGg-qJ-1DB">
-                                        <rect key="frame" x="113" y="57" width="72" height="30"/>
+                                    <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="rDo-Ii-pob">
+                                        <rect key="frame" x="8" y="8" width="96" height="30"/>
                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                        <nil key="textColor"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                                        <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
-                                    </textField>
-                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="KEu-MW-Ik7">
-                                        <rect key="frame" x="113" y="140" width="72" height="30"/>
+                                        <state key="normal" title="Add Control"/>
+                                        <connections>
+                                            <action selector="addControlBtnClick:" destination="IrJ-nO-Jqx" eventType="touchUpInside" id="D64-qy-ZcN"/>
+                                        </connections>
+                                    </button>
+                                    <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="GZQ-fB-eTn">
+                                        <rect key="frame" x="208" y="8" width="110" height="30"/>
                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                        <nil key="textColor"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                                        <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
-                                    </textField>
-                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="PFg-fR-Jk8">
-                                        <rect key="frame" x="468" y="54" width="72" height="30"/>
-                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
-                                        <nil key="textColor"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                                        <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
-                                    </textField>
-                                    <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="clc-xQ-3KH">
-                                        <rect key="frame" x="591" y="245" width="46" height="30"/>
-                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
-                                        <state key="normal" title="OK"/>
+                                        <state key="normal" title="Delete Control"/>
                                         <connections>
-                                            <action selector="okBtnClick:" destination="IrJ-nO-Jqx" eventType="touchUpInside" id="PSG-BJ-fVB"/>
+                                            <action selector="deleteControlBtnClick:" destination="IrJ-nO-Jqx" eventType="touchUpInside" id="wp2-SZ-Ll8"/>
                                         </connections>
                                     </button>
-                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="M9N-a4-XH5">
-                                        <rect key="frame" x="468" y="139" width="72" height="30"/>
-                                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
-                                        <nil key="textColor"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                                        <textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
-                                    </textField>
                                 </subviews>
                                 <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
                             </view>
@@ -1398,9 +1588,11 @@ textAlignment</string>
                     </navigationItem>
                     <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
                     <connections>
+                        <outlet property="attributeTableView" destination="0mh-T6-q54" id="XkY-3l-SCq"/>
                         <outlet property="hStepper" destination="DTJ-6C-VP7" id="G8b-ar-HWN"/>
                         <outlet property="hTextField" destination="M9N-a4-XH5" id="8b0-Jh-9rs"/>
                         <outlet property="ibSave" destination="lAX-gb-VMT" id="KOn-7l-p52"/>
+                        <outlet property="itemTableView" destination="VY6-LU-Lsa" id="bbc-7t-HQQ"/>
                         <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"/>
@@ -1416,6 +1608,13 @@ textAlignment</string>
             </objects>
             <point key="canvasLocation" x="1217" y="1102"/>
         </scene>
+        <!--Storyboard Reference-->
+        <scene sceneID="Eie-eC-pRg">
+            <objects>
+                <viewControllerPlaceholder id="wlh-YI-tG6" sceneMemberID="viewController"/>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="Zlw-Wf-aee" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+        </scene>
     </scenes>
     <resources>
         <image name="NewDoc" width="100" height="100"/>

+ 106 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign.xcodeproj/project.pbxproj

@@ -7,6 +7,20 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		425A00F41F8F196900286D6F /* attribute_template.json in Resources */ = {isa = PBXBuildFile; fileRef = 425A00F31F8F0EC200286D6F /* attribute_template.json */; };
+		42D49E561F8DF13A00AE39D5 /* AttributeTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D49E551F8DF13A00AE39D5 /* AttributeTextFieldCell.m */; };
+		42D49E591F8DF15800AE39D5 /* AttributeLabelCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D49E581F8DF15800AE39D5 /* AttributeLabelCell.m */; };
+		42D49E5C1F8DF16B00AE39D5 /* AttributeSwitchCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D49E5B1F8DF16B00AE39D5 /* AttributeSwitchCell.m */; };
+		42D49E641F8DFA3100AE39D5 /* PageItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D49E631F8DFA3100AE39D5 /* PageItemCell.m */; };
+		42D49E671F8DFA4B00AE39D5 /* PageSubItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D49E661F8DFA4B00AE39D5 /* PageSubItemCell.m */; };
+		42D49E6C1F8DFF2D00AE39D5 /* ItemTableDataSourceAndDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D49E6B1F8DFF2D00AE39D5 /* ItemTableDataSourceAndDelegate.m */; };
+		42D49E721F8DFF5000AE39D5 /* AttributeTableDataSourceAndDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D49E711F8DFF5000AE39D5 /* AttributeTableDataSourceAndDelegate.m */; };
+		42DDB8741F91C081002CCE22 /* ControlTemplateVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 42DDB8721F91C081002CCE22 /* ControlTemplateVC.m */; };
+		42DDB8751F91C081002CCE22 /* ControlTemplateVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42DDB8731F91C081002CCE22 /* ControlTemplateVC.xib */; };
+		42DDB8791F91DCE8002CCE22 /* ControlTemplateCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42DDB8771F91DCE8002CCE22 /* ControlTemplateCell.m */; };
+		42DDB87A1F91DCE8002CCE22 /* ControlTemplateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42DDB8781F91DCE8002CCE22 /* ControlTemplateCell.xib */; };
+		42DDB87C1F91E367002CCE22 /* template_type.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DDB87B1F91E351002CCE22 /* template_type.json */; };
+		42DDB87E1F91E949002CCE22 /* template_example.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DDB87D1F91E940002CCE22 /* template_example.json */; };
 		7108773C1F79DACE00C18B95 /* PageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7108773B1F79DACE00C18B95 /* PageViewController.m */; };
 		7115D4271E13B70C00EF4E4C /* DocumentListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7115D4261E13B70C00EF4E4C /* DocumentListViewController.m */; };
 		7115D42A1E14DE0A00EF4E4C /* DocListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7115D4291E14DE0A00EF4E4C /* DocListTableViewCell.m */; };
@@ -80,6 +94,29 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		425A00F31F8F0EC200286D6F /* attribute_template.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = attribute_template.json; sourceTree = "<group>"; };
+		42D49E541F8DF13A00AE39D5 /* AttributeTextFieldCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AttributeTextFieldCell.h; sourceTree = "<group>"; };
+		42D49E551F8DF13A00AE39D5 /* AttributeTextFieldCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AttributeTextFieldCell.m; sourceTree = "<group>"; };
+		42D49E571F8DF15800AE39D5 /* AttributeLabelCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AttributeLabelCell.h; sourceTree = "<group>"; };
+		42D49E581F8DF15800AE39D5 /* AttributeLabelCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AttributeLabelCell.m; sourceTree = "<group>"; };
+		42D49E5A1F8DF16B00AE39D5 /* AttributeSwitchCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AttributeSwitchCell.h; sourceTree = "<group>"; };
+		42D49E5B1F8DF16B00AE39D5 /* AttributeSwitchCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AttributeSwitchCell.m; sourceTree = "<group>"; };
+		42D49E621F8DFA3100AE39D5 /* PageItemCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PageItemCell.h; sourceTree = "<group>"; };
+		42D49E631F8DFA3100AE39D5 /* PageItemCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PageItemCell.m; sourceTree = "<group>"; };
+		42D49E651F8DFA4B00AE39D5 /* PageSubItemCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PageSubItemCell.h; sourceTree = "<group>"; };
+		42D49E661F8DFA4B00AE39D5 /* PageSubItemCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PageSubItemCell.m; sourceTree = "<group>"; };
+		42D49E6A1F8DFF2D00AE39D5 /* ItemTableDataSourceAndDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ItemTableDataSourceAndDelegate.h; sourceTree = "<group>"; };
+		42D49E6B1F8DFF2D00AE39D5 /* ItemTableDataSourceAndDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ItemTableDataSourceAndDelegate.m; sourceTree = "<group>"; };
+		42D49E701F8DFF5000AE39D5 /* AttributeTableDataSourceAndDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AttributeTableDataSourceAndDelegate.h; sourceTree = "<group>"; };
+		42D49E711F8DFF5000AE39D5 /* AttributeTableDataSourceAndDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AttributeTableDataSourceAndDelegate.m; sourceTree = "<group>"; };
+		42DDB8711F91C081002CCE22 /* ControlTemplateVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ControlTemplateVC.h; sourceTree = "<group>"; };
+		42DDB8721F91C081002CCE22 /* ControlTemplateVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ControlTemplateVC.m; sourceTree = "<group>"; };
+		42DDB8731F91C081002CCE22 /* ControlTemplateVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ControlTemplateVC.xib; sourceTree = "<group>"; };
+		42DDB8761F91DCE8002CCE22 /* ControlTemplateCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ControlTemplateCell.h; sourceTree = "<group>"; };
+		42DDB8771F91DCE8002CCE22 /* ControlTemplateCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ControlTemplateCell.m; sourceTree = "<group>"; };
+		42DDB8781F91DCE8002CCE22 /* ControlTemplateCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ControlTemplateCell.xib; sourceTree = "<group>"; };
+		42DDB87B1F91E351002CCE22 /* template_type.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = template_type.json; sourceTree = "<group>"; };
+		42DDB87D1F91E940002CCE22 /* template_example.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = template_example.json; sourceTree = "<group>"; };
 		7108773A1F79DACD00C18B95 /* PageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PageViewController.h; path = ../../common/PageViewController.h; sourceTree = "<group>"; };
 		7108773B1F79DACE00C18B95 /* PageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PageViewController.m; path = ../../common/PageViewController.m; sourceTree = "<group>"; };
 		7115D4251E13B70C00EF4E4C /* DocumentListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DocumentListViewController.h; path = ../../common/DocumentListViewController.h; sourceTree = "<group>"; };
@@ -226,6 +263,57 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		42D49E531F8DF08400AE39D5 /* Template Attributes  */ = {
+			isa = PBXGroup;
+			children = (
+				42DDB8701F91C055002CCE22 /* Control Template */,
+				42D49E691F8DFA6C00AE39D5 /* Page */,
+				42D49E681F8DFA5800AE39D5 /* Attribute */,
+			);
+			path = "Template Attributes ";
+			sourceTree = "<group>";
+		};
+		42D49E681F8DFA5800AE39D5 /* Attribute */ = {
+			isa = PBXGroup;
+			children = (
+				42D49E541F8DF13A00AE39D5 /* AttributeTextFieldCell.h */,
+				42D49E551F8DF13A00AE39D5 /* AttributeTextFieldCell.m */,
+				42D49E571F8DF15800AE39D5 /* AttributeLabelCell.h */,
+				42D49E581F8DF15800AE39D5 /* AttributeLabelCell.m */,
+				42D49E5A1F8DF16B00AE39D5 /* AttributeSwitchCell.h */,
+				42D49E5B1F8DF16B00AE39D5 /* AttributeSwitchCell.m */,
+				42D49E701F8DFF5000AE39D5 /* AttributeTableDataSourceAndDelegate.h */,
+				42D49E711F8DFF5000AE39D5 /* AttributeTableDataSourceAndDelegate.m */,
+			);
+			name = Attribute;
+			sourceTree = "<group>";
+		};
+		42D49E691F8DFA6C00AE39D5 /* Page */ = {
+			isa = PBXGroup;
+			children = (
+				42D49E621F8DFA3100AE39D5 /* PageItemCell.h */,
+				42D49E631F8DFA3100AE39D5 /* PageItemCell.m */,
+				42D49E651F8DFA4B00AE39D5 /* PageSubItemCell.h */,
+				42D49E661F8DFA4B00AE39D5 /* PageSubItemCell.m */,
+				42D49E6A1F8DFF2D00AE39D5 /* ItemTableDataSourceAndDelegate.h */,
+				42D49E6B1F8DFF2D00AE39D5 /* ItemTableDataSourceAndDelegate.m */,
+			);
+			name = Page;
+			sourceTree = "<group>";
+		};
+		42DDB8701F91C055002CCE22 /* Control Template */ = {
+			isa = PBXGroup;
+			children = (
+				42DDB8711F91C081002CCE22 /* ControlTemplateVC.h */,
+				42DDB8721F91C081002CCE22 /* ControlTemplateVC.m */,
+				42DDB8731F91C081002CCE22 /* ControlTemplateVC.xib */,
+				42DDB8761F91DCE8002CCE22 /* ControlTemplateCell.h */,
+				42DDB8771F91DCE8002CCE22 /* ControlTemplateCell.m */,
+				42DDB8781F91DCE8002CCE22 /* ControlTemplateCell.xib */,
+			);
+			name = "Control Template";
+			sourceTree = "<group>";
+		};
 		7115D4241E13B32800EF4E4C /* customerUI */ = {
 			isa = PBXGroup;
 			children = (
@@ -258,6 +346,7 @@
 		7128C23D1E124F4500FF635B /* Granite Expo eSign */ = {
 			isa = PBXGroup;
 			children = (
+				42D49E531F8DF08400AE39D5 /* Template Attributes  */,
 				71B152F11E67E86C00D2E5EC /* cam scan */,
 				7128C24A1E124F4500FF635B /* Assets.xcassets */,
 				7128C3241E1251D000FF635B /* config.h */,
@@ -450,6 +539,9 @@
 				713B9AE61F8C941B002F8E8B /* GEIC - Home Improvement Contract 2017 Desktop_2.pdf */,
 				71D5734E1F723260008179ED /* GEIC - Home Improvement Contract 2017 Desktop.json */,
 				714B870A1E24CAE200A40D18 /* debug.json */,
+				425A00F31F8F0EC200286D6F /* attribute_template.json */,
+				42DDB87B1F91E351002CCE22 /* template_type.json */,
+				42DDB87D1F91E940002CCE22 /* template_example.json */,
 			);
 			name = "pdf resource";
 			sourceTree = "<group>";
@@ -535,15 +627,20 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				42DDB87E1F91E949002CCE22 /* template_example.json in Resources */,
+				42DDB87C1F91E367002CCE22 /* template_type.json in Resources */,
+				425A00F41F8F196900286D6F /* attribute_template.json in Resources */,
 				713B9AE71F8C9446002F8E8B /* GEIC - Home Improvement Contract 2017 Desktop_2.pdf in Resources */,
 				71D5734F1F723260008179ED /* GEIC - Home Improvement Contract 2017 Desktop.json in Resources */,
 				7128C24B1E124F4500FF635B /* Assets.xcassets in Resources */,
 				7128C26F1E124FF200FF635B /* Main.storyboard in Resources */,
 				7128C2701E124FF200FF635B /* LaunchScreen.storyboard in Resources */,
 				7188C2891E8E435500938FFC /* GEIC - Home Improvement Contract 2017 Update.json in Resources */,
+				42DDB87A1F91DCE8002CCE22 /* ControlTemplateCell.xib in Resources */,
 				7115D45F1E16326C00EF4E4C /* CommonEditor.storyboard in Resources */,
 				7128C27D1E12500B00FF635B /* signature.storyboard in Resources */,
 				7128C2E81E12511B00FF635B /* LICENSE in Resources */,
+				42DDB8751F91C081002CCE22 /* ControlTemplateVC.xib in Resources */,
 				714B870B1E24CAE300A40D18 /* debug.json in Resources */,
 				714B37081E70FCFE00E99B90 /* cam_scan.storyboard in Resources */,
 			);
@@ -567,17 +664,22 @@
 				7128C33A1E12540F00FF635B /* ACNetwork.m in Sources */,
 				7128C2B71E1250CA00FF635B /* RectDrawable.m in Sources */,
 				71BBFC3A1E651CC4008668A7 /* DocnotesViewController.m in Sources */,
+				42D49E591F8DF15800AE39D5 /* AttributeLabelCell.m in Sources */,
 				7128C2D91E12510900FF635B /* mztools.c in Sources */,
 				714A9AEF1E9CADA100371995 /* PendingDocumentsTableViewCell.m in Sources */,
 				7128C2EB1E12511B00FF635B /* NSString+Base64.m in Sources */,
 				7128C2B31E1250CA00FF635B /* BasicDrawable.m in Sources */,
 				7128C2C71E1250FC00FF635B /* PDFUtils.m in Sources */,
 				717243441E1CCCEC00800678 /* CustomIOSAlertView.m in Sources */,
+				42D49E6C1F8DFF2D00AE39D5 /* ItemTableDataSourceAndDelegate.m in Sources */,
 				7128C3541E12548C00FF635B /* RAPDFScrollView.m in Sources */,
 				7128C3411E12542000FF635B /* LoginViewController.m in Sources */,
 				713B97B11F79E0CB002B86BF /* dbgPageVC.m in Sources */,
 				7128C3461E12545C00FF635B /* CheckSelectorViewController.m in Sources */,
+				42D49E721F8DFF5000AE39D5 /* AttributeTableDataSourceAndDelegate.m in Sources */,
+				42DDB8791F91DCE8002CCE22 /* ControlTemplateCell.m in Sources */,
 				7128C2B81E1250CA00FF635B /* LineDrawable.m in Sources */,
+				42D49E641F8DFA3100AE39D5 /* PageItemCell.m in Sources */,
 				7128C2DB1E12510900FF635B /* zip.c in Sources */,
 				7128C2C91E1250FC00FF635B /* Reachability.m in Sources */,
 				7128C27C1E12500B00FF635B /* SignatureViewController.m in Sources */,
@@ -587,10 +689,14 @@
 				7128C2B51E1250CA00FF635B /* GroupDrawable.m in Sources */,
 				714A9AEC1E9CA92000371995 /* PendingDocumentsViewController.m in Sources */,
 				7128C28E1E12501B00FF635B /* TouchImageView.m in Sources */,
+				42D49E5C1F8DF16B00AE39D5 /* AttributeSwitchCell.m in Sources */,
 				7128C2B41E1250CA00FF635B /* GridDrawable.m in Sources */,
 				71CDA0931F75EEBF0079F8E6 /* TemplateViewController.m in Sources */,
+				42D49E561F8DF13A00AE39D5 /* AttributeTextFieldCell.m in Sources */,
 				7115D4561E1606F700EF4E4C /* GEContractFilterViewController.m in Sources */,
 				7128C2DA1E12510900FF635B /* unzip.c in Sources */,
+				42D49E671F8DFA4B00AE39D5 /* PageSubItemCell.m in Sources */,
+				42DDB8741F91C081002CCE22 /* ControlTemplateVC.m in Sources */,
 				71CDA0901F75EE400079F8E6 /* DocumentTemplateViewController.m in Sources */,
 				7128C2981E12504300FF635B /* RAPDFViewController.m in Sources */,
 				7128C2CB1E1250FC00FF635B /* RAUtils.m in Sources */,

+ 7 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.h

@@ -30,4 +30,11 @@
 @property (nonatomic , copy) void (^OnSave)(NSString * file, NSString* subject );
 @property (assign) PDFEditAction action;
 
+- (void)clickItem:(NSInteger)tag;
+
+- (void)selectControl:(NSDictionary *)controlItem index:(NSInteger)index;
+- (void)selectCheck:(NSDictionary *)controlItem Section:(NSInteger)section Row:(NSInteger)row;
+- (void)updatePageControlProperty:(NSDictionary *)control_dic forIndex:(NSInteger)index Row:(NSInteger)row updateItemList:(BOOL)updateItemList;
+- (void)deleteCheckItemAtSection:(NSInteger)section Row:(NSInteger)row;
+- (void)addCheckOptionForSection:(NSInteger)section;
 @end

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

@@ -30,7 +30,12 @@
 #import "TextDrawable.h"
 #import "ImageDrawable.h"
 #import "RectDrawable.h"
-@interface DocumentTemplateViewController () <TemplateUpdateControlFrame>
+
+#import "ItemTableDataSourceAndDelegate.h"
+#import "AttributeTableDataSourceAndDelegate.h"
+#import "ControlTemplateVC.h"
+
+@interface DocumentTemplateViewController () <TemplateUpdateControlFrame,TemplateSelectionDelegate>
 
 @property (strong, nonatomic) IBOutlet UIView *positionControlBackground;
 @property (strong, nonatomic) IBOutlet UIStepper *xStepper;
@@ -44,6 +49,13 @@
 @property (strong, nonatomic) IBOutlet UITextField *hTextField;
 
 
+@property (weak, nonatomic) IBOutlet UITableView *itemTableView;
+@property (weak, nonatomic) IBOutlet UITableView *attributeTableView;
+
+@property (nonatomic,strong) ItemTableDataSourceAndDelegate *itemTableDataSource;
+@property (nonatomic,strong) AttributeTableDataSourceAndDelegate *attrTableDataSource;
+
+
 @property (nonatomic,weak) UIView *focusView;
 @property (nonatomic,strong) UIColor *focusViewNormalColor;
 
@@ -250,7 +262,27 @@
     // Do any additional setup after loading the view.
     
     [self.view bringSubviewToFront:self.positionControlBackground];
+    
+    
+    // Template
+//    self.itemTableDataSource = [[ItemTableDataSourceAndDelegate alloc] initWithTableView:self.itemTableView Controller:self];
+//    self.attrTableDataSource = [[AttributeTableDataSourceAndDelegate alloc] initWithTableView:self.attributeTableView Controller:self];
+}
+
+- (ItemTableDataSourceAndDelegate *)itemTableDataSource {
+    if (_itemTableDataSource == nil) {
+        _itemTableDataSource = [[ItemTableDataSourceAndDelegate alloc] initWithTableView:self.itemTableView Controller:self];
+    }
+    return _itemTableDataSource;
 }
+
+- (AttributeTableDataSourceAndDelegate *)attrTableDataSource {
+    if (_attrTableDataSource == nil) {
+        _attrTableDataSource = [[AttributeTableDataSourceAndDelegate alloc] initWithTableView:self.attributeTableView Controller:self];
+    }
+    return _attrTableDataSource;
+}
+
 -(void) dealloc
 {
     CFRelease(self.document);
@@ -1240,7 +1272,39 @@
             if (ig) {
                 [iv setImage:[ig imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
             }
+        } else if ([self.focusView isKindOfClass:[UITextView class]]) {
+            UITextView *tv = (UITextView *)self.focusView;
+            if (tv.text == nil || tv.text.length == 0) {
+                [tv setText:@"Text"];
+            }
+        } else if ([self.focusView isKindOfClass:[UITextField class]]) {
+            UITextField *tf = (UITextField *)self.focusView;
+            if (tf.text == nil || tf.text.length == 0) {
+                [tf setText:@"Text"];
+            }
+        } else if ([self.focusView isKindOfClass:[UILabel class]]) {
+            UILabel *lb = (UILabel *)self.focusView;
+            if (lb.text == nil || lb.text.length == 0) {
+                [lb setText:@"Text"];
+            }
+        } else if ([self.focusView isKindOfClass:[UIButton class]]) {
+            UIButton *btn = (UIButton *)self.focusView;
+            NSString *str = [btn titleForState:UIControlStateNormal];
+            if (str == nil || str.length == 0) {
+                [btn setTitle:@"Text" forState:UIControlStateNormal];
+            }
+        }
+        
+        NSInteger tag = self.focusView.tag;
+        NSInteger section = -1;
+        NSInteger row = -1;
+        if (tag >= CONTROL_BASE && tag < CHECK_BASE) {
+            section = tag - CONTROL_BASE;
+        } else if (tag >= CHECK_BASE) {
+            section = (tag - CHECK_BASE) / 1000;
+            row = (tag - CHECK_BASE) % 1000;
         }
+        [self.itemTableDataSource selectSection:section Row:row];
         
     }
 }
@@ -1258,9 +1322,189 @@
         }
     }
 }
-
+#pragma mark - Template Attributes
 - (void)currentShowViewController:(TemplateViewController *)vc {
     self.currentPageViewController = vc;
+    
+    [self pageChanged];
+    [self.itemTableDataSource changeData:vc.page_controlTemplate];
+    [self.attrTableDataSource changeData:nil type:ItemTypeNone forIndex:-1];
+}
+
+- (void)pageChanged {
+    [self setX:0 Y:0 W:0 H:0];
+}
+
+-(void)clickItem:(NSInteger)tag {
+    if (self.currentPageViewController) {
+        
+        UIView *v = [self.currentPageViewController.view viewWithTag:tag];
+        if (v) {
+            [self focusControlView:v frame:[self.currentPageViewController getViewFrame:v]];
+        } else {
+            [self setX:0 Y:0 W:0 H:0];
+            NSInteger section = -1;
+            NSInteger row = -1;
+            if (tag >= CONTROL_BASE && tag < CHECK_BASE) {
+                section = tag - CONTROL_BASE;
+            } else if (tag >= CHECK_BASE) {
+                section = (tag - CHECK_BASE) / 1000;
+                row = (tag - CHECK_BASE) % 1000;
+            }
+            [self.itemTableDataSource selectSection:section Row:row];
+        }
+    }
+}
+
+- (void)selectControl:(NSDictionary *)controlItem index:(NSInteger)index {
+    NSString *type = [controlItem objectForKey:@"type"];
+    
+    if ([type isEqualToString:@"TextView"]) {
+        [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeTextView forIndex:index];
+    }else if ([type isEqualToString:@"ignor"]) {
+        [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeIgnore forIndex:index];
+    } else if([type isEqualToString:@"Button"]) {
+        [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeButton forIndex:index];
+    } else if([type isEqualToString:@"Check"]) {
+       [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeCheck forIndex:index];
+    } else if([type isEqualToString:@"Signature"]) {
+        [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeSignature forIndex:index];
+    } else if([type isEqualToString:@"Image"]) {
+        [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeImage forIndex:index];
+    } else if([type isEqualToString:@"Label"]) {
+        [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeLabel forIndex:index];
+    } else if([type isEqualToString:@"DatePicker"]) {
+        [self.attrTableDataSource changeData:[controlItem mutableCopy] type:ItemTypeDatePicker forIndex:index];
+    } else {
+        [self.attrTableDataSource changeData:nil type:ItemTypeNone forIndex:-1];
+    }
+    
+}
+
+- (void)selectCheck:(NSDictionary *)control Section:(NSInteger)section Row:(NSInteger)row {
+
+    [self.attrTableDataSource changeCheckOptionData:[control mutableCopy] forSection:section Row:row];
+
+}
+
+- (void)updatePageControlProperty:(NSDictionary *)control_dic forIndex:(NSInteger)index Row:(NSInteger)row updateItemList:(BOOL)updateItemList {
+    // 刷新Page数据
+    if (self.currentPageViewController) {
+        [self.currentPageViewController updatePageControl:control_dic forIndex:index];
+    }
+    // 更新Item List视图
+    if (updateItemList) {
+        if (self.itemTableDataSource) {
+            [self.itemTableDataSource updateData:control_dic Section:index Row:row];
+        }
+    }
+}
+
+#pragma mark - Add & Delete
+
+- (IBAction)addControlBtnClick:(UIButton *)sender {
+    ControlTemplateVC *vc = [[ControlTemplateVC alloc] init];
+    vc.delegate = self;
+    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
+    nav.preferredContentSize = CGSizeMake(380, 430);
+    nav.modalPresentationStyle = UIModalPresentationFormSheet;
+    
+    [self presentViewController:nav animated:YES completion:nil];
+}
+
+- (IBAction)deleteControlBtnClick:(UIButton *)sender {
+    
+    if (self.focusView == nil) {
+        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"Please Select A Control" preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+        }];
+        [alert addAction:action];
+        [self presentViewController:alert animated:YES completion:nil];
+    } else {
+        if (self.currentPageViewController) {
+            [self.currentPageViewController deleteControl:self.focusView];
+            self.focusView = nil;
+            [self setX:0 Y:0 W:0 H:0];
+            [self.itemTableDataSource changeData:self.currentPageViewController.page_controlTemplate];
+            [self.attrTableDataSource changeData:nil type:ItemTypeNone forIndex:-1];
+        }
+    }
+    
+}
+
+- (void)selectTemplateStyle:(TemplateStyle)style {
+    
+    NSString *path = [[NSBundle mainBundle] pathForResource:@"template_example.json" ofType:nil];
+    NSData *json_data = [NSData dataWithContentsOfFile:path];
+    NSDictionary *template = [NSJSONSerialization JSONObjectWithData:json_data options:NSJSONReadingMutableLeaves error:nil];
+    
+    NSString *key = nil;
+    switch (style) {
+        case TemplateStyleTextView: {
+            key = @"TextView";
+        }
+            break;
+        case TemplateStyleLabel: {
+            key = @"Label";
+        }
+            break;
+        case TemplateStyleSignature: {
+            key = @"Signature";
+        }
+            break;
+        case TemplateStyleImage: {
+            key = @"Image";
+        }
+            break;
+        case TemplateStyleButton: {
+            key = @"Button";
+        }
+            break;
+        case TemplateStyleCheck: {
+            key = @"Check_0";
+        }
+            break;
+        case TemplateStyleDatePicker: {
+            key = @"DatePicker";
+        }
+            break;
+        case TemplateStyleCheckNoMarker: {
+            key = @"Check_1";
+        }
+            break;
+        default:
+            break;
+    }
+    if (key != nil) {
+        NSDictionary *control = [template objectForKey:key];
+        NSInteger control_tag = [self.currentPageViewController addNewControl:control];
+        [self.itemTableDataSource changeData:self.currentPageViewController.page_controlTemplate];
+        
+        [self clickItem:control_tag];
+    }
+}
+
+- (void)deleteCheckItemAtSection:(NSInteger)section Row:(NSInteger)row {
+    
+    if (self.currentPageViewController) {
+        [self.currentPageViewController deleteCheckItemAtSection:section Row:row];
+        self.focusView = nil;
+        [self setX:0 Y:0 W:0 H:0];
+        [self.itemTableDataSource changeData:self.currentPageViewController.page_controlTemplate];
+        [self.attrTableDataSource changeData:nil type:ItemTypeNone forIndex:-1];
+    }
+}
+
+- (void)addCheckOptionForSection:(NSInteger)section {
+    NSString *path = [[NSBundle mainBundle] pathForResource:@"template_example.json" ofType:nil];
+    NSData *json_data = [NSData dataWithContentsOfFile:path];
+    NSDictionary *template = [NSJSONSerialization JSONObjectWithData:json_data options:NSJSONReadingMutableLeaves error:nil];
+    NSArray *option = [template objectForKey:@"Check_Option"];
+    NSInteger marker_tag = [self.currentPageViewController addCheckOption:option ForSection:section];
+    [self.itemTableDataSource changeData:self.currentPageViewController.page_controlTemplate];
+    
+    [self clickItem:marker_tag];
 }
 
 @end

+ 16 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeLabelCell.h

@@ -0,0 +1,16 @@
+//
+//  AttributeLabelCell.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AttributeLabelCell : UITableViewCell
+
+- (void)setTitle:(NSString *)title;
+- (void)setValue:(NSString *)value;
+- (void)setTitle:(NSString *)title value:(NSString *)value forKey:(NSString *)key;
+@end

+ 46 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeLabelCell.m

@@ -0,0 +1,46 @@
+//
+//  AttributeLabelCell.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "AttributeLabelCell.h"
+
+@interface AttributeLabelCell ()
+@property (weak, nonatomic) IBOutlet UILabel *name_lb;
+@property (weak, nonatomic) IBOutlet UILabel *value_lb;
+
+@property (nonatomic,copy) NSString *key;
+
+@end
+
+@implementation AttributeLabelCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setTitle:(NSString *)title {
+    [self.name_lb setText:title];
+}
+
+- (void)setValue:(NSString *)value {
+    [self.value_lb setText:[NSString stringWithFormat:@"%@",value]];
+}
+
+- (void)setTitle:(NSString *)title value:(NSString *)value forKey:(NSString *)key {
+    [self setTitle:title];
+    [self setValue:value];
+    self.key = key;
+}
+
+@end

+ 18 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeSwitchCell.h

@@ -0,0 +1,18 @@
+//
+//  AttributeSwitchCell.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AttributeSwitchCell : UITableViewCell
+
+@property (nonatomic,copy) void(^valueChangeBlock)(BOOL value,NSString *key);
+
+- (void)setTitle:(NSString *)title;
+- (void)setValue:(BOOL)value;
+- (void)setTitle:(NSString *)title value:(BOOL)value forKey:(NSString *)key;
+@end

+ 52 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeSwitchCell.m

@@ -0,0 +1,52 @@
+//
+//  AttributeSwitchCell.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "AttributeSwitchCell.h"
+
+@interface AttributeSwitchCell ()
+@property (weak, nonatomic) IBOutlet UILabel *name_lb;
+@property (weak, nonatomic) IBOutlet UISwitch *value_sw;
+
+@property (nonatomic,copy) NSString *key;
+@end
+
+
+@implementation AttributeSwitchCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setTitle:(NSString *)title {
+    [self.name_lb setText:title];
+}
+
+- (void)setValue:(BOOL)value {
+    [self.value_sw setOn:value];
+}
+
+- (void)setTitle:(NSString *)title value:(BOOL)value forKey:(NSString *)key {
+    [self setTitle:title];
+    [self setValue:value];
+    self.key = key;
+}
+
+- (IBAction)clickedSwitch:(UISwitch *)sender {
+    if (self.valueChangeBlock) {
+        self.valueChangeBlock(sender.isOn, self.key);
+    }
+}
+
+@end

+ 31 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTableDataSourceAndDelegate.h

@@ -0,0 +1,31 @@
+//
+//  AttributeTableDataSource.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef enum : NSUInteger {
+    ItemTypeTextView,
+    ItemTypeSignature,
+    ItemTypeImage,
+    ItemTypeIgnore,
+    ItemTypeButton,
+    ItemTypeCheck,
+    ItemTypeLabel,
+    ItemTypeDatePicker,
+    ItemTypeNone
+} ItemType;
+
+@class DocumentTemplateViewController;
+@interface AttributeTableDataSourceAndDelegate : NSObject <UITableViewDataSource,UITableViewDelegate>
+
+- (instancetype)initWithTableView:(UITableView *)tableView Controller:(DocumentTemplateViewController *)viewController;
+
+- (void)changeData:(NSMutableDictionary *)data type:(ItemType)type forIndex:(NSInteger)index;
+- (void)changeCheckOptionData:(NSMutableDictionary *)data forSection:(NSInteger)section Row:(NSInteger)row;
+
+@end

+ 303 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTableDataSourceAndDelegate.m

@@ -0,0 +1,303 @@
+//
+//  AttributeTableDataSource.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "AttributeTableDataSourceAndDelegate.h"
+#import "AttributeTextFieldCell.h"
+#import "AttributeLabelCell.h"
+#import "AttributeSwitchCell.h"
+#import "DocumentTemplateViewController.h"
+
+typedef enum {
+    CellTypeTextField = 0,
+    CellTypeLabel = 1,
+    CellTypeSwitch = 2
+}CellType;
+
+@interface AttributeTableDataSourceAndDelegate ()
+
+@property (nonatomic,weak) DocumentTemplateViewController *table_vc;
+@property (nonatomic,weak) UITableView *tableView;
+@property (nonatomic,strong) NSMutableDictionary *template_data;
+@property (nonatomic,strong) NSMutableDictionary *data;
+
+@property (nonatomic,assign) NSInteger data_index;
+@property (nonatomic,assign) NSInteger data_row;
+@property (nonatomic,assign) BOOL check_option;
+
+@end
+
+
+@implementation AttributeTableDataSourceAndDelegate
+
+- (instancetype)initWithTableView:(UITableView *)tableView Controller:(DocumentTemplateViewController *)viewController {
+    if (self = [super init]) {
+        _tableView = tableView;
+        _table_vc = viewController;
+        _tableView.dataSource = self;
+        _tableView.delegate = self;
+    }
+    return self;
+}
+
+- (void)changeCheckOptionData:(NSMutableDictionary *)data forSection:(NSInteger)section Row:(NSInteger)row {
+    self.check_option = YES;
+    self.data_index = section;
+    self.data_row = row;
+    
+    NSString *path = [[NSBundle mainBundle] pathForResource:@"attribute_template.json" ofType:nil];
+    NSData *json_data = [NSData dataWithContentsOfFile:path];
+    NSDictionary *template = [NSJSONSerialization JSONObjectWithData:json_data options:NSJSONReadingMutableLeaves error:nil];
+    
+    self.template_data = [[template objectForKey:@"Check_Option"] mutableCopy];
+    [self.template_data removeObjectForKey:@"size&position"];
+    
+    self.data = data;
+    
+    [self.tableView reloadData];
+}
+
+- (void)changeData:(NSMutableDictionary *)data type:(ItemType)type forIndex:(NSInteger)index {
+    self.check_option = NO;
+    if (data == nil || type == ItemTypeNone) {
+        self.data = nil;
+        self.template_data = nil;
+        [self.tableView reloadData];
+        return;
+    }
+    self.data_index = index;
+    
+    NSString *path = [[NSBundle mainBundle] pathForResource:@"attribute_template.json" ofType:nil];
+    NSData *json_data = [NSData dataWithContentsOfFile:path];
+    NSDictionary *template = [NSJSONSerialization JSONObjectWithData:json_data options:NSJSONReadingMutableLeaves error:nil];
+    
+    NSString *key = nil;
+    switch (type) {
+        case ItemTypeTextView: {
+            key = @"TextView";
+        }
+            break;
+        case ItemTypeSignature: {
+            key = @"Signature";
+        }
+            break;
+        case ItemTypeImage: {
+            key = @"Image";
+        }
+            break;
+        case ItemTypeIgnore: {
+            key = @"Ignore";
+        }
+            break;
+        case ItemTypeButton: {
+            key = @"Button";
+        }
+            break;
+        case ItemTypeCheck: {
+            __block BOOL show_option = NO;
+//            NSMutableArray* cadedate = data[@"cadedate"];
+//            [cadedate enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+//                NSArray* item = (NSArray *)obj;
+//                NSArray* checkmarker = item[1];
+//                if (checkmarker.count != 0) {
+//                    show_option = YES;
+//                } else {
+//                    show_option = NO;
+//                    *stop = YES;
+//                }
+//            }];
+            
+            if ([data objectForKey:@"marker_size"] != nil) {
+                show_option = YES;
+            } else {
+                show_option = NO;
+            }
+            
+            if (show_option) {
+                key = @"Check_0";
+            } else {
+                key = @"Check_1";
+            }
+        }
+            break;
+        case ItemTypeLabel: {
+            key = @"Label";
+        }
+            break;
+        case ItemTypeDatePicker: {
+            key = @"DatePicker";
+        }
+            break;
+        default: {
+            self.template_data = nil;
+        }
+            break;
+    }
+    
+    self.template_data = [[template objectForKey:key] mutableCopy];
+    [self.template_data removeObjectForKey:@"size&position"];
+    
+    self.data = data;
+    
+    [self.tableView reloadData];
+}
+
+- (NSDictionary *)itemForSection:(NSInteger)section {
+    NSString *section_key = [self.template_data.allKeys objectAtIndex:section];
+    NSDictionary *section_dic = [self.template_data objectForKey:section_key];
+    return section_dic;
+}
+
+- (NSDictionary *)cellItemForIndexPath:(NSIndexPath *)indexPath {
+    
+    NSDictionary *section_dic = [self itemForSection:indexPath.section];
+    NSString *row_key = [section_dic.allKeys objectAtIndex:indexPath.row];
+    NSDictionary *row_dic = [section_dic objectForKey:row_key];
+    
+    return row_dic;
+}
+
+#pragma mark - DataSource & Delegate
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    if (self.template_data) {
+        return self.template_data.allKeys.count;
+    }
+    return 0;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    
+    NSDictionary *section_dic = [self itemForSection:section];
+    return section_dic.allKeys.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSDictionary *item = [self cellItemForIndexPath:indexPath];
+    NSInteger type = [[item objectForKey:@"type"] integerValue];
+    NSString *key = [item objectForKey:@"key"];
+    NSString *title = [item objectForKey:@"title"];
+    BOOL disable = [[item objectForKey:@"disable"] boolValue];
+
+    
+    __weak typeof(self) weakSelf = self;
+    switch (type) {
+        case CellTypeTextField: {
+            AttributeTextFieldCell *cell = [tableView dequeueReusableCellWithIdentifier:@"textfield_cell_identifier" forIndexPath:indexPath];
+            NSString *value = nil;
+            if (self.check_option) {
+                value = [item objectForKey:@"value"];
+                if (value == nil) {
+                    NSMutableArray* cadedate = self.data[@"cadedate"];
+                    NSArray *item = cadedate[self.data_row];
+                    value = item[0][0];
+                }
+                
+            } else {
+                value = [self.data objectForKey:key];
+            }
+            [cell setTitle:title value:value forKey:key];
+            cell.valueChangeBlock = ^(NSString *value, NSString *key) {
+                if (weakSelf.check_option) {
+                    NSMutableArray* cadedate = [weakSelf.data[@"cadedate"] mutableCopy];
+                    NSMutableArray *item = [cadedate[weakSelf.data_row] mutableCopy];
+                    NSMutableArray *checkMarker = [[item objectAtIndex:0] mutableCopy];
+                    
+                    [checkMarker replaceObjectAtIndex:0 withObject:value];
+                    [item replaceObjectAtIndex:0 withObject:checkMarker];
+                    [cadedate replaceObjectAtIndex:weakSelf.data_row withObject:item];
+                    [weakSelf.data setObject:cadedate forKey:@"cadedate"];
+                    [weakSelf.table_vc updatePageControlProperty:weakSelf.data forIndex:self.data_index Row:weakSelf.data_row updateItemList:YES];
+                } else {
+                    [weakSelf.data setValue:value forKey:key];
+                    [weakSelf.table_vc updatePageControlProperty:weakSelf.data forIndex:self.data_index Row:-1 updateItemList:NO];
+                }
+            };
+            cell.selectionStyle = UITableViewCellSelectionStyleNone;
+            cell.userInteractionEnabled = !disable;
+            return cell;
+        }
+            break;
+        case CellTypeLabel: {
+            AttributeLabelCell *cell = [tableView dequeueReusableCellWithIdentifier:@"label_cell_identifier" forIndexPath:indexPath];
+            NSString *value = nil;
+            if (self.check_option) {
+                value = [item objectForKey:@"value"];
+                if (value == nil) {
+                    NSMutableArray* cadedate = self.data[@"cadedate"];
+                    NSArray *item = cadedate[self.data_row];
+                    value = item[0][0];
+                }
+            } else {
+                value = [self.data objectForKey:key];
+            }
+            [cell setTitle:title value:value forKey:key];
+            cell.selectionStyle = UITableViewCellSelectionStyleNone;
+            cell.userInteractionEnabled = !disable;
+            return cell;
+        }
+            break;
+        case CellTypeSwitch: {
+            AttributeSwitchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"switch_cell_identifier" forIndexPath:indexPath];
+            BOOL value = nil;
+            if (self.check_option) {
+                if ([item objectForKey:@"value"] == nil) {
+                    NSMutableArray* cadedate = self.data[@"cadedate"];
+                    NSArray *item = cadedate[self.data_row];
+                    value = item[0][0];
+                } else {
+                    value = [[item objectForKey:@"value"] boolValue];
+                }
+            } else {
+                value = [[self.data objectForKey:key] boolValue];
+            }
+            [cell setTitle:title value:value forKey:key];
+            cell.valueChangeBlock = ^(BOOL value, NSString *key) {
+                
+                if (weakSelf.check_option) {
+                    NSMutableArray* cadedate = [weakSelf.data[@"cadedate"] mutableCopy];
+                    NSMutableArray *item = [cadedate[weakSelf.data_row] mutableCopy];
+                    NSMutableArray *checkMarker = [[item objectAtIndex:0] mutableCopy];
+                    
+                    [checkMarker replaceObjectAtIndex:0 withObject:@(value)];
+                    [item replaceObjectAtIndex:0 withObject:checkMarker];
+                    [cadedate replaceObjectAtIndex:weakSelf.data_row withObject:item];
+                    [weakSelf.data setObject:cadedate forKey:@"cadedate"];
+                    
+                    [weakSelf.table_vc updatePageControlProperty:weakSelf.data forIndex:self.data_index Row:weakSelf.data_row updateItemList:YES];
+                } else {
+                    [weakSelf.data setValue:@(value) forKey:key];
+                    [weakSelf.table_vc updatePageControlProperty:weakSelf.data forIndex:self.data_index Row:-1 updateItemList:NO];
+                }
+                
+                
+            };
+            cell.selectionStyle = UITableViewCellSelectionStyleNone;
+            cell.userInteractionEnabled = !disable;
+            return cell;
+        }
+            break;
+            
+        default:
+            break;
+    }
+    
+    return nil;
+}
+
+- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
+ 
+    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
+    label.backgroundColor = [UIColor brownColor];
+    NSString *title = [self.template_data.allKeys objectAtIndex:section];
+    [label setText:title];
+    
+    return label;
+}
+
+@end

+ 21 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTextFieldCell.h

@@ -0,0 +1,21 @@
+//
+//  AttributeTextFieldCell.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AttributeTextFieldCell : UITableViewCell
+
+@property (nonatomic,copy) void(^valueChangeBlock)(NSString *value,NSString *key);
+
+- (void)setTitle:(NSString *)title;
+
+- (void)setValue:(NSString *)value;
+
+- (void)setTitle:(NSString *)title value:(NSString *)value forKey:(NSString *)key;
+
+@end

+ 64 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /AttributeTextFieldCell.m

@@ -0,0 +1,64 @@
+//
+//  AttributeTextFieldCell.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "AttributeTextFieldCell.h"
+
+@interface AttributeTextFieldCell () <UITextFieldDelegate>
+@property (weak, nonatomic) IBOutlet UILabel *name_lb;
+@property (weak, nonatomic) IBOutlet UITextField *value_tf;
+
+@property (nonatomic,copy) NSString *key;
+
+@end
+
+@implementation AttributeTextFieldCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setTitle:(NSString *)title {
+    [self.name_lb setText:title];
+}
+
+- (void)setValue:(NSString *)value {
+    [self.value_tf setText:[NSString stringWithFormat:@"%@",value]];
+}
+
+- (void)setTitle:(NSString *)title value:(NSString *)value forKey:(NSString *)key {
+    [self setTitle:title];
+    [self setValue:value];
+    self.key = key;
+}
+
+- (void)changeValue:(NSString *)str {
+    if (self.valueChangeBlock) {
+        self.valueChangeBlock(str, self.key);
+    }
+}
+
+#pragma mark - Delegate
+
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
+    [self changeValue:newString];
+    return YES;
+}
+
+- (void)textFieldDidEndEditing:(UITextField *)textField {
+    
+}
+
+@end

+ 18 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateCell.h

@@ -0,0 +1,18 @@
+//
+//  ControlTemplateCell.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/14.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface ControlTemplateCell : UITableViewCell
+
+- (void) setTemplate:(NSDictionary *)template;
+
+- (NSInteger)templateType;
+
+@end

+ 42 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateCell.m

@@ -0,0 +1,42 @@
+//
+//  ControlTemplateCell.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/14.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "ControlTemplateCell.h"
+
+@interface ControlTemplateCell ()
+@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
+@property (nonatomic,assign) NSInteger templateType;
+@end
+
+@implementation ControlTemplateCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setTitle:(NSString *)title {
+    self.titleLabel.text = title;
+}
+
+- (void) setTemplate:(NSDictionary *)template {
+    self.templateType = [[template objectForKey:@"type"] integerValue];
+    self.titleLabel.text = [template objectForKey:@"title"];
+}
+
+- (NSInteger)templateType {
+    return _templateType;
+}
+
+@end

+ 43 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateCell.xib

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="control_template_cell" rowHeight="40" id="KGk-i7-Jjw" customClass="ControlTemplateCell">
+            <rect key="frame" x="0.0" y="0.0" width="354" height="40"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
+                <rect key="frame" x="0.0" y="0.0" width="354" height="40"/>
+                <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gTx-Ik-qbs">
+                        <rect key="frame" x="10" y="0.0" width="344" height="39.5"/>
+                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                        <nil key="textColor"/>
+                        <nil key="highlightedColor"/>
+                    </label>
+                </subviews>
+                <constraints>
+                    <constraint firstItem="gTx-Ik-qbs" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="PXI-bj-mMj"/>
+                    <constraint firstAttribute="bottom" secondItem="gTx-Ik-qbs" secondAttribute="bottom" id="asX-Jp-Df3"/>
+                    <constraint firstAttribute="trailing" secondItem="gTx-Ik-qbs" secondAttribute="trailing" id="lDF-Nv-eFw"/>
+                    <constraint firstItem="gTx-Ik-qbs" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="s2x-WM-XRp"/>
+                </constraints>
+            </tableViewCellContentView>
+            <viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
+            <connections>
+                <outlet property="titleLabel" destination="gTx-Ik-qbs" id="iA8-fv-LRy"/>
+            </connections>
+            <point key="canvasLocation" x="42" y="50"/>
+        </tableViewCell>
+    </objects>
+</document>

+ 32 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateVC.h

@@ -0,0 +1,32 @@
+//
+//  ControlTemplateVC.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/14.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef enum : NSUInteger {
+    TemplateStyleTextView       = 0,
+    TemplateStyleLabel          = 1,
+    TemplateStyleSignature      = 2,
+    TemplateStyleImage          = 3,
+    TemplateStyleButton         = 4,
+    TemplateStyleCheck          = 5,
+    TemplateStyleDatePicker     = 6,
+    TemplateStyleCheckNoMarker  = 7
+} TemplateStyle;
+
+@protocol TemplateSelectionDelegate<NSObject>
+
+- (void) selectTemplateStyle:(TemplateStyle)style;
+
+@end
+
+@interface ControlTemplateVC : UIViewController
+
+@property (nonatomic,weak) id<TemplateSelectionDelegate> delegate;
+
+@end

+ 70 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateVC.m

@@ -0,0 +1,70 @@
+//
+//  ControlTemplateVC.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/14.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "ControlTemplateVC.h"
+#import "ControlTemplateCell.h"
+
+@interface ControlTemplateVC () <UITableViewDelegate,UITableViewDataSource>
+@property (weak, nonatomic) IBOutlet UITableView *controlTableView;
+
+@property (nonatomic,strong) NSArray *templateTypeArray;
+
+@end
+
+@implementation ControlTemplateVC
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view from its nib.
+    
+    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done)];
+    [self.controlTableView registerNib:[UINib nibWithNibName:@"ControlTemplateCell" bundle:nil] forCellReuseIdentifier:@"control_template_cell"];
+    
+    [self loadTemplateTypes];
+}
+
+- (void) loadTemplateTypes {
+    NSString *path = [[NSBundle mainBundle] pathForResource:@"template_type.json" ofType:nil];
+    NSData *data = [NSData dataWithContentsOfFile:path];
+    self.templateTypeArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
+}
+
+- (void)done {
+    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return self.templateTypeArray.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    ControlTemplateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"control_template_cell" forIndexPath:indexPath];
+    
+    NSDictionary *type_dic = [self.templateTypeArray objectAtIndex:indexPath.row];
+    
+    [cell setTemplate:type_dic];
+    
+    return cell;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    ControlTemplateCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    if (self.delegate && [self.delegate respondsToSelector:@selector(selectTemplateStyle:)]) {
+        [self.delegate selectTemplateStyle:[cell templateType]];
+    }
+    [self done];
+}
+
+@end

+ 43 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ControlTemplateVC.xib

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="ipad10_5" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ControlTemplateVC">
+            <connections>
+                <outlet property="controlTableView" destination="LUJ-qL-1FR" id="kBY-LM-uMD"/>
+                <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
+            <rect key="frame" x="0.0" y="0.0" width="834" height="1112"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="40" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="LUJ-qL-1FR">
+                    <rect key="frame" x="0.0" y="20" width="834" height="1092"/>
+                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    <connections>
+                        <outlet property="dataSource" destination="-1" id="kf8-uK-YOU"/>
+                        <outlet property="delegate" destination="-1" id="WWr-RV-9ge"/>
+                    </connections>
+                </tableView>
+            </subviews>
+            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <constraints>
+                <constraint firstItem="LUJ-qL-1FR" firstAttribute="top" secondItem="Q5M-cg-NOt" secondAttribute="top" id="3J7-HS-CNZ"/>
+                <constraint firstItem="Q5M-cg-NOt" firstAttribute="bottom" secondItem="LUJ-qL-1FR" secondAttribute="bottom" id="DR7-qC-1xK"/>
+                <constraint firstItem="Q5M-cg-NOt" firstAttribute="trailing" secondItem="LUJ-qL-1FR" secondAttribute="trailing" id="T6m-rn-6UX"/>
+                <constraint firstItem="LUJ-qL-1FR" firstAttribute="leading" secondItem="Q5M-cg-NOt" secondAttribute="leading" id="Tmq-Uk-Wu3"/>
+            </constraints>
+            <viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
+        </view>
+    </objects>
+</document>

+ 20 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ItemTableDataSourceAndDelegate.h

@@ -0,0 +1,20 @@
+//
+//  ItemTableDataSource.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class DocumentTemplateViewController;
+@interface ItemTableDataSourceAndDelegate : NSObject <UITableViewDataSource,UITableViewDelegate>
+
+- (instancetype)initWithTableView:(UITableView *)tableView Controller:(DocumentTemplateViewController *)viewController;
+
+- (void)changeData:(NSMutableDictionary *)data;
+- (void)selectSection:(NSInteger)section Row:(NSInteger)row;
+- (void)updateData:(NSDictionary *)data Section:(NSInteger)section Row:(NSInteger)row; ///< row < 0 表示刷新Section
+
+@end

+ 222 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /ItemTableDataSourceAndDelegate.m

@@ -0,0 +1,222 @@
+//
+//  ItemTableDataSource.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "ItemTableDataSourceAndDelegate.h"
+#import "const.h"
+#import "PageItemCell.h"
+#import "PageSubItemCell.h"
+#import "DocumentTemplateViewController.h"
+
+@interface ItemTableDataSourceAndDelegate ()
+
+@property (nonatomic,weak) DocumentTemplateViewController *table_vc;
+@property (nonatomic,weak) UITableView *tableView;
+
+@property (nonatomic,strong) NSMutableDictionary *data;
+
+@property (nonatomic,assign) NSInteger selectedSection;
+@property (nonatomic,assign) NSInteger selectedRow;
+@property (nonatomic,weak) UIView *selectedCell;
+
+@end
+
+#define CELL_SELECTED_COLOR [UIColor blueColor]
+
+@implementation ItemTableDataSourceAndDelegate
+
+- (instancetype)initWithTableView:(UITableView *)tableView Controller:(DocumentTemplateViewController *)viewController {
+    if (self = [super init]) {
+        _tableView = tableView;
+        _table_vc = viewController;
+        _tableView.dataSource = self;
+        _tableView.delegate = self;
+    }
+    return self;
+}
+
+- (void)changeData:(NSMutableDictionary *)data {
+    self.data = data;
+    self.selectedRow = -1;
+    self.selectedSection = -1;
+    [self.tableView reloadData];
+}
+
+- (void)selectSection:(NSInteger)section Row:(NSInteger)row {
+    self.selectedSection = section;
+    self.selectedRow = row;
+    
+    if (self.selectedCell) {
+        self.selectedCell.backgroundColor = [UIColor clearColor];
+    }
+    UIView *cell = nil;
+    if (row < 0) {
+        cell = [self.tableView viewWithTag:CONTROL_BASE + section];
+        NSDictionary *control = [self.data objectForKey:[NSString stringWithFormat:@"control_%ld",section]];
+        [self.table_vc selectControl:control index:section];
+    } else {
+        cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]];
+        NSDictionary *control = [self.data objectForKey:[NSString stringWithFormat:@"control_%ld",section]];
+        [self.table_vc selectCheck:control Section:section Row:row];
+    }
+    cell.backgroundColor = CELL_SELECTED_COLOR;
+    self.selectedCell = cell;
+}
+
+- (void)updateData:(NSDictionary *)data Section:(NSInteger)section Row:(NSInteger)row {
+    [self.data setObject:data forKey:[NSString stringWithFormat:@"control_%ld",section]];
+    if (row > -1) {
+        [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:section]] withRowAnimation:UITableViewRowAnimationNone];
+    } else {
+        [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationNone];
+    }
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ 
+    NSInteger count = [[self.data objectForKey:@"count"] integerValue];
+    return count;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    NSDictionary *control = [self.data objectForKey:[NSString stringWithFormat:@"control_%ld",section]];
+    NSString *type = [control objectForKey:@"type"];
+    if ([type isEqualToString:@"Check"]) {
+        NSMutableArray* cadedate = control[@"cadedate"];
+        
+        if ([control objectForKey:@"marker_size"] != nil) {
+            return cadedate.count;
+        } else {
+            return 0;
+        }
+        
+//        __block int sub_count = 0;
+//        [cadedate enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+//            NSArray* item = (NSArray *)obj;
+//            NSArray* checkmarker = item[1];
+//            if (checkmarker.count != 0) {
+//                sub_count++;
+//            } else {
+//                sub_count = 0;
+//                *stop = YES;
+//            }
+//        }];
+//
+//        return sub_count;
+    } else {
+        return 0;
+    }
+    
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    PageSubItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"subitem_cell"];
+    NSDictionary *control = [self.data objectForKey:[NSString stringWithFormat:@"control_%ld",indexPath.section]];
+    NSMutableArray* cadedate = control[@"cadedate"];
+    NSArray *item = cadedate[indexPath.row];
+    NSString *title = item[0][0];
+    [cell setTitle:title];
+    cell.tag = CHECK_BASE + indexPath.section * 1000 + indexPath.row;
+    cell.selectionStyle = UITableViewCellSelectionStyleNone;
+    
+    if (indexPath.section == self.selectedSection && indexPath.row == self.selectedRow) {
+        self.selectedCell = cell;
+        cell.backgroundColor = CELL_SELECTED_COLOR;
+    } else {
+        cell.backgroundColor = [UIColor clearColor];
+    }
+    
+    return cell;
+}
+
+- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
+    
+    PageItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"item_cell"];
+    NSDictionary *control = [self.data objectForKey:[NSString stringWithFormat:@"control_%ld",section]];
+    __weak typeof(self) weakSelf = self;
+    // add check
+    if ([control objectForKey:@"marker_size"] != nil) {
+        cell.hideAddBtn = NO;
+    } else {
+        cell.hideAddBtn = YES;
+    }
+    cell.addCheckBlock = ^{
+        [weakSelf.table_vc addCheckOptionForSection:section];
+    };
+    
+    // normal
+    NSString *aname = nil;
+    if (control) {
+        aname = [control objectForKey:@"aname"];
+        if (aname == nil || aname.length < 1) {
+            aname = @"no name";
+        }
+    } else {
+        aname = @"no data";
+    }
+    
+    [cell setTitle:aname];
+    cell.tag = CONTROL_BASE + section;
+    
+    
+    cell.selectBlock = ^(NSInteger tag) {
+        [weakSelf.table_vc clickItem:tag];
+    };
+    
+    if (self.selectedRow == -1 && section == self.selectedSection) {
+        self.selectedCell = cell;
+        cell.backgroundColor = CELL_SELECTED_COLOR;
+    } else {
+        cell.backgroundColor = [UIColor clearColor];
+    }
+    
+    return cell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
+    return 40.0f;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    PageSubItemCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    
+    [self.table_vc clickItem:cell.tag];
+    
+}
+
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
+    return YES;
+}
+
+- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
+    __weak typeof(self) weakSelf = self;
+    UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
+        
+        NSString *control_key = [NSString stringWithFormat:@"control_%ld",indexPath.section];
+        // 更新数据
+        NSMutableDictionary *control = [[weakSelf.data objectForKey:control_key] mutableCopy];
+        NSMutableArray* cadedate = [control[@"cadedate"] mutableCopy];
+        [cadedate removeObjectAtIndex:indexPath.row];
+        [control setObject:cadedate forKey:@"cadedate"];
+        [weakSelf.data setObject:control forKey:control_key];
+
+        // 刷新视图
+        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+        [tableView reloadData];
+
+        // 通知外部视图刷新
+        [weakSelf.table_vc deleteCheckItemAtSection:indexPath.section Row:indexPath.row];
+    }];
+    
+    return @[action];
+}
+
+
+
+
+@end

+ 20 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageItemCell.h

@@ -0,0 +1,20 @@
+//
+//  PageItemCell.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface PageItemCell : UITableViewCell
+
+- (void)setTitle:(NSString *)title;
+
+@property (nonatomic,copy) void(^selectBlock)(NSInteger);
+@property (nonatomic,copy) void(^addCheckBlock)(void);
+
+@property (nonatomic,assign) BOOL hideAddBtn;
+
+@end

+ 50 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageItemCell.m

@@ -0,0 +1,50 @@
+//
+//  PageItemCell.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PageItemCell.h"
+
+@interface PageItemCell ()
+@property (weak, nonatomic) IBOutlet UILabel *title_lb;
+@property (weak, nonatomic) IBOutlet UIButton *addCheckBtn;
+
+@end
+
+@implementation PageItemCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setTitle:(NSString *)title {
+    self.title_lb.text = title;
+}
+
+- (void)setHideAddBtn:(BOOL)hideAddBtn {
+    self.addCheckBtn.hidden = hideAddBtn;
+}
+
+- (IBAction)itemClicked:(UIButton *)sender {
+    if (self.selectBlock) {
+        self.selectBlock(self.tag);
+    }
+}
+
+- (IBAction)addCheckBtnClick:(UIButton *)sender {
+    if (self.addCheckBlock) {
+        self.addCheckBlock();
+    }
+}
+
+@end

+ 15 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageSubItemCell.h

@@ -0,0 +1,15 @@
+//
+//  PageSubItemCell.h
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface PageSubItemCell : UITableViewCell
+
+- (void)setTitle:(NSString *)title;
+
+@end

+ 35 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/Template Attributes /PageSubItemCell.m

@@ -0,0 +1,35 @@
+//
+//  PageSubItemCell.m
+//  Granite Expo eSign
+//
+//  Created by Jack on 2017/10/11.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PageSubItemCell.h"
+
+@interface PageSubItemCell ()
+
+@property (weak, nonatomic) IBOutlet UILabel *title_lb;
+
+@end
+
+
+@implementation PageSubItemCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setTitle:(NSString *)title {
+    self.title_lb.text = title;
+}
+
+@end

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

@@ -48,4 +48,10 @@
 
 - (NSDictionary *)updatePageControl:(UIView*) control ;
 
+-(CGRect) getViewFrame:(UIView*)v;
+- (NSDictionary *)updatePageControl:(NSDictionary *)control_dic forIndex:(NSInteger)index;
+- (NSInteger)addNewControl:(NSDictionary *)control;
+- (void) deleteControl:(UIView *)controlView;
+- (void) deleteCheckItemAtSection:(NSInteger)section Row:(NSInteger)row;
+- (NSInteger)addCheckOption:(NSArray *)option ForSection:(NSInteger)section;
 @end

+ 317 - 69
Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.m

@@ -306,36 +306,36 @@ typedef enum {
         NSMutableDictionary * control =self.page_controlTemplate [[NSString stringWithFormat:@"control_%d",i] ];
         if([control[@"type"] isEqualToString:@"TextView"])
         {
-            [self addTextView:control destView:self.editControlView index:i];
+            [self addTextView:control destView:self.editControlView index:i update:NO];
         }
         else if([control[@"type"] isEqualToString:@"Button"])
         {
-            [self addButton:control destView:self.editControlView index:i];
+            [self addButton:control destView:self.editControlView index:i update:NO];
             
         }
         else if([control[@"type"] isEqualToString:@"Check"])
         {
-            [self addCheck:control destView:self.editControlView index:i];
+            [self addCheck:control destView:self.editControlView index:i update:NO];
             
         }
         else if([control[@"type"] isEqualToString:@"Signature"])
         {
-            [self addSignatureButton:control destView:self.editControlView index:i];
+            [self addSignatureButton:control destView:self.editControlView index:i update:NO];
             
         }
         else if([control[@"type"] isEqualToString:@"Image"])
         {
-            [self addImage:control destView:self.editControlView index:i];
+            [self addImage:control destView:self.editControlView index:i update:NO];
             
         }
         else if([control[@"type"] isEqualToString:@"Label"])
         {
-            [self addLabel:control destView:self.editControlView index:i];
+            [self addLabel:control destView:self.editControlView index:i update:NO];
             
         }
         else if([control[@"type"] isEqualToString:@"DatePicker"])
         {
-            [self addDatePicker:control destView:self.editControlView index:i];
+            [self addDatePicker:control destView:self.editControlView index:i update:NO];
             
         }
     }
@@ -468,6 +468,7 @@ typedef enum {
     int d_idx = [controlName intValue];
     return [self.view viewWithTag:d_idx+CONTROL_BASE];
 }
+
 -(UITextView*) findNextTV:(UITextView*)tv
 {
     long index = tv.tag - CONTROL_BASE;
@@ -495,12 +496,19 @@ typedef enum {
     return nil;
     
 }
--(void) addTextView:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+-(void) addTextView:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
 {
     
     CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
+
+    UITextView* tv = nil;
+    tv = (UITextView *)[destView viewWithTag:index+ CONTROL_BASE];
+    if (tv) {
+        tv.frame = srect;
+    } else {
+        tv = [[UITextView alloc] initWithFrame:srect];
+    }
     
-    UITextView* tv = [[UITextView alloc] initWithFrame:srect];
     if([template[@"next_end"] boolValue])
     tv.returnKeyType=UIReturnKeyDefault;
     else
@@ -516,9 +524,12 @@ typedef enum {
 //    tv.editable = !isdisable;
     tv.editable = true; // for update frame
     NSString* text= template[@"value"];
-    if(text.length==0)
-    text=@" ";
-    tv.text =text;
+    if (!update) {
+        
+        if(text.length==0)
+            text=@" ";
+        tv.text =text;
+    }
     
     float tv_vmargin= [template[@"tv_vmargin"] floatValue];
     NSString* capital= template[@"capital"];
@@ -554,8 +565,10 @@ typedef enum {
     [attr_str addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,attr_str.length)];
     
     tv.attributedText=attr_str;
-    if([text isEqualToString:(@" ")])
-    tv.text=@"";
+    if (!update) {
+        if([text isEqualToString:(@" ")])
+            tv.text=@"";
+    }
     
     tv.tag = index+ CONTROL_BASE;
     
@@ -583,7 +596,11 @@ typedef enum {
     
     //UIColorFromARGB(0x4066ccff);
     
-    tv.backgroundColor = UIColorFromRGB(TV_BG);//[UIColor lightGrayColor];
+    if (!update) {
+        tv.backgroundColor = UIColorFromRGB(TV_BG);
+    }
+    
+    //[UIColor lightGrayColor];
     //    tv.place
     //    [btn setTitle:template[@"title"] forState:UIControlStateNormal];
     //    ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
@@ -599,10 +616,16 @@ typedef enum {
     }
     [destView addSubview:tv];
 }
--(void) addLabel:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+-(void) addLabel:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
 {
     CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
-    UILabel* label = [[UILabel alloc] initWithFrame:srect];
+    UILabel* label = (UILabel *)[destView viewWithTag:index+ CONTROL_BASE];
+    if (label) {
+        label.frame = srect;
+    } else {
+        label = [[UILabel alloc] initWithFrame:srect];
+    }
+    
     float fontsize = [template[@"size"] floatValue];
     if(fontsize==0)
     fontsize=10;
@@ -618,7 +641,9 @@ typedef enum {
     label.textAlignment=NSTextAlignmentRight;
     
     
-    label.text =template[@"value"];
+    if (!update) {
+        label.text =template[@"value"];
+    }
     
     label.tag = index+ CONTROL_BASE;
     
@@ -636,26 +661,41 @@ typedef enum {
     if(DEBUG_PDFSIG)
     {
         
-        [label setBackgroundColor:[UIColor grayColor]];
+        if (!update) {
+            [label setBackgroundColor:[UIColor grayColor]];
+        }
         
     }
     
-    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
-    [label addGestureRecognizer:tap];
-    label.userInteractionEnabled = YES;
+    if (!update) {
+        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
+        [label addGestureRecognizer:tap];
+        label.userInteractionEnabled = YES;
+    }
     
     [destView addSubview:label];
 }
 
--(void) addButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+-(void) addButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
 {
     CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
-    UIButton* btn = [[UIButton alloc] initWithFrame:srect];
-    [btn setTitle:template[@"title"] forState:UIControlStateNormal];
+    UIButton* btn = (UIButton *)[destView viewWithTag:index+ CONTROL_BASE];
+    if (btn) {
+        btn.frame = srect;
+    } else {
+        btn = [[UIButton alloc] initWithFrame:srect];
+    }
+    
+    if (!update) {
+        [btn setTitle:template[@"title"] forState:UIControlStateNormal];
+    }
     
     btn.tag = index+ CONTROL_BASE;
     //    ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
-    btn.backgroundColor = UIColorFromRGB(BT_BG);
+    if (!update) {
+        btn.backgroundColor = UIColorFromRGB(BT_BG);
+    }
+    
     [btn addTarget:self action:@selector(ControlButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
     if(DEBUG_PDFSIG)
     {
@@ -665,13 +705,19 @@ typedef enum {
     }
     [destView addSubview:btn];
 }
--(void) addDatePicker:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+-(void) addDatePicker:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
 {
     CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
-    UIButton* btn = [[UIButton alloc] initWithFrame:srect];
-    
+    UIButton* btn = (UIButton *)[destView viewWithTag:index + CONTROL_BASE];
+    if (btn) {
+        btn.frame = srect;
+    } else {
+        btn = [[UIButton alloc] initWithFrame:srect];
+    }
     
-    [btn setTitle:template[@"value"] forState:UIControlStateNormal];
+    if (!update) {
+        [btn setTitle:template[@"value"] forState:UIControlStateNormal];
+    }
     float fontsize = [template[@"size"] floatValue];
     if(fontsize==0)
     fontsize=10;
@@ -682,7 +728,9 @@ typedef enum {
     btn.tag = index+ CONTROL_BASE;
     [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     //    ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
-    btn.backgroundColor = UIColorFromRGB(BT_BG);
+    if (!update) {
+        btn.backgroundColor = UIColorFromRGB(BT_BG);
+    }
     [btn addTarget:self action:@selector(ControlDatePickerClicked:) forControlEvents:UIControlEventTouchUpInside];
     if(DEBUG_PDFSIG)
     {
@@ -701,11 +749,16 @@ typedef enum {
     return v;
     
 }
--(void) addCheck:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+-(void) addCheck:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
 {
     
     CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
-    UIButton* btn = [[UIButton alloc] initWithFrame:srect];
+    UIButton* btn = (UIButton *)[destView viewWithTag:index+ CONTROL_BASE];
+    if (btn) {
+        btn.frame = srect;
+    } else {
+        btn = [[UIButton alloc] initWithFrame:srect];
+    }
     
     //    ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
     btn.tag = index+ CONTROL_BASE;
@@ -713,9 +766,11 @@ typedef enum {
     UIColor* marker_bg=UIColorFromRGB(CK_BG);//[UIColor clearColor];
     if(DEBUG_PDFSIG)
     {
-        btn.backgroundColor = [UIColor lightGrayColor];
-        btn.alpha = 0.5;
-        [btn setTitle:template[@"title"] forState:UIControlStateNormal];
+        if (!update) {
+            btn.backgroundColor = [UIColor lightGrayColor];
+            btn.alpha = 0.5;
+            [btn setTitle:template[@"title"] forState:UIControlStateNormal];
+        }
         //        marker_bg = [UIColor redColor];
         
         // [btn setBackgroundImage:[UIColor grayColor] forState:UIControlStateNormal];
@@ -737,51 +792,76 @@ typedef enum {
     {
         NSArray* item = cadedate[i];
         NSArray* checkmarker = item[1];
-        if(checkmarker.count==0)
-        {
-            [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-            btn.titleLabel.font = [UIFont systemFontOfSize: fontsize];
-            btn.backgroundColor = UIColorFromRGB(CK_BG);
-            if([checkedData containsObject:[NSNumber numberWithLong:i]])
+        if (!update) {
+            if(checkmarker.count==0)
             {
-                [btn setTitle:item[0][0] forState:UIControlStateNormal];
-                
+                [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+                btn.titleLabel.font = [UIFont systemFontOfSize: fontsize];
+                btn.backgroundColor = UIColorFromRGB(CK_BG);
+                if([checkedData containsObject:[NSNumber numberWithLong:i]])
+                {
+                    [btn setTitle:item[0][0] forState:UIControlStateNormal];
+                    
+                }
+                continue;
+            }
+            else
+            {
+                [btn setTitle:@"" forState:UIControlStateNormal];
+            }
+        } else {
+            
+            if(checkmarker.count==0) {
+                continue;
             }
-            continue;
         }
-        else
-        {
-            [btn setTitle:@"" forState:UIControlStateNormal];
+        UIView* marker= (UIView *)[destView viewWithTag:CHECK_BASE+index*1000+i];
+        
+        if (marker) {
+            int x = [item[1][0] intValue];
+            int y = [item[1][1] intValue];
+            int size = [template[@"marker_size"] intValue];
+            CGRect srect = [self scaleControl:CGRectMake(x,y,size,size) from:CGSizeMake(768, 960) to:destView.frame.size];
+            marker.frame = srect;
+        } else {
+            marker = [self createMarker:[template[@"marker_size"] intValue] x:[item[1][0] intValue] y:[item[1][1] intValue] destView:destView];
         }
-        UIView* marker=[self createMarker:[template[@"marker_size"] intValue] x:[item[1][0] intValue] y:[item[1][1] intValue] destView:destView];
-        
-        marker.backgroundColor = marker_bg;
-        marker.tag = CHECK_BASE+index*1000+i;
         
         
-        if([checkedData containsObject:[NSNumber numberWithLong:i]])
-        {
-            
-            marker.backgroundColor= UIColorFromRGB(CK_MK);
+        marker.tag = CHECK_BASE+index*1000+i;
+        if (!update) {
+            marker.backgroundColor = marker_bg;
+            if([checkedData containsObject:[NSNumber numberWithLong:i]])
+            {
+                
+                marker.backgroundColor= UIColorFromRGB(CK_MK);
+                
+            }
+            else
+            {
+                marker.backgroundColor= marker_bg;
+            }
             
+            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
+            [marker addGestureRecognizer:tap];
         }
-        else
-        {
-            marker.backgroundColor= marker_bg;
-        }
-        
-        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
-        [marker addGestureRecognizer:tap];
         
         [destView addSubview:marker];
         
     }
     
 }
--(void) addSignatureButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+-(void) addSignatureButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
 {
     CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
-    TouchImageView* btn = [[TouchImageView alloc] initWithFrame:srect];
+    TouchImageView* btn = (TouchImageView*)[destView viewWithTag:index+ CONTROL_BASE];
+    
+    if (btn) {
+        btn.frame = srect;
+    } else {
+        btn = [[TouchImageView alloc] initWithFrame:srect];
+    }
+    
     
     btn.contentMode = UIViewContentModeScaleAspectFit;
     btn.delegate = self;
@@ -813,7 +893,9 @@ typedef enum {
     }
     
     
-    btn.backgroundColor = UIColorFromRGB(SIG_BG);
+    if (!update) {
+        btn.backgroundColor = UIColorFromRGB(SIG_BG);
+    }
     
     if(DEBUG_PDFSIG)
     {
@@ -823,10 +905,16 @@ typedef enum {
     }
     [destView addSubview:btn];
 }
--(void) addImage:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+-(void) addImage:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
 {
     CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
-    UIImageView* btn = [[UIImageView alloc] initWithFrame:srect];
+    
+    UIImageView* btn = (UIImageView *)[destView viewWithTag:index+ CONTROL_BASE];
+    if (btn) {
+        btn.frame = srect;
+    } else {
+        btn = [[UIImageView alloc] initWithFrame:srect];
+    }
     
     btn.contentMode = UIViewContentModeScaleAspectFit;
     
@@ -847,7 +935,9 @@ typedef enum {
     }
     
     
-    btn.backgroundColor = UIColorFromRGB(SIG_BG);
+    if (!update) {
+        btn.backgroundColor = UIColorFromRGB(SIG_BG);
+    }
     
     if(DEBUG_PDFSIG)
     {
@@ -2114,6 +2204,30 @@ typedef enum {
     }
 }
 
+- (NSDictionary *)updatePageControl:(NSDictionary *)control_dic forIndex:(NSInteger)index {
+    
+    [self.page_controlTemplate setObject:control_dic forKey:[NSString stringWithFormat:@"control_%ld",index]];
+    NSMutableDictionary * control = [control_dic mutableCopy];
+    if([control[@"type"] isEqualToString:@"TextView"]) {
+        [self addTextView:control destView:self.editControlView index:(int)index update:YES];
+    } else if ([control[@"type"] isEqualToString:@"Signature"]) {
+        [self addSignatureButton:control destView:self.editControlView index:(int)index update:YES];
+    } else if ([control[@"type"] isEqualToString:@"Image"]) {
+        [self addImage:control destView:self.editControlView index:(int)index update:YES];
+    } else if([control[@"type"] isEqualToString:@"Button"]) {
+        [self addButton:control destView:self.editControlView index:(int)index update:YES];
+    } else if([control[@"type"] isEqualToString:@"Check"]) {
+        [self addCheck:control destView:self.editControlView index:(int)index update:YES];
+    }  else if([control[@"type"] isEqualToString:@"Label"]) {
+        [self addLabel:control destView:self.editControlView index:(int)index update:YES];
+    } else if([control[@"type"] isEqualToString:@"DatePicker"]) {
+        [self addDatePicker:control destView:self.editControlView index:(int)index update:YES];
+    }
+    
+    
+    return self.page_controlTemplate;
+}
+
 - (NSDictionary *)updatePageControl:(UIView*) control {
     
 //    int count = [self.page_controlTemplate[@"count"] intValue];
@@ -2293,4 +2407,138 @@ typedef enum {
     return self.page_controlTemplate;
 }
 
+#pragma mark - Add & Delete
+
+- (NSInteger)addNewControl:(NSDictionary *)control {
+    NSInteger count = [[self.page_controlTemplate objectForKey:@"count"] integerValue];
+    
+    // 更新视图
+    if([control[@"type"] isEqualToString:@"TextView"])
+    {
+        [self addTextView:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
+    }
+    else if([control[@"type"] isEqualToString:@"Button"])
+    {
+        [self addButton:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
+        
+    }
+    else if([control[@"type"] isEqualToString:@"Check"])
+    {
+        [self addCheck:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
+        
+    }
+    else if([control[@"type"] isEqualToString:@"Signature"])
+    {
+        [self addSignatureButton:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
+        
+    }
+    else if([control[@"type"] isEqualToString:@"Image"])
+    {
+        [self addImage:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
+        
+    }
+    else if([control[@"type"] isEqualToString:@"Label"])
+    {
+        [self addLabel:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
+        
+    }
+    else if([control[@"type"] isEqualToString:@"DatePicker"])
+    {
+        [self addDatePicker:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
+        
+    }
+    
+    // 更新数据
+    NSString *key = [NSString stringWithFormat:@"control_%ld",count];
+    [self.page_controlTemplate setObject:control forKey:key];
+    [self.page_controlTemplate setObject:@(++count) forKey:@"count"];
+    
+    // 返回新Control的Tag
+    return --count + CONTROL_BASE;
+}
+
+- (void) deleteControl:(UIView *)controlView {
+    if (controlView == nil) {
+        return;
+    }
+    // 更新数据
+    NSInteger index = controlView.tag - CONTROL_BASE;
+    NSInteger count = [[self.page_controlTemplate objectForKey:@"count"] integerValue];
+    // 删除旧数据
+    NSString *key = [NSString stringWithFormat:@"control_%ld",index];
+//    [self.page_controlTemplate removeObjectForKey:key];
+    // 重新排序
+    for (int i = 0; i < count; i++) {
+        if (i > index) {
+            key = [NSString stringWithFormat:@"control_%d",i];
+            id value = [self.page_controlTemplate objectForKey:key];
+            key = [NSString stringWithFormat:@"control_%d",i - 1];
+            [self.page_controlTemplate setObject:value forKey:key];
+        }
+    }
+    [self.page_controlTemplate setObject:@(--count) forKey:@"count"];
+    
+    // 更新视图
+    [self viewWillLayoutSubviews];
+}
+
+- (void) deleteCheckItemAtSection:(NSInteger)section Row:(NSInteger)row {
+    
+    // 数据在Cell删除操作时已经更新,再删除就会删除下一个
+//    NSString *control_key = [NSString stringWithFormat:@"control_%ld",section];
+//    // 更新数据
+//    NSMutableDictionary *control = [[self.page_controlTemplate objectForKey:control_key] mutableCopy];
+//    NSMutableArray* cadedate = [control[@"cadedate"] mutableCopy];
+//    [cadedate removeObjectAtIndex:row];
+//    [control setObject:cadedate forKey:@"cadedate"];
+//    [self.page_controlTemplate setObject:control forKey:control_key];
+    
+    // 刷新视图
+    [self viewWillLayoutSubviews];
+}
+
+- (NSInteger)addCheckOption:(NSArray *)option ForSection:(NSInteger)section {
+    NSString *control_key = [NSString stringWithFormat:@"control_%ld",section];
+    NSMutableDictionary *control = [[self.page_controlTemplate objectForKey:control_key] mutableCopy];
+    NSMutableArray *cadedate = [[control objectForKey:@"cadedate"] mutableCopy];
+    [cadedate addObject:option];
+    [control setObject:cadedate forKey:@"cadedate"];
+    [self.page_controlTemplate setObject:control forKey:control_key];
+    
+    return [self addCheck:control Marker:option AtSection:section Row:cadedate.count - 1];
+}
+
+- (NSInteger)addCheck:(NSDictionary *)template Marker:(NSArray *)item AtSection:(NSInteger)section Row:(NSInteger)row {
+    
+    NSInteger index = section;
+    NSInteger i = row;
+    
+    UIView *destView = self.editControlView;
+    UIView* marker= [self createMarker:[template[@"marker_size"] intValue] x:[item[1][0] intValue] y:[item[1][1] intValue] destView:destView];;
+    
+    NSArray* checkedData = self.page_controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"];
+    
+    NSInteger tag = CHECK_BASE+index*1000+i;
+    marker.tag = tag;
+    UIColor *marker_bg=UIColorFromRGB(CK_BG);
+    marker.backgroundColor = marker_bg;
+    if([checkedData containsObject:[NSNumber numberWithLong:i]])
+    {
+        
+        marker.backgroundColor= UIColorFromRGB(CK_MK);
+        
+    }
+    else
+    {
+        marker.backgroundColor= marker_bg;
+    }
+    
+    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
+    [marker addGestureRecognizer:tap];
+    
+    [destView addSubview:marker];
+    
+    return tag;
+}
+
 @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
 

+ 277 - 0
Ants Contract/Granite Expo eSign/attribute_template.json

@@ -0,0 +1,277 @@
+{
+    "TextView": {
+        "size&position": {
+            "x": {
+                "type": 0,
+                "key": "pos_x"
+            },
+            "y": {
+                "type": 0,
+                "key": "pos_y"
+            },
+            "w": {
+                "type": 0,
+                "key": "width"
+            },
+            "h": {
+                "type": 0,
+                "key": "height"
+            }
+        },
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            },
+            "dirty": {
+                "type": 2,
+                "title": "Dirty",
+                "key": "dirty",
+                "disable": true
+            }
+        },
+        "Property": {
+            "tv_vmargin": {
+                "type": 0,
+                "title": "TV VMargin",
+                "key": "tv_vmargin"
+            },
+            "aname": {
+                "type": 0,
+                "title": "Aname",
+                "key": "aname"
+            },
+            "Font Size": {
+                "type": 0,
+                "title": "Font Size",
+                "key": "size"
+            },
+            "Required": {
+                "type": 2,
+                "title": "Required",
+                "key": "required"
+            },
+            "Filed": {
+                "type": 0,
+                "title": "Field",
+                "key": "field"
+            },
+            "Disable": {
+                "type": 2,
+                "title": "Disable",
+                "key": "disable"
+            }
+        }
+    },
+    "Ignore": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            }
+        }
+    },
+    "Signature": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            },
+            "dirty": {
+                "type": 2,
+                "title": "Dirty",
+                "key": "dirty",
+                "disable": true
+            }
+        },
+        "Property": {
+            "required": {
+                "type": 2,
+                "title": "Required",
+                "key": "required"
+            }
+        }
+    },
+    "Image": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            },
+            "dirty": {
+                "type": 2,
+                "title": "Dirty",
+                "key": "dirty",
+                "disable": true
+            }
+        },
+        "Property": {
+            "required": {
+                "type": 2,
+                "title": "Required",
+                "key": "required"
+            }
+        }
+    },
+    "Label": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            },
+            "dirty": {
+                "type": 2,
+                "title": "Dirty",
+                "key": "dirty",
+                "disable": true
+            }
+        },
+        "Property": {
+            "Font Size": {
+                "type": 0,
+                "title": "Font Size",
+                "key": "size"
+            },
+            "Required": {
+                "type": 2,
+                "title": "Required",
+                "key": "required"
+            },
+            "Filed": {
+                "type": 0,
+                "title": "Field",
+                "key": "field"
+            }
+        }
+    },
+    "DatePicker": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            },
+            "dirty": {
+                "type": 2,
+                "title": "Dirty",
+                "key": "dirty",
+                "disable": true
+            }
+        },
+        "Property": {
+            "Font Size": {
+                "type": 0,
+                "title": "Font Size",
+                "key": "size"
+            },
+            "Required": {
+                "type": 2,
+                "title": "Required",
+                "key": "required"
+            },
+            "Disable": {
+                "type": 2,
+                "title": "Disable",
+                "key": "disable"
+            }
+        }
+    },
+    "Check_0": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            },
+            "dirty": {
+                "type": 2,
+                "title": "Dirty",
+                "key": "dirty",
+                "disable": true
+            }
+        },
+        "Property": {
+            "Marker Size": {
+                "type": 0,
+                "title": "Marker Size",
+                "key": "marker_size"
+            },
+            "Required": {
+                "type": 2,
+                "title": "Required",
+                "key": "required"
+            },
+            "Single Select": {
+                "type": 2,
+                "title": "Single Select",
+                "key": "single_select"
+            },
+            "Show Detail": {
+                "type": 2,
+                "title": "Show Detail",
+                "key": "show_detail"
+            }
+        }
+    },
+    "Check_1": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "key": "type",
+                "disable": true
+            },
+            "dirty": {
+                "type": 2,
+                "title": "Dirty",
+                "key": "dirty",
+                "disable": true
+            }
+        },
+        "Property": {
+            "Required": {
+                "type": 2,
+                "title": "Required",
+                "key": "required"
+            },
+            "Single Select": {
+                "type": 2,
+                "title": "Single Select",
+                "key": "single_select"
+            },
+            "Show Detail": {
+                "type": 2,
+                "title": "Show Detail",
+                "key": "show_detail"
+            }
+        }
+    },
+    "Check_Option": {
+        "Information": {
+            "type": {
+                "type": 1,
+                "title": "Type",
+                "value": "Check Marker",
+                "disable": true
+            }
+        },
+        "Property": {
+            "title": {
+                "type": 0,
+                "title": "Title"
+            }
+        }
+    }
+}

+ 136 - 0
Ants Contract/Granite Expo eSign/template_example.json

@@ -0,0 +1,136 @@
+{
+    "TextView": {
+        "textAlignment": "center",
+        "width": 80,
+        "tv_vmargin": 0.3,
+        "aname": "New Add TextView",
+        "type": "TextView",
+        "size": "10",
+        "pos_y": 0,
+        "field": "new add",
+        "value": "",
+        "dirty": false,
+        "height": 20,
+        "margin_top": "2",
+        "required": true,
+        "pos_x": 0
+    },
+    "Label": {
+        "height": 30,
+        "textAlignment": "center",
+        "pos_x": 0,
+        "width": 100,
+        "size": "8",
+        "field": "new add",
+        "pos_y": 0,
+        "type": "Label",
+        "required": true,
+        "value": "",
+        "dirty": false
+    },
+    "Signature": {
+        "required_validation": true,
+        "validation_code": "1111",
+        "name": "new Add Signature",
+        "width": 100,
+        "pos_y": 0,
+        "aname": "new add Signature",
+        "linewidth": 8,
+        "type": "Signature",
+        "height": 30,
+        "value": "",
+        "dirty": false,
+        "required": true,
+        "pos_x": 0
+    },
+    "Image": {
+        "height": 30,
+        "pos_x": 0,
+        "dirty": false,
+        "width": 100,
+        "value": "",
+        "type": "Image",
+        "pos_y": 0,
+        "name": "new Add Image",
+        "required": true
+    },
+    "Button": {
+        "disable": true,
+        "textAlignment": "center",
+        "width": 100,
+        "pos_y": 0,
+        "aname": "new add Button",
+        "type": "Button",
+        "field": "new add Button",
+        "value": "NA",
+        "dirty": false,
+        "height": 30,
+        "margin_left": "4",
+        "margin_top": "1",
+        "required": true,
+        "pos_x": 0
+    },
+    "DatePicker": {
+        "disable": true,
+        "textAlignment": "center",
+        "width": 100,
+        "pos_y": 0,
+        "aname": "new add DatePicker",
+        "type": "DatePicker",
+        "field": "new add DatePicker",
+        "value": "NA",
+        "dirty": false,
+        "height": 30,
+        "margin_left": "4",
+        "margin_top": "1",
+        "required": true,
+        "pos_x": 0
+    },
+    "Check_0": {
+        "width": 100,
+        "pos_y": 0,
+        "aname": "new add Check",
+        "type": "Check",
+        "field": "new add check",
+        "title": "new add check",
+        "single_select": false,
+        "show_detail": false,
+        "value": [
+        ],
+        "height": 70,
+        "dirty": false,
+        "marker_size": 6,
+        "cadedate": [
+        ],
+        "required": true,
+        "pos_x": 0
+    },
+    "Check_1": {
+        "width": 100,
+        "pos_y": 0,
+        "aname": "new add check no marker",
+        "type": "Check",
+        "field": "new add check no marker",
+        "title": "new add check no marker",
+        "single_select": false,
+        "show_detail": false,
+        "value": [
+        ],
+        "height": 70,
+        "dirty": false,
+        "cadedate": [
+        ],
+        "required": true,
+        "pos_x": 0
+    },
+    "Check_Option" : [
+                      [
+                       "New Add Check Option",
+                       "New Add Check Option"
+                       ],
+                      [
+                       0,
+                       0
+                       ]
+                      ]
+}

+ 34 - 0
Ants Contract/Granite Expo eSign/template_type.json

@@ -0,0 +1,34 @@
+[
+  {
+    "type": 0,
+    "title": "TextView"
+  },
+  {
+    "type": 1,
+    "title": "Label"
+  },
+  {
+    "type": 2,
+    "title": "Signature"
+  },
+  {
+    "type": 3,
+    "title": "Image"
+  },
+  {
+    "type": 4,
+    "title": "Button"
+  },
+  {
+    "type": 5,
+    "title": "Check"
+  },
+  {
+    "type": 6,
+    "title": "DatePicker"
+  },
+ {
+ "type": 7,
+ "title": "Check (No Marker)"
+ }
+]