Skip to content

Commit

Permalink
Make space for error message when using compact height
Browse files Browse the repository at this point in the history
  • Loading branch information
BPerlakiH committed Oct 9, 2024
1 parent 78f5f7d commit 43f104e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Kiwix/SplashScreenKiwix.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="welcomeLogo" adjustsImageSizeForAccessibilityContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aq8-ue-tYD" userLabel="Logo">
<rect key="frame" x="142" y="61" width="284" height="134"/>
<rect key="frame" x="142" y="82" width="284" height="92"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="zyG-3z-VNV"/>
</constraints>
Expand All @@ -45,7 +45,7 @@
<constraint firstItem="aq8-ue-tYD" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" constant="-58" id="tmp-PG-GZz">
<variation key="heightClass=compact" constant="-32"/>
</constraint>
<constraint firstItem="aq8-ue-tYD" firstAttribute="height" secondItem="Ze5-6b-2t3" secondAttribute="height" constant="-186" id="yNt-tV-blG"/>
<constraint firstItem="aq8-ue-tYD" firstAttribute="height" secondItem="Ze5-6b-2t3" secondAttribute="height" constant="-228" id="yNt-tV-blG"/>
</constraints>
<variation key="default">
<mask key="constraints">
Expand Down
17 changes: 10 additions & 7 deletions Views/BuildingBlocks/LoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ struct LogoCalc {
/// 50 top bar
/// 20 spacing above logo
/// Logo itself
/// 20 between logo and buttons
/// 44 height for the row of buttons
/// 20 spacing between logo and buttons
/// 44 height for the one row of buttons
/// 20 spacing below buttons
/// 22 for error message
/// 20 spacing below error message
/// 32 for bottom navbar
/// ---------
/// 186 > it's also used on the splash screen
static let minNonLogoSpace: CGFloat = barHeights + oneRowOfButtonsHeight + 3 * spacing
/// 228 > it's also used on the splash screen
static let minNonLogoSpace: CGFloat = barHeights + oneRowOfButtonsHeight + 4 * spacing + errorMsgHeight
static let barHeights: CGFloat = 50 + 32
static let oneRowOfButtonsHeight: CGFloat = 44
static let twoRowsOfButtonsHeight: CGFloat = 96
Expand Down Expand Up @@ -104,11 +106,12 @@ struct LogoCalc {
}

var errorTextCenterY: CGFloat {
if isVerticalCompact { // put the error to the top of the screen
return logoCenterY - logoSize.height * 0.5 - Const.errorMsgHeight * 0.5 - Const.spacing
let buttonsHeight = if isVerticalCompact {
Const.oneRowOfButtonsHeight
} else {
return buttonCenterY + Const.twoRowsOfButtonsHeight * 0.5 + Const.spacing + Const.errorMsgHeight * 0.5
Const.twoRowsOfButtonsHeight
}
return buttonCenterY + buttonsHeight * 0.5 + Const.spacing + Const.errorMsgHeight * 0.5
}

var buttonCenterY: CGFloat {
Expand Down
3 changes: 3 additions & 0 deletions Views/Welcome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ struct Welcome: View {
.opacity(hasSeenCategories ? 1 : 0)
.frame(maxWidth: logoCalc.buttonsWidth)
.onChange(of: library.state) { state in
if state == .error {
hasSeenCategories = true
}
guard state == .complete else { return }
#if os(macOS)
navigation.currentItem = .categories
Expand Down

0 comments on commit 43f104e

Please sign in to comment.