Skip to content

Commit 864f51b

Browse files
authored
Fix layout not fitting on small screen sizes (#943)
* Apply fixes
1 parent feda8c4 commit 864f51b

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

Stepic/Sources/Modules/CourseInfo/Views/CourseInfoHeaderView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extension CourseInfoHeaderView {
55
struct Appearance {
66
let actionButtondTitleColor = UIColor.black.withAlphaComponent(0.87)
77
let actionButtonHeight: CGFloat = 42.0
8-
let actionButtonWidthRatio: CGFloat = 0.55
8+
let actionButtonWidthRatio: CGFloat = DeviceInfo.current.isSmallDiagonal ? 0.75 : 0.55
99

1010
let actionButtonsStackViewInsets = UIEdgeInsets(top: 10, left: 30, bottom: 15, right: 30)
1111
let actionButtonsStackViewSpacing: CGFloat = 15.0

Stepic/Sources/Modules/CourseInfoSubmodules/CourseInfoTabReviews/Views/Cell/CourseInfoTabReviewsCellView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension CourseInfoTabReviewsCellView {
1515

1616
let nameLabelTextColor = UIColor.stepikMaterialPrimaryText
1717
let nameLabelFont = Typography.subheadlineFont
18-
let nameLabelInsets = UIEdgeInsets(top: 8, left: 16, bottom: 0, right: 20)
18+
let nameLabelInsets = UIEdgeInsets(top: 4, left: 16, bottom: 0, right: 20)
1919

2020
let textLabelTextColor = UIColor.stepikMaterialSecondaryText
2121
let textLabelFont = Typography.subheadlineFont

Stepic/Sources/Modules/CourseInfoSubmodules/CourseInfoTabSyllabus/Views/Section/CourseInfoTabSyllabusSectionExamActionButton.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import UIKit
44
extension CourseInfoTabSyllabusSectionExamActionButton {
55
struct Appearance {
66
let titleColor = UIColor.dynamic(light: .stepikVioletFixed, dark: .stepikViolet05Fixed)
7-
let font = Typography.bodyFont
7+
let font = UIFont.systemFont(ofSize: 16)
88

99
let cornerRadius: CGFloat = 8
1010
let borderWidth: CGFloat = 1
@@ -46,6 +46,7 @@ extension CourseInfoTabSyllabusSectionExamActionButton: ProgrammaticallyInitiali
4646
func setupView() {
4747
self.setTitleColor(self.appearance.titleColor, for: .normal)
4848
self.titleLabel?.font = self.appearance.font
49+
self.titleLabel?.adjustsFontSizeToFitWidth = true
4950

5051
self.layer.cornerRadius = self.appearance.cornerRadius
5152
self.layer.borderWidth = self.appearance.borderWidth

Stepic/Sources/Modules/CourseInfoSubmodules/CourseInfoTabSyllabus/Views/Section/CourseInfoTabSyllabusSectionView.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ final class CourseInfoTabSyllabusSectionView: UIView {
151151
private var indexLabelCenterYBadgesConstraint: Constraint?
152152
private var indexLabelCenterYTitleConstraint: Constraint?
153153

154+
private var textStackViewTrailingToDownloadButtonLeadingConstraint: Constraint?
155+
private var textStackViewTrailingToSuperviewConstraint: Constraint?
156+
154157
// To properly center when downloaded size visible
155158
private var downloadButtonCenterYConstraint: Constraint?
156159

@@ -235,6 +238,14 @@ final class CourseInfoTabSyllabusSectionView: UIView {
235238
self.downloadButton.actionState = .downloading(progress: progress)
236239
}
237240

241+
if self.downloadButton.isHidden {
242+
self.textStackViewTrailingToDownloadButtonLeadingConstraint?.deactivate()
243+
self.textStackViewTrailingToSuperviewConstraint?.activate()
244+
} else {
245+
self.textStackViewTrailingToSuperviewConstraint?.deactivate()
246+
self.textStackViewTrailingToDownloadButtonLeadingConstraint?.activate()
247+
}
248+
238249
if let downloadedBytesTotal = downloadedBytesTotal {
239250
self.downloadedSizeLabel.text = FormatterHelper.megabytesInBytes(downloadedBytesTotal)
240251
self.downloadedSizeLabel.isHidden = false
@@ -394,7 +405,19 @@ extension CourseInfoTabSyllabusSectionView: ProgrammaticallyInitializableViewPro
394405
self.textStackView.snp.makeConstraints { make in
395406
make.top.equalToSuperview().offset(self.appearance.textStackViewInsets.top)
396407
make.leading.equalTo(self.indexLabel.snp.trailing).offset(self.appearance.textStackViewInsets.left)
397-
make.trailing.equalTo(self.downloadButton.snp.leading).offset(-self.appearance.textStackViewInsets.right)
408+
409+
self.textStackViewTrailingToDownloadButtonLeadingConstraint = make
410+
.trailing
411+
.equalTo(self.downloadButton.snp.leading)
412+
.offset(-self.appearance.textStackViewInsets.right)
413+
.constraint
414+
415+
self.textStackViewTrailingToSuperviewConstraint = make
416+
.trailing
417+
.equalToSuperview()
418+
.offset(-self.appearance.textStackViewInsets.right)
419+
.constraint
420+
self.textStackViewTrailingToSuperviewConstraint?.deactivate()
398421
}
399422

400423
self.deadlinesView.translatesAutoresizingMaskIntoConstraints = false

Stepic/Sources/Modules/NewProfileSubmodules/SocialProfiles/Views/NewProfileSocialProfilesItemView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension NewProfileSocialProfilesItemView: ProgrammaticallyInitializableViewPro
116116
make.leading.equalTo(self.imageView.snp.trailing).offset(self.appearance.textLabelInsets.left)
117117
make.centerY.equalToSuperview()
118118
make.trailing
119-
.greaterThanOrEqualTo(self.accessoryImageView.snp.leading)
119+
.lessThanOrEqualTo(self.accessoryImageView.snp.leading)
120120
.offset(-self.appearance.textLabelInsets.right)
121121
}
122122

0 commit comments

Comments
 (0)