Skip to content
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

Sync: Part 9 sync to upstream #554

Merged
merged 9 commits into from
Dec 19, 2024
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
10 changes: 7 additions & 3 deletions Core/Core/Configuration/Config/ThemeConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
//

import Foundation
import OEXFoundation

private enum ThemeKeys: String {
private enum ThemeKeys: String, RawStringExtractable {
case isRoundedCorners = "ROUNDED_CORNERS_STYLE"
case buttonCornersRadius = "BUTTON_CORNERS_RADIUS"
}

public final class ThemeConfig: NSObject {
public var isRoundedCorners: Bool

public var buttonCornersRadius: Double

init(dictionary: [String: AnyObject]) {
isRoundedCorners = dictionary[ThemeKeys.isRoundedCorners.rawValue] as? Bool != false
isRoundedCorners = dictionary[ThemeKeys.isRoundedCorners] as? Bool != false
buttonCornersRadius = dictionary[ThemeKeys.buttonCornersRadius] as? Double ?? 8.0
super.init()
}
}
Expand Down
12 changes: 6 additions & 6 deletions Core/Core/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public enum CoreLocalization {
/// Yesterday
public static let yesterday = CoreLocalization.tr("Localizable", "YESTERDAY", fallback: "Yesterday")
public enum Alert {
/// ACCEPT
public static let accept = CoreLocalization.tr("Localizable", "ALERT.ACCEPT", fallback: "ACCEPT")
/// Accept
public static let accept = CoreLocalization.tr("Localizable", "ALERT.ACCEPT", fallback: "Accept")
/// Add
public static let add = CoreLocalization.tr("Localizable", "ALERT.ADD", fallback: "Add")
/// Remove course calendar
public static let calendarShiftPromptRemoveCourseCalendar = CoreLocalization.tr("Localizable", "ALERT.CALENDAR_SHIFT_PROMPT_REMOVE_COURSE_CALENDAR", fallback: "Remove course calendar")
/// CANCEL
public static let cancel = CoreLocalization.tr("Localizable", "ALERT.CANCEL", fallback: "CANCEL")
/// DELETE
public static let delete = CoreLocalization.tr("Localizable", "ALERT.DELETE", fallback: "DELETE")
/// Cancel
public static let cancel = CoreLocalization.tr("Localizable", "ALERT.CANCEL", fallback: "Cancel")
/// Delete
public static let delete = CoreLocalization.tr("Localizable", "ALERT.DELETE", fallback: "Delete")
/// Keep editing
public static let keepEditing = CoreLocalization.tr("Localizable", "ALERT.KEEP_EDITING", fallback: "Keep editing")
/// Leave
Expand Down
24 changes: 12 additions & 12 deletions Core/Core/View/Base/AlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public struct AlertView: View {
.fill(Theme.Colors.warning)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
Expand Down Expand Up @@ -319,7 +319,7 @@ public struct AlertView: View {
.fill(Theme.Colors.accentColor)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
Expand All @@ -344,17 +344,17 @@ public struct AlertView: View {
})
.background(
Theme.Shapes.buttonShape
.fill(.clear)
.fill(Theme.Colors.background)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
lineJoin: .round,
miterLimit: 1
))
.foregroundColor(Theme.Colors.secondaryButtonBorderColor)
.foregroundColor(Theme.Colors.accentColor)
)
.frame(maxWidth: 215)
}
Expand Down Expand Up @@ -411,7 +411,7 @@ public struct AlertView: View {
} label: {
ZStack {
Text(primaryButtonTitle)
.foregroundColor(Theme.Colors.styledButtonText)
.foregroundColor(Theme.Colors.primaryButtonTextColor)
.font(Theme.Fonts.labelLarge)
.frame(maxWidth: .infinity)
.padding(.horizontal, 16)
Expand All @@ -420,10 +420,10 @@ public struct AlertView: View {
}
.background(
Theme.Shapes.buttonShape
.fill(Theme.Colors.accentButtonColor)
.fill(Theme.Colors.accentColor)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
Expand All @@ -439,7 +439,7 @@ public struct AlertView: View {
}, label: {
ZStack {
Text(secondaryButtonTitle)
.foregroundColor(Theme.Colors.secondaryButtonTextColor)
.foregroundColor(Theme.Colors.accentColor)
.font(Theme.Fonts.labelLarge)
.frame(maxWidth: .infinity)
.padding(.horizontal, 16)
Expand All @@ -448,17 +448,17 @@ public struct AlertView: View {
})
.background(
Theme.Shapes.buttonShape
.fill(Theme.Colors.secondaryButtonBGColor)
.fill(Theme.Colors.background)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
lineJoin: .round,
miterLimit: 1
))
.foregroundColor(Theme.Colors.secondaryButtonBorderColor)
.foregroundColor(Theme.Colors.accentColor)
)
.frame(maxWidth: 215)
}
Expand Down
1 change: 1 addition & 0 deletions Core/Core/View/Base/DownloadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public struct DownloadAvailableView: View {
CoreAssets.startDownloading.swiftUIImage.renderingMode(.template)
.resizable()
.scaledToFit()
.foregroundColor(Theme.Colors.textPrimary)
.frame(width: 24, height: 24)
}
.frame(width: 30, height: 30)
Expand Down
4 changes: 4 additions & 0 deletions Core/Core/View/Base/LogistrationBottomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public enum LogistrationSourceScreen: Equatable, Sendable {
case discovery
case courseDetail(String, String)
case programDetails(String)

public var value: String? {
return String(describing: self).components(separatedBy: "(").first
}
}

public enum LogistrationAction: Sendable {
Expand Down
12 changes: 9 additions & 3 deletions Core/Core/View/Base/UnitButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,16 @@ public struct UnitButtonView: View {
case .continueLesson, .nextSection:
HStack {
Text(type.stringValue())
.foregroundColor(Theme.Colors.styledButtonText)
.foregroundColor(
type == .continueLesson ? Theme.Colors.resumeButtonText :
Theme.Colors.styledButtonText
)
.padding(.leading, 20)
.font(Theme.Fonts.labelLarge)
CoreAssets.arrowLeft.swiftUIImage.renderingMode(.template)
.foregroundColor(
type == .continueLesson
? Theme.Colors.accentColor
? Theme.Colors.resumeButtonText
: Theme.Colors.styledButtonText
)
.rotationEffect(Angle.degrees(180))
Expand Down Expand Up @@ -184,7 +187,10 @@ public struct UnitButtonView: View {

case .continueLesson, .nextSection, .reload, .finish, .custom:
Theme.Shapes.buttonShape
.fill(bgColor ?? Theme.Colors.accentButtonColor)
.fill(
type == .continueLesson ? Theme.Colors.resumeButtonBG :
bgColor ?? Theme.Colors.accentButtonColor
)

.shadow(color: (type == .first
|| type == .next
Expand Down
6 changes: 3 additions & 3 deletions Core/Core/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
"DATE.DUE_IN" = "Due in ";
"DATE.DUE_IN_DAYS" = "Due in %@ Days";

"ALERT.ACCEPT" = "ACCEPT";
"ALERT.CANCEL" = "CANCEL";
"ALERT.ACCEPT" = "Accept";
"ALERT.CANCEL" = "Cancel";
"ALERT.LOGOUT" = "Log out";
"ALERT.LEAVE" = "Leave";
"ALERT.KEEP_EDITING" = "Keep editing";
"ALERT.DELETE" = "DELETE";
"ALERT.DELETE" = "Delete";
"ALERT.ADD" = "Add";
"ALERT.REMOVE" = "Remove";
"ALERT.CALENDAR_SHIFT_PROMPT_REMOVE_COURSE_CALENDAR"="Remove course calendar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct CourseProgressView: View {
ZStack(alignment: .leading) {
GeometryReader { geometry in
RoundedRectangle(cornerRadius: 10)
.fill(Theme.Colors.textSecondary.opacity(0.5))
.fill(Theme.Colors.courseProgressBG)
.frame(width: geometry.size.width, height: 10)

if let total = progress.totalAssignmentsCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ struct CustomDisclosureGroup: View {
.rotationEffect(.degrees(expandedSections[chapter.id] ?? false ? -90 : 90))
.foregroundColor(Theme.Colors.textPrimary)
if chapter.childs.allSatisfy({ $0.completion == 1 }) {
CoreAssets.finishedSequence.swiftUIImage
CoreAssets.finishedSequence.swiftUIImage.renderingMode(.template)
.foregroundColor(Theme.Colors.success)
}
Text(chapter.displayName)
.font(Theme.Fonts.titleMedium)
Expand Down Expand Up @@ -112,7 +113,9 @@ struct CustomDisclosureGroup: View {
HStack {
if sequential.completion == 1 {
CoreAssets.finishedSequence.swiftUIImage
.renderingMode(.template)
.resizable()
.foregroundColor(Theme.Colors.success)
.frame(width: 20, height: 20)
} else {
sequential.type.image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public struct PrimaryCardView: View {
}

private var assignments: some View {
VStack(alignment: .leading, spacing: 8) {
VStack(alignment: .leading, spacing: 0) {
// pastAssignments
if pastAssignments.count == 1, let pastAssignment = pastAssignments.first {
courseButton(
Expand Down Expand Up @@ -188,6 +188,7 @@ public struct PrimaryCardView: View {
description: DashboardLocalization.Learn.PrimaryCard.resume,
icon: CoreAssets.resumeCourse.swiftUIImage,
selected: true,
bgColor: Theme.Colors.accentButtonColor,
action: { resumeAction() }
)
} else {
Expand All @@ -196,6 +197,7 @@ public struct PrimaryCardView: View {
description: nil,
icon: CoreAssets.resumeCourse.swiftUIImage,
selected: true,
bgColor: Theme.Colors.accentButtonColor,
action: { resumeAction() }
)
}
Expand All @@ -207,6 +209,7 @@ public struct PrimaryCardView: View {
description: String?,
icon: Image,
selected: Bool,
bgColor: Color = Theme.Colors.primaryCardCautionBG,
action: @escaping () -> Void
) -> some View {
Button(action: {
Expand Down Expand Up @@ -242,14 +245,15 @@ public struct PrimaryCardView: View {
.padding(.top, 2)
}
}
.padding(.bottom, 8)
Spacer()
CoreAssets.chevronRight.swiftUIImage
.foregroundStyle(foregroundColor(selected))
.padding(8)
}
.padding(.top, 8)
.padding(.bottom, selected ? 10 : 0)
}.background(selected ? Theme.Colors.accentButtonColor : .clear)
}.background(bgColor)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct ProgressLineView: View {
ZStack(alignment: .leading) {
GeometryReader { geometry in
Rectangle()
.foregroundStyle(Theme.Colors.cardViewStroke)
.foregroundStyle(Theme.Colors.primaryCardProgressBG)
Rectangle()
.foregroundStyle(Theme.Colors.accentButtonColor)
.frame(width: geometry.size.width * progressValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,25 @@ extension DiscoveryWebviewViewModel: WebViewNavigationDelegate {
}

if let url = request.url, outsideLink || capturedLink || externalLink, UIApplication.shared.canOpenURL(url) {
analytics.externalLinkOpen(url: url.absoluteString, screen: sourceScreen.value ?? "")
router.presentAlert(
alertTitle: DiscoveryLocalization.Alert.leavingAppTitle,
alertMessage: DiscoveryLocalization.Alert.leavingAppMessage,
positiveAction: CoreLocalization.Webview.Alert.continue,
onCloseTapped: { [weak self] in
self?.router.dismiss(animated: true)
}, okTapped: {
self?.analytics.externalLinkOpenAction(
url: url.absoluteString,
screen: self?.sourceScreen.value ?? "",
action: "cancel"
)
}, okTapped: { [weak self] in
UIApplication.shared.open(url, options: [:])
self?.analytics.externalLinkOpenAction(
url: url.absoluteString,
screen: self?.sourceScreen.value ?? "",
action: "continue"
)
}, type: .default(positiveAction: CoreLocalization.Webview.Alert.continue, image: nil)
)
return true
Expand Down
19 changes: 13 additions & 6 deletions Discussion/Discussion/Presentation/Comments/Base/CommentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public struct CommentCell: View {
.resizable()
.frame(width: 32, height: 32)
.cornerRadius(16)
.overlay {
Circle()
.stroke(Theme.Colors.avatarStroke, lineWidth: 1)
}
})

VStack(alignment: .leading) {
Expand All @@ -70,16 +74,18 @@ public struct CommentCell: View {
Button(action: {
onReportTap()
}, label: {
comment.abuseFlagged
let icon = comment.abuseFlagged
? CoreAssets.reported.swiftUIImage
: CoreAssets.report.swiftUIImage
icon.renderingMode(.template)

Text(comment.abuseFlagged
? DiscussionLocalization.Comment.unreport
: DiscussionLocalization.Comment.report)
.font(Theme.Fonts.labelMedium)
}).foregroundColor(comment.abuseFlagged
? Theme.Colors.alert
: Theme.Colors.textSecondary)
? Theme.Colors.irreversibleAlert
: Theme.Colors.textSecondaryLight)
}
Text(comment.postBodyHtml.hideHtmlTagsAndUrls())
.font(Theme.Fonts.bodyMedium)
Expand Down Expand Up @@ -125,15 +131,16 @@ public struct CommentCell: View {
: CoreAssets.vote.swiftUIImage.renderingMode(.template)
Text("\(comment.votesCount)")
Text(DiscussionLocalization.votesCount(comment.votesCount))
.font(Theme.Fonts.labelLarge)
}).foregroundColor(comment.voted
? Theme.Colors.accentXColor
: Theme.Colors.textSecondary)
? Theme.Colors.accentColor
: Theme.Colors.textSecondaryLight)
.font(Theme.Fonts.labelLarge)

Spacer()
if addCommentAvailable {
HStack {
Image(systemName: "message.fill")
.renderingMode(.template)
Text("\(comment.responsesCount)")
Text(DiscussionLocalization.commentsCount(comment.responsesCount))
}
Expand Down
Loading
Loading