minor improvements
This commit is contained in:
1 parent
4195f97d56
commit
57a8c22a3f
2 files changed
+29
-4
No files matched your search
@@ -958,9 +958,16 @@ import ObjectiveC.runtime
|
|||||||
self.denormalizedHeightFactor = widgetSize.height/baselineHeightLargeSquare;
|
self.denormalizedHeightFactor = widgetSize.height/baselineHeightLargeSquare;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate(self.shape == "round" ? [
|
||||||
|
label.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 13), // set up label size contrain within UIView
|
||||||
|
label.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -13),
|
||||||
|
label.centerXAnchor.constraint(equalTo: centerXAnchor),
|
||||||
|
label.centerYAnchor.constraint(equalTo: centerYAnchor),]
|
||||||
|
: [
|
||||||
label.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 10), // set up label size contrain within UIView
|
label.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 10), // set up label size contrain within UIView
|
||||||
label.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -10),
|
label.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -10),
|
||||||
|
label.topAnchor.constraint(equalTo: self.topAnchor, constant: 8), // set up label size contrain within UIView
|
||||||
|
label.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -8),
|
||||||
label.centerXAnchor.constraint(equalTo: centerXAnchor),
|
label.centerXAnchor.constraint(equalTo: centerXAnchor),
|
||||||
label.centerYAnchor.constraint(equalTo: centerYAnchor),])
|
label.centerYAnchor.constraint(equalTo: centerYAnchor),])
|
||||||
|
|
||||||
@@ -969,9 +976,27 @@ import ObjectiveC.runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func automaticSquareButtonCornerRadius(for size: CGSize) -> CGFloat {
|
||||||
|
let shortSideLen = min(size.width, size.height)
|
||||||
|
let longSideLen = max(size.width, size.height)
|
||||||
|
let aspectRatio = longSideLen / max(shortSideLen, 1)
|
||||||
|
let aspectProgress = min(max((aspectRatio - 1) / 1.6, 0), 1)
|
||||||
|
let radiusRatio = 0.34 - aspectProgress * 0.08
|
||||||
|
let minRadius: CGFloat = min(16, shortSideLen/2)
|
||||||
|
let maxRadius: CGFloat = 30
|
||||||
|
return min(max(shortSideLen * radiusRatio, minRadius), maxRadius)
|
||||||
|
}
|
||||||
|
|
||||||
private func setSquareWidgetCornerRadius(){
|
private func setSquareWidgetCornerRadius(){
|
||||||
let shortSideLen = min(self.layer.bounds.size.width, self.layer.bounds.size.height)
|
let boundsSize = self.layer.bounds.size
|
||||||
self.layer.cornerRadius = shortSideLen/2 < 16 ? shortSideLen/3.2 : 16
|
let shortSideLen = min(boundsSize.width, boundsSize.height)
|
||||||
|
|
||||||
|
if self.widgetType == .button, self.shape == "square" {
|
||||||
|
self.layer.cornerRadius = automaticSquareButtonCornerRadius(for: boundsSize)
|
||||||
|
} else {
|
||||||
|
self.layer.cornerRadius = shortSideLen/2 < 16 ? shortSideLen/3.2 : 16
|
||||||
|
}
|
||||||
|
|
||||||
if #available(iOS 13.0, *) {
|
if #available(iOS 13.0, *) {
|
||||||
self.layer.cornerCurve = .continuous
|
self.layer.cornerCurve = .continuous
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2129,7 +2129,7 @@ struct WidgetPickerView: View {
|
|||||||
private func defaultLabelPart(for item: WidgetPoolItem) -> String? {
|
private func defaultLabelPart(for item: WidgetPoolItem) -> String? {
|
||||||
switch item.source {
|
switch item.source {
|
||||||
case .gamepad:
|
case .gamepad:
|
||||||
return item.cmd.lowercased().capitalized
|
return item.displayCmd
|
||||||
case .keyboard:
|
case .keyboard:
|
||||||
let label = (item.displayText ?? item.cmd).trimmingCharacters(in: .whitespacesAndNewlines)
|
let label = (item.displayText ?? item.cmd).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
guard !label.isEmpty else { return nil }
|
guard !label.isEmpty else { return nil }
|
||||||
|
|||||||
Reference in new issue
Block a user