@@ -23,20 +23,19 @@ class UserProfileView: UIView {
2323 } ( )
2424
2525 private lazy var tableView : UITableView = {
26- let tableView = UITableView ( frame: . zero)
26+ let tableView = UITableView ( frame: . zero, style : . insetGrouped )
2727 tableView. translatesAutoresizingMaskIntoConstraints = false
2828 tableView. register ( UserProfileViewCell . self, forCellReuseIdentifier: UserProfileViewCell . identifier)
29- tableView. register ( UserProfileViewGeneralCell . self, forCellReuseIdentifier: UserProfileViewGeneralCell . identifier)
29+ // tableView.register(UserProfileViewGeneralCell.self, forCellReuseIdentifier: UserProfileViewGeneralCell.identifier)
30+ tableView. register ( UITableViewCell . self, forCellReuseIdentifier: UITableViewCell . reuseIdentifier)
3031 return tableView
3132 } ( )
3233
3334 override init ( frame: CGRect ) {
3435 super. init ( frame: frame)
3536 self . tableView. delegate = self
3637 self . tableView. dataSource = self
37- self . configViews ( )
38- self . buildHierarchy ( )
39- self . setupConstraints ( )
38+ self . setupView ( )
4039 }
4140
4241 required init ? ( coder: NSCoder ) {
@@ -46,27 +45,27 @@ class UserProfileView: UIView {
4645
4746extension UserProfileView : ViewCodable {
4847
49- func configViews ( ) {
50- backgroundColor = . white
51- }
52-
53- func buildHierarchy( ) {
48+ func buildHierarchy( ) {
5449 addSubview ( headerStackView)
5550 addSubview ( tableView)
5651 }
5752
58- func setupConstraints( ) {
53+ func setupConstraints( ) {
5954 NSLayoutConstraint . activate ( [
60- headerStackView. topAnchor. constraint ( equalTo: topAnchor) ,
55+ headerStackView. topAnchor. constraint ( equalTo: topAnchor, constant : 32 ) ,
6156 headerStackView. leadingAnchor. constraint ( equalTo: leadingAnchor) ,
6257 headerStackView. trailingAnchor. constraint ( equalTo: trailingAnchor) ,
6358
64- tableView. topAnchor. constraint ( lessThanOrEqualTo: headerStackView. bottomAnchor, constant: 16 ) ,
59+ tableView. topAnchor. constraint ( lessThanOrEqualTo: headerStackView. bottomAnchor, constant: 8 ) ,
6560 tableView. leadingAnchor. constraint ( equalTo: leadingAnchor) ,
6661 tableView. trailingAnchor. constraint ( equalTo: trailingAnchor) ,
6762 tableView. bottomAnchor. constraint ( equalTo: bottomAnchor)
6863 ] )
6964 }
65+
66+ func applyAdditionalChanges( ) {
67+ backgroundColor = . init( hexString: " #F2F2F7 " )
68+ }
7069}
7170
7271extension UserProfileView : UITableViewDelegate , UITableViewDataSource {
@@ -97,22 +96,25 @@ extension UserProfileView: UITableViewDelegate, UITableViewDataSource {
9796 cell. configure ( leftLabel: userData [ indexPath. row] , rightLabel: userModel [ indexPath. row] )
9897 return cell
9998 } else if indexPath. section == 0 && indexPath. row > 2 && indexPath. row < 6 {
100- let buttonCell = tableView . dequeueReusableCell ( withIdentifier : UserProfileViewGeneralCell . identifier , for : indexPath) as! UserProfileViewGeneralCell
101- buttonCell. configure ( generalLabel : self . testModel [ indexPath. row - 3 ] )
102-
99+ let buttonCell : UITableViewCell = . createCell ( for : tableView , at : indexPath) !
100+ buttonCell. textLabel ? . text = self . testModel [ indexPath. row - 3 ]
101+ buttonCell . accessoryType = . disclosureIndicator
103102 return buttonCell
104-
105103 } else if indexPath. section == 1 && indexPath. row < 2 {
106- let generalCell = tableView. dequeueReusableCell ( withIdentifier: UserProfileViewGeneralCell . identifier, for: indexPath) as! UserProfileViewGeneralCell
107- generalCell. configure ( generalLabel: generalModel [ indexPath. row] )
108-
109- return generalCell
110-
104+ let buttonCell : UITableViewCell = . createCell( for: tableView, at: indexPath) !
105+ buttonCell. textLabel? . text = generalModel [ indexPath. row]
106+ buttonCell. accessoryType = . disclosureIndicator
107+ return buttonCell
111108 } else {
112109 let versionCell = tableView. dequeueReusableCell ( withIdentifier: UserProfileViewCell . identifier, for: indexPath) as! UserProfileViewCell
113110 versionCell. configure ( leftLabel: appModel [ indexPath. row - 2 ] , rightLabel: versionModel [ indexPath. row - 2 ] )
114-
115111 return versionCell
116112 }
117113 }
114+
115+ func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
116+ // Chamar um método
117+
118+ tableView. deselectRow ( at: indexPath, animated: false )
119+ }
118120}
0 commit comments