Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -54,32 +54,38 @@ public extension UISegmentedControl {
)
}

func setFontStyle() {
let style: [NSAttributedString.Key: Any] = [
func setFontStyle(_ selectionColor: UIColor?) {

let normalStyle: [NSAttributedString.Key: Any] = [
.font: UIFont.scaledNamedFont(.regular14),
.foregroundColor: UIColor.textDark
]

setTitleTextAttributes(style, for: .normal)
setTitleTextAttributes(style, for: .selected)
let selectedStyle: [NSAttributedString.Key: Any] = [
.font: UIFont.scaledNamedFont(.bold14),
.foregroundColor: selectionColor ?? .textDark
]

setTitleTextAttributes(normalStyle, for: .normal)
setTitleTextAttributes(selectedStyle, for: .selected)
}

func addUnderlineForSelectedSegment() {
func addUnderlineForSelectedSegment(_ selectionColor: UIColor?) {
if let existingView = viewWithTag(1) {
existingView.frame.size.width = self.bounds.size.width / CGFloat(self.numberOfSegments)
existingView.frame.origin.x = selectedSegmentOriginX
return
}
removeBorders()
setFontStyle()
setFontStyle(selectionColor)
let underlineWidth: CGFloat = bounds.size.width / CGFloat(numberOfSegments)
let underlineHeight: CGFloat = 1.5
let underlineXPosition = CGFloat(selectedSegmentIndex * Int(underlineWidth))
let underLineYPosition = bounds.size.height - 0.5
let underlineFrame = CGRect(x: underlineXPosition, y: underLineYPosition, width: underlineWidth, height: underlineHeight)
let underline = UIView(frame: underlineFrame)
underline.translatesAutoresizingMaskIntoConstraints = false
underline.backgroundColor = .backgroundInfo
underline.backgroundColor = selectionColor ?? .backgroundInfo
underline.tag = 1
addSubview(underline)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class SubmissionDetailsViewController: ScreenViewTrackableViewController, Submis
var contentViewController: UIViewController?
var drawerContentViewController: UIViewController?
var env: AppEnvironment?
private var context: Context?

public lazy var screenViewTrackingParameters: ScreenViewTrackingParameters = {
let courseID = presenter?.course.first?.id ?? ""
let assignmentID = presenter?.assignmentID ?? ""
Expand All @@ -51,6 +53,7 @@ class SubmissionDetailsViewController: ScreenViewTrackableViewController, Submis
static func create(env: AppEnvironment, context: Context, assignmentID: String, userID: String, selectedAttempt: Int? = nil) -> SubmissionDetailsViewController {
let controller = loadFromStoryboard()
controller.env = env
controller.context = context
controller.presenter = SubmissionDetailsPresenter(env: env, view: controller, context: context, assignmentID: assignmentID, userID: userID, selectedAttempt: selectedAttempt)
return controller
}
Expand All @@ -60,6 +63,7 @@ class SubmissionDetailsViewController: ScreenViewTrackableViewController, Submis
view.backgroundColor = .backgroundLightest

setupTitleViewInNavbar(title: String(localized: "Submission", bundle: .student))
drawer?.selectionColor = env.flatMap({ context?.color(in: $0.database.viewContext) })
drawer?.tabs?.addTarget(self, action: #selector(drawerTabChanged), for: .valueChanged)
emptyView?.submitCallback = { [weak self] button in
self?.presenter?.submit(button: button)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Drawer: UIView {
@IBOutlet weak var contentView: UIView?
@IBOutlet weak var contentViewHeight: NSLayoutConstraint?

var selectionColor: UIColor?
var height: CGFloat = 0
// this number doesnt seem to be accurate all the time, especially on iphones with a notch
// Thus this number is more of a starting place. There is a constraint on the drawer to prevent
Expand Down Expand Up @@ -82,7 +83,7 @@ class Drawer: UIView {
super.layoutSubviews()
DispatchQueue.main.async { [weak self] in
self?.drawerControls?.roundCorners(corners: [.topLeft, .topRight], radius: 10)
self?.tabs?.addUnderlineForSelectedSegment()
self?.tabs?.addUnderlineForSelectedSegment(self?.selectionColor)
}
addDropShadow()
}
Expand Down