Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verticals popup menu on CourseUnitView #190

Merged
merged 12 commits into from
Dec 8, 2023
4 changes: 4 additions & 0 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
02F6EF3B28D9B8EC00835477 /* CourseCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F6EF3A28D9B8EC00835477 /* CourseCellView.swift */; };
02F6EF4A28D9F0A700835477 /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F6EF4928D9F0A700835477 /* DateExtension.swift */; };
02F98A7F28F81EE900DE94C0 /* Container+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F98A7E28F81EE900DE94C0 /* Container+App.swift */; };
0604C9AA2B22FACF00AD5DBF /* UIComponentsConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0604C9A92B22FACF00AD5DBF /* UIComponentsConfig.swift */; };
070019A528F6F17900D5FC78 /* Data_Media.swift in Sources */ = {isa = PBXBuildFile; fileRef = 070019A428F6F17900D5FC78 /* Data_Media.swift */; };
070019AC28F6FD0100D5FC78 /* CourseDetailBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 070019AB28F6FD0100D5FC78 /* CourseDetailBlock.swift */; };
070019AE28F701B200D5FC78 /* Certificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 070019AD28F701B200D5FC78 /* Certificate.swift */; };
Expand Down Expand Up @@ -245,6 +246,7 @@
02F6EF3A28D9B8EC00835477 /* CourseCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseCellView.swift; sourceTree = "<group>"; };
02F6EF4928D9F0A700835477 /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
02F98A7E28F81EE900DE94C0 /* Container+App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Container+App.swift"; sourceTree = "<group>"; };
0604C9A92B22FACF00AD5DBF /* UIComponentsConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIComponentsConfig.swift; sourceTree = "<group>"; };
070019A428F6F17900D5FC78 /* Data_Media.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data_Media.swift; sourceTree = "<group>"; };
070019AB28F6FD0100D5FC78 /* CourseDetailBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDetailBlock.swift; sourceTree = "<group>"; };
070019AD28F701B200D5FC78 /* Certificate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Certificate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -688,6 +690,7 @@
DBF6F2422B014AF30098414B /* Config */ = {
isa = PBXGroup;
children = (
0604C9A92B22FACF00AD5DBF /* UIComponentsConfig.swift */,
0727876F28D23411002E9142 /* Config.swift */,
DBF6F2402B014ADA0098414B /* FirebaseConfig.swift */,
DBF6F2492B0380E00098414B /* FeaturesConfig.swift */,
Expand Down Expand Up @@ -1020,6 +1023,7 @@
025B36752A13B7D5001A640E /* UnitButtonView.swift in Sources */,
028F9F39293A452B00DE65D0 /* ResetPassword.swift in Sources */,
0233D56F2AF13EB200BAC8BD /* StarRatingView.swift in Sources */,
0604C9AA2B22FACF00AD5DBF /* UIComponentsConfig.swift in Sources */,
027BD3B82909476200392132 /* DismissKeyboardTapViewModifier.swift in Sources */,
024BE3DF29B2615500BCDEE2 /* CGColorExtension.swift in Sources */,
0770DE6128D0B2CB006D8A5D /* Assets.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Core/Core/Configuration/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public protocol ConfigProtocol {
var google: GoogleConfig { get }
var appleSignIn: AppleSignInConfig { get }
var features: FeaturesConfig { get }
var uiComponents: UIComponentsConfig { get }
}

public enum TokenType: String {
Expand Down
28 changes: 28 additions & 0 deletions Core/Core/Configuration/Config/UIComponentsConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// UIComponentsConfig.swift
// Core
//
// Created by Vadim Kuznetsov on 5.12.23.
//

import Foundation

private enum Keys: String {
case isVerticalsMenuEnabled = "VERTICALS_MENU_ENABLED"
}

public class UIComponentsConfig: NSObject {
public var isVerticalsMenuEnabled: Bool = false

init(dictionary: [String: Any]) {
isVerticalsMenuEnabled = dictionary[Keys.isVerticalsMenuEnabled.rawValue] as? Bool ?? false
super.init()
}
}

private let key = "UI_COMPONENTS"
extension Config {
public var uiComponents: UIComponentsConfig {
return UIComponentsConfig(dictionary: properties[key] as? [String: AnyObject] ?? [:])
}
}
32 changes: 32 additions & 0 deletions Course/Course.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
02F78AEB29E6BCA20038DE30 /* VideoPlayerViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F78AEA29E6BCA20038DE30 /* VideoPlayerViewModelTests.swift */; };
02F98A8128F8224200DE94C0 /* Discussion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02F98A8028F8224200DE94C0 /* Discussion.framework */; };
02FFAD0D29E4347300140E46 /* VideoPlayerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02FFAD0C29E4347300140E46 /* VideoPlayerViewModel.swift */; };
068DDA5F2B1E198700FF8CCB /* CourseUnitDropDownList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068DDA5B2B1E198700FF8CCB /* CourseUnitDropDownList.swift */; };
068DDA602B1E198700FF8CCB /* CourseUnitVerticalsDropdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068DDA5C2B1E198700FF8CCB /* CourseUnitVerticalsDropdownView.swift */; };
068DDA612B1E198700FF8CCB /* CourseUnitDropDownCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068DDA5D2B1E198700FF8CCB /* CourseUnitDropDownCell.swift */; };
068DDA622B1E198700FF8CCB /* CourseUnitDropDownTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068DDA5E2B1E198700FF8CCB /* CourseUnitDropDownTitle.swift */; };
06FD7EDF2B1F29F3008D632B /* CourseVerticalImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06FD7EDE2B1F29F3008D632B /* CourseVerticalImageView.swift */; };
06FD7EE32B1F3FF6008D632B /* DropdownAnimationModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06FD7EE22B1F3FF6008D632B /* DropdownAnimationModifier.swift */; };
073512E229C0E400005CFA41 /* BaseCourseViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 073512E129C0E400005CFA41 /* BaseCourseViewModel.swift */; };
0766DFCC299AA7A600EBEF6A /* YouTubeVideoPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0766DFCB299AA7A600EBEF6A /* YouTubeVideoPlayer.swift */; };
0766DFCE299AB26D00EBEF6A /* EncodedVideoPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0766DFCD299AB26D00EBEF6A /* EncodedVideoPlayer.swift */; };
Expand Down Expand Up @@ -135,6 +141,12 @@
02F78AEA29E6BCA20038DE30 /* VideoPlayerViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = VideoPlayerViewModelTests.swift; path = CourseTests/Presentation/Unit/VideoPlayerViewModelTests.swift; sourceTree = SOURCE_ROOT; };
02F98A8028F8224200DE94C0 /* Discussion.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Discussion.framework; sourceTree = BUILT_PRODUCTS_DIR; };
02FFAD0C29E4347300140E46 /* VideoPlayerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerViewModel.swift; sourceTree = "<group>"; };
068DDA5B2B1E198700FF8CCB /* CourseUnitDropDownList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CourseUnitDropDownList.swift; sourceTree = "<group>"; };
068DDA5C2B1E198700FF8CCB /* CourseUnitVerticalsDropdownView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CourseUnitVerticalsDropdownView.swift; sourceTree = "<group>"; };
068DDA5D2B1E198700FF8CCB /* CourseUnitDropDownCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CourseUnitDropDownCell.swift; sourceTree = "<group>"; };
068DDA5E2B1E198700FF8CCB /* CourseUnitDropDownTitle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CourseUnitDropDownTitle.swift; sourceTree = "<group>"; };
06FD7EDE2B1F29F3008D632B /* CourseVerticalImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseVerticalImageView.swift; sourceTree = "<group>"; };
06FD7EE22B1F3FF6008D632B /* DropdownAnimationModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropdownAnimationModifier.swift; sourceTree = "<group>"; };
073512E129C0E400005CFA41 /* BaseCourseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseCourseViewModel.swift; sourceTree = "<group>"; };
0766DFCB299AA7A600EBEF6A /* YouTubeVideoPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YouTubeVideoPlayer.swift; sourceTree = "<group>"; };
0766DFCD299AB26D00EBEF6A /* EncodedVideoPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncodedVideoPlayer.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -214,6 +226,7 @@
02454C9E2A2618D40043052A /* Subviews */ = {
isa = PBXGroup;
children = (
068DDA5A2B1E198700FF8CCB /* DropdownList */,
02454C9F2A2618E70043052A /* YouTubeView.swift */,
02454CA12A26190A0043052A /* EncodedVideoView.swift */,
02454CA32A26193F0043052A /* WebView.swift */,
Expand Down Expand Up @@ -343,6 +356,18 @@
path = Presentation;
sourceTree = "<group>";
};
068DDA5A2B1E198700FF8CCB /* DropdownList */ = {
isa = PBXGroup;
children = (
068DDA5B2B1E198700FF8CCB /* CourseUnitDropDownList.swift */,
068DDA5C2B1E198700FF8CCB /* CourseUnitVerticalsDropdownView.swift */,
068DDA5D2B1E198700FF8CCB /* CourseUnitDropDownCell.swift */,
068DDA5E2B1E198700FF8CCB /* CourseUnitDropDownTitle.swift */,
06FD7EE22B1F3FF6008D632B /* DropdownAnimationModifier.swift */,
);
path = DropdownList;
sourceTree = "<group>";
};
070019A328F6EFC100D5FC78 /* Model */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -370,6 +395,7 @@
0270210128E736E700F54332 /* CourseOutlineView.swift */,
02A8076729474831007F53AB /* CourseVerticalView.swift */,
0248C92629C097EB00DC8402 /* CourseVerticalViewModel.swift */,
06FD7EDE2B1F29F3008D632B /* CourseVerticalImageView.swift */,
);
path = Outline;
sourceTree = "<group>";
Expand Down Expand Up @@ -697,15 +723,19 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
06FD7EE32B1F3FF6008D632B /* DropdownAnimationModifier.swift in Sources */,
02FFAD0D29E4347300140E46 /* VideoPlayerViewModel.swift in Sources */,
02454CA42A26193F0043052A /* WebView.swift in Sources */,
022C64DA29ACEC50000F532B /* HandoutsViewModel.swift in Sources */,
02635AC72A24F181008062F2 /* ContinueWithView.swift in Sources */,
068DDA622B1E198700FF8CCB /* CourseUnitDropDownTitle.swift in Sources */,
022C64DE29AD167A000F532B /* HandoutsUpdatesDetailView.swift in Sources */,
0270210328E736E700F54332 /* CourseOutlineView.swift in Sources */,
068DDA602B1E198700FF8CCB /* CourseUnitVerticalsDropdownView.swift in Sources */,
022C64E029ADEA9B000F532B /* Data_UpdatesResponse.swift in Sources */,
02454CA02A2618E70043052A /* YouTubeView.swift in Sources */,
02454CA22A26190A0043052A /* EncodedVideoView.swift in Sources */,
068DDA612B1E198700FF8CCB /* CourseUnitDropDownCell.swift in Sources */,
02B6B3BC28E1D14F00232911 /* CourseRepository.swift in Sources */,
02280F60294B50030032823A /* CoursePersistenceProtocol.swift in Sources */,
02454CAA2A2619B40043052A /* LessonProgressView.swift in Sources */,
Expand All @@ -715,6 +745,7 @@
0276D75B29DDA3890004CDF8 /* Data_ResumeBlock.swift in Sources */,
0276D75D29DDA3F80004CDF8 /* ResumeBlock.swift in Sources */,
02F3BFDD29252E900051930C /* CourseRouter.swift in Sources */,
068DDA5F2B1E198700FF8CCB /* CourseUnitDropDownList.swift in Sources */,
022F8E182A1E2642008EFAB9 /* EncodedVideoPlayerViewModel.swift in Sources */,
0248C92729C097EB00DC8402 /* CourseVerticalViewModel.swift in Sources */,
02F0145728F4A2FF002E513D /* CourseContainerViewModel.swift in Sources */,
Expand All @@ -728,6 +759,7 @@
DB7D6EB02ADFDA0E0036BB13 /* CourseDates.swift in Sources */,
02E685C028E4B629000AE015 /* CourseDetailsViewModel.swift in Sources */,
0295C889299BBE8200ABE571 /* CourseNavigationView.swift in Sources */,
06FD7EDF2B1F29F3008D632B /* CourseVerticalImageView.swift in Sources */,
DB7D6EAE2ADFCB4A0036BB13 /* CourseDatesViewModel.swift in Sources */,
02F066E829DC71750073E13B /* SubtittlesView.swift in Sources */,
022C64E229ADEB83000F532B /* CourseUpdate.swift in Sources */,
Expand Down
6 changes: 4 additions & 2 deletions Course/Course/Presentation/CourseRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public protocol CourseRouter: BaseRouter {
verticalIndex: Int,
chapters: [CourseChapter],
chapterIndex: Int,
sequentialIndex: Int
sequentialIndex: Int,
animated: Bool
)

