From 2ebd92c050a7eceea1e469df08a60348b7728807 Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:41:29 +0300 Subject: [PATCH 1/8] Add landscape mode support --- .../Presentation/Login/SignInView.swift | 6 +- .../Registration/SignUpView.swift | 4 + .../Reset Password/ResetPasswordView.swift | 7 +- Core/Core/Extensions/ViewExtension.swift | 60 ++++- Core/Core/View/Base/AlertView.swift | 195 +++++++++----- .../View/Base/FlexibleKeyboardInputView.swift | 145 ++++++----- Core/Core/View/Base/PickerMenu.swift | 13 +- Core/Core/View/Base/UnitButtonView.swift | 8 +- .../Details/CourseDetailsView.swift | 5 +- .../Unit/CourseNavigationView.swift | 39 ++- .../Presentation/Unit/CourseUnitView.swift | 243 +++++++++++------- .../Video/EncodedVideoPlayer.swift | 91 +++---- .../Video/YouTubeVideoPlayer.swift | 44 +--- .../Comments/Responses/ResponsesView.swift | 3 +- .../Comments/Thread/ThreadView.swift | 3 +- OpenEdX.xcodeproj/project.pbxproj | 18 +- OpenEdX/AppDelegate.swift | 26 +- .../EditProfile/EditProfileView.swift | 2 +- .../EditProfile/ProfileBottomSheet.swift | 9 +- 19 files changed, 543 insertions(+), 378 deletions(-) diff --git a/Authorization/Authorization/Presentation/Login/SignInView.swift b/Authorization/Authorization/Presentation/Login/SignInView.swift index fd98fde7c..3bdab24ca 100644 --- a/Authorization/Authorization/Presentation/Login/SignInView.swift +++ b/Authorization/Authorization/Presentation/Login/SignInView.swift @@ -13,6 +13,8 @@ public struct SignInView: View { @State private var email: String = "" @State private var password: String = "" + @Environment (\.isHorizontal) private var isHorizontal + @ObservedObject private var viewModel: SignInViewModel @@ -32,7 +34,8 @@ public struct SignInView: View { CoreAssets.appLogo.swiftUIImage .resizable() .frame(maxWidth: 189, maxHeight: 54) - .padding(.vertical, 40) + .padding(.top, isHorizontal ? 20 : 40) + .padding(.bottom, isHorizontal ? 10 : 40) ScrollView { VStack { @@ -152,6 +155,7 @@ public struct SignInView: View { .hideNavigationBar() .navigationBarBackButtonHidden(true) .navigationBarHidden(true) + .ignoresSafeArea(.all, edges: .horizontal) .background(Theme.Colors.background.ignoresSafeArea(.all)) } } diff --git a/Authorization/Authorization/Presentation/Registration/SignUpView.swift b/Authorization/Authorization/Presentation/Registration/SignUpView.swift index 2ce5f263c..d4dc67acf 100644 --- a/Authorization/Authorization/Presentation/Registration/SignUpView.swift +++ b/Authorization/Authorization/Presentation/Registration/SignUpView.swift @@ -13,6 +13,8 @@ public struct SignUpView: View { @State private var disclosureGroupOpen: Bool = false + @Environment (\.isHorizontal) private var isHorizontal + @ObservedObject private var viewModel: SignUpViewModel @@ -44,6 +46,7 @@ public struct SignUpView: View { .backButtonStyle(color: .white) }) .foregroundColor(Theme.Colors.styledButtonText) + .padding(.leading, isHorizontal ? 48 : 0) }.frame(minWidth: 0, maxWidth: .infinity, @@ -135,6 +138,7 @@ public struct SignUpView: View { } } } + .ignoresSafeArea(.all, edges: .horizontal) .background(Theme.Colors.background.ignoresSafeArea(.all)) .hideNavigationBar() } diff --git a/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift b/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift index 17f7466c0..0b93441a5 100644 --- a/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift +++ b/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift @@ -14,6 +14,8 @@ public struct ResetPasswordView: View { @State private var isRecovered: Bool = false + @Environment (\.isHorizontal) private var isHorizontal + @ObservedObject private var viewModel: ResetPasswordViewModel @@ -35,7 +37,7 @@ public struct ResetPasswordView: View { leftButtonColor: .white, leftButtonAction: { viewModel.router.back() - }) + }) .padding(.leading, isHorizontal ? 48 : 0) ScrollView { VStack { @@ -149,7 +151,10 @@ public struct ResetPasswordView: View { } } } + .ignoresSafeArea(.all, edges: .horizontal) + .background(Theme.Colors.background.ignoresSafeArea(.all)) + .hideNavigationBar() } } diff --git a/Core/Core/Extensions/ViewExtension.swift b/Core/Core/Extensions/ViewExtension.swift index d6584cbcf..d7b3fede3 100644 --- a/Core/Core/Extensions/ViewExtension.swift +++ b/Core/Core/Extensions/ViewExtension.swift @@ -89,11 +89,52 @@ public extension View { .padding(.horizontal, 48) } + @ViewBuilder func frameLimit(sizePortrait: CGFloat = 560, sizeLandscape: CGFloat = 648) -> some View { - return HStack { - Spacer(minLength: 0) - self.frame(maxWidth: UIDevice.current.orientation == .portrait ? sizePortrait : sizeLandscape) - Spacer(minLength: 0) + if UIDevice.current.userInterfaceIdiom == .pad { + HStack { + Spacer(minLength: 0) + self.frame(maxWidth: UIDevice.current.orientation.isPortrait ? sizePortrait : sizeLandscape) + Spacer(minLength: 0) + } + } else { self } + } + + @ViewBuilder + func adaptiveHStack(spacing: CGFloat = 0, currentOrientation: UIInterfaceOrientation, + @ViewBuilder content: () -> Content) -> some View { + if currentOrientation.isLandscape && UIDevice.current.userInterfaceIdiom != .pad { + VStack(alignment: .center, spacing: spacing, content: content) + } else if currentOrientation.isPortrait && UIDevice.current.userInterfaceIdiom != .pad { + HStack(spacing: spacing, content: content) + } else if UIDevice.current.userInterfaceIdiom != .phone { + HStack(spacing: spacing, content: content) + } + } + + @ViewBuilder + func adaptiveStack(spacing: CGFloat = 0, + isHorizontal: Bool, + @ViewBuilder content: () -> Content) -> some View { + if isHorizontal, UIDevice.current.userInterfaceIdiom != .pad { + HStack(spacing: spacing, content: content) + } else { + VStack(alignment: .center, spacing: spacing, content: content) + } + } + + @ViewBuilder + func adaptiveNavigationStack(spacing: CGFloat = 0, + isHorizontal: Bool, + @ViewBuilder content: () -> Content) -> some View { + if UIDevice.current.userInterfaceIdiom == .pad { + HStack(spacing: spacing, content: content) + } else { + if isHorizontal { + HStack(spacing: spacing, content: content) + } else { + VStack(alignment: .center, spacing: spacing, content: content) + } } } @@ -199,3 +240,14 @@ public extension Image { .foregroundColor(color) } } + +public extension EnvironmentValues { + var isHorizontal: Bool { + if UIDevice.current.userInterfaceIdiom != .pad { + if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene { + return windowScene.windows.first?.windowScene?.interfaceOrientation.isLandscape ?? true + } + } + return false + } +} diff --git a/Core/Core/View/Base/AlertView.swift b/Core/Core/View/Base/AlertView.swift index f230eba9b..6f2723a7b 100644 --- a/Core/Core/View/Base/AlertView.swift +++ b/Core/Core/View/Base/AlertView.swift @@ -33,6 +33,8 @@ public struct AlertView: View { private var nextSectionTapped: (() -> Void) = {} private let type: AlertViewType + @Environment(\.isHorizontal) private var isHorizontal + public init( alertTitle: String, alertMessage: String, @@ -74,38 +76,77 @@ public struct AlertView: View { .onTapGesture { onCloseTapped() } - VStack(alignment: .center, spacing: 20) { - if case let .action(_, image) = type { - image.padding(.top, 48) - } + adaptiveStack(spacing: isHorizontal ? 10 : 20, isHorizontal: (type == .leaveProfile && isHorizontal)) { +// VStack(alignment: .center, spacing: isHorizontal ? 10 : 20) { if type == .logOut { - CoreAssets.logOut.swiftUIImage - .padding(.top, 54) + HStack { + Spacer(minLength: 100) + CoreAssets.logOut.swiftUIImage + .padding(.top, isHorizontal ? 20 : 54) + Spacer(minLength: 100) + } Text(alertMessage) .font(Theme.Fonts.titleLarge) - .padding(.vertical, 40) + .padding(.vertical, isHorizontal ? 6 : 40) .multilineTextAlignment(.center) .padding(.horizontal, 40) .frame(maxWidth: 250) } else if type == .leaveProfile { - CoreAssets.leaveProfile.swiftUIImage - .padding(.top, 54) - Text(alertTitle) - .font(Theme.Fonts.titleLarge) - .padding(.horizontal, 40) - Text(alertMessage) - .font(Theme.Fonts.bodyMedium) - .multilineTextAlignment(.center) - .padding(.horizontal, 40) + VStack(spacing: 20) { + CoreAssets.leaveProfile.swiftUIImage + .padding(.top, isHorizontal ? 20 : 54) + Text(alertTitle) + .font(Theme.Fonts.titleLarge) + .padding(.horizontal, 40) + Text(alertMessage) + .font(Theme.Fonts.bodyMedium) + .multilineTextAlignment(.center) + .padding(.horizontal, 40) + + }.padding(.bottom, 20) } else { - Text(alertTitle) - .font(Theme.Fonts.titleLarge) - .padding(.horizontal, 40) - Text(alertMessage) - .font(Theme.Fonts.bodyMedium) - .multilineTextAlignment(.center) - .padding(.horizontal, 40) - .frame(maxWidth: 250) + HStack { + VStack(alignment: .center, spacing: 10) { + if case let .action(_, image) = type { + image.padding(.top, 48) + } + Text(alertTitle) + .font(Theme.Fonts.titleLarge) + .padding(.horizontal, 40) + Text(alertMessage) + .font(Theme.Fonts.bodyMedium) + .multilineTextAlignment(.center) + .padding(.horizontal, 40) + .frame(maxWidth: 250) + } + if isHorizontal { + if case let .action(action, _) = type { + VStack(spacing: 20) { + if nextSectionName != nil { + UnitButtonView(type: .nextSection, action: { nextSectionTapped() }) + .frame(maxWidth: 215) + } + UnitButtonView(type: .custom(action), + bgColor: .clear, + action: { okTapped() }) + .frame(maxWidth: 215) + + if let nextSectionName { + Group { + Text(CoreLocalization.Courseware.nextSectionDescriptionFirst) + + Text(nextSectionName) + + Text(CoreLocalization.Courseware.nextSectionDescriptionLast) + }.frame(maxWidth: 215) + .padding(.horizontal, 40) + .multilineTextAlignment(.center) + .font(Theme.Fonts.labelSmall) + .foregroundColor(CoreAssets.textSecondary.swiftUIColor) + } + }.padding(.top, 70) + .padding(.trailing, 20) + } + } + } } HStack { switch type { @@ -116,28 +157,31 @@ public struct AlertView: View { .frame(maxWidth: 135) .saturation(0) case let .action(action, _): - VStack(spacing: 20) { - if nextSectionName != nil { - UnitButtonView(type: .nextSection, action: { nextSectionTapped() }) - .frame(maxWidth: 215) - } - UnitButtonView(type: .custom(action), - bgColor: .clear, - action: { okTapped() }) + if !isHorizontal { + VStack(spacing: 20) { + if nextSectionName != nil { + UnitButtonView(type: .nextSection, action: { nextSectionTapped() }) + .frame(maxWidth: 215) + } + UnitButtonView(type: .custom(action), + bgColor: .clear, + action: { okTapped() }) .frame(maxWidth: 215) - - if let nextSectionName { - Group { - Text(CoreLocalization.Courseware.nextSectionDescriptionFirst) + - Text(nextSectionName) + - Text(CoreLocalization.Courseware.nextSectionDescriptionLast) - }.frame(maxWidth: 215) - .padding(.horizontal, 40) - .multilineTextAlignment(.center) - .font(Theme.Fonts.labelSmall) - .foregroundColor(Theme.Colors.textSecondary) + + if let nextSectionName { + Group { + Text(CoreLocalization.Courseware.nextSectionDescriptionFirst) + + Text(nextSectionName) + + Text(CoreLocalization.Courseware.nextSectionDescriptionLast) + }.frame(maxWidth: 215) + .padding(.horizontal, 40) + .multilineTextAlignment(.center) + .font(Theme.Fonts.labelSmall) + .foregroundColor(CoreAssets.textSecondary.swiftUIColor) + } } - + } else { + EmptyView() } case .logOut: Button(action: { @@ -157,7 +201,7 @@ public struct AlertView: View { }) .background( Theme.Shapes.buttonShape - .fill(Theme.Colors.warning) + .fill(CoreAssets.warning.swiftUIColor) ) .overlay( RoundedRectangle(cornerRadius: 8) @@ -186,7 +230,7 @@ public struct AlertView: View { }) .background( Theme.Shapes.buttonShape - .fill(Theme.Colors.warning) + .fill(CoreAssets.warning.swiftUIColor) ) .overlay( RoundedRectangle(cornerRadius: 8) @@ -199,13 +243,13 @@ public struct AlertView: View { .foregroundColor(.clear) ) .frame(maxWidth: 215) - .padding(.bottom, 24) + .padding(.bottom, isHorizontal ? 10 : 24) Button(action: { onCloseTapped() }, label: { ZStack { Text(CoreLocalization.Alert.keepEditing) - .foregroundColor(Theme.Colors.textPrimary) + .foregroundColor(CoreAssets.textPrimary.swiftUIColor) .font(Theme.Fonts.labelLarge) .frame(maxWidth: .infinity) .padding(.horizontal, 16) @@ -224,34 +268,36 @@ public struct AlertView: View { lineJoin: .round, miterLimit: 1 )) - .foregroundColor(Theme.Colors.textPrimary) + .foregroundColor(CoreAssets.textPrimary.swiftUIColor) ) .frame(maxWidth: 215) - } + }.padding(.trailing, isHorizontal ? 20 : 0) } } .padding(.top, 5) - .padding(.bottom, type.contentPadding) + .padding(.bottom, isHorizontal ? 16 : type.contentPadding) } .background( Theme.Shapes.cardShape - .fill(Theme.Colors.cardViewBackground) + .fill(CoreAssets.cardViewBackground.swiftUIColor) .shadow(radius: 24) - .frame(width: reader.size.width < 420 - ? reader.size.width - 80 - : 360) +// .frame(width: reader.size.width < 420 +// ? reader.size.width - 80 +// : 530) + .fixedSize(horizontal: false, vertical: false) ) .overlay( RoundedRectangle(cornerRadius: 12) .stroke(style: .init(lineWidth: 1, lineCap: .round, lineJoin: .round, miterLimit: 1)) - .foregroundColor(Theme.Colors.backgroundStroke) - .frame(width: reader.size.width < 420 - ? reader.size.width - 80 - : 360) + .foregroundColor(CoreAssets.backgroundStroke.swiftUIColor) +// .frame(width: reader.size.width < 420 +// ? reader.size.width - 80 +// : 360) + .fixedSize(horizontal: false, vertical: false) ) - .padding() + .frame(maxWidth: isHorizontal ? nil : 390) + .padding(40) } - .ignoresSafeArea() } } @@ -272,6 +318,33 @@ struct AlertView_Previews: PreviewProvider { ) .previewLayout(.sizeThatFits) .background(Color.gray) + + AlertView(alertTitle: "Comfirm log out", + alertMessage: "Are you sure you want to log out?", + positiveAction: "Yes", + onCloseTapped: {}, + okTapped: {}, + type: .logOut) + + AlertView(alertTitle: "Leave profile?", + alertMessage: "Changes you have made not be saved.", + positiveAction: "Yes", + onCloseTapped: {}, + okTapped: {}, + type: .leaveProfile) + +// AlertView( +// alertTitle: "Warning", +// alertMessage: "Something goes wrong. Do you want to exterminate your phone, right now", +// nextSectionName: "Ahmad tea is a power", +// mainAction: "Back to outline", +// image: CoreAssets.goodWork.swiftUIImage, +// onCloseTapped: {}, +// okTapped: {}, +// nextSectionTapped: {} +// ) + .previewLayout(.sizeThatFits) + .background(Color.gray) } } //swiftlint:enable all diff --git a/Core/Core/View/Base/FlexibleKeyboardInputView.swift b/Core/Core/View/Base/FlexibleKeyboardInputView.swift index 97bc11401..25cdba411 100644 --- a/Core/Core/View/Base/FlexibleKeyboardInputView.swift +++ b/Core/Core/View/Base/FlexibleKeyboardInputView.swift @@ -11,6 +11,7 @@ public struct FlexibleKeyboardInputView: View { @State private var commentText: String = "" @State private var commentSize: CGFloat = .init(64) + @Environment (\.isHorizontal) private var isHorizontal public var sendText: ((String) -> Void) private let hint: String @@ -24,79 +25,83 @@ public struct FlexibleKeyboardInputView: View { public var body: some View { VStack { - Spacer() - VStack(alignment: .leading) { - - ScrollView { - HStack(alignment: .top, spacing: 6) { - Text("\(commentText) ").foregroundColor(.clear).padding(8) - .lineLimit(3) - .frame(maxWidth: .infinity) - .background( - GeometryReader { reader in - Color.clear.preference( - key: ViewSizePreferenceKey.self, - value: reader.size - ) + VStack { + Spacer() + VStack(alignment: .leading) { + + ScrollView { + HStack(alignment: .top, spacing: 6) { + Text("\(commentText) ").foregroundColor(.clear).padding(8) + .lineLimit(3) + .frame(maxWidth: .infinity) + .background( + GeometryReader { reader in + Color.clear.preference( + key: ViewSizePreferenceKey.self, + value: reader.size + ) + } + ) + .onPreferenceChange(ViewSizePreferenceKey.self) { size in + commentSize = size.height } - ) - .onPreferenceChange(ViewSizePreferenceKey.self) { size in - commentSize = size.height - } - .overlay( - TextEditor(text: $commentText) - .padding(.horizontal, 8) - .foregroundColor(Theme.Colors.textPrimary) - .hideScrollContentBackground() - .frame(maxHeight: commentSize) - .background( - ZStack(alignment: .leading) { + .overlay( + TextEditor(text: $commentText) + .padding(.horizontal, 8) + .foregroundColor(Theme.Colors.textPrimary) + .hideScrollContentBackground() + .frame(maxHeight: commentSize) + .background( + ZStack(alignment: .leading) { + Theme.Shapes.textInputShape + .fill(Theme.Colors.textInputBackground) + Text(commentText.count == 0 ? hint : "") + .foregroundColor(Theme.Colors.textSecondary) + .font(Theme.Fonts.labelLarge) + .padding(.leading, 14) + } + ) + .overlay( Theme.Shapes.textInputShape - .fill(Theme.Colors.textInputBackground) - Text(commentText.count == 0 ? hint : "") - .foregroundColor(Theme.Colors.textSecondary) - .font(Theme.Fonts.labelLarge) - .padding(.leading, 14) - } - ) - .overlay( - Theme.Shapes.textInputShape - .stroke(lineWidth: 1) - .fill( - Theme.Colors.textInputStroke - ) - ) - ).padding(8) - Button(action: { - if commentText.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 { - sendText(commentText) - self.commentText = "" - } - }, label: { - VStack { - commentText.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 - ? CoreAssets.send.swiftUIImage - : CoreAssets.sendDisabled.swiftUIImage - } - .frame(width: 36, height: 36) - .foregroundColor(.white) - }).padding(.top, 8) - } - } - .padding(.leading, 6) - .padding(.trailing, 14) - }.frame(maxWidth: .infinity, maxHeight: commentSize + 16) - .background( - Theme.Colors.commentCellBackground - .ignoresSafeArea() - ) - .overlay( - GeometryReader { proxy in - Rectangle() - .size(width: proxy.size.width, height: 1) - .foregroundColor(Theme.Colors.cardViewStroke) + .stroke(lineWidth: 1) + .fill( + Theme.Colors.textInputStroke + ) + ) + ).padding(8) + Button(action: { + if commentText.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 { + sendText(commentText) + self.commentText = "" + } + }, label: { + VStack { + commentText.trimmingCharacters(in: .whitespacesAndNewlines).count > 0 + ? CoreAssets.send.swiftUIImage + : CoreAssets.sendDisabled.swiftUIImage + } + .frame(width: 36, height: 36) + .foregroundColor(.white) + }).padding(.top, 8) + + }.padding(.horizontal, isHorizontal ? 50 : 16) + } - ) + .padding(.leading, 6) + .padding(.trailing, 14) + }.frame(maxWidth: .infinity, maxHeight: commentSize + 16) + .background( + Theme.Colors.commentCellBackground + // .ignoresSafeArea() + ) + .overlay( + GeometryReader { proxy in + Rectangle() + .size(width: proxy.size.width, height: 1) + .foregroundColor(Theme.Colors.cardViewStroke) + } + ) + } } } } diff --git a/Core/Core/View/Base/PickerMenu.swift b/Core/Core/View/Base/PickerMenu.swift index a967ffdde..09271213c 100644 --- a/Core/Core/View/Base/PickerMenu.swift +++ b/Core/Core/View/Base/PickerMenu.swift @@ -25,6 +25,7 @@ public struct PickerMenu: View { @State private var search: String = "" @State public var selectedItem: PickerItem = PickerItem(key: "", value: "") + @Environment (\.isHorizontal) private var isHorizontal private let ipadPickerWidth: CGFloat = 300 private var items: [PickerItem] private let titleText: String @@ -90,7 +91,11 @@ public struct PickerMenu: View { } .pickerStyle(.wheel) } - .frame(minWidth: 0, maxWidth: idiom == .pad ? ipadPickerWidth : .infinity) + .frame(minWidth: 0, + maxWidth: (idiom == .pad || (idiom == .phone && isHorizontal)) + ? ipadPickerWidth + : .infinity) + .padding() .background(Theme.Colors.textInputBackground.cornerRadius(16)) .padding(.horizontal, 16) @@ -106,13 +111,17 @@ public struct PickerMenu: View { }) { Text(CoreLocalization.Picker.accept) .foregroundColor(Theme.Colors.textPrimary) - .frame(minWidth: 0, maxWidth: idiom == .pad ? ipadPickerWidth : .infinity) + .frame(minWidth: 0, + maxWidth: (idiom == .pad || (idiom == .phone && isHorizontal)) + ? ipadPickerWidth + : .infinity) .padding() .background(Theme.Colors.textInputBackground.cornerRadius(16)) .padding(.horizontal, 16) } .padding(.bottom, 4) .disabled(acceptButtonDisabled) + } .avoidKeyboard(dismissKeyboardByTap: true) .transition(.move(edge: .bottom)) diff --git a/Core/Core/View/Base/UnitButtonView.swift b/Core/Core/View/Base/UnitButtonView.swift index 67a49d0da..00999e643 100644 --- a/Core/Core/View/Base/UnitButtonView.swift +++ b/Core/Core/View/Base/UnitButtonView.swift @@ -99,13 +99,15 @@ public struct UnitButtonView: View { HStack { Text(type.stringValue()) .foregroundColor(Theme.Colors.styledButtonText) - .padding(.leading, 16) + .padding(.leading, 8) .font(Theme.Fonts.labelLarge) + .scaledToFit() + .minimumScaleFactor(0.4) Spacer() CoreAssets.check.swiftUIImage.renderingMode(.template) .foregroundColor(Theme.Colors.styledButtonText) - .padding(.trailing, 16) - } + .padding(.trailing, 8) + }.frame(maxWidth: 110) case .finish: HStack { Text(type.stringValue()) diff --git a/Course/Course/Presentation/Details/CourseDetailsView.swift b/Course/Course/Presentation/Details/CourseDetailsView.swift index 168dd8de1..2b846d526 100644 --- a/Course/Course/Presentation/Details/CourseDetailsView.swift +++ b/Course/Course/Presentation/Details/CourseDetailsView.swift @@ -14,6 +14,7 @@ public struct CourseDetailsView: View { @ObservedObject private var viewModel: CourseDetailsViewModel @Environment(\.colorScheme) var colorScheme + @Environment(\.isHorizontal) var isHorizontal @State private var isOverviewRendering = true private var title: String private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } @@ -54,7 +55,7 @@ public struct CourseDetailsView: View { if let courseDetails = viewModel.courseDetails { // MARK: - iPad - if idiom == .pad && viewModel.isHorisontal { + if viewModel.isHorisontal { HStack(alignment: .top) { VStack(alignment: .leading) { @@ -303,7 +304,7 @@ private struct CourseBannerView: View { .onFailureImage(CoreAssets.noCourseImage.image) .resizable() .aspectRatio(16/9, contentMode: .fill) - .frame(width: idiom == .pad ? 312 : proxy.size.width - 12) + .frame(width: 312) .opacity(animate ? 1 : 0) .onAppear { withAnimation(.linear(duration: 0.5)) { diff --git a/Course/Course/Presentation/Unit/CourseNavigationView.swift b/Course/Course/Presentation/Unit/CourseNavigationView.swift index ba9d34a5a..30f41a2f1 100644 --- a/Course/Course/Presentation/Unit/CourseNavigationView.swift +++ b/Course/Course/Presentation/Unit/CourseNavigationView.swift @@ -15,6 +15,7 @@ struct CourseNavigationView: View { private var viewModel: CourseUnitViewModel private let sectionName: String private let playerStateSubject: CurrentValueSubject + @Environment(\.isHorizontal) private var isHorizontal init( sectionName: String, @@ -27,13 +28,20 @@ struct CourseNavigationView: View { } var body: some View { - HStack(alignment: .top, spacing: 7) { + adaptiveNavigationStack(spacing: 7, isHorizontal: !isHorizontal) { if viewModel.selectedLesson() == viewModel.verticals[viewModel.verticalIndex].childs.first && viewModel.verticals[viewModel.verticalIndex].childs.count != 1 { - UnitButtonView(type: .nextBig, action: { - playerStateSubject.send(VideoPlayerState.pause) - viewModel.select(move: .next) - }).frame(width: 215) + if isHorizontal { + UnitButtonView(type: .nextBig, action: { + playerStateSubject.send(VideoPlayerState.pause) + viewModel.select(move: .next) + }).fixedSize() + } else { + UnitButtonView(type: .nextBig, action: { + playerStateSubject.send(VideoPlayerState.pause) + viewModel.select(move: .next) + }).frame(width: 215) + } } else { if viewModel.selectedLesson() == viewModel.verticals[viewModel.verticalIndex].childs.last { if viewModel.selectedLesson() != viewModel.verticals[viewModel.verticalIndex].childs.first { @@ -72,8 +80,9 @@ struct CourseNavigationView: View { okTapped: { playerStateSubject.send(VideoPlayerState.pause) playerStateSubject.send(VideoPlayerState.kill) - - viewModel.trackFinishVerticalBackToOutlineClicked() + viewModel.analytics + .finishVerticalBackToOutlineClicked(courseId: viewModel.courseID, + courseName: viewModel.courseName) viewModel.router.dismiss(animated: false) viewModel.router.back(animated: true) }, @@ -143,7 +152,7 @@ struct CourseNavigationView: View { }) } } - }.frame(minWidth: 0, maxWidth: .infinity) + }//.frame(minWidth: 0, maxWidth: .infinity) .padding(.horizontal, 24) } } @@ -165,12 +174,14 @@ struct CourseNavigationView_Previews: PreviewProvider { connectivity: Connectivity(), manager: DownloadManagerMock() ) - - CourseNavigationView( - sectionName: "Name", - viewModel: viewModel, - playerStateSubject: CurrentValueSubject(nil) - ) + HStack(alignment: .center) { + Spacer() + CourseNavigationView( + sectionName: "Name", + viewModel: viewModel, + playerStateSubject: CurrentValueSubject(nil) + ) + } } } #endif diff --git a/Course/Course/Presentation/Unit/CourseUnitView.swift b/Course/Course/Presentation/Unit/CourseUnitView.swift index e9afacbc1..bf79e8a24 100644 --- a/Course/Course/Presentation/Unit/CourseUnitView.swift +++ b/Course/Course/Presentation/Unit/CourseUnitView.swift @@ -26,7 +26,7 @@ public struct CourseUnitView: View { @State var offsetView: CGFloat = 0 @State var showDiscussion: Bool = false @Environment(\.presentationMode) private var presentationMode - + @Environment(\.isHorizontal) private var isHorizontal private let sectionName: String public let playerStateSubject = CurrentValueSubject(nil) @@ -44,67 +44,83 @@ public struct CourseUnitView: View { ZStack(alignment: .bottom) { GeometryReader { reader in VStack(spacing: 0) { - VStack {}.frame(height: 100) - LazyVStack(spacing: 0) { - let data = Array(viewModel.verticals[viewModel.verticalIndex].childs.enumerated()) - ForEach(data, id: \.offset) { index, block in - VStack(spacing: 0) { - if index >= viewModel.index - 1 && index <= viewModel.index + 1 { - switch LessonType.from(block) { - // MARK: YouTube - case let .youtube(url, blockID): - if viewModel.connectivity.isInternetAvaliable { - YouTubeView( - name: block.displayName, - url: url, - courseID: viewModel.courseID, - blockID: blockID, - playerStateSubject: playerStateSubject, - languages: block.subtitles ?? [], - isOnScreen: index == viewModel.index - ).frameLimit() + VStack {CoreAssets.background.swiftUIColor}.frame(width: reader.size.width, height: isHorizontal ? 50 : 100) + LazyVStack(alignment: .leading, spacing: 0) { + let data = Array(viewModel.verticals[viewModel.verticalIndex].childs.enumerated()) + ForEach(data, id: \.offset) { index, block in + VStack(spacing: 0) { + if index >= viewModel.index - 1 && index <= viewModel.index + 1 { + switch LessonType.from(block) { + // MARK: YouTube + case let .youtube(url, blockID): + if viewModel.connectivity.isInternetAvaliable { + YouTubeView( + name: block.displayName, + url: url, + courseID: viewModel.courseID, + blockID: blockID, + playerStateSubject: playerStateSubject, + languages: block.subtitles ?? [], + isOnScreen: index == viewModel.index + ).frameLimit() + // .frame( + // width: isHorizontal + // ? reader.size.width - 240 + // : reader.size.width, + // height: reader.size.height + // ) + if !isHorizontal { Spacer(minLength: 100) - } else { - NoInternetView(playerStateSubject: playerStateSubject) } - // MARK: Encoded Video - case let .video(encodedUrl, blockID): - let url = viewModel.urlForVideoFileOrFallback( - blockId: blockID, - url: encodedUrl - ) - if viewModel.connectivity.isInternetAvaliable || url?.isFileURL == true { - EncodedVideoView( - name: block.displayName, - url: url, - courseID: viewModel.courseID, - blockID: blockID, - playerStateSubject: playerStateSubject, - languages: block.subtitles ?? [], - isOnScreen: index == viewModel.index - ).frameLimit() + } else { + NoInternetView(playerStateSubject: playerStateSubject) + } + // MARK: Encoded Video + case let .video(encodedUrl, blockID): + let url = viewModel.urlForVideoFileOrFallback( + blockId: blockID, + url: encodedUrl + ) + if viewModel.connectivity.isInternetAvaliable || url?.isFileURL == true { + EncodedVideoView( + name: block.displayName, + url: url, + courseID: viewModel.courseID, + blockID: blockID, + playerStateSubject: playerStateSubject, + languages: block.subtitles ?? [], + isOnScreen: index == viewModel.index + ).frameLimit() + // .frame( + // width: isHorizontal + // ? reader.size.width - 240 + // : reader.size.width, + // height: reader.size.height + // ) + if !isHorizontal { Spacer(minLength: 100) - } else { - NoInternetView(playerStateSubject: playerStateSubject) } - // MARK: Web - case .web(let url): - if viewModel.connectivity.isInternetAvaliable { - WebView(url: url, viewModel: viewModel) - } else { - NoInternetView(playerStateSubject: playerStateSubject) - } - // MARK: Unknown - case .unknown(let url): - if viewModel.connectivity.isInternetAvaliable { + } else { + NoInternetView(playerStateSubject: playerStateSubject) + } + // MARK: Web + case .web(let url): + if viewModel.connectivity.isInternetAvaliable { + WebView(url: url, viewModel: viewModel) + } else { + NoInternetView(playerStateSubject: playerStateSubject) + } + // MARK: Unknown + case .unknown(let url): + if viewModel.connectivity.isInternetAvaliable { UnknownView(url: url, viewModel: viewModel) Spacer() - } else { - NoInternetView(playerStateSubject: playerStateSubject) - } - // MARK: Discussion - case let .discussion(blockID, blockKey, title): - if viewModel.connectivity.isInternetAvaliable { + } else { + NoInternetView(playerStateSubject: playerStateSubject) + } + // MARK: Discussion + case let .discussion(blockID, blockKey, title): + if viewModel.connectivity.isInternetAvaliable { VStack { if showDiscussion { DiscussionView( @@ -121,31 +137,64 @@ public struct CourseUnitView: View { } } }.frameLimit() - } else { - NoInternetView(playerStateSubject: playerStateSubject) - } + } else { + NoInternetView(playerStateSubject: playerStateSubject) } - } else { - EmptyView() } + } else { + EmptyView() } - .frame(height: reader.size.height) - .id(index) } + .frame( + width: isHorizontal + ? reader.size.width - 140 + : reader.size.width, + height: reader.size.height + ) + .id(index) } - .offset(y: offsetView) - .clipped() - .onChange(of: viewModel.index, perform: { index in - DispatchQueue.main.async { - withAnimation(Animation.easeInOut(duration: 0.2)) { - offsetView = -(reader.size.height * CGFloat(index)) - DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { - showDiscussion = viewModel.selectedLesson().type == .discussion - } + } + .offset(y: offsetView) + .clipped() + .onAppear { + offsetView = -(reader.size.height * CGFloat(viewModel.index)) + } + .onAppear { + NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillShowNotification, + object: nil, queue: .main) { _ in + offsetView = -(reader.size.height * CGFloat(viewModel.index)) + } + NotificationCenter.default.addObserver(forName: UIResponder.keyboardDidShowNotification, + object: nil, queue: .main) { _ in + offsetView = -(reader.size.height * CGFloat(viewModel.index)) + } + NotificationCenter.default.addObserver(forName: UIResponder.keyboardDidHideNotification, + object: nil, queue: .main) { _ in + offsetView = -(reader.size.height * CGFloat(viewModel.index)) + } + } + .onChange(of: UIDevice.current.orientation, perform: { _ in + offsetView = -(reader.size.height * CGFloat(viewModel.index)) + }) + .onChange(of: viewModel.verticalIndex, perform: { index in + DispatchQueue.main.async { + withAnimation(Animation.easeInOut(duration: 0.2)) { + offsetView = -(reader.size.height * CGFloat(index)) + } + } + + }) + .onChange(of: viewModel.index, perform: { index in + DispatchQueue.main.async { + withAnimation(Animation.easeInOut(duration: 0.2)) { + offsetView = -(reader.size.height * CGFloat(index)) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + showDiscussion = viewModel.selectedLesson().type == .discussion } } - - }) + } + + }) }.frame(maxWidth: .infinity) .clipped() @@ -179,17 +228,23 @@ public struct CourseUnitView: View { // MARK: - Course Navigation VStack { - CourseNavigationView( - sectionName: sectionName, - viewModel: viewModel, - playerStateSubject: playerStateSubject - ).padding(.bottom, 30) - .frameLimit(sizePortrait: 420) + HStack(alignment: .center) { + if isHorizontal { + Spacer() + } + VStack { + Spacer() + CourseNavigationView( + sectionName: sectionName, + viewModel: viewModel, + playerStateSubject: playerStateSubject + )//.fixedSize(horizontal: true, vertical: false) + Spacer() + }.frame(height: isHorizontal ? nil : 44) + + .padding(.bottom, isHorizontal ? 0 : 50) + }.frameLimit(sizePortrait: 420) }.frame(maxWidth: .infinity) - .onRightSwipeGesture { - playerStateSubject.send(VideoPlayerState.kill) - viewModel.router.back() - } } .onDisappear { if !presentationMode.wrappedValue.isPresented { @@ -197,14 +252,24 @@ public struct CourseUnitView: View { } } } + .ignoresSafeArea(.all, edges: .top) + .ignoresSafeArea(.all, edges: .bottom) + .ignoresSafeArea(.all, edges: UIDevice.current.orientation == .landscapeLeft ? .trailing : .bottom) + // .ignoresSafeArea(.all, edges: UIDevice.current.orientation == .landscapeRight ? .leading : .bottom) + + .onRightSwipeGesture { + playerStateSubject.send(VideoPlayerState.kill) + viewModel.router.back() + } .navigationBarHidden(false) .navigationBarBackButtonHidden(false) .navigationTitle("") - .ignoresSafeArea() - .background( - Theme.Colors.background - .ignoresSafeArea() - ) + // .ignoresSafeArea() + + .background( + Theme.Colors.background + .ignoresSafeArea() + ) } } diff --git a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift index 251b59417..105ef5b4c 100644 --- a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift +++ b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift @@ -40,6 +40,8 @@ public struct EncodedVideoPlayer: View { } } + @Environment(\.isHorizontal) private var isHorizontal + public init( viewModel: EncodedVideoPlayerViewModel, isOnScreen: Bool @@ -50,72 +52,37 @@ public struct EncodedVideoPlayer: View { public var body: some View { ZStack { - VStack(alignment: .leading) { - PlayerViewController( - videoURL: viewModel.url, - controller: viewModel.controller, - progress: { progress in - if progress >= 0.8 { - if !isViewedOnce { - Task { - await viewModel.blockCompletionRequest() + VStack { + HStack { + PlayerViewController( + videoURL: viewModel.url, + controller: viewModel.controller, + progress: { progress in + if progress >= 0.8 { + if !isViewedOnce { + Task { + await viewModel.blockCompletionRequest() + } + isViewedOnce = true } - isViewedOnce = true - } - } - }, seconds: { seconds in - currentTime = seconds - }) - .aspectRatio(16 / 9, contentMode: .fit) - .cornerRadius(12) - .padding(.horizontal, 6) - .onReceive(NotificationCenter.Publisher( - center: .default, - name: UIDevice.orientationDidChangeNotification) - ) { _ in - if isOnScreen { - self.orientation = UIDevice.current.orientation - if self.orientation.isLandscape { - viewModel.controller.enterFullScreen(animated: true) - viewModel.controller.player?.play() - isOrientationChanged = true - } else { - if isOrientationChanged { - viewModel.controller.exitFullScreen(animated: true) - viewModel.controller.player?.pause() - isOrientationChanged = false } - } - } - } - SubtittlesView(languages: viewModel.languages, - currentTime: $currentTime, - viewModel: viewModel) - Spacer() - if !orientation.isLandscape || idiom != .pad { - VStack {}.onAppear { - isLoading = false - alertMessage = CourseLocalization.Alert.rotateDevice + }, seconds: { seconds in + currentTime = seconds + }) + .aspectRatio(16 / 9, contentMode: .fit) + .frame(minWidth: 380) + .cornerRadius(12) + .padding(.horizontal, 6) + if isHorizontal { + SubtittlesView(languages: viewModel.languages, + currentTime: $currentTime, + viewModel: viewModel) } } - } - - // MARK: - Alert - if showAlert, let alertMessage { - VStack(alignment: .center) { - Spacer() - HStack(spacing: 6) { - CoreAssets.rotateDevice.swiftUIImage.renderingMode(.template) - Text(alertMessage) - }.shadowCardStyle(bgColor: Theme.Colors.snackbarInfoAlert, - textColor: .white) - .transition(.move(edge: .bottom)) - .onAppear { - doAfter(Theme.Timeout.snackbarMessageLongTimeout) { - self.alertMessage = nil - showAlert = false - } - } + if !isHorizontal { + SubtittlesView(languages: viewModel.languages, + currentTime: $currentTime, + viewModel: viewModel) } } } diff --git a/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift b/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift index f3a886c72..ac2e170d1 100644 --- a/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift +++ b/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift @@ -28,6 +28,8 @@ public struct YouTubeVideoPlayer: View { } } + @Environment(\.isHorizontal) private var isHorizontal + public init(viewModel: YouTubeVideoPlayerViewModel, isOnScreen: Bool) { self._viewModel = StateObject(wrappedValue: { viewModel }()) self.isOnScreen = isOnScreen @@ -35,7 +37,7 @@ public struct YouTubeVideoPlayer: View { public var body: some View { ZStack { - VStack { + adaptiveStack(isHorizontal: isHorizontal) { YouTubePlayerView( viewModel.youtubePlayer, transaction: .init(animation: .easeIn), @@ -46,26 +48,7 @@ public struct YouTubeVideoPlayer: View { .cornerRadius(12) .padding(.horizontal, 6) .aspectRatio(16 / 8.8, contentMode: .fit) - .onReceive(NotificationCenter.Publisher( - center: .default, name: UIDevice.orientationDidChangeNotification - )) { _ in - if isOnScreen { - let orientation = UIDevice.current.orientation - if orientation.isPortrait { - viewModel.youtubePlayer.update(configuration: YouTubePlayer.Configuration(configure: { - $0.playInline = true - $0.autoPlay = viewModel.play - $0.startTime = Int(viewModel.currentTime) - })) - } else { - viewModel.youtubePlayer.update(configuration: YouTubePlayer.Configuration(configure: { - $0.playInline = false - $0.autoPlay = true - $0.startTime = Int(viewModel.currentTime) - })) - } - } - } + .frame(minWidth: 380) SubtittlesView( languages: viewModel.languages, currentTime: $viewModel.currentTime, @@ -76,25 +59,6 @@ public struct YouTubeVideoPlayer: View { if viewModel.isLoading { ProgressBar(size: 40, lineWidth: 8) } - - // MARK: - Alert - if showAlert, let alertMessage { - VStack(alignment: .center) { - Spacer() - HStack(spacing: 6) { - CoreAssets.rotateDevice.swiftUIImage.renderingMode(.template) - Text(alertMessage) - }.shadowCardStyle(bgColor: Theme.Colors.snackbarInfoAlert, - textColor: .white) - .transition(.move(edge: .bottom)) - .onAppear { - doAfter(Theme.Timeout.snackbarMessageLongTimeout) { - self.alertMessage = nil - showAlert = false - } - } - } - } } } } diff --git a/Discussion/Discussion/Presentation/Comments/Responses/ResponsesView.swift b/Discussion/Discussion/Presentation/Comments/Responses/ResponsesView.swift index 69e666844..d30530ea8 100644 --- a/Discussion/Discussion/Presentation/Comments/Responses/ResponsesView.swift +++ b/Discussion/Discussion/Presentation/Comments/Responses/ResponsesView.swift @@ -157,7 +157,7 @@ public struct ResponsesView: View { } } } - ) + ).ignoresSafeArea(.all, edges: .horizontal) } } } @@ -192,6 +192,7 @@ public struct ResponsesView: View { } } } + .ignoresSafeArea(.all, edges: .horizontal) .navigationBarHidden(false) .navigationBarBackButtonHidden(false) .navigationTitle(title) diff --git a/Discussion/Discussion/Presentation/Comments/Thread/ThreadView.swift b/Discussion/Discussion/Presentation/Comments/Thread/ThreadView.swift index bdc5ae96a..de404ceef 100644 --- a/Discussion/Discussion/Presentation/Comments/Thread/ThreadView.swift +++ b/Discussion/Discussion/Presentation/Comments/Thread/ThreadView.swift @@ -157,7 +157,7 @@ public struct ThreadView: View { } } } - ) + ).ignoresSafeArea(.all, edges: .horizontal) } } .onReceive(viewModel.addPostSubject, perform: { newComment in @@ -212,6 +212,7 @@ public struct ThreadView: View { } } } + .ignoresSafeArea(.all, edges: .horizontal) .navigationBarHidden(false) .navigationBarBackButtonHidden(false) .navigationTitle(title) diff --git a/OpenEdX.xcodeproj/project.pbxproj b/OpenEdX.xcodeproj/project.pbxproj index 8aecb5c84..4fc81e931 100644 --- a/OpenEdX.xcodeproj/project.pbxproj +++ b/OpenEdX.xcodeproj/project.pbxproj @@ -509,8 +509,7 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -598,8 +597,7 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -693,8 +691,7 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -782,8 +779,7 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -931,8 +927,7 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -966,8 +961,7 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/OpenEdX/AppDelegate.swift b/OpenEdX/AppDelegate.swift index 3c3cad303..ab56eca02 100644 --- a/OpenEdX/AppDelegate.swift +++ b/OpenEdX/AppDelegate.swift @@ -22,7 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - private var orientationLock: UIInterfaceOrientationMask = .portrait +// private var orientationLock: UIInterfaceOrientationMask = .all private var assembler: Assembler? @@ -55,18 +55,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } - func application( - _ application: UIApplication, - supportedInterfaceOrientationsFor window: UIWindow? - ) -> UIInterfaceOrientationMask { - //Allows external windows, such as WebView Player, to work in any orientation - if window == self.window { - return UIDevice.current.userInterfaceIdiom == .phone ? orientationLock : .all - } else { - return UIDevice.current.userInterfaceIdiom == .phone ? .allButUpsideDown : .all - } - } - +// func application( +// _ application: UIApplication, +// supportedInterfaceOrientationsFor window: UIWindow? +// ) -> UIInterfaceOrientationMask { +// //Allows external windows, such as WebView Player, to work in any orientation +//// if window == self.window { +//// return UIDevice.current.userInterfaceIdiom == .phone ? orientationLock : .all +//// } else { +//// return UIDevice.current.userInterfaceIdiom == .phone ? .allButUpsideDown : .all +//// } +// } +// private func initDI() { let navigation = UINavigationController() navigation.modalPresentationStyle = .fullScreen diff --git a/Profile/Profile/Presentation/EditProfile/EditProfileView.swift b/Profile/Profile/Presentation/EditProfile/EditProfileView.swift index f0a439d48..5e0530e48 100644 --- a/Profile/Profile/Presentation/EditProfile/EditProfileView.swift +++ b/Profile/Profile/Presentation/EditProfile/EditProfileView.swift @@ -209,7 +209,7 @@ public struct EditProfileView: View { CoreAssets.arrowLeft.swiftUIImage .renderingMode(.template) .foregroundColor(Theme.Colors.accentColor) - }).opacity(viewModel.isChanged ? 1 : 0.3) + }) }) ToolbarItem(placement: .navigationBarTrailing, content: { Button(action: { diff --git a/Profile/Profile/Presentation/EditProfile/ProfileBottomSheet.swift b/Profile/Profile/Presentation/EditProfile/ProfileBottomSheet.swift index 9a3f09330..00a6c13f6 100644 --- a/Profile/Profile/Presentation/EditProfile/ProfileBottomSheet.swift +++ b/Profile/Profile/Presentation/EditProfile/ProfileBottomSheet.swift @@ -38,6 +38,8 @@ struct ProfileBottomSheet: View { private var removePhoto: () -> Void @Binding private var showingBottomSheet: Bool + @Environment (\.isHorizontal) private var isHorizontal + init( showingBottomSheet: Binding, openGallery: @escaping () -> Void, @@ -96,7 +98,12 @@ struct ProfileBottomSheet: View { }).padding(.top, 34) }.padding(.horizontal, 24) - }.frame(maxWidth: idiom == .pad ? 330 : .infinity, maxHeight: 290, alignment: .topLeading) + } + .frame(minWidth: 0, + maxWidth: (idiom == .pad || (idiom == .phone && isHorizontal)) + ? 330 + : .infinity, + maxHeight: 290, alignment: .topLeading) .background(Theme.Colors.cardViewBackground) .cornerRadius(8) .padding(.horizontal, 22) From d8f1524aeecc24cfcf36eea7de9c7077df0bf3fd Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:41:11 +0300 Subject: [PATCH 2/8] remove commented lines --- Core/Core/View/Base/AlertView.swift | 23 +++---------------- .../Presentation/Unit/CourseUnitView.swift | 20 ++++------------ OpenEdX/AppDelegate.swift | 18 ++------------- 3 files changed, 10 insertions(+), 51 deletions(-) diff --git a/Core/Core/View/Base/AlertView.swift b/Core/Core/View/Base/AlertView.swift index 6f2723a7b..8b2498190 100644 --- a/Core/Core/View/Base/AlertView.swift +++ b/Core/Core/View/Base/AlertView.swift @@ -77,7 +77,6 @@ public struct AlertView: View { onCloseTapped() } adaptiveStack(spacing: isHorizontal ? 10 : 20, isHorizontal: (type == .leaveProfile && isHorizontal)) { -// VStack(alignment: .center, spacing: isHorizontal ? 10 : 20) { if type == .logOut { HStack { Spacer(minLength: 100) @@ -281,18 +280,12 @@ public struct AlertView: View { Theme.Shapes.cardShape .fill(CoreAssets.cardViewBackground.swiftUIColor) .shadow(radius: 24) -// .frame(width: reader.size.width < 420 -// ? reader.size.width - 80 -// : 530) .fixedSize(horizontal: false, vertical: false) ) .overlay( RoundedRectangle(cornerRadius: 12) .stroke(style: .init(lineWidth: 1, lineCap: .round, lineJoin: .round, miterLimit: 1)) .foregroundColor(CoreAssets.backgroundStroke.swiftUIColor) -// .frame(width: reader.size.width < 420 -// ? reader.size.width - 80 -// : 360) .fixedSize(horizontal: false, vertical: false) ) .frame(maxWidth: isHorizontal ? nil : 390) @@ -307,9 +300,9 @@ public struct AlertView: View { struct AlertView_Previews: PreviewProvider { static var previews: some View { AlertView( - alertTitle: "Warning", - alertMessage: "Something goes wrong. Do you want to exterminate your phone, right now", - nextSectionName: "Ahmad tea is a power", + alertTitle: "Congratulations!", + alertMessage: "You've passed the course", + nextSectionName: "Continue", mainAction: "Back to outline", image: CoreAssets.goodWork.swiftUIImage, onCloseTapped: {}, @@ -333,16 +326,6 @@ struct AlertView_Previews: PreviewProvider { okTapped: {}, type: .leaveProfile) -// AlertView( -// alertTitle: "Warning", -// alertMessage: "Something goes wrong. Do you want to exterminate your phone, right now", -// nextSectionName: "Ahmad tea is a power", -// mainAction: "Back to outline", -// image: CoreAssets.goodWork.swiftUIImage, -// onCloseTapped: {}, -// okTapped: {}, -// nextSectionTapped: {} -// ) .previewLayout(.sizeThatFits) .background(Color.gray) } diff --git a/Course/Course/Presentation/Unit/CourseUnitView.swift b/Course/Course/Presentation/Unit/CourseUnitView.swift index bf79e8a24..4d747ff9a 100644 --- a/Course/Course/Presentation/Unit/CourseUnitView.swift +++ b/Course/Course/Presentation/Unit/CourseUnitView.swift @@ -44,7 +44,8 @@ public struct CourseUnitView: View { ZStack(alignment: .bottom) { GeometryReader { reader in VStack(spacing: 0) { - VStack {CoreAssets.background.swiftUIColor}.frame(width: reader.size.width, height: isHorizontal ? 50 : 100) + VStack {CoreAssets.background.swiftUIColor}.frame(width: reader.size.width, + height: isHorizontal ? 50 : 100) LazyVStack(alignment: .leading, spacing: 0) { let data = Array(viewModel.verticals[viewModel.verticalIndex].childs.enumerated()) ForEach(data, id: \.offset) { index, block in @@ -63,12 +64,7 @@ public struct CourseUnitView: View { languages: block.subtitles ?? [], isOnScreen: index == viewModel.index ).frameLimit() - // .frame( - // width: isHorizontal - // ? reader.size.width - 240 - // : reader.size.width, - // height: reader.size.height - // ) + if !isHorizontal { Spacer(minLength: 100) } @@ -91,12 +87,7 @@ public struct CourseUnitView: View { languages: block.subtitles ?? [], isOnScreen: index == viewModel.index ).frameLimit() - // .frame( - // width: isHorizontal - // ? reader.size.width - 240 - // : reader.size.width, - // height: reader.size.height - // ) + if !isHorizontal { Spacer(minLength: 100) } @@ -238,7 +229,7 @@ public struct CourseUnitView: View { sectionName: sectionName, viewModel: viewModel, playerStateSubject: playerStateSubject - )//.fixedSize(horizontal: true, vertical: false) + ) Spacer() }.frame(height: isHorizontal ? nil : 44) @@ -255,7 +246,6 @@ public struct CourseUnitView: View { .ignoresSafeArea(.all, edges: .top) .ignoresSafeArea(.all, edges: .bottom) .ignoresSafeArea(.all, edges: UIDevice.current.orientation == .landscapeLeft ? .trailing : .bottom) - // .ignoresSafeArea(.all, edges: UIDevice.current.orientation == .landscapeRight ? .leading : .bottom) .onRightSwipeGesture { playerStateSubject.send(VideoPlayerState.kill) diff --git a/OpenEdX/AppDelegate.swift b/OpenEdX/AppDelegate.swift index ab56eca02..bb7c92a3b 100644 --- a/OpenEdX/AppDelegate.swift +++ b/OpenEdX/AppDelegate.swift @@ -21,9 +21,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } var window: UIWindow? - -// private var orientationLock: UIInterfaceOrientationMask = .all - + private var assembler: Assembler? private var lastForceLogoutTime: TimeInterval = 0 @@ -54,19 +52,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } - -// func application( -// _ application: UIApplication, -// supportedInterfaceOrientationsFor window: UIWindow? -// ) -> UIInterfaceOrientationMask { -// //Allows external windows, such as WebView Player, to work in any orientation -//// if window == self.window { -//// return UIDevice.current.userInterfaceIdiom == .phone ? orientationLock : .all -//// } else { -//// return UIDevice.current.userInterfaceIdiom == .phone ? .allButUpsideDown : .all -//// } -// } -// + private func initDI() { let navigation = UINavigationController() navigation.modalPresentationStyle = .fullScreen From 6f92524870df0e2e0268249b5bd542445336d625 Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Tue, 10 Oct 2023 19:23:44 +0300 Subject: [PATCH 3/8] Update CourseUnitView.swift Add one dot to progress --- Course/Course/Presentation/Unit/CourseUnitView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Course/Course/Presentation/Unit/CourseUnitView.swift b/Course/Course/Presentation/Unit/CourseUnitView.swift index 4d747ff9a..89bc6646c 100644 --- a/Course/Course/Presentation/Unit/CourseUnitView.swift +++ b/Course/Course/Presentation/Unit/CourseUnitView.swift @@ -191,10 +191,9 @@ public struct CourseUnitView: View { .clipped() // MARK: Progress Dots - if viewModel.verticals[viewModel.verticalIndex].childs.count > 1 { LessonProgressView(viewModel: viewModel) - } } + // MARK: - Alert if showAlert { ZStack(alignment: .bottomLeading) { From 3270dfc2354b3f3d97ad09f035e2275e32703b98 Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Fri, 13 Oct 2023 12:29:35 +0300 Subject: [PATCH 4/8] update design --- Core/Core/Extensions/ViewExtension.swift | 30 ++++++- Core/Core/View/Base/AlertView.swift | 56 +++++++------ Core/Core/View/Base/UnitButtonView.swift | 4 +- .../Unit/CourseNavigationView.swift | 40 ++++----- .../Presentation/Unit/CourseUnitView.swift | 83 +++++++++++++------ .../Unit/Subviews/EncodedVideoView.swift | 7 -- .../Presentation/Unit/Subviews/WebView.swift | 2 +- .../Unit/Subviews/YouTubeView.swift | 10 +-- .../Video/EncodedVideoPlayer.swift | 58 +++++++------ .../Video/YouTubeVideoPlayer.swift | 51 +++++++----- .../xcschemes/OpenEdXDev.xcscheme | 1 + 11 files changed, 198 insertions(+), 144 deletions(-) diff --git a/Core/Core/Extensions/ViewExtension.swift b/Core/Core/Extensions/ViewExtension.swift index d7b3fede3..756bf608f 100644 --- a/Core/Core/Extensions/ViewExtension.swift +++ b/Core/Core/Extensions/ViewExtension.swift @@ -124,14 +124,16 @@ public extension View { } @ViewBuilder - func adaptiveNavigationStack(spacing: CGFloat = 0, - isHorizontal: Bool, - @ViewBuilder content: () -> Content) -> some View { + func adaptiveNavigationStack( + spacing: CGFloat = 0, + isHorizontal: Bool, + @ViewBuilder content: () -> Content + ) -> some View { if UIDevice.current.userInterfaceIdiom == .pad { HStack(spacing: spacing, content: content) } else { if isHorizontal { - HStack(spacing: spacing, content: content) + HStack(alignment: .top, spacing: spacing, content: content) } else { VStack(alignment: .center, spacing: spacing, content: content) } @@ -159,6 +161,26 @@ public extension View { } } + func roundedBackgroundWeb( + _ color: Color = Theme.Colors.background, + strokeColor: Color = Theme.Colors.backgroundStroke, + ipadMaxHeight: CGFloat = .infinity, + maxIpadWidth: CGFloat = 420 + ) -> some View { + var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } + return VStack { + VStack {}.frame(height: 1) + ZStack { + self + .frame(maxWidth: maxIpadWidth, maxHeight: idiom == .pad ? ipadMaxHeight : .infinity) + RoundedCorners(tl: 24, tr: 24) + .stroke(style: StrokeStyle(lineWidth: 1)) + .foregroundColor(strokeColor) + .offset(y: -1) + } + } + } + func hideNavigationBar() -> some View { if #available(iOS 16.0, *) { return self.navigationBarHidden(true) diff --git a/Core/Core/View/Base/AlertView.swift b/Core/Core/View/Base/AlertView.swift index 8b2498190..926a347fa 100644 --- a/Core/Core/View/Base/AlertView.swift +++ b/Core/Core/View/Base/AlertView.swift @@ -34,7 +34,7 @@ public struct AlertView: View { private let type: AlertViewType @Environment(\.isHorizontal) private var isHorizontal - + public init( alertTitle: String, alertMessage: String, @@ -70,12 +70,12 @@ public struct AlertView: View { } public var body: some View { - GeometryReader { reader in - ZStack(alignment: .center) { - Color.black.opacity(0.5) - .onTapGesture { - onCloseTapped() - } + ZStack(alignment: .center) { + Color.black.opacity(0.5) + .onTapGesture { + onCloseTapped() + } + ZStack(alignment: .topTrailing) { adaptiveStack(spacing: isHorizontal ? 10 : 20, isHorizontal: (type == .leaveProfile && isHorizontal)) { if type == .logOut { HStack { @@ -101,7 +101,7 @@ public struct AlertView: View { .font(Theme.Fonts.bodyMedium) .multilineTextAlignment(.center) .padding(.horizontal, 40) - + }.padding(.bottom, 20) } else { HStack { @@ -276,23 +276,31 @@ public struct AlertView: View { .padding(.top, 5) .padding(.bottom, isHorizontal ? 16 : type.contentPadding) } - .background( - Theme.Shapes.cardShape - .fill(CoreAssets.cardViewBackground.swiftUIColor) - .shadow(radius: 24) - .fixedSize(horizontal: false, vertical: false) - ) - .overlay( - RoundedRectangle(cornerRadius: 12) - .stroke(style: .init(lineWidth: 1, lineCap: .round, lineJoin: .round, miterLimit: 1)) - .foregroundColor(CoreAssets.backgroundStroke.swiftUIColor) - .fixedSize(horizontal: false, vertical: false) - ) - .frame(maxWidth: isHorizontal ? nil : 390) - .padding(40) - } - .ignoresSafeArea() + Button(action: { + onCloseTapped() + }, label: { + Image(systemName: "xmark") + .padding(.trailing, 40) + .padding(.top, 24) + }) + + }.frame(maxWidth: type == .logOut ? 390 : nil) + .background( + Theme.Shapes.cardShape + .fill(CoreAssets.cardViewBackground.swiftUIColor) + .shadow(radius: 24) + .fixedSize(horizontal: false, vertical: false) + ) + .overlay( + RoundedRectangle(cornerRadius: 12) + .stroke(style: .init(lineWidth: 1, lineCap: .round, lineJoin: .round, miterLimit: 1)) + .foregroundColor(CoreAssets.backgroundStroke.swiftUIColor) + .fixedSize(horizontal: false, vertical: false) + ) + .frame(maxWidth: isHorizontal ? nil : 390) + .padding(40) } + .ignoresSafeArea() } } diff --git a/Core/Core/View/Base/UnitButtonView.swift b/Core/Core/View/Base/UnitButtonView.swift index 00999e643..5e7b3ce2e 100644 --- a/Core/Core/View/Base/UnitButtonView.swift +++ b/Core/Core/View/Base/UnitButtonView.swift @@ -102,12 +102,12 @@ public struct UnitButtonView: View { .padding(.leading, 8) .font(Theme.Fonts.labelLarge) .scaledToFit() - .minimumScaleFactor(0.4) +// .minimumScaleFactor(0.4) Spacer() CoreAssets.check.swiftUIImage.renderingMode(.template) .foregroundColor(Theme.Colors.styledButtonText) .padding(.trailing, 8) - }.frame(maxWidth: 110) + }//.frame(maxWidth: 110) case .finish: HStack { Text(type.stringValue()) diff --git a/Course/Course/Presentation/Unit/CourseNavigationView.swift b/Course/Course/Presentation/Unit/CourseNavigationView.swift index 30f41a2f1..212706480 100644 --- a/Course/Course/Presentation/Unit/CourseNavigationView.swift +++ b/Course/Course/Presentation/Unit/CourseNavigationView.swift @@ -15,7 +15,6 @@ struct CourseNavigationView: View { private var viewModel: CourseUnitViewModel private let sectionName: String private let playerStateSubject: CurrentValueSubject - @Environment(\.isHorizontal) private var isHorizontal init( sectionName: String, @@ -28,20 +27,13 @@ struct CourseNavigationView: View { } var body: some View { - adaptiveNavigationStack(spacing: 7, isHorizontal: !isHorizontal) { + HStack(alignment: .top, spacing: 7) { if viewModel.selectedLesson() == viewModel.verticals[viewModel.verticalIndex].childs.first && viewModel.verticals[viewModel.verticalIndex].childs.count != 1 { - if isHorizontal { - UnitButtonView(type: .nextBig, action: { - playerStateSubject.send(VideoPlayerState.pause) - viewModel.select(move: .next) - }).fixedSize() - } else { - UnitButtonView(type: .nextBig, action: { - playerStateSubject.send(VideoPlayerState.pause) - viewModel.select(move: .next) - }).frame(width: 215) - } + UnitButtonView(type: .nextBig, action: { + playerStateSubject.send(VideoPlayerState.pause) + viewModel.select(move: .next) + }).frame(width: 215) } else { if viewModel.selectedLesson() == viewModel.verticals[viewModel.verticalIndex].childs.last { if viewModel.selectedLesson() != viewModel.verticals[viewModel.verticalIndex].childs.first { @@ -67,7 +59,7 @@ struct CourseNavigationView: View { if viewModel.verticals.count > viewModel.verticalIndex + 1 { return viewModel.verticals[viewModel.verticalIndex + 1].displayName } else if sequentials.count > viewModel.sequentialIndex + 1 { - return sequentials[viewModel.sequentialIndex + 1].childs.first?.displayName + return sequentials[viewModel.sequentialIndex + 1].childs.first?.displayName ?? "" } else if chapters.count > viewModel.chapterIndex + 1 { return chapters[viewModel.chapterIndex + 1].childs.first?.childs.first?.displayName } else { @@ -80,9 +72,8 @@ struct CourseNavigationView: View { okTapped: { playerStateSubject.send(VideoPlayerState.pause) playerStateSubject.send(VideoPlayerState.kill) - viewModel.analytics - .finishVerticalBackToOutlineClicked(courseId: viewModel.courseID, - courseName: viewModel.courseName) + + viewModel.trackFinishVerticalBackToOutlineClicked() viewModel.router.dismiss(animated: false) viewModel.router.back(animated: true) }, @@ -131,6 +122,7 @@ struct CourseNavigationView: View { sequentialIndex: sequentialIndex) } ) + playerStateSubject.send(VideoPlayerState.pause) viewModel.analytics.finishVerticalClicked( courseId: viewModel.courseID, courseName: viewModel.courseName, @@ -174,14 +166,12 @@ struct CourseNavigationView_Previews: PreviewProvider { connectivity: Connectivity(), manager: DownloadManagerMock() ) - HStack(alignment: .center) { - Spacer() - CourseNavigationView( - sectionName: "Name", - viewModel: viewModel, - playerStateSubject: CurrentValueSubject(nil) - ) - } + + CourseNavigationView( + sectionName: "Name", + viewModel: viewModel, + playerStateSubject: CurrentValueSubject(nil) + ) } } #endif diff --git a/Course/Course/Presentation/Unit/CourseUnitView.swift b/Course/Course/Presentation/Unit/CourseUnitView.swift index 89bc6646c..1da170e1c 100644 --- a/Course/Course/Presentation/Unit/CourseUnitView.swift +++ b/Course/Course/Presentation/Unit/CourseUnitView.swift @@ -45,7 +45,7 @@ public struct CourseUnitView: View { GeometryReader { reader in VStack(spacing: 0) { VStack {CoreAssets.background.swiftUIColor}.frame(width: reader.size.width, - height: isHorizontal ? 50 : 100) + height: isHorizontal ? 75 : 50) LazyVStack(alignment: .leading, spacing: 0) { let data = Array(viewModel.verticals[viewModel.verticalIndex].childs.enumerated()) ForEach(data, id: \.offset) { index, block in @@ -66,7 +66,7 @@ public struct CourseUnitView: View { ).frameLimit() if !isHorizontal { - Spacer(minLength: 100) + Spacer(minLength: 150) } } else { NoInternetView(playerStateSubject: playerStateSubject) @@ -89,7 +89,7 @@ public struct CourseUnitView: View { ).frameLimit() if !isHorizontal { - Spacer(minLength: 100) + Spacer(minLength: 150) } } else { NoInternetView(playerStateSubject: playerStateSubject) @@ -137,9 +137,7 @@ public struct CourseUnitView: View { } } .frame( - width: isHorizontal - ? reader.size.width - 140 - : reader.size.width, + width: reader.size.width, height: reader.size.height ) .id(index) @@ -176,6 +174,7 @@ public struct CourseUnitView: View { }) .onChange(of: viewModel.index, perform: { index in +// self.title = viewModel.verticals[viewModel.verticalIndex].childs[index].displayName DispatchQueue.main.async { withAnimation(Animation.easeInOut(duration: 0.2)) { offsetView = -(reader.size.height * CGFloat(index)) @@ -192,6 +191,8 @@ public struct CourseUnitView: View { // MARK: Progress Dots LessonProgressView(viewModel: viewModel) + .ignoresSafeArea(.all, edges: .leading) + .ignoresSafeArea(.all, edges: .trailing) } // MARK: - Alert @@ -218,22 +219,59 @@ public struct CourseUnitView: View { // MARK: - Course Navigation VStack { - HStack(alignment: .center) { - if isHorizontal { - Spacer() + ZStack { + GeometryReader { reader in + VStack { + HStack { + let currentBlock = viewModel.verticals[viewModel.verticalIndex] + .childs[viewModel.index] + if currentBlock.type == .video { + let title = currentBlock.displayName + Text(title) + .lineLimit(1) + .frame(maxWidth: isHorizontal ? reader.size.width * 0.5 : nil) + .font(Theme.Fonts.titleLarge) + .foregroundStyle(Theme.Colors.textPrimary) + .padding(.leading, isHorizontal ? 30 : 42) + .padding(.top, isHorizontal ? 14 : 2) + Spacer() + } + } + Spacer() + } } VStack { - Spacer() - CourseNavigationView( - sectionName: sectionName, - viewModel: viewModel, - playerStateSubject: playerStateSubject - ) - Spacer() - }.frame(height: isHorizontal ? nil : 44) - + NavigationBar( + title: "", + leftButtonAction: { + viewModel.router.back() + playerStateSubject.send(VideoPlayerState.kill) + }).padding(.top, isHorizontal ? 10 : 0) + .padding(.leading, isHorizontal ? -16 : 0) + Spacer() + } + HStack(alignment: .center) { + if isHorizontal { + Spacer() + } + VStack { + if !isHorizontal { + Spacer() + } + CourseNavigationView( + sectionName: sectionName, + viewModel: viewModel, + playerStateSubject: playerStateSubject + ) + if isHorizontal { + Spacer() + } + }//.frame(height: isHorizontal ? nil : 44) + .padding(.bottom, isHorizontal ? 0 : 50) - }.frameLimit(sizePortrait: 420) + .padding(.top, isHorizontal ? 12 : 0) + }.frameLimit(sizePortrait: 420) + } }.frame(maxWidth: .infinity) } .onDisappear { @@ -242,18 +280,15 @@ public struct CourseUnitView: View { } } } - .ignoresSafeArea(.all, edges: .top) .ignoresSafeArea(.all, edges: .bottom) - .ignoresSafeArea(.all, edges: UIDevice.current.orientation == .landscapeLeft ? .trailing : .bottom) .onRightSwipeGesture { playerStateSubject.send(VideoPlayerState.kill) viewModel.router.back() } - .navigationBarHidden(false) - .navigationBarBackButtonHidden(false) + .navigationBarHidden(true) + .navigationBarBackButtonHidden(true) .navigationTitle("") - // .ignoresSafeArea() .background( Theme.Colors.background diff --git a/Course/Course/Presentation/Unit/Subviews/EncodedVideoView.swift b/Course/Course/Presentation/Unit/Subviews/EncodedVideoView.swift index 1bdc629fa..d790664cd 100644 --- a/Course/Course/Presentation/Unit/Subviews/EncodedVideoView.swift +++ b/Course/Course/Presentation/Unit/Subviews/EncodedVideoView.swift @@ -21,11 +21,6 @@ struct EncodedVideoView: View { let isOnScreen: Bool var body: some View { - VStack(alignment: .leading, spacing: 8) { - Text(name) - .font(Theme.Fonts.titleLarge) - .padding(.horizontal, 24) - let vm = Container.shared.resolve( EncodedVideoPlayerViewModel.self, arguments: url, @@ -35,7 +30,5 @@ struct EncodedVideoView: View { playerStateSubject )! EncodedVideoPlayer(viewModel: vm, isOnScreen: isOnScreen) - Spacer(minLength: 100) - } } } diff --git a/Course/Course/Presentation/Unit/Subviews/WebView.swift b/Course/Course/Presentation/Unit/Subviews/WebView.swift index 9cdc59269..5f1d45388 100644 --- a/Course/Course/Presentation/Unit/Subviews/WebView.swift +++ b/Course/Course/Presentation/Unit/Subviews/WebView.swift @@ -18,6 +18,6 @@ struct WebView: View { WebUnitView(url: url, viewModel: Container.shared.resolve(WebUnitViewModel.self)!) Spacer(minLength: 5) } - .roundedBackground(strokeColor: .clear, maxIpadWidth: .infinity) + .roundedBackgroundWeb(strokeColor: Theme.Colors.textInputUnfocusedStroke, maxIpadWidth: .infinity) } } diff --git a/Course/Course/Presentation/Unit/Subviews/YouTubeView.swift b/Course/Course/Presentation/Unit/Subviews/YouTubeView.swift index 94080fc32..49f1cfb3d 100644 --- a/Course/Course/Presentation/Unit/Subviews/YouTubeView.swift +++ b/Course/Course/Presentation/Unit/Subviews/YouTubeView.swift @@ -21,12 +21,6 @@ struct YouTubeView: View { let isOnScreen: Bool var body: some View { - VStack(alignment: .leading, spacing: 8) { - VStack(alignment: .leading) { - Text(name) - .font(Theme.Fonts.titleLarge) - .padding(.horizontal, 24) - let vm = Container.shared.resolve( YouTubeVideoPlayerViewModel.self, arguments: url, @@ -36,8 +30,6 @@ struct YouTubeView: View { playerStateSubject )! YouTubeVideoPlayer(viewModel: vm, isOnScreen: isOnScreen) - Spacer(minLength: 100) - }.background(Theme.Colors.background) - } + .background(Theme.Colors.background) } } diff --git a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift index 105ef5b4c..e760b56f4 100644 --- a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift +++ b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift @@ -52,38 +52,44 @@ public struct EncodedVideoPlayer: View { public var body: some View { ZStack { - VStack { - HStack { - PlayerViewController( - videoURL: viewModel.url, - controller: viewModel.controller, - progress: { progress in - if progress >= 0.8 { - if !isViewedOnce { - Task { - await viewModel.blockCompletionRequest() + GeometryReader {reader in + VStack { + HStack { + VStack { + PlayerViewController( + videoURL: viewModel.url, + controller: viewModel.controller, + progress: { progress in + if progress >= 0.8 { + if !isViewedOnce { + Task { + await viewModel.blockCompletionRequest() + } + isViewedOnce = true + } } - isViewedOnce = true - } + }, seconds: { seconds in + currentTime = seconds + }) + .aspectRatio(16 / 9, contentMode: .fit) + .frame(minWidth: isHorizontal ? reader.size.width * 0.6 : 380) + .cornerRadius(12) + if isHorizontal { + Spacer() } - }, seconds: { seconds in - currentTime = seconds - }) - .aspectRatio(16 / 9, contentMode: .fit) - .frame(minWidth: 380) - .cornerRadius(12) - .padding(.horizontal, 6) - if isHorizontal { + } + if isHorizontal { + SubtittlesView(languages: viewModel.languages, + currentTime: $currentTime, + viewModel: viewModel) + } + } + if !isHorizontal { SubtittlesView(languages: viewModel.languages, currentTime: $currentTime, viewModel: viewModel) } - } - if !isHorizontal { - SubtittlesView(languages: viewModel.languages, - currentTime: $currentTime, - viewModel: viewModel) - } + }.padding(.horizontal, isHorizontal ? 0 : 8) } } } diff --git a/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift b/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift index ac2e170d1..646816835 100644 --- a/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift +++ b/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift @@ -36,31 +36,38 @@ public struct YouTubeVideoPlayer: View { } public var body: some View { - ZStack { - adaptiveStack(isHorizontal: isHorizontal) { - YouTubePlayerView( - viewModel.youtubePlayer, - transaction: .init(animation: .easeIn), - overlay: { _ in }) - .onAppear { - alertMessage = CourseLocalization.Alert.rotateDevice + ZStack { + GeometryReader { reader in + adaptiveStack(isHorizontal: isHorizontal) { + VStack { + YouTubePlayerView( + viewModel.youtubePlayer, + transaction: .init(animation: .easeIn), + overlay: { _ in }) + .onAppear { + alertMessage = CourseLocalization.Alert.rotateDevice + } + .cornerRadius(12) + .padding(.horizontal, isHorizontal ? 0 : 8) + .aspectRatio(16 / 8.8, contentMode: .fit) + .frame(minWidth: isHorizontal ? reader.size.width * 0.6 : 380) + // Adjust the width based on the horizontal state + if isHorizontal { + Spacer() + } + } + SubtittlesView( + languages: viewModel.languages, + currentTime: $viewModel.currentTime, + viewModel: viewModel + ) + } + } + if viewModel.isLoading { + ProgressBar(size: 40, lineWidth: 8) } - .cornerRadius(12) - .padding(.horizontal, 6) - .aspectRatio(16 / 8.8, contentMode: .fit) - .frame(minWidth: 380) - SubtittlesView( - languages: viewModel.languages, - currentTime: $viewModel.currentTime, - viewModel: viewModel - ) - } - - if viewModel.isLoading { - ProgressBar(size: 40, lineWidth: 8) } } - } } #if DEBUG diff --git a/OpenEdX.xcodeproj/xcshareddata/xcschemes/OpenEdXDev.xcscheme b/OpenEdX.xcodeproj/xcshareddata/xcschemes/OpenEdXDev.xcscheme index 3a38de2f5..c2f6ffa2b 100644 --- a/OpenEdX.xcodeproj/xcshareddata/xcschemes/OpenEdXDev.xcscheme +++ b/OpenEdX.xcodeproj/xcshareddata/xcschemes/OpenEdXDev.xcscheme @@ -103,6 +103,7 @@ buildConfiguration = "DebugDev" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "uk" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" From bf9b5343516f69352a6f96d245b9e73bf702d31e Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Fri, 13 Oct 2023 13:45:11 +0300 Subject: [PATCH 5/8] resolve merge conflicts --- .../Video/EncodedVideoPlayer.swift | 43 ++++++++----------- .../Presentation/Video/SubtittlesView.swift | 2 +- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift index 38799507a..e952e71f4 100644 --- a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift +++ b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift @@ -81,39 +81,30 @@ public struct EncodedVideoPlayer: View { } if isHorizontal { SubtittlesView(languages: viewModel.languages, - currentTime: $currentTime, - viewModel: viewModel, scrollTo: { date in - viewModel.controller.player?.seek(to: CMTime(seconds: date.secondsSinceMidnight(), - preferredTimescale: 10000)) - pauseScrolling() - currentTime = (date.secondsSinceMidnight() + 1) - }) + currentTime: $currentTime, + viewModel: viewModel, scrollTo: { date in + viewModel.controller.player?.seek(to: CMTime(seconds: date.secondsSinceMidnight(), + preferredTimescale: 10000)) + pauseScrolling() + currentTime = (date.secondsSinceMidnight() + 1) + }) } } if !isHorizontal { SubtittlesView(languages: viewModel.languages, - currentTime: $currentTime, - viewModel: viewModel, scrollTo: { date in - viewModel.controller.player?.seek(to: CMTime(seconds: date.secondsSinceMidnight(), - preferredTimescale: 10000)) - pauseScrolling() - currentTime = (date.secondsSinceMidnight() + 1) - }) + currentTime: $currentTime, + viewModel: viewModel, scrollTo: { date in + viewModel.controller.player?.seek(to: CMTime(seconds: date.secondsSinceMidnight(), + preferredTimescale: 10000)) + pauseScrolling() + currentTime = (date.secondsSinceMidnight() + 1) + }) } - }.padding(.horizontal, isHorizontal ? 0 : 8) - SubtittlesView(languages: viewModel.languages, - currentTime: $currentTime, - viewModel: viewModel, scrollTo: { date in - viewModel.controller.player?.seek(to: CMTime(seconds: date.secondsSinceMidnight(), - preferredTimescale: 10000)) - pauseScrolling() - currentTime = (date.secondsSinceMidnight() + 1) - }) - } - }.padding(.horizontal, isHorizontal ? 0 : 8) + } } - } + }.padding(.horizontal, isHorizontal ? 0 : 8) } + private func pauseScrolling() { pause = true DispatchQueue.main.asyncAfter(deadline: .now() + 2) { diff --git a/Course/Course/Presentation/Video/SubtittlesView.swift b/Course/Course/Presentation/Video/SubtittlesView.swift index eb3496bdc..e7dca9735 100644 --- a/Course/Course/Presentation/Video/SubtittlesView.swift +++ b/Course/Course/Presentation/Video/SubtittlesView.swift @@ -96,7 +96,7 @@ public struct SubtittlesView: View { })) } }.padding(.horizontal, 24) - .padding(.top, 34) + .padding(.top, 16) } } From 52b33255aaf77dd13022ab3065375845c0b82184 Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:02:09 +0300 Subject: [PATCH 6/8] update progress dots --- Course/Course/Presentation/Unit/CourseUnitView.swift | 6 +++--- .../Presentation/Unit/Subviews/LessonProgressView.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Course/Course/Presentation/Unit/CourseUnitView.swift b/Course/Course/Presentation/Unit/CourseUnitView.swift index b1a3c5d3d..a025b1d00 100644 --- a/Course/Course/Presentation/Unit/CourseUnitView.swift +++ b/Course/Course/Presentation/Unit/CourseUnitView.swift @@ -137,7 +137,7 @@ public struct CourseUnitView: View { } } .frame( - width: reader.size.width, + width: isHorizontal ? reader.size.width - 16 : reader.size.width, height: reader.size.height ) .id(index) @@ -191,8 +191,8 @@ public struct CourseUnitView: View { // MARK: Progress Dots LessonProgressView(viewModel: viewModel) - .ignoresSafeArea(.all, edges: .leading) - .ignoresSafeArea(.all, edges: .trailing) +// .ignoresSafeArea(.all, edges: .leading) +// .ignoresSafeArea(.all, edges: .trailing) } // MARK: - Alert diff --git a/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift b/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift index 57a881589..21baa1336 100644 --- a/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift +++ b/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift @@ -36,7 +36,7 @@ struct LessonProgressView: View { } Spacer() } - .padding(.trailing, 6) + //.padding(.trailing, 6) } } } From abf3db2f1456d98688262fb3bbe0864cf8063438 Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:14:03 +0300 Subject: [PATCH 7/8] bug fixes When a user swipes back from the problem screen, the app numbs and the user cannot tap. Fixed. The component name is in the center of the screen. Fixed. --- Core/Core/Extensions/UIApplicationExtension.swift | 6 +++++- Course/Course/Presentation/Unit/CourseUnitView.swift | 8 +------- .../Presentation/Unit/Subviews/LessonProgressView.swift | 4 +++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Core/Core/Extensions/UIApplicationExtension.swift b/Core/Core/Extensions/UIApplicationExtension.swift index 616b9f466..9c6f88c6f 100644 --- a/Core/Core/Extensions/UIApplicationExtension.swift +++ b/Core/Core/Extensions/UIApplicationExtension.swift @@ -58,6 +58,10 @@ extension UINavigationController: UIGestureRecognizerDelegate { } public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { - return viewControllers.count > 1 + if #available(iOS 17, *) { + return false + } else { + return viewControllers.count > 1 + } } } diff --git a/Course/Course/Presentation/Unit/CourseUnitView.swift b/Course/Course/Presentation/Unit/CourseUnitView.swift index a025b1d00..484fdda9f 100644 --- a/Course/Course/Presentation/Unit/CourseUnitView.swift +++ b/Course/Course/Presentation/Unit/CourseUnitView.swift @@ -174,7 +174,6 @@ public struct CourseUnitView: View { }) .onChange(of: viewModel.index, perform: { index in -// self.title = viewModel.verticals[viewModel.verticalIndex].childs[index].displayName DispatchQueue.main.async { withAnimation(Animation.easeInOut(duration: 0.2)) { offsetView = -(reader.size.height * CGFloat(index)) @@ -191,8 +190,6 @@ public struct CourseUnitView: View { // MARK: Progress Dots LessonProgressView(viewModel: viewModel) -// .ignoresSafeArea(.all, edges: .leading) -// .ignoresSafeArea(.all, edges: .trailing) } // MARK: - Alert @@ -229,14 +226,13 @@ public struct CourseUnitView: View { let title = currentBlock.displayName Text(title) .lineLimit(1) - .frame(maxWidth: isHorizontal ? reader.size.width * 0.5 : nil) .font(Theme.Fonts.titleLarge) .foregroundStyle(Theme.Colors.textPrimary) .padding(.leading, isHorizontal ? 30 : 42) .padding(.top, isHorizontal ? 14 : 2) Spacer() } - } + }.frame(maxWidth: isHorizontal ? reader.size.width * 0.5 : nil) Spacer() } } @@ -281,7 +277,6 @@ public struct CourseUnitView: View { } } .ignoresSafeArea(.all, edges: .bottom) - .onRightSwipeGesture { playerStateSubject.send(VideoPlayerState.kill) viewModel.router.back() @@ -294,7 +289,6 @@ public struct CourseUnitView: View { .navigationBarHidden(true) .navigationBarBackButtonHidden(true) .navigationTitle("") - .background( Theme.Colors.background .ignoresSafeArea() diff --git a/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift b/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift index 21baa1336..da2010150 100644 --- a/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift +++ b/Course/Course/Presentation/Unit/Subviews/LessonProgressView.swift @@ -11,6 +11,8 @@ import Core struct LessonProgressView: View { @ObservedObject var viewModel: CourseUnitViewModel + @Environment (\.isHorizontal) private var isHorizontal + init(viewModel: CourseUnitViewModel) { self.viewModel = viewModel } @@ -36,7 +38,7 @@ struct LessonProgressView: View { } Spacer() } - //.padding(.trailing, 6) + .padding(.trailing, isHorizontal ? 0 : 6) } } } From 6459522fd652b240156ce28877e3a3c14a97e49a Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:24:36 +0300 Subject: [PATCH 8/8] code style improvements --- .../Reset Password/ResetPasswordView.swift | 2 +- Core/Core/Extensions/ViewExtension.swift | 31 +++++++------ Core/Core/View/Base/AlertView.swift | 14 +++--- .../View/Base/FlexibleKeyboardInputView.swift | 1 - Core/Core/View/Base/UnitButtonView.swift | 3 +- .../Unit/CourseNavigationView.swift | 3 +- .../Video/EncodedVideoPlayer.swift | 46 ++++++++++++------- 7 files changed, 57 insertions(+), 43 deletions(-) diff --git a/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift b/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift index 0b93441a5..ef4d1c7fb 100644 --- a/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift +++ b/Authorization/Authorization/Presentation/Reset Password/ResetPasswordView.swift @@ -37,7 +37,7 @@ public struct ResetPasswordView: View { leftButtonColor: .white, leftButtonAction: { viewModel.router.back() - }) .padding(.leading, isHorizontal ? 48 : 0) + }).padding(.leading, isHorizontal ? 48 : 0) ScrollView { VStack { diff --git a/Core/Core/Extensions/ViewExtension.swift b/Core/Core/Extensions/ViewExtension.swift index 756bf608f..91a66ed92 100644 --- a/Core/Core/Extensions/ViewExtension.swift +++ b/Core/Core/Extensions/ViewExtension.swift @@ -101,21 +101,26 @@ public extension View { } @ViewBuilder - func adaptiveHStack(spacing: CGFloat = 0, currentOrientation: UIInterfaceOrientation, - @ViewBuilder content: () -> Content) -> some View { - if currentOrientation.isLandscape && UIDevice.current.userInterfaceIdiom != .pad { - VStack(alignment: .center, spacing: spacing, content: content) - } else if currentOrientation.isPortrait && UIDevice.current.userInterfaceIdiom != .pad { - HStack(spacing: spacing, content: content) - } else if UIDevice.current.userInterfaceIdiom != .phone { - HStack(spacing: spacing, content: content) - } - } + func adaptiveHStack( + spacing: CGFloat = 0, + currentOrientation: UIInterfaceOrientation, + @ViewBuilder content: () -> Content + ) -> some View { + if currentOrientation.isLandscape && UIDevice.current.userInterfaceIdiom != .pad { + VStack(alignment: .center, spacing: spacing, content: content) + } else if currentOrientation.isPortrait && UIDevice.current.userInterfaceIdiom != .pad { + HStack(spacing: spacing, content: content) + } else if UIDevice.current.userInterfaceIdiom != .phone { + HStack(spacing: spacing, content: content) + } + } @ViewBuilder - func adaptiveStack(spacing: CGFloat = 0, - isHorizontal: Bool, - @ViewBuilder content: () -> Content) -> some View { + func adaptiveStack( + spacing: CGFloat = 0, + isHorizontal: Bool, + @ViewBuilder content: () -> Content + ) -> some View { if isHorizontal, UIDevice.current.userInterfaceIdiom != .pad { HStack(spacing: spacing, content: content) } else { diff --git a/Core/Core/View/Base/AlertView.swift b/Core/Core/View/Base/AlertView.swift index 926a347fa..15afa8774 100644 --- a/Core/Core/View/Base/AlertView.swift +++ b/Core/Core/View/Base/AlertView.swift @@ -176,7 +176,7 @@ public struct AlertView: View { .padding(.horizontal, 40) .multilineTextAlignment(.center) .font(Theme.Fonts.labelSmall) - .foregroundColor(CoreAssets.textSecondary.swiftUIColor) + .foregroundColor(Theme.Colors.textSecondary) } } } else { @@ -200,7 +200,7 @@ public struct AlertView: View { }) .background( Theme.Shapes.buttonShape - .fill(CoreAssets.warning.swiftUIColor) + .fill(Theme.Colors.warning) ) .overlay( RoundedRectangle(cornerRadius: 8) @@ -229,7 +229,7 @@ public struct AlertView: View { }) .background( Theme.Shapes.buttonShape - .fill(CoreAssets.warning.swiftUIColor) + .fill(Theme.Colors.warning) ) .overlay( RoundedRectangle(cornerRadius: 8) @@ -248,7 +248,7 @@ public struct AlertView: View { }, label: { ZStack { Text(CoreLocalization.Alert.keepEditing) - .foregroundColor(CoreAssets.textPrimary.swiftUIColor) + .foregroundColor(Theme.Colors.textPrimary) .font(Theme.Fonts.labelLarge) .frame(maxWidth: .infinity) .padding(.horizontal, 16) @@ -267,7 +267,7 @@ public struct AlertView: View { lineJoin: .round, miterLimit: 1 )) - .foregroundColor(CoreAssets.textPrimary.swiftUIColor) + .foregroundColor(Theme.Colors.textPrimary) ) .frame(maxWidth: 215) }.padding(.trailing, isHorizontal ? 20 : 0) @@ -287,14 +287,14 @@ public struct AlertView: View { }.frame(maxWidth: type == .logOut ? 390 : nil) .background( Theme.Shapes.cardShape - .fill(CoreAssets.cardViewBackground.swiftUIColor) + .fill(Theme.Colors.cardViewBackground) .shadow(radius: 24) .fixedSize(horizontal: false, vertical: false) ) .overlay( RoundedRectangle(cornerRadius: 12) .stroke(style: .init(lineWidth: 1, lineCap: .round, lineJoin: .round, miterLimit: 1)) - .foregroundColor(CoreAssets.backgroundStroke.swiftUIColor) + .foregroundColor(Theme.Colors.backgroundStroke) .fixedSize(horizontal: false, vertical: false) ) .frame(maxWidth: isHorizontal ? nil : 390) diff --git a/Core/Core/View/Base/FlexibleKeyboardInputView.swift b/Core/Core/View/Base/FlexibleKeyboardInputView.swift index 25cdba411..8747a260f 100644 --- a/Core/Core/View/Base/FlexibleKeyboardInputView.swift +++ b/Core/Core/View/Base/FlexibleKeyboardInputView.swift @@ -92,7 +92,6 @@ public struct FlexibleKeyboardInputView: View { }.frame(maxWidth: .infinity, maxHeight: commentSize + 16) .background( Theme.Colors.commentCellBackground - // .ignoresSafeArea() ) .overlay( GeometryReader { proxy in diff --git a/Core/Core/View/Base/UnitButtonView.swift b/Core/Core/View/Base/UnitButtonView.swift index 5e7b3ce2e..e6d658c49 100644 --- a/Core/Core/View/Base/UnitButtonView.swift +++ b/Core/Core/View/Base/UnitButtonView.swift @@ -102,12 +102,11 @@ public struct UnitButtonView: View { .padding(.leading, 8) .font(Theme.Fonts.labelLarge) .scaledToFit() -// .minimumScaleFactor(0.4) Spacer() CoreAssets.check.swiftUIImage.renderingMode(.template) .foregroundColor(Theme.Colors.styledButtonText) .padding(.trailing, 8) - }//.frame(maxWidth: 110) + } case .finish: HStack { Text(type.stringValue()) diff --git a/Course/Course/Presentation/Unit/CourseNavigationView.swift b/Course/Course/Presentation/Unit/CourseNavigationView.swift index 212706480..505d865e0 100644 --- a/Course/Course/Presentation/Unit/CourseNavigationView.swift +++ b/Course/Course/Presentation/Unit/CourseNavigationView.swift @@ -144,8 +144,7 @@ struct CourseNavigationView: View { }) } } - }//.frame(minWidth: 0, maxWidth: .infinity) - .padding(.horizontal, 24) + }.padding(.horizontal, 24) } } diff --git a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift index e952e71f4..233469250 100644 --- a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift +++ b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift @@ -80,31 +80,43 @@ public struct EncodedVideoPlayer: View { } } if isHorizontal { - SubtittlesView(languages: viewModel.languages, - currentTime: $currentTime, - viewModel: viewModel, scrollTo: { date in - viewModel.controller.player?.seek(to: CMTime(seconds: date.secondsSinceMidnight(), - preferredTimescale: 10000)) - pauseScrolling() - currentTime = (date.secondsSinceMidnight() + 1) - }) + SubtittlesView( + languages: viewModel.languages, + currentTime: $currentTime, + viewModel: viewModel, + scrollTo: { date in + viewModel.controller.player?.seek( + to: CMTime( + seconds: date.secondsSinceMidnight(), + preferredTimescale: 10000 + ) + ) + pauseScrolling() + currentTime = (date.secondsSinceMidnight() + 1) + }) } } if !isHorizontal { - SubtittlesView(languages: viewModel.languages, - currentTime: $currentTime, - viewModel: viewModel, scrollTo: { date in - viewModel.controller.player?.seek(to: CMTime(seconds: date.secondsSinceMidnight(), - preferredTimescale: 10000)) - pauseScrolling() - currentTime = (date.secondsSinceMidnight() + 1) - }) + SubtittlesView( + languages: viewModel.languages, + currentTime: $currentTime, + viewModel: viewModel, + scrollTo: { date in + viewModel.controller.player?.seek( + to: CMTime( + seconds: date.secondsSinceMidnight(), + preferredTimescale: 10000 + ) + ) + pauseScrolling() + currentTime = (date.secondsSinceMidnight() + 1) + }) } } } }.padding(.horizontal, isHorizontal ? 0 : 8) } - + private func pauseScrolling() { pause = true DispatchQueue.main.asyncAfter(deadline: .now() + 2) {