ui(training): 统一课程学习与在线考试步骤栏样式
This commit is contained in:
@@ -9,7 +9,9 @@ final class TrainingCourseViewController: TrainingBaseViewController {
|
||||
private let service: any TrainingDataServing
|
||||
private let viewModel: TrainingRemoteReadingViewModel
|
||||
private let webView: WKWebView
|
||||
private let headerStack = UIStackView()
|
||||
private let toolbar = UIStackView()
|
||||
private let stepView = TrainingStepView(currentStep: .learning)
|
||||
private let sectionsButton = TrainingUI.button("章节目录", secondary: true)
|
||||
private let attachmentsButton = TrainingUI.button("课程附件", secondary: true)
|
||||
private let bottomStack = UIStackView()
|
||||
@@ -70,6 +72,9 @@ final class TrainingCourseViewController: TrainingBaseViewController {
|
||||
toolbar.distribution = .fillEqually
|
||||
toolbar.addArrangedSubview(sectionsButton)
|
||||
toolbar.addArrangedSubview(attachmentsButton)
|
||||
headerStack.axis = .vertical
|
||||
headerStack.spacing = 20
|
||||
headerStack.addArrangedSubview(toolbar)
|
||||
bottomStack.axis = .vertical
|
||||
bottomStack.spacing = 8
|
||||
bottomStack.layoutMargins = UIEdgeInsets(top: 10, left: 12, bottom: 10, right: 12)
|
||||
@@ -80,19 +85,19 @@ final class TrainingCourseViewController: TrainingBaseViewController {
|
||||
actionButton.accessibilityIdentifier = "training.reading.action"
|
||||
sectionsButton.accessibilityIdentifier = "training.reading.sections"
|
||||
attachmentsButton.accessibilityIdentifier = "training.reading.attachments"
|
||||
view.addSubview(toolbar)
|
||||
view.addSubview(headerStack)
|
||||
view.addSubview(webView)
|
||||
view.addSubview(bottomStack)
|
||||
applyState()
|
||||
}
|
||||
|
||||
override func setupConstraints() {
|
||||
toolbar.snp.makeConstraints {
|
||||
headerStack.snp.makeConstraints {
|
||||
$0.top.equalTo(view.safeAreaLayoutGuide).offset(8)
|
||||
$0.leading.trailing.equalToSuperview().inset(13)
|
||||
}
|
||||
webView.snp.makeConstraints {
|
||||
$0.top.equalTo(toolbar.snp.bottom).offset(8)
|
||||
$0.top.equalTo(headerStack.snp.bottom).offset(8)
|
||||
$0.leading.trailing.equalTo(view.safeAreaLayoutGuide)
|
||||
$0.bottom.equalTo(bottomStack.snp.top)
|
||||
}
|
||||
@@ -185,11 +190,10 @@ final class TrainingCourseViewController: TrainingBaseViewController {
|
||||
<!doctype html><html lang="zh-CN"><head><meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src https: data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
|
||||
<style>
|
||||
*{box-sizing:border-box}body{font:15px -apple-system,BlinkMacSystemFont,sans-serif;color:#34435b;background:#f5f8fc;margin:0;padding:14px 13px;line-height:1.95;overflow-wrap:anywhere}
|
||||
*{box-sizing:border-box}body{font:15px -apple-system,BlinkMacSystemFont,sans-serif;color:#34435b;background:#f5f8fc;margin:0;padding:0 13px 14px;line-height:1.95;overflow-wrap:anywhere}
|
||||
h1{font-size:17px;font-weight:600;line-height:1.6;color:#172033;margin:14px 0 6px}h2{font-size:15.5px;font-weight:600;color:#172033;margin:0 0 10px}img{max-width:100%;height:auto}table{max-width:100%;display:block;overflow:auto}a{color:#2379ff}
|
||||
.step{display:flex;gap:20px;background:#edf1f7;padding:9px 12px;border-radius:8px;font-size:13px;color:#8994a6}.step b{font-weight:500;color:#2379ff}
|
||||
.muted{font-size:12.5px;color:#8491a6;line-height:1.65;margin:6px 0}.reading{background:white;border:1px solid #e3ebf5;border-radius:11px;padding:14px;margin-top:14px}
|
||||
</style></head><body><div class='step'><b>1 课程学习</b><span>\(task.mode == .exam ? "2 在线考试" : "完成学习")</span></div>
|
||||
</style></head><body>
|
||||
<h1>\(escape(task.title))</h1><p class='muted'>\(escape(course.title))</p><p class='muted'>\(metadata)</p><p class='muted'>\(escape(course.introduction))</p>
|
||||
<p class='muted'>第 \(section.order) / \(course.sectionCount) 节</p><div class='reading'><h2>\(escape(section.title))</h2>\(section.contentHTML)</div></body></html>
|
||||
""", baseURL: nil)
|
||||
@@ -202,6 +206,10 @@ final class TrainingCourseViewController: TrainingBaseViewController {
|
||||
|
||||
private func applyState() {
|
||||
guard !viewModel.isInvalidated else { leaveUnavailableCourse(); return }
|
||||
if let task = viewModel.task?.summary {
|
||||
stepView.configure(mode: task.mode)
|
||||
if stepView.superview == nil { headerStack.addArrangedSubview(stepView) }
|
||||
}
|
||||
let canInteract = userRequestID == nil
|
||||
sectionsButton.isUserInteractionEnabled = canInteract
|
||||
attachmentsButton.isUserInteractionEnabled = canInteract
|
||||
|
||||
Reference in New Issue
Block a user