func showCourseVerticalView(
Expand Down Expand Up @@ -98,7 +99,8 @@ public class CourseRouterMock: BaseRouterMock, CourseRouter {
verticalIndex: Int,
chapters: [CourseChapter],
chapterIndex: Int,
sequentialIndex: Int
sequentialIndex: Int,
animated: Bool
) {}

public func showCourseVerticalView(
Expand Down
116 changes: 116 additions & 0 deletions Course/Course/Presentation/Outline/CourseVerticalImageView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
//
// CourseVerticalImageView.swift
// Course
//
// Created by Vadim Kuznetsov on 5.12.23.
//

import Core
import SwiftUI

struct CourseVerticalImageView: View {
var blocks: [CourseBlock]

var body: some View {
if blocks.contains(where: { $0.type == .problem }) {
return CoreAssets.pen.swiftUIImage.renderingMode(.template)
} else if blocks.contains(where: { $0.type == .video }) {
return CoreAssets.video.swiftUIImage.renderingMode(.template)
} else if blocks.contains(where: { $0.type == .discussion }) {
return CoreAssets.discussion.swiftUIImage.renderingMode(.template)
} else if blocks.contains(where: { $0.type == .html }) {
return CoreAssets.extra.swiftUIImage.renderingMode(.template)
} else {
return CoreAssets.extra.swiftUIImage.renderingMode(.template)
}
}
}
#if DEBUG
struct CourseVerticalImageView_Previews: PreviewProvider {
static var previews: some View {
let blocks1 = [
CourseBlock(
blockId: "1",
id: "1",
courseId: "123",
topicId: "1",
graded: false,
completion: 1,
type: .video,
displayName: "Block 1",
studentUrl: "",
videoUrl: nil,
youTubeUrl: nil
)
]

let blocks2 = [
CourseBlock(
blockId: "1",
id: "1",
courseId: "123",
topicId: "1",
graded: false,
completion: 1,
type: .problem,
displayName: "Block 1",
studentUrl: "",
videoUrl: nil,
youTubeUrl: nil
)
]
let blocks3 = [
CourseBlock(
blockId: "1",
id: "1",
courseId: "123",
topicId: "1",
graded: false,
completion: 1,
type: .discussion,
displayName: "Block 1",
studentUrl: "",
videoUrl: nil,
youTubeUrl: nil
)
]
let blocks4 = [
CourseBlock(
blockId: "1",
id: "1",
courseId: "123",
topicId: "1",
graded: false,
completion: 1,
type: .html,
displayName: "Block 1",
studentUrl: "",
videoUrl: nil,
youTubeUrl: nil
)
]
let blocks5 = [
CourseBlock(
blockId: "1",
id: "1",
courseId: "123",
topicId: "1",
graded: false,
completion: 1,
type: .unknown,
displayName: "Block 1",
studentUrl: "",
videoUrl: nil,
youTubeUrl: nil
)
]
HStack {
CourseVerticalImageView(blocks: blocks1)
CourseVerticalImageView(blocks: blocks2)
CourseVerticalImageView(blocks: blocks3)
CourseVerticalImageView(blocks: blocks4)
CourseVerticalImageView(blocks: blocks5)
}
}
}
#endif
16 changes: 1 addition & 15 deletions Course/Course/Presentation/Outline/CourseVerticalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ public struct CourseVerticalView: View {
self.viewModel = viewModel
}

private func verticalImage(childs: [CourseBlock]) -> Image {
if childs.contains(where: { $0.type == .problem }) {
return CoreAssets.pen.swiftUIImage.renderingMode(.template)
} else if childs.contains(where: { $0.type == .video }) {
return CoreAssets.video.swiftUIImage.renderingMode(.template)
} else if childs.contains(where: { $0.type == .discussion }) {
return CoreAssets.discussion.swiftUIImage.renderingMode(.template)
} else if childs.contains(where: { $0.type == .html }) {
return CoreAssets.extra.swiftUIImage.renderingMode(.template)
} else {
return CoreAssets.extra.swiftUIImage.renderingMode(.template)
}
}

public var body: some View {
ZStack(alignment: .top) {
// MARK: - Page Body
Expand Down Expand Up @@ -82,7 +68,7 @@ public struct CourseVerticalView: View {
.renderingMode(.template)
.foregroundColor(.accentColor)
} else {
verticalImage(childs: vertical.childs)
CourseVerticalImageView(blocks: vertical.childs)
}
Text(vertical.displayName)
.font(Theme.Fonts.titleMedium)
Expand Down
4 changes: 3 additions & 1 deletion Course/Course/Presentation/Unit/CourseNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ struct CourseNavigationView: View {
verticalIndex: verticalIndex,
chapters: viewModel.chapters,
chapterIndex: chapterIndex,
sequentialIndex: sequentialIndex)
sequentialIndex: sequentialIndex,
animated: true
)
}
)
playerStateSubject.send(VideoPlayerState.pause)
Expand Down
Loading