Skip to content

Commit

Permalink
chore: address feedback, disable block if content is verified only
Browse files Browse the repository at this point in the history
  • Loading branch information
mumer92 committed Nov 6, 2023
1 parent e078c71 commit d087d0d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Course/Course/Data/CourseRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ And there are various ways of describing it-- call it oral poetry or
"date_type": "assignment-due-date",
"description": "",
"learner_has_access": true,
"link": "https://courses.edx.org/courses/course-v1:MITx+6.00.1x+2T2023a/jump_to/block-v1:MITx+6.00.1x+2T2023a+type@sequential+block@ca19e125470846f2a36ad1225410e39aa",
"link": "",
"link_text": "",
"title": "Problem Set 1.1",
"extra_info": null,
Expand Down
8 changes: 7 additions & 1 deletion Course/Course/Domain/Model/CourseDates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ extension Date {
}
}

public struct CourseDateBlock {
public struct CourseDateBlock: Identifiable {
public let id: UUID = UUID()

let assignmentType: String?
let complete: Bool?
let date: Date
Expand Down Expand Up @@ -142,6 +144,10 @@ public struct CourseDateBlock {
return !isUnreleased && isLearnerAssignment
}

var isAvailable: Bool {
return learnerHasAccess && (!isUnreleased || !isLearnerAssignment)
}

var blockStatus: BlockStatus {
if isComplete {
return .completed
Expand Down
24 changes: 17 additions & 7 deletions Course/Course/Presentation/Dates/CourseDatesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public struct CourseDatesView: View {
}
} else if let courseDates = viewModel.courseDates, !courseDates.courseDateBlocks.isEmpty {
CourseDateListView(viewModel: viewModel, courseDates: courseDates)
.padding(.top)
.padding(.top, 10)
}
}
if viewModel.showError {
Expand Down Expand Up @@ -189,9 +189,10 @@ struct BlockStatusView: View {
}
}

ForEach(blocks, id: \.firstComponentBlockID) { block in
ForEach(blocks) { block in
styleBlock(block: block, allHaveSameStatus: allHaveSameStatus)
}
.padding(.top, 0.2)
}
.padding(.vertical, 0)
.padding(.leading, 5)
Expand All @@ -205,7 +206,7 @@ struct BlockStatusView: View {
attributedString += AttributedString("\(prefix): ")
}

attributedString += attributedSubtitle(string: block.title, underline: block.canShowLink)
attributedString += styleTitle(block: block)

if !allHaveSameStatus {
attributedString.appendSpaces(2)
Expand All @@ -216,14 +217,23 @@ struct BlockStatusView: View {
}

return Text(attributedString)
.padding(.bottom, 2)
.font(Theme.Fonts.bodyMedium)
.foregroundColor({
if block.isAssignment {
return block.isAvailable ? Color.black : Color.gray.opacity(0.6)
} else {
return Color.black
}
}())
.onTapGesture {

}
}

func attributedSubtitle(string: String, underline: Bool) -> AttributedString {
var attributedString = AttributedString(string)
func styleTitle(block: CourseDateBlock) -> AttributedString {
var attributedString = AttributedString(block.title)
attributedString.font = Theme.Fonts.bodyMedium
if underline {
if block.canShowLink && !block.firstComponentBlockID.isEmpty {
attributedString.underlineStyle = .single
}
return attributedString
Expand Down

0 comments on commit d087d0d

Please sign in to comment.