diff --git a/godtools.xcodeproj/project.pbxproj b/godtools.xcodeproj/project.pbxproj index 3214085c0b..c1258a07d5 100644 --- a/godtools.xcodeproj/project.pbxproj +++ b/godtools.xcodeproj/project.pbxproj @@ -1140,8 +1140,8 @@ 45C152482A43D21D00F2A1E8 /* ToolSettingsTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C152462A43D21D00F2A1E8 /* ToolSettingsTopBarView.swift */; }; 45C1527F2A44888100F2A1E8 /* LessonEvaluationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C152782A44888100F2A1E8 /* LessonEvaluationView.swift */; }; 45C152812A44888100F2A1E8 /* LessonEvaluationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C1527A2A44888100F2A1E8 /* LessonEvaluationViewModel.swift */; }; - 45C1529F2A44896C00F2A1E8 /* ToolView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C1528E2A44896C00F2A1E8 /* ToolView.swift */; }; - 45C152A52A44896C00F2A1E8 /* ToolViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C152982A44896C00F2A1E8 /* ToolViewModel.swift */; }; + 45C1529F2A44896C00F2A1E8 /* TractView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C1528E2A44896C00F2A1E8 /* TractView.swift */; }; + 45C152A52A44896C00F2A1E8 /* TractViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C152982A44896C00F2A1E8 /* TractViewModel.swift */; }; 45C152A62A44896C00F2A1E8 /* ChooseYourOwnAdventureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C1529A2A44896C00F2A1E8 /* ChooseYourOwnAdventureView.swift */; }; 45C152A92A44896C00F2A1E8 /* ChooseYourOwnAdventureViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C1529E2A44896C00F2A1E8 /* ChooseYourOwnAdventureViewModel.swift */; }; 45C1A43528256B3300B8469A /* ProcessedEventResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C1A43428256B3300B8469A /* ProcessedEventResult.swift */; }; @@ -1566,6 +1566,9 @@ D4C26CA62C518EF70082B479 /* ToolFilterAnyCategoryDomainModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C26CA52C518EF70082B479 /* ToolFilterAnyCategoryDomainModel.swift */; }; D4C26CAA2C529C090082B479 /* ToolFilterAnyLanguageDomainModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C26CA92C529C090082B479 /* ToolFilterAnyLanguageDomainModel.swift */; }; D4C26CB22C5D1EAB0082B479 /* SetUserPreferredAppLanguageRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C26CB12C5D1EAB0082B479 /* SetUserPreferredAppLanguageRepositoryTests.swift */; }; + D4C26CB42C62EB2D0082B479 /* TractToolSettingsObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C26CB32C62EB2D0082B479 /* TractToolSettingsObserver.swift */; }; + D4C26CB62C6A98480082B479 /* CYOAToolSettingsObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C26CB52C6A98480082B479 /* CYOAToolSettingsObserver.swift */; }; + D4C26CB82C6A98950082B479 /* RemoteShareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C26CB72C6A98950082B479 /* RemoteShareable.swift */; }; D4C2A5532C2E31C10035AB4D /* LessonFilterLanguageSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C2A5522C2E31C10035AB4D /* LessonFilterLanguageSelectionView.swift */; }; D4C2A5552C2E32030035AB4D /* LessonFilterLanguageSelectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C2A5542C2E32030035AB4D /* LessonFilterLanguageSelectionViewModel.swift */; }; D4C2A5602C30906C0035AB4D /* ViewLessonFilterLanguagesUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C2A55F2C30906C0035AB4D /* ViewLessonFilterLanguagesUseCase.swift */; }; @@ -2779,8 +2782,8 @@ 45C152462A43D21D00F2A1E8 /* ToolSettingsTopBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolSettingsTopBarView.swift; sourceTree = ""; }; 45C152782A44888100F2A1E8 /* LessonEvaluationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LessonEvaluationView.swift; sourceTree = ""; }; 45C1527A2A44888100F2A1E8 /* LessonEvaluationViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LessonEvaluationViewModel.swift; sourceTree = ""; }; - 45C1528E2A44896C00F2A1E8 /* ToolView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolView.swift; sourceTree = ""; }; - 45C152982A44896C00F2A1E8 /* ToolViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolViewModel.swift; sourceTree = ""; }; + 45C1528E2A44896C00F2A1E8 /* TractView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TractView.swift; sourceTree = ""; }; + 45C152982A44896C00F2A1E8 /* TractViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TractViewModel.swift; sourceTree = ""; }; 45C1529A2A44896C00F2A1E8 /* ChooseYourOwnAdventureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseYourOwnAdventureView.swift; sourceTree = ""; }; 45C1529E2A44896C00F2A1E8 /* ChooseYourOwnAdventureViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseYourOwnAdventureViewModel.swift; sourceTree = ""; }; 45C1A43428256B3300B8469A /* ProcessedEventResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProcessedEventResult.swift; sourceTree = ""; }; @@ -3322,6 +3325,9 @@ D4C26CA52C518EF70082B479 /* ToolFilterAnyCategoryDomainModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolFilterAnyCategoryDomainModel.swift; sourceTree = ""; }; D4C26CA92C529C090082B479 /* ToolFilterAnyLanguageDomainModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolFilterAnyLanguageDomainModel.swift; sourceTree = ""; }; D4C26CB12C5D1EAB0082B479 /* SetUserPreferredAppLanguageRepositoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetUserPreferredAppLanguageRepositoryTests.swift; sourceTree = ""; }; + D4C26CB32C62EB2D0082B479 /* TractToolSettingsObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TractToolSettingsObserver.swift; sourceTree = ""; }; + D4C26CB52C6A98480082B479 /* CYOAToolSettingsObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CYOAToolSettingsObserver.swift; sourceTree = ""; }; + D4C26CB72C6A98950082B479 /* RemoteShareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteShareable.swift; sourceTree = ""; }; D4C2A5522C2E31C10035AB4D /* LessonFilterLanguageSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LessonFilterLanguageSelectionView.swift; sourceTree = ""; }; D4C2A5542C2E32030035AB4D /* LessonFilterLanguageSelectionViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LessonFilterLanguageSelectionViewModel.swift; sourceTree = ""; }; D4C2A55F2C30906C0035AB4D /* ViewLessonFilterLanguagesUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewLessonFilterLanguagesUseCase.swift; sourceTree = ""; }; @@ -6527,7 +6533,8 @@ isa = PBXGroup; children = ( 456AC1972B8CE89E00169C11 /* ToolSettingsObserver.swift */, - 456AC19D2B8CEE6200169C11 /* ToolSettingsLanguages.swift */, + D47EAFC52C6ADD5C0071E6CA /* Subclasses */, + D47EAFC62C6ADD730071E6CA /* Protocols */, ); path = Observer; sourceTree = ""; @@ -9272,13 +9279,13 @@ path = Subviews; sourceTree = ""; }; - 45C1528D2A44896C00F2A1E8 /* Tool */ = { + 45C1528D2A44896C00F2A1E8 /* Tract */ = { isa = PBXGroup; children = ( - 45C1528E2A44896C00F2A1E8 /* ToolView.swift */, - 45C152982A44896C00F2A1E8 /* ToolViewModel.swift */, + 45C1528E2A44896C00F2A1E8 /* TractView.swift */, + 45C152982A44896C00F2A1E8 /* TractViewModel.swift */, ); - path = Tool; + path = Tract; sourceTree = ""; }; 45C152992A44896C00F2A1E8 /* ChooseYourOwnAdventure */ = { @@ -11442,7 +11449,7 @@ children = ( 45C152992A44896C00F2A1E8 /* ChooseYourOwnAdventure */, D473469329072A3300579463 /* Dashboard */, - 45C1528D2A44896C00F2A1E8 /* Tool */, + 45C1528D2A44896C00F2A1E8 /* Tract */, D473469629072A8700579463 /* Tools */, ); path = Presentation; @@ -11490,6 +11497,24 @@ path = Cache; sourceTree = ""; }; + D47EAFC52C6ADD5C0071E6CA /* Subclasses */ = { + isa = PBXGroup; + children = ( + D4C26CB52C6A98480082B479 /* CYOAToolSettingsObserver.swift */, + 456AC19D2B8CEE6200169C11 /* ToolSettingsLanguages.swift */, + D4C26CB32C62EB2D0082B479 /* TractToolSettingsObserver.swift */, + ); + path = Subclasses; + sourceTree = ""; + }; + D47EAFC62C6ADD730071E6CA /* Protocols */ = { + isa = PBXGroup; + children = ( + D4C26CB72C6A98950082B479 /* RemoteShareable.swift */, + ); + path = Protocols; + sourceTree = ""; + }; D4B05FF3291061E8005852D0 /* MobileContentAuthTokenRepository */ = { isa = PBXGroup; children = ( @@ -12562,7 +12587,7 @@ 459BF77E2AFEE0320053BA09 /* ToolScreenShareTutorialViewDataModel.swift in Sources */, 45EB9B7229F16CF200CA74A8 /* UILabel+AttributedString.swift in Sources */, 45B54C572A2641FE0042CD0E /* RealmDatabase+Read.swift in Sources */, - 45C152A52A44896C00F2A1E8 /* ToolViewModel.swift in Sources */, + 45C152A52A44896C00F2A1E8 /* TractViewModel.swift in Sources */, 45B6482025E58EE70098BAF1 /* (null) in Sources */, 45645C162AFE774900BD233D /* GetShareToolScreenShareSessionInterfaceStringsRepository.swift in Sources */, 45AD1BD925938A4F00A096A0 /* AlertMessageView.swift in Sources */, @@ -12687,6 +12712,7 @@ D4C2A57D2C348E2A0035AB4D /* SearchLessonFilterLanguagesUseCase.swift in Sources */, 45043FA12BFB875A00324573 /* GetDeleteAccountProgressInterfaceStringsInterface.swift in Sources */, 45645C1D2AFE7A5600BD233D /* ShareToolScreenShareSessionDomainModel.swift in Sources */, + D4C26CB82C6A98950082B479 /* RemoteShareable.swift in Sources */, 458721252BFB7756005DA242 /* DeleteAccountProgressView.swift in Sources */, 454CA1FC2B7BC3DC009A3976 /* GetAppLanguageRepositoryInterface.swift in Sources */, 450D4FA92B7FF963001DD006 /* ViewToolsDomainModel.swift in Sources */, @@ -12805,6 +12831,7 @@ 45E4DBB92BECFB09006ED2F3 /* SyncInvalidator.swift in Sources */, 45EB9B7629F16CF200CA74A8 /* UIView+Constraints.swift in Sources */, 455EE8442AEC59EB00C3205C /* DownloadToolProgressFeatureDataLayerDependencies.swift in Sources */, + D4C26CB62C6A98480082B479 /* CYOAToolSettingsObserver.swift in Sources */, 4598BD2B2BF7DF6800196463 /* SocialSignInAuthenticationType.swift in Sources */, D4BC79E429AE995A0040651B /* GetTrainingTipCompletedUseCase.swift in Sources */, 45DC190F2BB59A0C007542A5 /* UITestsDeepLinkParser.swift in Sources */, @@ -13090,6 +13117,7 @@ 45006D482B80EB9B002E480D /* GetToolsRepositoryInterface.swift in Sources */, 45E3476B2A49BE230014CCD1 /* Flow+PresentNativeMailApp.swift in Sources */, 4534F9222AE99EEA00A7A071 /* LessonEvaluationFeatureDiContainer.swift in Sources */, + D4C26CB42C62EB2D0082B479 /* TractToolSettingsObserver.swift in Sources */, 4535BE152B348BF100A8B62F /* ReviewShareShareableViewModel.swift in Sources */, 45E347892A49C0120014CCD1 /* ProgressBarView.swift in Sources */, 454CC4132C5D268B00046437 /* LanguageDirectionDomainModel.swift in Sources */, @@ -13380,7 +13408,7 @@ 4598BD202BF7DF6800196463 /* AuthUserDomainModel.swift in Sources */, 45B338312AF42A9400D18C63 /* GetTutorialInterfaceStringsRepository.swift in Sources */, 453D2F822AD88C2B001C44E3 /* GetLanguageSettingsInterfaceStringsRepository.swift in Sources */, - 45C1529F2A44896C00F2A1E8 /* ToolView.swift in Sources */, + 45C1529F2A44896C00F2A1E8 /* TractView.swift in Sources */, 45BDA5CE2954F67D007E259B /* RealmResourceView.swift in Sources */, 45C1523C2A43D1BD00F2A1E8 /* ToolSettingsViewModel.swift in Sources */, 450EE28629A6648900524F64 /* ToolPathDeepLinkParser.swift in Sources */, diff --git a/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureViewModel.swift b/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureViewModel.swift index d5618cc802..ae57f9327f 100644 --- a/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureViewModel.swift +++ b/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureViewModel.swift @@ -172,9 +172,57 @@ extension ChooseYourOwnAdventureViewModel { } } + @objc func toolSettingsTapped() { + + let toolSettingsObserver = createToolSettingsObserver() + + flowDelegate?.navigate(step: .toolSettingsTappedFromChooseYourOwnAdventure(toolSettingsObserver: toolSettingsObserver)) + } + func languageTapped(index: Int) { let pageRenderer: MobileContentPageRenderer = renderer.value.pageRenderers[index] setPageRenderer(pageRenderer: pageRenderer, navigationEvent: nil, pagePositions: nil) } } + +extension ChooseYourOwnAdventureViewModel { + + private func createToolSettingsObserver() -> CYOAToolSettingsObserver { + + let languages = ToolSettingsLanguages( + primaryLanguageId: languages[0].id, + parallelLanguageId: languages[safe: 1]?.id, + selectedLanguageId: languages[selectedLanguageIndex].id + ) + + let toolSettingsObserver = CYOAToolSettingsObserver( + toolId: renderer.value.resource.id, + languages: languages, + pageNumber: currentRenderedPageNumber, + trainingTipsEnabled: trainingTipsEnabled + ) + + toolSettingsObserver.$languages + .receive(on: DispatchQueue.main) + .sink { [weak self] (languages: ToolSettingsLanguages) in + + self?.setRendererPrimaryLanguage( + primaryLanguageId: languages.primaryLanguageId, + parallelLanguageId: languages.parallelLanguageId, + selectedLanguageId: languages.selectedLanguageId + ) + } + .store(in: &cancellables) + + toolSettingsObserver.$trainingTipsEnabled + .receive(on: DispatchQueue.main) + .sink { [weak self] (trainingTipsEnabled: Bool) in + + self?.setTrainingTipsEnabled(enabled: trainingTipsEnabled) + } + .store(in: &cancellables) + + return toolSettingsObserver + } +} diff --git a/godtools/App/Features/Dashboard/Presentation/Tool/ToolView.swift b/godtools/App/Features/Dashboard/Presentation/Tract/TractView.swift similarity index 93% rename from godtools/App/Features/Dashboard/Presentation/Tool/ToolView.swift rename to godtools/App/Features/Dashboard/Presentation/Tract/TractView.swift index 6f3498e140..c8bab83fa4 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tool/ToolView.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tract/TractView.swift @@ -1,5 +1,5 @@ // -// ToolView.swift +// TractView.swift // godtools // // Created by Levi Eggert on 10/30/20. @@ -8,11 +8,11 @@ import UIKit -class ToolView: MobileContentPagesView { +class TractView: MobileContentPagesView { - private let viewModel: ToolViewModel + private let viewModel: TractViewModel - init(viewModel: ToolViewModel, navigationBar: AppNavigationBar?) { + init(viewModel: TractViewModel, navigationBar: AppNavigationBar?) { self.viewModel = viewModel super.init(viewModel: viewModel, navigationBar: navigationBar) } @@ -81,7 +81,7 @@ class ToolView: MobileContentPagesView { // MARK: - ToolPageViewDelegate -extension ToolView: ToolPageViewDelegate { +extension TractView: ToolPageViewDelegate { func toolPageCardPositionChanged(pageView: ToolPageView, page: Int, cardPosition: Int?, animated: Bool) { diff --git a/godtools/App/Features/Dashboard/Presentation/Tool/ToolViewModel.swift b/godtools/App/Features/Dashboard/Presentation/Tract/TractViewModel.swift similarity index 98% rename from godtools/App/Features/Dashboard/Presentation/Tool/ToolViewModel.swift rename to godtools/App/Features/Dashboard/Presentation/Tract/TractViewModel.swift index d93a893ca9..e4cd2a64b2 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tool/ToolViewModel.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tract/TractViewModel.swift @@ -1,5 +1,5 @@ // -// ToolViewModel.swift +// TractViewModel.swift // godtools // // Created by Levi Eggert on 10/30/20. @@ -10,7 +10,7 @@ import UIKit import GodToolsToolParser import Combine -class ToolViewModel: MobileContentPagesViewModel { +class TractViewModel: MobileContentPagesViewModel { private let tractRemoteSharePublisher: TractRemoteSharePublisher private let tractRemoteShareSubscriber: TractRemoteShareSubscriber @@ -169,7 +169,7 @@ class ToolViewModel: MobileContentPagesViewModel { ) } - private func createToolSettingsObserver() -> ToolSettingsObserver { + private func createToolSettingsObserver() -> TractToolSettingsObserver { let languages = ToolSettingsLanguages( primaryLanguageId: languages[0].id, @@ -177,7 +177,7 @@ class ToolViewModel: MobileContentPagesViewModel { selectedLanguageId: languages[selectedLanguageIndex].id ) - let toolSettingsObserver = ToolSettingsObserver( + let toolSettingsObserver = TractToolSettingsObserver( toolId: renderer.value.resource.id, languages: languages, pageNumber: currentRenderedPageNumber, @@ -237,7 +237,7 @@ class ToolViewModel: MobileContentPagesViewModel { // MARK: - Inputs -extension ToolViewModel { +extension TractViewModel { @objc func homeTapped() { @@ -325,7 +325,7 @@ extension ToolViewModel { // MARK: - Remote Share Subscriber / Publisher -extension ToolViewModel { +extension TractViewModel { private func trackShareScreenOpened() { diff --git a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift index 476344700a..e141ac5b99 100644 --- a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift +++ b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift @@ -38,15 +38,18 @@ struct ToolSettingsOptionsView: View { } ) - ToolSettingsOptionView( - viewBackground: .color(color: Color(.sRGB, red: 245 / 256, green: 245 / 256, blue: 245 / 256, opacity: 1)), - title: viewModel.screenShareTitle, - titleColorStyle: .lightBackground, - iconImage: ImageCatalog.toolSettingsOptionScreenShare.image, - tappedClosure: { - viewModel.screenShareTapped() - } - ) + if !viewModel.hidesShareScreenButton { + + ToolSettingsOptionView( + viewBackground: .color(color: Color(.sRGB, red: 245 / 256, green: 245 / 256, blue: 245 / 256, opacity: 1)), + title: viewModel.screenShareTitle, + titleColorStyle: .lightBackground, + iconImage: ImageCatalog.toolSettingsOptionScreenShare.image, + tappedClosure: { + viewModel.screenShareTapped() + } + ) + } if !viewModel.hidesTrainingTipsButton { diff --git a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/ToolSettingsViewModel.swift b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/ToolSettingsViewModel.swift index d004a65aac..97c3bcc199 100644 --- a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/ToolSettingsViewModel.swift +++ b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/ToolSettingsViewModel.swift @@ -31,6 +31,7 @@ class ToolSettingsViewModel: ObservableObject { @Published var trainingTipsIcon: SwiftUI.Image = Image("") @Published var trainingTipsTitle: String = "" @Published var hidesTrainingTipsButton: Bool = true + @Published var hidesShareScreenButton: Bool = true @Published var chooseLanguageTitle: String = "" @Published var chooseLanguageToggleMessage: String = "" @Published var primaryLanguageTitle: String = "" @@ -46,6 +47,7 @@ class ToolSettingsViewModel: ObservableObject { self.viewToolSettingsUseCase = viewToolSettingsUseCase self.getShareablesUseCase = getShareablesUseCase self.getShareableImageUseCase = getShareableImageUseCase + self.hidesShareScreenButton = toolSettingsObserver.isRemoteShareable == false getCurrentAppLanguageUseCase .getLanguagePublisher() diff --git a/godtools/App/Flows/ChooseYourOwnAdventure/ChooseYourOwnAdventureFlow.swift b/godtools/App/Flows/ChooseYourOwnAdventure/ChooseYourOwnAdventureFlow.swift index bf15969274..35ec5b9a86 100644 --- a/godtools/App/Flows/ChooseYourOwnAdventure/ChooseYourOwnAdventureFlow.swift +++ b/godtools/App/Flows/ChooseYourOwnAdventure/ChooseYourOwnAdventureFlow.swift @@ -14,6 +14,7 @@ class ChooseYourOwnAdventureFlow: ToolNavigationFlow { private let appLanguage: AppLanguageDomainModel + private var toolSettingsFlow: ToolSettingsFlow? private var cancellables: Set = Set() private weak var flowDelegate: FlowDelegate? @@ -47,6 +48,27 @@ class ChooseYourOwnAdventureFlow: ToolNavigationFlow { func navigate(step: FlowStep) { switch step { + case .toolSettingsTappedFromChooseYourOwnAdventure(let toolSettingsObserver): + + let toolSettingsFlow = ToolSettingsFlow( + flowDelegate: self, + appDiContainer: appDiContainer, + sharedNavigationController: navigationController, + toolSettingsObserver: toolSettingsObserver + ) + + navigationController.present(toolSettingsFlow.getInitialView(), animated: true) + + self.toolSettingsFlow = toolSettingsFlow + + case .toolSettingsFlowCompleted(let state): + + guard toolSettingsFlow != nil else { return } + + navigationController.dismiss(animated: true) + + toolSettingsFlow = nil + case .backTappedFromChooseYourOwnAdventure: closeTool() @@ -110,18 +132,30 @@ extension ChooseYourOwnAdventureFlow { hidesBarItemPublisher: viewModel.$hidesBackButton.eraseToAnyPublisher(), layoutDirectionPublisher: Just(navBarLayoutDirection).eraseToAnyPublisher() ) - - var chooseYourOwnAdventureView: ChooseYourOwnAdventureView? + + let toolSettingsBarItem = NavBarItem( + controllerType: .base, + itemData: NavBarItemData( + contentType: .image(value: ImageCatalog.navToolSettings.uiImage), + style: .plain, + color: nil, + target: viewModel, + action: #selector(viewModel.toolSettingsTapped), + accessibilityIdentifier: nil + ), + hidesBarItemPublisher: nil + ) let navigationBar = AppNavigationBar( appearance: viewModel.navBarAppearance, backButton: nil, leadingItems: [homeButton, backButton], - trailingItems: [], + trailingItems: [toolSettingsBarItem], titleView: nil, title: nil ) + var chooseYourOwnAdventureView: ChooseYourOwnAdventureView? let view = ChooseYourOwnAdventureView(viewModel: viewModel, navigationBar: navigationBar) chooseYourOwnAdventureView = view diff --git a/godtools/App/Flows/Flow/FlowStep.swift b/godtools/App/Flows/Flow/FlowStep.swift index 394d0968c2..e5eee87ec3 100644 --- a/godtools/App/Flows/Flow/FlowStep.swift +++ b/godtools/App/Flows/Flow/FlowStep.swift @@ -84,7 +84,7 @@ enum FlowStep { // tool case homeTappedFromTool(isScreenSharing: Bool) case backTappedFromTool - case toolSettingsTappedFromTool(toolSettingsObserver: ToolSettingsObserver) + case toolSettingsTappedFromTool(toolSettingsObserver: TractToolSettingsObserver) case tractFlowCompleted(state: TractFlowCompletedState) // tutorial @@ -169,6 +169,7 @@ enum FlowStep { case didFailToDownloadArticleFromLoadingArticle(alertMessage: AlertMessageType) // choose your own adventure + case toolSettingsTappedFromChooseYourOwnAdventure(toolSettingsObserver: CYOAToolSettingsObserver) case backTappedFromChooseYourOwnAdventure case chooseYourOwnAdventureFlowCompleted(state: ChooseYourOwnAdventureFlowCompletedState) diff --git a/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift b/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift index 8ac57d6f07..6f22540997 100644 --- a/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift +++ b/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift @@ -12,7 +12,9 @@ import Combine class ToolScreenShareFlow: Flow { - private let toolSettingsObserver: ToolSettingsObserver + typealias ToolScreenShareSettingsObserver = ToolSettingsObserver & RemoteShareable + + private let toolSettingsObserver: ToolScreenShareSettingsObserver private var toolScreenShareTutorialModal: UIViewController? private var creatingToolScreenShareSessionModal: UIViewController? @@ -27,7 +29,7 @@ class ToolScreenShareFlow: Flow { let appDiContainer: AppDiContainer let navigationController: AppNavigationController - init(flowDelegate: FlowDelegate, appDiContainer: AppDiContainer, sharedNavigationController: AppNavigationController, toolSettingsObserver: ToolSettingsObserver) { + init(flowDelegate: FlowDelegate, appDiContainer: AppDiContainer, sharedNavigationController: AppNavigationController, toolSettingsObserver: ToolScreenShareSettingsObserver) { self.flowDelegate = flowDelegate self.appDiContainer = appDiContainer diff --git a/godtools/App/Flows/ToolSettings/Observer/Protocols/RemoteShareable.swift b/godtools/App/Flows/ToolSettings/Observer/Protocols/RemoteShareable.swift new file mode 100644 index 0000000000..27489fb96d --- /dev/null +++ b/godtools/App/Flows/ToolSettings/Observer/Protocols/RemoteShareable.swift @@ -0,0 +1,14 @@ +// +// RemoteShareable.swift +// godtools +// +// Created by Rachael Skeath on 8/12/24. +// Copyright © 2024 Cru. All rights reserved. +// + +import Foundation + +protocol RemoteShareable { + + var tractRemoteSharePublisher: TractRemoteSharePublisher { get } +} diff --git a/godtools/App/Flows/ToolSettings/Observer/Subclasses/CYOAToolSettingsObserver.swift b/godtools/App/Flows/ToolSettings/Observer/Subclasses/CYOAToolSettingsObserver.swift new file mode 100644 index 0000000000..35316ab60d --- /dev/null +++ b/godtools/App/Flows/ToolSettings/Observer/Subclasses/CYOAToolSettingsObserver.swift @@ -0,0 +1,13 @@ +// +// CYOAToolSettingsObserver.swift +// godtools +// +// Created by Rachael Skeath on 8/12/24. +// Copyright © 2024 Cru. All rights reserved. +// + +import Foundation + +class CYOAToolSettingsObserver: ToolSettingsObserver { + +} diff --git a/godtools/App/Flows/ToolSettings/Observer/ToolSettingsLanguages.swift b/godtools/App/Flows/ToolSettings/Observer/Subclasses/ToolSettingsLanguages.swift similarity index 100% rename from godtools/App/Flows/ToolSettings/Observer/ToolSettingsLanguages.swift rename to godtools/App/Flows/ToolSettings/Observer/Subclasses/ToolSettingsLanguages.swift diff --git a/godtools/App/Flows/ToolSettings/Observer/Subclasses/TractToolSettingsObserver.swift b/godtools/App/Flows/ToolSettings/Observer/Subclasses/TractToolSettingsObserver.swift new file mode 100644 index 0000000000..7f0815eb40 --- /dev/null +++ b/godtools/App/Flows/ToolSettings/Observer/Subclasses/TractToolSettingsObserver.swift @@ -0,0 +1,26 @@ +// +// CYOAToolSettingsObserver.swift +// godtools +// +// Created by Rachael Skeath on 8/6/24. +// Copyright © 2024 Cru. All rights reserved. +// + +import Foundation + +class TractToolSettingsObserver: ToolSettingsObserver, RemoteShareable { + + let tractRemoteSharePublisher: TractRemoteSharePublisher + + init(toolId: String, languages: ToolSettingsLanguages, pageNumber: Int, trainingTipsEnabled: Bool, tractRemoteSharePublisher: TractRemoteSharePublisher) { + + self.tractRemoteSharePublisher = tractRemoteSharePublisher + + super.init( + toolId: toolId, + languages: languages, + pageNumber: pageNumber, + trainingTipsEnabled: trainingTipsEnabled + ) + } +} diff --git a/godtools/App/Flows/ToolSettings/Observer/ToolSettingsObserver.swift b/godtools/App/Flows/ToolSettings/Observer/ToolSettingsObserver.swift index 3ee3fd46d4..aa7a224346 100644 --- a/godtools/App/Flows/ToolSettings/Observer/ToolSettingsObserver.swift +++ b/godtools/App/Flows/ToolSettings/Observer/ToolSettingsObserver.swift @@ -15,14 +15,18 @@ class ToolSettingsObserver: ObservableObject { let toolId: String let pageNumber: Int - let tractRemoteSharePublisher: TractRemoteSharePublisher - init(toolId: String, languages: ToolSettingsLanguages, pageNumber: Int, trainingTipsEnabled: Bool, tractRemoteSharePublisher: TractRemoteSharePublisher) { + init(toolId: String, languages: ToolSettingsLanguages, pageNumber: Int, trainingTipsEnabled: Bool) { self.toolId = toolId self.languages = languages self.pageNumber = pageNumber self.trainingTipsEnabled = trainingTipsEnabled - self.tractRemoteSharePublisher = tractRemoteSharePublisher + } +} + +extension ToolSettingsObserver { + var isRemoteShareable: Bool { + return self is RemoteShareable } } diff --git a/godtools/App/Flows/ToolSettings/ToolSettingsFlow.swift b/godtools/App/Flows/ToolSettings/ToolSettingsFlow.swift index 20aa16eb32..79bf0c7431 100644 --- a/godtools/App/Flows/ToolSettings/ToolSettingsFlow.swift +++ b/godtools/App/Flows/ToolSettings/ToolSettingsFlow.swift @@ -255,6 +255,7 @@ extension ToolSettingsFlow { extension ToolSettingsFlow { private func presentToolScreenShareFlow() { + guard let toolSettingsObserver = toolSettingsObserver as? ToolScreenShareFlow.ToolScreenShareSettingsObserver else { return } let toolScreenShareFlow = ToolScreenShareFlow( flowDelegate: self, diff --git a/godtools/App/Flows/Tract/TractFlow.swift b/godtools/App/Flows/Tract/TractFlow.swift index 6a8d8ec773..b857b7c3c6 100644 --- a/godtools/App/Flows/Tract/TractFlow.swift +++ b/godtools/App/Flows/Tract/TractFlow.swift @@ -173,7 +173,7 @@ extension TractFlow { let parentFlowIsHomeFlow: Bool = flowDelegate is AppFlow - let viewModel = ToolViewModel( + let viewModel = TractViewModel( flowDelegate: self, renderer: renderer, tractRemoteSharePublisher: appDiContainer.feature.toolScreenShare.dataLayer.getTractRemoteSharePublisher(), @@ -228,7 +228,7 @@ extension TractFlow { hidesBarItemPublisher: nil ) - var toolView: ToolView? + var tractView: TractView? let navigationBar = AppNavigationBar( appearance: viewModel.navBarAppearance, @@ -239,9 +239,9 @@ extension TractFlow { title: nil ) - let view = ToolView(viewModel: viewModel, navigationBar: navigationBar) + let view = TractView(viewModel: viewModel, navigationBar: navigationBar) - toolView = view + tractView = view viewModel.$languageNames .receive(on: DispatchQueue.main) @@ -250,7 +250,7 @@ extension TractFlow { let languageSelectorView: NavBarSelectorView? if languageNames.count > 1 { - languageSelectorView = self?.getNewLanguageSelectorView(view: toolView, viewModel: viewModel, navBarLayoutDirection: navBarLayoutDirection) + languageSelectorView = self?.getNewLanguageSelectorView(view: tractView, viewModel: viewModel, navBarLayoutDirection: navBarLayoutDirection) } else { languageSelectorView = nil @@ -273,7 +273,7 @@ extension TractFlow { return view } - private func getNewLanguageSelectorView(view: ToolView?, viewModel: ToolViewModel, navBarLayoutDirection: UISemanticContentAttribute) -> NavBarSelectorView { + private func getNewLanguageSelectorView(view: TractView?, viewModel: TractViewModel, navBarLayoutDirection: UISemanticContentAttribute) -> NavBarSelectorView { let barColor: UIColor = viewModel.navBarAppearance.backgroundColor let controlColor: UIColor = viewModel.navBarAppearance.controlColor ?? .white