Skip to content

Add paddings to SubmissionViewer #3409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 3, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct SubmissionViewer: View {

@Environment(\.appEnvironment) var env
@Environment(\.viewController) var controller
@Environment(\.dynamicTypeSize) var dynamicTypeSize
@ObservedObject private var studentAnnotationViewModel: StudentAnnotationSubmissionViewerViewModel

public init(assignment: Assignment, submission: Submission, fileID: String?, studentAnnotationViewModel: StudentAnnotationSubmissionViewerViewModel, handleRefresh: (() -> Void)?) {
Expand Down Expand Up @@ -65,7 +66,9 @@ struct SubmissionViewer: View {
Text("This student's responses are hidden because this assignment is anonymous.", bundle: .teacher)
Spacer()
}
.font(.regular16).foregroundColor(.textDarkest)
.font(.regular16)
.padding(InstUI.Styles.Padding.standard.rawValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use the standard value directly:
.paddingStyle(.all, .standard) or .paddingStyle(.horizontal, .standard)

(For some reason .paddingStyle(.standard) doesn't work, this could be fixed later)

Same for other usage below

Copy link
Contributor Author

@petkybenedek petkybenedek Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift will not figure out which parameter was specified between multiple, non-named parameters with default values. Here's a short example without type inference:

func testFunction(_ message: String = "", _ statusCode: Int = 200) {
    print("Test Function Called: \(message) with status code: \(statusCode)")
}

testFunction(200)    // Cannot convert value of type 'Int' to expected argument type 'String'
testFunction()
testFunction("Open in Safari")
testFunction("Open in Safari", 200)

I fixed it, .paddingStyle(.standard) can be used now.

.foregroundColor(.textDarkest)
.multilineTextAlignment(.center)
} else {
WebSession(url: submission.previewUrl) { url in
Expand Down Expand Up @@ -105,21 +108,24 @@ struct SubmissionViewer: View {
VStack(alignment: .center, spacing: 0) {
Spacer()
Text("Failed to load submission data!", bundle: .teacher)
.font(.regular16).foregroundColor(.textDarkest)
.font(.regular16)
.foregroundColor(.textDarkest)
Text(error.localizedDescription)
.font(.regular16).foregroundColor(.textDarkest)
.font(.regular16)
.foregroundColor(.textDarkest)
.padding(.bottom, 10)
Button(action: studentAnnotationViewModel.retry, label: {
Button(action: studentAnnotationViewModel.retry) {
Text("Retry", bundle: .teacher)
.foregroundColor(Color(Brand.shared.primary))
})
}
Spacer()
}
.padding()
.padding(InstUI.Styles.Padding.standard.rawValue)
.frame(maxWidth: .infinity)
case nil:
ProgressView()
.progressViewStyle(.indeterminateCircle())
.padding(InstUI.Styles.Padding.standard.rawValue)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
.onAppear {
studentAnnotationViewModel.viewDidAppear()
Expand All @@ -140,7 +146,9 @@ struct SubmissionViewer: View {
}
Spacer()
}
.font(.regular16).foregroundColor(.textDarkest)
.font(.regular16)
.padding(InstUI.Styles.Padding.standard.rawValue)
.foregroundColor(.textDarkest)
.multilineTextAlignment(.center)
}
}
Expand All @@ -155,3 +163,24 @@ struct SubmissionViewer: View {
return true
}
}

#if DEBUG
#Preview {
let environment = PreviewEnvironment()
SubmissionViewer(
assignment: .save(
.make(anonymous_submissions: true),
in: environment.database.viewContext,
updateSubmission: false,
updateScoreStatistics: false
),
submission: .save(
.make(submission_type: .online_quiz),
in: environment.database.viewContext,
),
fileID: nil,
studentAnnotationViewModel: .init(submission: .save(.make(), in: environment.database.viewContext)),
handleRefresh: { }
)
}
#endif