Skip to content

Commit 11e7a96

Browse files
committed
changed text color when selected, add next on keyboard
1 parent 66ca973 commit 11e7a96

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

AnimalsApp/AnimalsApp/Views/RegisterViewController/RegisterViewController.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,27 @@ class RegisterViewController: UIViewController {
162162

163163
extension RegisterViewController: UIGestureRecognizerDelegate, UITextFieldDelegate {
164164
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
165-
textField.resignFirstResponder()
165+
if textField == textFieldName {
166+
textFieldImageLink.becomeFirstResponder()
167+
} else if textField == textFieldImageLink {
168+
textFieldDescription.becomeFirstResponder()
169+
} else if textField == textFieldDescription {
170+
textFieldSpecie.becomeFirstResponder()
171+
} else if textField == textFieldSpecie {
172+
textFieldAge.becomeFirstResponder()
173+
}
166174
return true
167175
}
176+
177+
func textFieldDidBeginEditing(_ textField: UITextField) {
178+
if textField.isEditing {
179+
textField.layer.borderColor = UIColor.black.cgColor
180+
}
181+
}
182+
183+
func textFieldDidEndEditing(_ textField: UITextField) {
184+
if textField.endEditing(true) {
185+
textField.layer.borderColor = UIColor.grayCellFrame?.cgColor
186+
}
187+
}
168188
}

AnimalsApp/AnimalsApp/Views/RegisterViewController/RegisterViewController.xib

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,41 @@
4545
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
4646
<subviews>
4747
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uTn-FQ-xzf">
48-
<rect key="frame" x="0.0" y="0.0" width="375" height="525"/>
48+
<rect key="frame" x="0.0" y="0.0" width="375" height="550"/>
4949
<subviews>
50-
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" alignment="top" spacing="25" translatesAutoresizingMaskIntoConstraints="NO" id="aHz-3L-Vgj">
51-
<rect key="frame" x="13" y="20" width="349" height="485"/>
50+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" alignment="top" spacing="30" translatesAutoresizingMaskIntoConstraints="NO" id="aHz-3L-Vgj">
51+
<rect key="frame" x="13" y="20" width="349" height="510"/>
5252
<subviews>
5353
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Nome" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="SD0-gJ-dkh">
5454
<rect key="frame" x="0.0" y="0.0" width="349" height="60"/>
5555
<constraints>
5656
<constraint firstAttribute="height" constant="60" id="jeK-zE-jfS"/>
5757
</constraints>
5858
<fontDescription key="fontDescription" type="system" pointSize="14"/>
59-
<textInputTraits key="textInputTraits" returnKeyType="done"/>
59+
<textInputTraits key="textInputTraits" returnKeyType="next"/>
6060
</textField>
6161
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Link da imagem" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="xF5-Gv-lri">
62-
<rect key="frame" x="0.0" y="85" width="349" height="60"/>
62+
<rect key="frame" x="0.0" y="90" width="349" height="60"/>
6363
<fontDescription key="fontDescription" type="system" pointSize="14"/>
64-
<textInputTraits key="textInputTraits" returnKeyType="done"/>
64+
<textInputTraits key="textInputTraits" returnKeyType="next"/>
6565
</textField>
6666
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Descrição" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Jyn-Gz-FpY">
67-
<rect key="frame" x="0.0" y="170" width="349" height="60"/>
67+
<rect key="frame" x="0.0" y="180" width="349" height="60"/>
6868
<fontDescription key="fontDescription" type="system" pointSize="14"/>
69-
<textInputTraits key="textInputTraits" returnKeyType="done"/>
69+
<textInputTraits key="textInputTraits" returnKeyType="next"/>
7070
</textField>
7171
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Espécie" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="rD2-wq-owE">
72-
<rect key="frame" x="0.0" y="255" width="349" height="60"/>
72+
<rect key="frame" x="0.0" y="270" width="349" height="60"/>
7373
<fontDescription key="fontDescription" type="system" pointSize="14"/>
74-
<textInputTraits key="textInputTraits" returnKeyType="done"/>
74+
<textInputTraits key="textInputTraits" returnKeyType="next"/>
7575
</textField>
7676
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Idade" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="8vc-1n-XQI">
77-
<rect key="frame" x="0.0" y="340" width="349" height="60"/>
77+
<rect key="frame" x="0.0" y="360" width="349" height="60"/>
7878
<fontDescription key="fontDescription" type="system" pointSize="14"/>
7979
<textInputTraits key="textInputTraits" keyboardType="numberPad" returnKeyType="done"/>
8080
</textField>
8181
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IgQ-5e-alS">
82-
<rect key="frame" x="0.0" y="425" width="349" height="60"/>
82+
<rect key="frame" x="0.0" y="450" width="349" height="60"/>
8383
<color key="backgroundColor" name="purpleButtonColor"/>
8484
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
8585
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -116,7 +116,7 @@
116116
</constraints>
117117
</view>
118118
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="ksy-aq-ngY">
119-
<rect key="frame" x="230" y="465" width="20" height="20"/>
119+
<rect key="frame" x="230" y="490" width="20" height="20"/>
120120
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
121121
<color key="color" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
122122
</activityIndicatorView>
@@ -147,6 +147,9 @@
147147
<point key="canvasLocation" x="131.8840579710145" y="99.776785714285708"/>
148148
</view>
149149
</objects>
150+
<designables>
151+
<designable name="jGf-Ob-KRg"/>
152+
</designables>
150153
<resources>
151154
<namedColor name="purpleButtonColor">
152155
<color red="0.45100000500679016" green="0.19200000166893005" blue="0.97600001096725464" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>

0 commit comments

Comments
 (0)