Skip to content

Commit b65fc49

Browse files
authored
Merge pull request #16 from i-stack/release_1.3.0
Fix keyboard inset restoration and improve rotation handling
2 parents 5c45ac4 + 3697bfc commit b65fc49

4 files changed

Lines changed: 25 additions & 24 deletions

File tree

‎.swiftlint.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
included:
1111
- Sources
1212

13+
# SwiftLint analyze 的 unused_import 对系统框架 import(Foundation/UIKit/Security 等)存在已知误报:
14+
# swiftc 编译日志 0 条 unused import 警告,删除这些 import 会导致编译失败
15+
# (如 STSecurityModels 依赖 Foundation 的 Date/TimeInterval,见 .github/workflows/swift.yml 的 Analyze 步骤)。
16+
# 该规则已整体禁用(见下方 analyzer_rules),故无需在此按文件排除。
1317
excluded:
1418
- Sources/STMarkdown/Resources
1519
- .build
@@ -67,8 +71,15 @@ opt_in_rules:
6771
force_cast: error # as! 直接 error
6872

6973
analyzer_rules:
70-
- unused_import
71-
- unused_declaration
74+
# 本仓库是底层公用库:大量 public/internal/fileprivate API 提供给宿主 App / Example 模块调用,
75+
# SwiftLint analyze 的 analyzer_rules 只扫描包内 99 个文件,看不到外部调用方,
76+
# 会系统性误报 unused_import 与 unused_declaration(且 swiftc 编译日志证明 import 必需)。
77+
# 验证依据见下。故整体禁用这两个 analyzer 规则。
78+
# - unused_import : 系统框架 import(Foundation/UIKit/Security 等)被误判为冗余,
79+
# clean build 的 swiftc 编译日志 unused import 警告为 0 条,删除会导致编译失败。
80+
# - unused_declaration: 对外暴露的库 API 在包内无引用,被误判为未使用。
81+
# - unused_import
82+
# - unused_declaration
7283

7384
# 公开 API 文档缺失检查:存量 882 个未清零,暂移出 opt_in_rules(见 disabled_rules),
7485
# 待文档补齐专项后再恢复并重新纳入 --strict 门槛。仅检查 public 级别。

‎Sources/STBaseView/STBaseView.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ open class STBaseView: UIView {
404404
guard self.layoutMode == .scroll else { return }
405405
guard appearing || self.baseContentInset != nil else { return }
406406
guard let userInfo = note.userInfo, self.enableScrollViewKeyboardAdjustment else {
407-
if !appearing, let baseContent = self.baseContentInset {
407+
if !appearing, self.baseContentInset != nil {
408408
// 键盘调整被关闭,但仍需还原已注入的 inset。
409409
self.restoreBaseInsets()
410410
}

‎Sources/STConfig/STOrientationManager.swift‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,13 @@ public final class STOrientationManager {
3232
}
3333

3434
private func requestGeometryUpdate(_ orientations: UIInterfaceOrientationMask, in windowScene: UIWindowScene?) {
35-
let targetWindowScene = windowScene ?? self.activeWindowScene()
36-
if #available(iOS 16.0, *), let targetWindowScene {
37-
targetWindowScene.requestGeometryUpdate(.iOS(interfaceOrientations: orientations)) { error in
38-
STLog("[STOrientationManager] requestGeometryUpdate failed: \(error.localizedDescription)")
39-
}
40-
} else {
41-
UIDevice.current.setValue(self.preferredOrientation(for: orientations).rawValue, forKey: "orientation")
35+
guard let targetWindowScene = windowScene ?? self.activeWindowScene() else {
36+
STLog("[STOrientationManager] No active UIWindowScene found; cannot request geometry update.")
37+
return
38+
}
39+
targetWindowScene.requestGeometryUpdate(.iOS(interfaceOrientations: orientations)) { error in
40+
STLog("[STOrientationManager] requestGeometryUpdate failed: \(error.localizedDescription)")
4241
}
43-
UIViewController.attemptRotationToDeviceOrientation()
44-
}
45-
46-
private func preferredOrientation(for orientations: UIInterfaceOrientationMask) -> UIInterfaceOrientation {
47-
if orientations.contains(.portrait) { return .portrait }
48-
if orientations.contains(.landscapeLeft) { return .landscapeLeft }
49-
if orientations.contains(.landscapeRight) { return .landscapeRight }
50-
if orientations.contains(.portraitUpsideDown) { return .portraitUpsideDown }
51-
return .portrait
5242
}
5343

5444
private func activeWindowScene() -> UIWindowScene? {

‎Sources/STHUD/STAlertController.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private enum STAlertLayoutConstant {
5555
static let titleMessageSpacing: CGFloat = 10
5656
}
5757

58-
public enum STAlertBtnClickType {
58+
public enum STAlertBtnClickType: String {
5959
case btnClick
6060
case leftBtnClick
6161
case rightBtnClick
@@ -300,7 +300,7 @@ open class STAlertController: UIViewController {
300300
handler(true, sender.titleLabel?.text ?? "")
301301
}
302302
} else {
303-
if let type = sender.identifier as? STAlertBtnClickType, type == .leftBtnClick {
303+
if sender.stringIdentifier == STAlertBtnClickType.leftBtnClick.rawValue {
304304
if let handler = self.alertInfo.buttonHandlers.first {
305305
handler(true, sender.titleLabel?.text ?? "")
306306
}
@@ -335,7 +335,7 @@ open class STAlertController: UIViewController {
335335
}()
336336
let btn = self.createBtn(action: singleAction)
337337
btn.tag = 0
338-
btn.identifier = STAlertBtnClickType.btnClick
338+
btn.stringIdentifier = STAlertBtnClickType.btnClick.rawValue
339339
btn.addTarget(self, action: #selector(alertButtonClick), for: .touchUpInside)
340340
self.alertView.addSubview(btn)
341341
self.view.addConstraints([
@@ -370,7 +370,7 @@ open class STAlertController: UIViewController {
370370
}()
371371
let leftBtn = self.createBtn(action: leftAction)
372372
leftBtn.tag = 0
373-
leftBtn.identifier = STAlertBtnClickType.leftBtnClick
373+
leftBtn.stringIdentifier = STAlertBtnClickType.leftBtnClick.rawValue
374374
leftBtn.addTarget(self, action: #selector(alertButtonClick), for: .touchUpInside)
375375
self.alertView.addSubview(leftBtn)
376376

@@ -390,7 +390,7 @@ open class STAlertController: UIViewController {
390390
}()
391391
let rightBtn = self.createBtn(action: rightAction)
392392
rightBtn.tag = 1
393-
rightBtn.identifier = STAlertBtnClickType.rightBtnClick
393+
rightBtn.stringIdentifier = STAlertBtnClickType.rightBtnClick.rawValue
394394
rightBtn.addTarget(self, action: #selector(alertButtonClick), for: .touchUpInside)
395395
self.alertView.addSubview(rightBtn)
396396
self.view.addConstraints([

0 commit comments

Comments
 (0)