Skip to content

Commit

Permalink
Merge pull request #2246 from CruGlobal/GT-2199-Tool-Options-for-Openers
Browse files Browse the repository at this point in the history
GT-2199 tool options for openers
  • Loading branch information
rachaelblue authored Aug 13, 2024
2 parents 67c8591 + 2380bde commit da77586
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 47 deletions.
52 changes: 40 additions & 12 deletions godtools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */; };
Expand Down Expand Up @@ -2779,8 +2782,8 @@
45C152462A43D21D00F2A1E8 /* ToolSettingsTopBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolSettingsTopBarView.swift; sourceTree = "<group>"; };
45C152782A44888100F2A1E8 /* LessonEvaluationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LessonEvaluationView.swift; sourceTree = "<group>"; };
45C1527A2A44888100F2A1E8 /* LessonEvaluationViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LessonEvaluationViewModel.swift; sourceTree = "<group>"; };
45C1528E2A44896C00F2A1E8 /* ToolView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolView.swift; sourceTree = "<group>"; };
45C152982A44896C00F2A1E8 /* ToolViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolViewModel.swift; sourceTree = "<group>"; };
45C1528E2A44896C00F2A1E8 /* TractView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TractView.swift; sourceTree = "<group>"; };
45C152982A44896C00F2A1E8 /* TractViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TractViewModel.swift; sourceTree = "<group>"; };
45C1529A2A44896C00F2A1E8 /* ChooseYourOwnAdventureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseYourOwnAdventureView.swift; sourceTree = "<group>"; };
45C1529E2A44896C00F2A1E8 /* ChooseYourOwnAdventureViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseYourOwnAdventureViewModel.swift; sourceTree = "<group>"; };
45C1A43428256B3300B8469A /* ProcessedEventResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProcessedEventResult.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3322,6 +3325,9 @@
D4C26CA52C518EF70082B479 /* ToolFilterAnyCategoryDomainModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolFilterAnyCategoryDomainModel.swift; sourceTree = "<group>"; };
D4C26CA92C529C090082B479 /* ToolFilterAnyLanguageDomainModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolFilterAnyLanguageDomainModel.swift; sourceTree = "<group>"; };
D4C26CB12C5D1EAB0082B479 /* SetUserPreferredAppLanguageRepositoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetUserPreferredAppLanguageRepositoryTests.swift; sourceTree = "<group>"; };
D4C26CB32C62EB2D0082B479 /* TractToolSettingsObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TractToolSettingsObserver.swift; sourceTree = "<group>"; };
D4C26CB52C6A98480082B479 /* CYOAToolSettingsObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CYOAToolSettingsObserver.swift; sourceTree = "<group>"; };
D4C26CB72C6A98950082B479 /* RemoteShareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteShareable.swift; sourceTree = "<group>"; };
D4C2A5522C2E31C10035AB4D /* LessonFilterLanguageSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LessonFilterLanguageSelectionView.swift; sourceTree = "<group>"; };
D4C2A5542C2E32030035AB4D /* LessonFilterLanguageSelectionViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LessonFilterLanguageSelectionViewModel.swift; sourceTree = "<group>"; };
D4C2A55F2C30906C0035AB4D /* ViewLessonFilterLanguagesUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewLessonFilterLanguagesUseCase.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6527,7 +6533,8 @@
isa = PBXGroup;
children = (
456AC1972B8CE89E00169C11 /* ToolSettingsObserver.swift */,
456AC19D2B8CEE6200169C11 /* ToolSettingsLanguages.swift */,
D47EAFC52C6ADD5C0071E6CA /* Subclasses */,
D47EAFC62C6ADD730071E6CA /* Protocols */,
);
path = Observer;
sourceTree = "<group>";
Expand Down Expand Up @@ -9272,13 +9279,13 @@
path = Subviews;
sourceTree = "<group>";
};
45C1528D2A44896C00F2A1E8 /* Tool */ = {
45C1528D2A44896C00F2A1E8 /* Tract */ = {
isa = PBXGroup;
children = (
45C1528E2A44896C00F2A1E8 /* ToolView.swift */,
45C152982A44896C00F2A1E8 /* ToolViewModel.swift */,
45C1528E2A44896C00F2A1E8 /* TractView.swift */,
45C152982A44896C00F2A1E8 /* TractViewModel.swift */,
);
path = Tool;
path = Tract;
sourceTree = "<group>";
};
45C152992A44896C00F2A1E8 /* ChooseYourOwnAdventure */ = {
Expand Down Expand Up @@ -11442,7 +11449,7 @@
children = (
45C152992A44896C00F2A1E8 /* ChooseYourOwnAdventure */,
D473469329072A3300579463 /* Dashboard */,
45C1528D2A44896C00F2A1E8 /* Tool */,
45C1528D2A44896C00F2A1E8 /* Tract */,
D473469629072A8700579463 /* Tools */,
);
path = Presentation;
Expand Down Expand Up @@ -11490,6 +11497,24 @@
path = Cache;
sourceTree = "<group>";
};
D47EAFC52C6ADD5C0071E6CA /* Subclasses */ = {
isa = PBXGroup;
children = (
D4C26CB52C6A98480082B479 /* CYOAToolSettingsObserver.swift */,
456AC19D2B8CEE6200169C11 /* ToolSettingsLanguages.swift */,
D4C26CB32C62EB2D0082B479 /* TractToolSettingsObserver.swift */,
);
path = Subclasses;
sourceTree = "<group>";
};
D47EAFC62C6ADD730071E6CA /* Protocols */ = {
isa = PBXGroup;
children = (
D4C26CB72C6A98950082B479 /* RemoteShareable.swift */,
);
path = Protocols;
sourceTree = "<group>";
};
D4B05FF3291061E8005852D0 /* MobileContentAuthTokenRepository */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ToolView.swift
// TractView.swift
// godtools
//
// Created by Levi Eggert on 10/30/20.
Expand All @@ -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)
}
Expand Down Expand Up @@ -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) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ToolViewModel.swift
// TractViewModel.swift
// godtools
//
// Created by Levi Eggert on 10/30/20.
Expand All @@ -10,7 +10,7 @@ import UIKit
import GodToolsToolParser
import Combine

