Skip to content

Commit

Permalink
✨ Don't reset padding if all values are equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Jun 17, 2024
1 parent 1705c86 commit 77cc326
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,19 @@ struct PaddingConfigurationView: View {
paddingModel.configureScreenPadding = newValue

if !paddingModel.configureScreenPadding {
paddingModel.window = 0
paddingModel.top = 0
paddingModel.bottom = 0
paddingModel.right = 0
paddingModel.left = 0
if paddingModel.allEqual {
let window = paddingModel.window
paddingModel.top = window
paddingModel.bottom = window
paddingModel.right = window
paddingModel.left = window
} else {
paddingModel.window = 0
paddingModel.top = 0
paddingModel.bottom = 0
paddingModel.right = 0
paddingModel.left = 0
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Loop/Utilities/PaddingModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ struct PaddingModel: Codable, Defaults.Serializable, Hashable {
var totalHorizontalPadding: CGFloat {
right + left
}

var allEqual: Bool {
window == top && window == bottom && window == right && window == left
}
}

0 comments on commit 77cc326

Please sign in to comment.