Skip to content

Commit

Permalink
Ensure that users read the tutorial on the first app launch
Browse files Browse the repository at this point in the history
  • Loading branch information
philipturner committed Sep 13, 2021
1 parent 52c1356 commit 8ef7fd7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
8 changes: 6 additions & 2 deletions AR MultiPendulum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "";
Expand All @@ -1534,10 +1535,11 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.philipturner.AR-MultiPendulum";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1548,6 +1550,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "";
Expand All @@ -1559,10 +1562,11 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.philipturner.AR-MultiPendulum";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
11 changes: 10 additions & 1 deletion AR MultiPendulum/App Setup/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ final class Coordinator: NSObject, MTKViewDelegate, ARSessionDelegate, Observabl
@Published var settingsShouldBeAnimated: Bool = false
@Published var showingAppTutorial: Bool = false

var shouldImmediatelyHideSettingsIcon: Bool = false
@Published var appTutorialCheck: AppTutorialView.Check = .init()

var canCloseTutorial = true
var shouldImmediatelyHideSettingsIcon = false

@Published var renderingSettings: RenderingSettings!
@Published var interactionSettings: InteractionSettings!
Expand Down Expand Up @@ -83,6 +86,7 @@ final class Coordinator: NSObject, MTKViewDelegate, ARSessionDelegate, Observabl

if storedSettings.isFirstAppLaunch {
showingAppTutorial = true
canCloseTutorial = false
}

func makeGestureRecognizer() -> UILongPressGestureRecognizer {
Expand Down Expand Up @@ -115,6 +119,11 @@ final class Coordinator: NSObject, MTKViewDelegate, ARSessionDelegate, Observabl
func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) { }

func draw(in view: MTKView) {
if !appTutorialCheck.check1 {
if appTutorialCheck.check2 { appTutorialCheck.check2 = false }
if appTutorialCheck.check3 { appTutorialCheck.check3 = false }
}

if gestureRecognizer.state != .possible || separatorGestureRecognizer.state != .possible {
renderer.pendingTap = .init()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import SwiftUI
struct AppTutorialView: View {
@EnvironmentObject var coordinator: Coordinator

struct Check: Equatable {
var check1 = false
var check2 = false
var check3 = false
}

var body: some View {
VStack {

Expand Down Expand Up @@ -78,10 +84,48 @@ struct AppTutorialView: View {
""")

if !coordinator.canCloseTutorial {
VStack(alignment: .leading) {
VStack {
Toggle(isOn: $coordinator.appTutorialCheck.check1) {
Text("I read the above tutorial")
}

Toggle(isOn: $coordinator.appTutorialCheck.check2) {
Text("I know how to access the settings panel")
}
.disabled(!coordinator.appTutorialCheck.check1)

Toggle(isOn: $coordinator.appTutorialCheck.check3) {
Text("I know how to control the simulation with my on-screen hand")
}
.disabled(!coordinator.appTutorialCheck.check1)
}
.frame(maxWidth: UIScreen.main.bounds.width, alignment: .center)

Text("You can access this tutorial at any time through the settings panel.")
.frame(alignment: .leading)
}
.padding(.bottom, 20)
}

VStack {
Button("Close Tutorial") {
coordinator.showingAppTutorial = false

if !coordinator.canCloseTutorial {
coordinator.canCloseTutorial = true
}
}
.disabled({
if coordinator.canCloseTutorial {
return false
}

let check = coordinator.appTutorialCheck

return !check.check1 || !check.check2 || !check.check3
}())
}
.frame(maxWidth: UIScreen.main.bounds.width, alignment: .center)
}
Expand Down

0 comments on commit 8ef7fd7

Please sign in to comment.