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

chore: Elm theme improvement on Course Discussions #90

Open
wants to merge 7 commits into
base: 2U/develop
Choose a base branch
from
Open
8 changes: 6 additions & 2 deletions Core/Core/Configuration/Config/ThemeConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@

import Foundation

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

Choose a reason for hiding this comment

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

Vertical Whitespace Violation: Limit vertical whitespace to a single empty line; currently 2 (vertical_whitespace)


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
10 changes: 5 additions & 5 deletions Core/Core/View/Base/AlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,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 @@ -334,7 +334,7 @@ public struct AlertView: View {
.fill(Theme.Colors.accentColor)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
Expand Down Expand Up @@ -362,7 +362,7 @@ public struct AlertView: View {
.fill(.clear)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
Expand Down Expand Up @@ -448,7 +448,7 @@ public struct AlertView: View {
.fill(Theme.Colors.accentButtonColor)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
Expand Down Expand Up @@ -476,7 +476,7 @@ public struct AlertView: View {
.fill(Theme.Colors.secondaryButtonBGColor)
)
.overlay(
RoundedRectangle(cornerRadius: 8)
Theme.Shapes.buttonShape
.stroke(style: .init(
lineWidth: 1,
lineCap: .round,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,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 @@ -122,15 +124,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
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ public struct ParentCommentView: View {
KFImage(URL(string: comments.authorAvatar))
.onFailureImage(KFCrossPlatformImage(systemName: "person"))
.resizable()
.background(Color.gray)
.frame(width: 48, height: 48)
.cornerRadius(isThread ? 8 : 24)
.cornerRadius(24)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this change acceptable for upstream?
Screenshot 2024-10-18 at 14 47 46

Copy link
Author

Choose a reason for hiding this comment

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

I guess so because this is the only place where the user avatar isn't circular. So after this change, the user avatar will be consistent across the app.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hello @marcotuts and @sdaitzman. Could you please confirm that this almost square avatar is not a design feature and should be the same throughout the app? Thank you

Copy link

Choose a reason for hiding this comment

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

to me the avatar being square and circle is a design inconsistency. It should either be circle everywhere or square everywhere. For 2U we have a circular approach to icons and buttons.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with you. Just need confirmation we shouldn't add theming here.

})
VStack(alignment: .leading) {
Text(comments.authorName)
Expand All @@ -65,6 +64,7 @@ public struct ParentCommentView: View {
onFollowTap()
}, label: {
Image(systemName: comments.followed ? "star.fill" : "star")
.renderingMode(.template)
Text(comments.followed
? DiscussionLocalization.Comment.unfollow
: DiscussionLocalization.Comment.follow)
Expand Down Expand Up @@ -108,29 +108,31 @@ public struct ParentCommentView: View {
}, label: {
comments.voted
? (CoreAssets.voted.swiftUIImage.renderingMode(.template))
: (CoreAssets.vote.swiftUIImage.renderingMode(.template))
: CoreAssets.vote.swiftUIImage.renderingMode(.template)

Text("\(comments.votesCount)")
.foregroundColor(Theme.Colors.textPrimary)
Text(DiscussionLocalization.votesCount(comments.votesCount))
.font(Theme.Fonts.labelLarge)
.foregroundColor(Theme.Colors.textPrimary)

}).foregroundColor(comments.voted
? Theme.Colors.accentXColor
? Theme.Colors.accentColor
: Theme.Colors.textSecondaryLight)
Spacer()
Button(action: {
onReportTap()
}, label: {
comments.abuseFlagged
let icon = comments.abuseFlagged
? CoreAssets.reported.swiftUIImage
: CoreAssets.report.swiftUIImage
icon.renderingMode(.template)

Text(comments.abuseFlagged
? DiscussionLocalization.Comment.unreport
: DiscussionLocalization.Comment.report)
})
}
.accentColor(comments.abuseFlagged
? Theme.Colors.alert
? Theme.Colors.irreversibleAlert
: Theme.Colors.textSecondaryLight)
.font(Theme.Fonts.labelLarge)
}
Expand Down
1 change: 1 addition & 0 deletions OpenEdX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

if let config = Container.shared.resolve(ConfigProtocol.self) {
Theme.Shapes.isRoundedCorners = config.theme.isRoundedCorners
Theme.Shapes.buttonCornersRadius = config.theme.buttonCornersRadius

if config.facebook.enabled {
ApplicationDelegate.shared.application(
Expand Down
3 changes: 2 additions & 1 deletion Theme/Theme/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,15 @@ public struct Theme {

public struct Shapes {
public static var isRoundedCorners: Bool = true
public static var buttonCornersRadius: Double = 8.0
public static let screenBackgroundRadius = 24.0
public static let cardImageRadius = 10.0
public static let textInputShape = {
let radius: CGFloat = isRoundedCorners ? 8 : 0
return RoundedRectangle(cornerRadius: radius)
}()
public static let buttonShape = {
let radius: CGFloat = isRoundedCorners ? 8 : 0
let radius: CGFloat = isRoundedCorners ? buttonCornersRadius : 0
return RoundedCorners(tl: radius, tr: radius, bl: radius, br: radius)
}()
public static let unitButtonShape = RoundedCorners(tl: 21, tr: 21, bl: 21, br: 21)
Expand Down
Loading