@@ -25,9 +25,6 @@ @interface ApptentiveMessageCenterProfileView ()
25
25
@property (strong , nonatomic ) NSArray *portraitFullConstraints;
26
26
@property (strong , nonatomic ) NSArray *landscapeFullConstraints;
27
27
28
- @property (strong , nonatomic ) NSArray *portraitCompactConstraints;
29
- @property (strong , nonatomic ) NSArray *landscapeCompactConstraints;
30
-
31
28
@property (strong , nonatomic ) NSArray *baseConstraints;
32
29
33
30
@end
@@ -42,14 +39,12 @@ - (void)awakeFromNib {
42
39
self.buttonBar .layer .borderWidth = borderWidth;
43
40
44
41
self.portraitFullConstraints = @[self .nameTrailingConstraint, self .emailLeadingConstraint, self .nameVerticalSpaceToEmail];
45
- self.portraitCompactConstraints = @[self .nameTrailingConstraint, self .emailLeadingConstraint];
46
42
47
43
self.nameHorizontalSpaceToEmail = [NSLayoutConstraint constraintWithItem: self .nameField attribute: NSLayoutAttributeTrailing relatedBy: NSLayoutRelationEqual toItem: self .emailField attribute: NSLayoutAttributeLeading multiplier: 1.0 constant: -8.0 ];
48
44
NSLayoutConstraint *nameEmailTopAlignment = [NSLayoutConstraint constraintWithItem: self .nameField attribute: NSLayoutAttributeTop relatedBy: NSLayoutRelationEqual toItem: self .emailField attribute: NSLayoutAttributeTop multiplier: 1.0 constant: 0.0 ];
49
45
NSLayoutConstraint *nameEmailBottomAlignment = [NSLayoutConstraint constraintWithItem: self .nameField attribute: NSLayoutAttributeBottom relatedBy: NSLayoutRelationEqual toItem: self .emailField attribute: NSLayoutAttributeBottom multiplier: 1.0 constant: 0.0 ];
50
46
51
47
self.landscapeFullConstraints = @[self .nameHorizontalSpaceToEmail, nameEmailTopAlignment, nameEmailBottomAlignment];
52
- self.landscapeCompactConstraints = @[self .emailLeadingConstraint, nameEmailTopAlignment, nameEmailBottomAlignment];
53
48
54
49
// Find constraints common to both modes/orientations
55
50
NSMutableSet *baseConstraintSet = [NSMutableSet setWithArray: self .containerView.constraints];
@@ -60,11 +55,7 @@ - (void)awakeFromNib {
60
55
}
61
56
62
57
- (BOOL )becomeFirstResponder {
63
- if (self.mode == ATMessageCenterProfileModeFull) {
64
- return [self .nameField becomeFirstResponder ];
65
- } else {
66
- return [self .emailField becomeFirstResponder ];
67
- }
58
+ return [self .nameField becomeFirstResponder ];
68
59
}
69
60
70
61
- (void )setBorderColor : (UIColor *)borderColor {
@@ -79,65 +70,12 @@ - (void)traitCollectionDidChange:(nullable UITraitCollection *)previousTraitColl
79
70
80
71
// Deactivate all, then selectively re-activate
81
72
[NSLayoutConstraint deactivateConstraints: self .portraitFullConstraints];
82
- [NSLayoutConstraint deactivateConstraints: self .portraitCompactConstraints];
83
73
[NSLayoutConstraint deactivateConstraints: self .landscapeFullConstraints];
84
- [NSLayoutConstraint deactivateConstraints: self .landscapeCompactConstraints];
85
74
86
75
if (self.traitCollection .verticalSizeClass == UIUserInterfaceSizeClassCompact) {
87
- switch (self.mode ) {
88
- case ATMessageCenterProfileModeFull:
89
- [NSLayoutConstraint activateConstraints: self .landscapeFullConstraints];
90
- break ;
91
-
92
- case ATMessageCenterProfileModeCompact:
93
- [NSLayoutConstraint activateConstraints: self .landscapeCompactConstraints];
94
- break ;
95
- }
76
+ [NSLayoutConstraint activateConstraints: self .landscapeFullConstraints];
96
77
} else {
97
- switch (self.mode ) {
98
- case ATMessageCenterProfileModeFull:
99
- [NSLayoutConstraint activateConstraints: self .portraitFullConstraints];
100
- break ;
101
-
102
- case ATMessageCenterProfileModeCompact:
103
- [NSLayoutConstraint activateConstraints: self .portraitCompactConstraints];
104
- break ;
105
- }
106
- }
107
- }
108
-
109
- - (void )setMode : (ATMessageCenterProfileMode)mode {
110
- if (_mode != mode) {
111
- _mode = mode;
112
-
113
- CGFloat nameFieldAlpha;
114
-
115
- if (mode == ATMessageCenterProfileModeCompact) {
116
- self.requiredLabel .hidden = NO ;
117
- nameFieldAlpha = 0 ;
118
- self.emailVerticalSpaceToButtonBar .constant = 37.0 ;
119
- } else {
120
- self.nameField .hidden = NO ;
121
- nameFieldAlpha = 1 ;
122
- self.emailVerticalSpaceToButtonBar .constant = 16.0 ;
123
- }
124
-
125
- [self traitCollectionDidChange: self .traitCollection];
126
-
127
- [UIView animateWithDuration: 0.25
128
- animations: ^{
129
- self.nameField .alpha = nameFieldAlpha;
130
- self.requiredLabel .alpha = 1.0 - nameFieldAlpha;
131
-
132
- [self layoutIfNeeded ];
133
- }
134
- completion: ^(BOOL finished) {
135
- if (nameFieldAlpha == 0 ) {
136
- self.nameField .hidden = YES ;
137
- } else {
138
- self.requiredLabel .hidden = YES ;
139
- }
140
- }];
78
+ [NSLayoutConstraint activateConstraints: self .portraitFullConstraints];
141
79
}
142
80
}
143
81
0 commit comments