Skip to content

Commit

Permalink
fix: Part 5 sync to upstream (#542)
Browse files Browse the repository at this point in the history
* Merge pull request #42 from edx/password-input-view-eye

feat: eye icon for password field

* chore: added SecureInputView to project

* Merge pull request #44 from edx/clear-cookies-by-logout

fix: clear cookies by logout

* Merge pull request #47 from edx/reduce-grid-spacing

style: reduce grid spacing

* chore: Fix outdated course dates alert title truncation issue (#53)

* Merge pull request #57 from edx/remaining-size-in-gb-or-mb

chore: size in GB or MB

* fix: Remove urls from headings of End User lisence agreements (#65)

* fix: move padding to right place

* chore: fixed double space

---------

Co-authored-by: Anton Yarmolenko <[email protected]>
Co-authored-by: Shafqat Muneer <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 255e2b7 commit f209262
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct FieldsView: View {
}

private func handleURL(_ url: URL) -> OpenURLAction.Result {
router.showWebBrowser(title: url.host ?? "", url: url)
router.showWebBrowser(title: "", url: url)
return .handled
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ public struct SignInView: View {
.foregroundColor(Theme.Colors.textPrimary)
.padding(.top, 18)
.accessibilityIdentifier("password_text")
SecureField("", text: $password)
SecureInputView($password)
.font(Theme.Fonts.bodyLarge)
.foregroundColor(Theme.Colors.textInputTextColor)
.padding(.all, 14)
.background(
Theme.InputFieldBackground(
Expand Down Expand Up @@ -280,7 +279,7 @@ public struct SignInView: View {
.navigationBarHidden(true)
.ignoresSafeArea(.all, edges: .horizontal)
.background(Theme.Colors.background.ignoresSafeArea(.all))
.onFirstAppear{
.onFirstAppear {
viewModel.trackScreenEvent()
}
}
Expand Down Expand Up @@ -309,7 +308,7 @@ public struct SignInView: View {
}

private func handleURL(_ url: URL) -> OpenURLAction.Result {
viewModel.router.showWebBrowser(title: url.host ?? "", url: url)
viewModel.router.showWebBrowser(title: "", url: url)
return .handled
}
}
Expand Down
4 changes: 4 additions & 0 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
9784D47E2BF7762800AFEFFF /* FullScreenErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9784D47D2BF7762800AFEFFF /* FullScreenErrorView.swift */; };
A53A32352B233DEC005FE38A /* ThemeConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53A32342B233DEC005FE38A /* ThemeConfig.swift */; };
A595689B2B6173DF00ED4F90 /* BranchConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A595689A2B6173DF00ED4F90 /* BranchConfig.swift */; };
A5D4B3DE2CDD0A9700688951 /* SecureInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D4B3DD2CDD0A9700688951 /* SecureInputView.swift */; };
A5F4E7B52B61544A00ACD166 /* BrazeConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F4E7B42B61544A00ACD166 /* BrazeConfig.swift */; };
BA4AFB422B5A7A0900A21367 /* VideoDownloadQualityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA4AFB412B5A7A0900A21367 /* VideoDownloadQualityView.swift */; };
BA4AFB442B6A5AF100A21367 /* CheckBoxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA4AFB432B6A5AF100A21367 /* CheckBoxView.swift */; };
Expand Down Expand Up @@ -340,6 +341,7 @@
9E0B33614CBD791307FFDEAE /* Pods-App-Core-CoreTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core-CoreTests.release.xcconfig"; path = "Target Support Files/Pods-App-Core-CoreTests/Pods-App-Core-CoreTests.release.xcconfig"; sourceTree = "<group>"; };
A53A32342B233DEC005FE38A /* ThemeConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeConfig.swift; sourceTree = "<group>"; };
A595689A2B6173DF00ED4F90 /* BranchConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BranchConfig.swift; sourceTree = "<group>"; };
A5D4B3DD2CDD0A9700688951 /* SecureInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureInputView.swift; sourceTree = "<group>"; };
A5F4E7B42B61544A00ACD166 /* BrazeConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrazeConfig.swift; sourceTree = "<group>"; };
B2556B4A2D4F84F402A7A7D9 /* Pods-CoreTests.releaseprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreTests.releaseprod.xcconfig"; path = "Target Support Files/Pods-CoreTests/Pods-CoreTests.releaseprod.xcconfig"; sourceTree = "<group>"; };
BA4AFB412B5A7A0900A21367 /* VideoDownloadQualityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoDownloadQualityView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -735,6 +737,7 @@
06DEA4A22BBD66A700110D20 /* BackNavigationButton.swift */,
06DEA4A42BBD66D700110D20 /* BackNavigationButtonViewModel.swift */,
0267F8502C3C256F0089D810 /* FileWebView.swift */,
A5D4B3DD2CDD0A9700688951 /* SecureInputView.swift */,
);
path = Base;
sourceTree = "<group>";
Expand Down Expand Up @@ -1130,6 +1133,7 @@
06619EAA2B8F2936001FAADE /* ReadabilityModifier.swift in Sources */,
BAFB99902B14B377007D09F9 /* GoogleConfig.swift in Sources */,
029A132C2C2471F8005FB830 /* OfflineSyncEndpoint.swift in Sources */,
A5D4B3DE2CDD0A9700688951 /* SecureInputView.swift in Sources */,
02CF46C829546AA200A698EE /* NoCachedDataError.swift in Sources */,
0727877728D23847002E9142 /* DataLayer.swift in Sources */,
0241666B28F5A78B00082765 /* HTMLFormattedText.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Core/Core/View/Base/AlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public struct AlertView: View {
.font(Theme.Fonts.titleLarge)
.foregroundColor(Theme.Colors.textPrimary)
.padding(.horizontal, 40)
.fixedSize(horizontal: false, vertical: true)
Text(alertMessage)
.font(Theme.Fonts.bodyMedium)
.foregroundColor(Theme.Colors.textPrimary)
Expand Down
2 changes: 1 addition & 1 deletion Core/Core/View/Base/RegistrationTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public struct RegistrationTextField: View {
.accessibilityIdentifier("\(config.field.name)_textarea")
} else {
if textContentType == .password {
SecureField(placeholder, text: $config.text)
SecureInputView($config.text)
.keyboardType(keyboardType)
.textContentType(textContentType)
.autocapitalization(.none)
Expand Down
39 changes: 39 additions & 0 deletions Core/Core/View/Base/SecureInputView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// SecureInputView.swift
// Core
//
// Created by Anton Yarmolenka on 25/07/2024.
//

import SwiftUI
import Theme

public struct SecureInputView: View {

@Binding private var text: String
@State private var isSecured: Bool = true

public init(_ text: Binding<String>) {
self._text = text
}

public var body: some View {
ZStack(alignment: .trailing) {
Group {
if isSecured {
SecureField("", text: $text)
} else {
TextField("", text: $text)
}
}.padding(.trailing, 32)

Button(action: {
isSecured.toggle()
}) {
Image(systemName: self.isSecured ? "eye.slash" : "eye")
.accentColor(Theme.Colors.textInputPlaceholderColor)
}
.frame(height: 23)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct CourseVideoDownloadBarView: View {
.accessibilityIdentifier("remaining_videos_text")
}
if let totalSize = viewModel.totalSize {
let text = ", \(totalSize)MB \(CourseLocalization.Download.total)"
let text = ", \(totalSize) \(CourseLocalization.Download.total)"
Text(text)
.accessibilityElement(children: .ignore)
.accessibilityLabel(text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ final class CourseVideoDownloadBarViewModel: ObservableObject {
if isOn {
let size = mb - calculateSize(value: mb, percentage: progress * 100)
if size == 0 {
return String(format: "%.2f", mb)
return sizeInMbOrGb(size: mb)
}
return String(format: "%.2f", size)
return sizeInMbOrGb(size: size)
}

let size = blockToMB(
Expand All @@ -101,7 +101,15 @@ final class CourseVideoDownloadBarViewModel: ObservableObject {
downloadQuality: downloadQuality
)

return String(format: "%.2f", size)
return sizeInMbOrGb(size: size)
}

private func sizeInMbOrGb(size: Double) -> String {
if size >= 1024.0 {
return String(format: "%.2fGB", size / 1024.0)
} else {
return String(format: "%.2fMB", size)
}
}

init(
Expand Down
16 changes: 8 additions & 8 deletions Dashboard/Dashboard/Presentation/AllCoursesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct AllCoursesView: View {
.frameLimit(width: proxy.size.width)
if let myEnrollments = viewModel.myEnrollments {
let useRelativeDates = viewModel.storage.useRelativeDates
LazyVGrid(columns: columns(), spacing: 15) {
LazyVGrid(columns: columns(), spacing: 0) {
ForEach(
Array(myEnrollments.courses.enumerated()),
id: \.offset
Expand Down Expand Up @@ -101,9 +101,9 @@ public struct AllCoursesView: View {
}
}
}
.padding(10)
.frameLimit(width: proxy.size.width)
}
.padding(10)
.frameLimit(width: proxy.size.width)
}
// MARK: - ProgressBar
if viewModel.nextPage <= viewModel.totalPages, !viewModel.refresh {
Expand Down Expand Up @@ -173,13 +173,13 @@ public struct AllCoursesView: View {
private func columns() -> [GridItem] {
isHorizontal || idiom == .pad
? [
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible())
GridItem(.flexible(), spacing: 0),
GridItem(.flexible(), spacing: 0),
GridItem(.flexible(), spacing: 0)
]
: [
GridItem(.flexible()),
GridItem(.flexible())
GridItem(.flexible(), spacing: 0),
GridItem(.flexible(), spacing: 0)
]
}

Expand Down
6 changes: 6 additions & 0 deletions OpenEdX/Data/AppStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ public class AppStorage: CoreStorage, ProfileStorage, WhatsNewStorage, CourseSto
cookiesDate = nil
user = nil
userProfile = nil
// delete all cookies
if let cookies = HTTPCookieStorage.shared.cookies {
for cookie in cookies {
HTTPCookieStorage.shared.deleteCookie(cookie)
}
}
}

private let KEY_ACCESS_TOKEN = "accessToken"
Expand Down

0 comments on commit f209262

Please sign in to comment.