Skip to content

Commit

Permalink
Merge branch 'develop' into chore/migration-to-swift6
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanStepanok committed Nov 20, 2024
2 parents bb42d08 + 331062c commit 74b3f5f
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -36,7 +36,7 @@ jobs:
run: bundle exec fastlane unit_tests

- name: Archive artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: test-output
Expand All @@ -45,6 +45,6 @@ jobs:
if-no-files-found: ignore

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
flags: unittests
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 @@ -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 @@ -342,6 +343,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 @@ -741,6 +743,7 @@
06DEA4A22BBD66A700110D20 /* BackNavigationButton.swift */,
06DEA4A42BBD66D700110D20 /* BackNavigationButtonViewModel.swift */,
0267F8502C3C256F0089D810 /* FileWebView.swift */,
A5D4B3DD2CDD0A9700688951 /* SecureInputView.swift */,
);
path = Base;
sourceTree = "<group>";
Expand Down Expand Up @@ -1127,6 +1130,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
3 changes: 0 additions & 3 deletions Core/Core/View/Base/OfflineSnackBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ public struct OfflineSnackBarView: View {
HStack(spacing: 12) {
Text(CoreLocalization.NoInternet.offline)
.accessibilityIdentifier("no_internet_text")
.foregroundColor(Theme.Colors.snackbarTextColor)
Spacer()
Button(action: {
withAnimation {
dismiss = true
}
}, label: {
Text(CoreLocalization.NoInternet.dismiss)
.foregroundColor(Theme.Colors.snackbarTextColor)
})
.accessibilityIdentifier("no_internet_dismiss_button")
Button(action: {
Expand All @@ -49,7 +47,6 @@ public struct OfflineSnackBarView: View {
}
}, label: {
Text(CoreLocalization.NoInternet.reload)
.foregroundColor(Theme.Colors.snackbarTextColor)
}
)
.accessibilityIdentifier("no_internet_reload_button")
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 @@ -89,9 +89,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 @@ -102,7 +102,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 @@ -60,7 +60,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 @@ -102,9 +102,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 @@ -174,13 +174,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 final class AppStorage: CoreStorage, ProfileStorage, WhatsNewStorage, Cou
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 74b3f5f

Please sign in to comment.