Skip to content

Commit

Permalink
Force users to read tutorial when opening app for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
philipturner committed Sep 5, 2021
1 parent 35db664 commit a0047e7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
4 changes: 2 additions & 2 deletions AR MultiPendulum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 6T952M2592;
ENABLE_PREVIEWS = YES;
Expand All @@ -1549,7 +1549,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 6T952M2592;
ENABLE_PREVIEWS = YES;
Expand Down
17 changes: 4 additions & 13 deletions AR MultiPendulum/App Setup/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ import ARKit
final class Coordinator: NSObject, MTKViewDelegate, ARSessionDelegate, ObservableObject {
@Published var settingsIconIsHidden: Bool = false
@Published var settingsAreShown: Bool = false
@Published var settingsShouldBeAnimated: Bool = false
@Published var showingAppTutorial: Bool = false

var shouldImmediatelyHideSettingsIcon: Bool = false

@Published var renderingSettings: RenderingSettings!
@Published var interactionSettings: InteractionSettings!
@Published var lidarEnabledSettings: LiDAREnabledSettings!

@Published var caseSize: LensDistortionCorrector.StoredSettings.CaseSize = .small

@Published var showingAppTutorial: Bool = false
@Published var settingsShouldBeAnimated: Bool = false

var session: ARSession!
var view: MTKView!
var renderer: Renderer!
Expand All @@ -45,13 +43,9 @@ final class Coordinator: NSObject, MTKViewDelegate, ARSessionDelegate, Observabl
configuration.frameSemantics.insert(.sceneDepth)
configuration.frameSemantics.insert(.personSegmentation)

func isCorrectAspectRatio(_ size: CGSize) -> Bool {
size.width * 3 == size.height * 4
}

if !isCorrectAspectRatio(configuration.videoFormat.imageResolution) {
if configuration.videoFormat.imageResolution != CGSize(width: 1920, height: 1440) {
if let desiredFormat = ARWorldTrackingConfiguration.supportedVideoFormats.first(where: {
isCorrectAspectRatio($0.imageResolution)
$0.imageResolution == CGSize(width: 1920, height: 1440)
}) {
configuration.videoFormat = desiredFormat
} else {
Expand Down Expand Up @@ -88,10 +82,7 @@ final class Coordinator: NSObject, MTKViewDelegate, ARSessionDelegate, Observabl
caseSize = renderer.userSettings.lensDistortionCorrector.storedSettings.caseSize

if storedSettings.isFirstAppLaunch {
renderer.userSettings.storedSettings.isFirstAppLaunch = false
showingAppTutorial = true

renderer.showingFirstAppTutorial = true
}

func makeGestureRecognizer() -> UILongPressGestureRecognizer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ struct AppTutorialView: View {
VStack {

}
.sheet(isPresented: $coordinator.showingAppTutorial) {
.fullScreenCover(isPresented: $coordinator.showingAppTutorial) {
ScrollView(.vertical, showsIndicators: true) {
VStack {

}
.frame(height: 100)
.frame(height: 50)

VStack {
VStack {
Expand Down
1 change: 0 additions & 1 deletion AR MultiPendulum/Renderer/Renderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ final class Renderer {

var timeSinceSettingsOpenAnimationStart = Int.min
var shouldRenderToDisplay = true
var showingFirstAppTutorial = false

var doingMixedRealityRendering = false
var usingModifiedPerspective = false
Expand Down
6 changes: 2 additions & 4 deletions AR MultiPendulum/Renderer/RendererExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ extension Renderer: GeometryRenderer {
timeSinceSettingsOpenAnimationStart = .min
}

shouldRenderToDisplay = timeSinceSettingsOpenAnimationStart < Int(MainSettingsView.openAnimationDuration * 60 * 2)

if coordinator.showingAppTutorial, showingFirstAppTutorial {
if coordinator.showingAppTutorial {
shouldRenderToDisplay = false
} else {
showingFirstAppTutorial = false
shouldRenderToDisplay = timeSinceSettingsOpenAnimationStart < Int(MainSettingsView.openAnimationDuration * 60 * 2)
}


Expand Down
4 changes: 0 additions & 4 deletions AR MultiPendulum/User Settings/UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ final class UserSettings: DelegateRenderer {

storedSettings = Self.retrieveSettings() ?? .defaultSettings

if storedSettings.isFirstAppLaunch {
shouldSaveSettings = true
}

cameraMeasurements = CameraMeasurements (userSettings: self, library: library)
lensDistortionCorrector = LensDistortionCorrector(userSettings: self, library: library)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ extension UserSettings {
newStoredSettings.transferData(from: coordinator.interactionSettings)
newStoredSettings.transferData(from: coordinator.lidarEnabledSettings)

if newStoredSettings.isFirstAppLaunch, !coordinator.showingAppTutorial {
newStoredSettings.isFirstAppLaunch = false
}

lensDistortionCorrector.pendingStoredSettings.caseSize = renderer.coordinator.caseSize

if newStoredSettings != storedSettings {
Expand Down

0 comments on commit a0047e7

Please sign in to comment.