Skip to content

Commit

Permalink
Localization after refactoring, readme (#18)
Browse files Browse the repository at this point in the history
* Update readme,add English support (#9)

* update_readme

Signed-off-by: pengzishang <[email protected]>

* add link

Signed-off-by: pengzishang <[email protected]>

* Set theme jekyll-theme-minimal

* Fix a bug caused by a screen rotation (#11)

Signed-off-by: pengzishang <[email protected]>

* Fix a bug caused by a screen rotation (#11)

Signed-off-by: pengzishang <[email protected]>

* Update README.md

* Update HorizontalCodeController.swift

* Update EasyStepIndicator.podspec

* Update EasyStepIndicator.swift

* Update README_EN.md

* refactor code (#15)

* wip day1

Signed-off-by: pengzishang <[email protected]>

* wip day2

Signed-off-by: pengzishang <[email protected]>

* wip day3

Signed-off-by: pengzishang <[email protected]>

* wip day4

Signed-off-by: pengzishang <[email protected]>

* wip day5

Signed-off-by: pengzishang <[email protected]>

* bug day 1

Signed-off-by: pengzishang <[email protected]>

* bug day2

Signed-off-by: pengzishang <[email protected]>

* 里程碑:横向描述,文字显示正常

Signed-off-by: pengzishang <[email protected]>

* 里程碑:垂直适配

Signed-off-by: pengzishang <[email protected]>

* 里程碑:各元素设立独立属性

Signed-off-by: pengzishang <[email protected]>

* 里程碑:旋转修复

Signed-off-by: pengzishang <[email protected]>

* 修复纵向起始点问题

Signed-off-by: pengzishang <[email protected]>

* 纵向 shouldStepLineFitDescriptionText测试成功

Signed-off-by: pengzishang <[email protected]>

* bug day 2

Signed-off-by: pengzishang <[email protected]>

* wip demo

Signed-off-by: pengzishang <[email protected]>

* format

Signed-off-by: pengzishang <[email protected]>

* 里程碑:全部测试完毕

Signed-off-by: pengzishang <[email protected]>

* demo code

Signed-off-by: pengzishang <[email protected]>


重构代码,可以分别定义每个元素的属性

* Localization after refactoring, readme (#17)

* readme and localization

Signed-off-by: pengzishang <[email protected]>

* update readme

Signed-off-by: pengzishang <[email protected]>

* readme day2

Signed-off-by: pengzishang <[email protected]>

* fix bug when number = 1

Signed-off-by: pengzishang <[email protected]>
  • Loading branch information
pengzishang authored Nov 7, 2019
1 parent 4ab16c0 commit 9314948
Show file tree
Hide file tree
Showing 9 changed files with 351 additions and 96 deletions.
8 changes: 5 additions & 3 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions EasyStepIndicator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
3CB31F4623587519004726A1 /* 2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 2.png; sourceTree = "<group>"; };
3CF8C4A223696BE200275B81 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
3CFB1D732372CCD800A7AB57 /* HorizontalController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalController.swift; sourceTree = "<group>"; };
3CFB1D762372D6BE00A7AB57 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -225,6 +226,7 @@
isa = PBXVariantGroup;
children = (
3CB31F1423572BDF004726A1 /* Base */,
3CFB1D762372D6BE00A7AB57 /* en */,
);
name = Main.storyboard;
sourceTree = "<group>";
Expand Down
13 changes: 10 additions & 3 deletions EasyStepIndicator/EasyStepIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ public class EasyStepIndicator: UIView {
}

/// 对齐模式
public var alignmentMode: AlignmentMode = .center
public var alignmentMode: AlignmentMode = .center {
didSet {
self.updateSubLayers()
}
}

//步骤描述文字未完成时候颜色
@IBInspectable public var stepDescriptionTextIncompleteColor: UIColor = UIColor.red {
Expand Down Expand Up @@ -330,6 +334,10 @@ public class EasyStepIndicator: UIView {
self.layer.addSublayer(self.containerLayer)
self.updateSubLayers()
}

public func reload() {
self.updateSubLayers()
}

private func updateData() {
for index in 0..<self.numberOfSteps {
Expand Down Expand Up @@ -709,8 +717,7 @@ public class EasyStepIndicator: UIView {
}()
let annularStartX: CGFloat = {
guard self.numberOfSteps > 1 else {
let firstAnnularLayer = self.annularLayers.first
return self.containerLayer.frame.width / 2.0 - circleRadius(firstAnnularLayer)
return 0
}

if let _ = self.dataSource {
Expand Down
54 changes: 44 additions & 10 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -361,27 +361,61 @@
</mask>
</variation>
</view>
<stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="g8C-gp-vKE">
<rect key="frame" x="160" y="696.5" width="94" height="32"/>
<connections>
<action selector="didChangeValue:" destination="Cij-yo-usf" eventType="valueChanged" id="WaJ-eG-KEn"/>
</connections>
</stepper>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tl9-Ad-qF6">
<rect key="frame" x="148.5" y="139.5" width="117" height="60"/>
<rect key="frame" x="148.5" y="119.5" width="117" height="60"/>
<fontDescription key="fontDescription" type="system" pointSize="50"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="14" translatesAutoresizingMaskIntoConstraints="NO" id="eiS-rz-PWp">
<rect key="frame" x="30" y="696.5" width="354" height="122"/>
<subviews>
<stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="g8C-gp-vKE">
<rect key="frame" x="130" y="0.0" width="94" height="32"/>
<connections>
<action selector="didChangeValue:" destination="Cij-yo-usf" eventType="valueChanged" id="WaJ-eG-KEn"/>
</connections>
</stepper>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="OwO-3a-fNa">
<rect key="frame" x="0.0" y="46" width="354" height="32"/>
<segments>
<segment title="top"/>
<segment title="center"/>
<segment title="centerWithAnnularStartAndAnnularEnd"/>
</segments>
<connections>
<action selector="changeSegmentValue:" destination="Cij-yo-usf" eventType="valueChanged" id="5T3-bC-t0K"/>
</connections>
</segmentedControl>
<stackView opaque="NO" contentMode="scaleToFill" spacing="28" translatesAutoresizingMaskIntoConstraints="NO" id="LZN-R2-B4O">
<rect key="frame" x="37" y="91" width="280" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="shouldStepLineFitDescriptionText" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QhV-BO-ub6">
<rect key="frame" x="0.0" y="0.0" width="203" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="pvL-Oz-adJ">
<rect key="frame" x="231" y="0.0" width="51" height="31"/>
<connections>
<action selector="changeSwitchValue:" destination="Cij-yo-usf" eventType="valueChanged" id="bBB-l0-PQ8"/>
</connections>
</switch>
</subviews>
</stackView>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<constraints>
<constraint firstItem="fml-x6-zBM" firstAttribute="trailing" secondItem="H3T-pM-BZD" secondAttribute="trailing" constant="40" id="Hsp-TZ-byk"/>
<constraint firstItem="H3T-pM-BZD" firstAttribute="centerY" secondItem="Qsm-5i-9VB" secondAttribute="centerY" id="LfU-pR-lYs"/>
<constraint firstItem="H3T-pM-BZD" firstAttribute="top" secondItem="tl9-Ad-qF6" secondAttribute="bottom" constant="10" id="Ma5-3H-gD2"/>
<constraint firstItem="g8C-gp-vKE" firstAttribute="centerX" secondItem="H3T-pM-BZD" secondAttribute="centerX" id="QMz-uW-Y6S"/>
<constraint firstItem="eiS-rz-PWp" firstAttribute="leading" secondItem="Qsm-5i-9VB" secondAttribute="leading" constant="30" id="MRT-JJ-j4P"/>
<constraint firstItem="H3T-pM-BZD" firstAttribute="top" secondItem="tl9-Ad-qF6" secondAttribute="bottom" constant="30" id="Ma5-3H-gD2"/>
<constraint firstItem="eiS-rz-PWp" firstAttribute="centerX" secondItem="Qsm-5i-9VB" secondAttribute="centerX" id="QnL-Yj-bQQ"/>
<constraint firstItem="H3T-pM-BZD" firstAttribute="leading" secondItem="fml-x6-zBM" secondAttribute="leading" constant="40" id="SdV-K1-92M"/>
<constraint firstItem="g8C-gp-vKE" firstAttribute="top" secondItem="H3T-pM-BZD" secondAttribute="bottom" constant="10" id="cvj-Eh-l0f"/>
<constraint firstItem="eiS-rz-PWp" firstAttribute="top" secondItem="H3T-pM-BZD" secondAttribute="bottom" constant="10" id="qL9-5B-oxX"/>
<constraint firstItem="tl9-Ad-qF6" firstAttribute="centerX" secondItem="Qsm-5i-9VB" secondAttribute="centerX" id="wjM-nF-LwK"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fml-x6-zBM"/>
Expand Down
8 changes: 4 additions & 4 deletions Example/HorizontalCodeController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ class HorizontalCodeController: UIViewController {
var indicator: EasyStepIndicator?
var currentStep: UILabel!


override func viewDidLoad() {
super.viewDidLoad()

self.indicator = EasyStepIndicator.init(frame: CGRect.init(origin: CGPoint.zero, size: CGSize.init(width: self.view.bounds.width, height: self.view.bounds.width/2)))
self.indicator?.center = self.view.center
indicator?.numberOfSteps = 4
indicator?.numberOfSteps = 4 // 必须第一时间赋予
self.view.addSubview(indicator!)

indicator?.delegate = self
indicator?.dataSource = self
self.view.addSubview(indicator!)
indicator?.currentStep = 0 //如果需要调整目前进度

self.stepper = UIStepper.init(frame: CGRect.init(origin: CGPoint.zero, size: CGSize.init(width: 30, height: 20)))
self.stepper?.center = CGPoint.init(x: (indicator?.frame.midX ?? 0), y: (indicator?.frame.maxY ?? 400))
self.view.addSubview((stepper!))
stepper?.maximumValue = 4
stepper?.maximumValue = Double(indicator?.numberOfSteps ?? 0)
stepper?.minimumValue = 0
stepper?.stepValue = 1
stepper?.value = 0
Expand Down
18 changes: 15 additions & 3 deletions Example/VerticalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class VerticalController: UIViewController {
@IBOutlet weak var indicator: EasyStepIndicator!
@IBOutlet weak var currentStep: UILabel!

var shouldStepLineFitText = false

override func viewDidLoad() {
super.viewDidLoad()
self.indicator.dataSource = self
self.indicator.delegate = self
self.indicator.alignmentMode = .center
self.indicator.alignmentMode = .top
stepper.maximumValue = Double(indicator.numberOfSteps - 1)
setState(step: 0)
}
Expand All @@ -35,6 +37,16 @@ class VerticalController: UIViewController {
@IBAction func didChangeValue(_ sender: UIStepper) {
setState(step: Int(sender.value))
}

@IBAction func changeSegmentValue(_ sender: UISegmentedControl) {
indicator.alignmentMode = [AlignmentMode.top,AlignmentMode.center,AlignmentMode.centerWithAnnularStartAndAnnularEnd][sender.selectedSegmentIndex]
}

@IBAction func changeSwitchValue(_ sender: UISwitch) {
self.shouldStepLineFitText = sender.isOn
indicator.reload()
}

}

extension VerticalController:EasyStepIndicatorDataSource {
Expand All @@ -44,7 +56,7 @@ extension VerticalController:EasyStepIndicatorDataSource {

func titleForStep(indicator: EasyStepIndicator, index: Int) -> String {
// return ["Alarm\ntriggered", "Dispatch\na guard", "Track\nprogress", "Finishes\ninvestigation","Finishes\ninvestigation"][index]
["Yours faithfully", " This is to introduce Mr. Frank Jones, our new marketing specialist who will be in London from April 5 to mid April on business. We are pleased to introduce Mr. Wang You, our import manager of Textiles Department. Mr. Wang is spending three weeks in your city to develop our business with chief manufactures and to make purchases of decorative fabrics for the coming season.", "Track progress", "Finishes\ninvestigation"][index]
[ "This is to introduce Mr. Frank Jones, our new marketing specialist who will be in London from April 5 to mid April on business. We are pleased to introduce Mr. Wang You, our import manager of Textiles Department. ","Yours faithfully", "Track progress", "Finishes\ninvestigation,in London from April 5 to mid April on business. We are pleased to introduce Mr. Wang"][index]
}
}

Expand Down Expand Up @@ -79,6 +91,6 @@ extension VerticalController :EasyStepIndicatorDelegate {
}

func shouldStepLineFitDescriptionText() -> Bool {
false
return self.shouldStepLineFitText
}
}
33 changes: 33 additions & 0 deletions Example/en.lproj/Main.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

/* Class = "UINavigationItem"; title = "横向显示(Storyboard)"; ObjectID = "4m3-UD-06t"; */
"4m3-UD-06t.title" = "Horizontal(Storyboard)";

/* Class = "UILabel"; text = "纵向显示(Storyboard)"; ObjectID = "6RC-Xf-fjR"; */
"6RC-Xf-fjR.text" = "Vertical(Storyboard)";

/* Class = "UILabel"; text = "Label"; ObjectID = "AXk-OI-Srz"; */
"AXk-OI-Srz.text" = "Label";

/* Class = "UINavigationItem"; title = "横向显示(Code)"; ObjectID = "BgK-gK-gxR"; */
"BgK-gK-gxR.title" = "Horizontal(Code)";

/* Class = "UINavigationItem"; title = "纵向显示(Storyboard)"; ObjectID = "JBH-bJ-HoF"; */
"JBH-bJ-HoF.title" = "Vertical(Storyboard)";

/* Class = "UIBarButtonItem"; title = " "; ObjectID = "JFc-cE-BJK"; */
"JFc-cE-BJK.title" = " ";

/* Class = "UILabel"; text = "横向显示(Code)"; ObjectID = "R7N-mC-FGV"; */
"R7N-mC-FGV.text" = "Horizontal(Code)";

/* Class = "UIViewController"; title = "横向显示(Code)"; ObjectID = "eUL-NA-AYK"; */
"eUL-NA-AYK.title" = "Horizontal(Code)";

/* Class = "UINavigationItem"; title = "EasyStepIndicator"; ObjectID = "pUY-FH-cHE"; */
"pUY-FH-cHE.title" = "EasyStepIndicator";

/* Class = "UILabel"; text = "Label"; ObjectID = "tl9-Ad-qF6"; */
"tl9-Ad-qF6.text" = "Label";

/* Class = "UILabel"; text = "横向显示(Storyboard)"; ObjectID = "udb-gL-h3q"; */
"udb-gL-h3q.text" = "Horizontal(Storyboard)";
Loading

0 comments on commit 9314948

Please sign in to comment.