class ToolViewModel: MobileContentPagesViewModel {
class TractViewModel: MobileContentPagesViewModel {

private let tractRemoteSharePublisher: TractRemoteSharePublisher
private let tractRemoteShareSubscriber: TractRemoteShareSubscriber
Expand Down Expand Up @@ -169,15 +169,15 @@ class ToolViewModel: MobileContentPagesViewModel {
)
}

private func createToolSettingsObserver() -> ToolSettingsObserver {
private func createToolSettingsObserver() -> TractToolSettingsObserver {

let languages = ToolSettingsLanguages(
primaryLanguageId: languages[0].id,
parallelLanguageId: languages[safe: 1]?.id,
selectedLanguageId: languages[selectedLanguageIndex].id
)

let toolSettingsObserver = ToolSettingsObserver(
let toolSettingsObserver = TractToolSettingsObserver(
toolId: renderer.value.resource.id,
languages: languages,
pageNumber: currentRenderedPageNumber,
Expand Down Expand Up @@ -237,7 +237,7 @@ class ToolViewModel: MobileContentPagesViewModel {

// MARK: - Inputs

extension ToolViewModel {
extension TractViewModel {

@objc func homeTapped() {

Expand Down Expand Up @@ -325,7 +325,7 @@ extension ToolViewModel {

// MARK: - Remote Share Subscriber / Publisher

extension ToolViewModel {
extension TractViewModel {

private func trackShareScreenOpened() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -46,6 +47,7 @@ class ToolSettingsViewModel: ObservableObject {
self.viewToolSettingsUseCase = viewToolSettingsUseCase
self.getShareablesUseCase = getShareablesUseCase
self.getShareableImageUseCase = getShareableImageUseCase
self.hidesShareScreenButton = toolSettingsObserver.isRemoteShareable == false

getCurrentAppLanguageUseCase
.getLanguagePublisher()
Expand Down
Loading

0 comments on commit da77586

Please sign in to comment.