Skip to content

Commit

Permalink
Merge pull request #27 from amiantos/intro-swipers
Browse files Browse the repository at this point in the history
Introduction Swipe Cards
  • Loading branch information
amiantos committed Apr 6, 2023
2 parents de843bb + 464b8ca commit 762fdc7
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 6 deletions.
33 changes: 31 additions & 2 deletions GamebookEngine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
440EF3F22323279D000A7C9F /* ContentSizedTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440EF3F12323279D000A7C9F /* ContentSizedTableView.swift */; };
4417DC292314867C00A6F96B /* RuleEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4417DC272314867C00A6F96B /* RuleEditorViewController.swift */; };
4417DC2A2314867C00A6F96B /* RuleEditorViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4417DC282314867C00A6F96B /* RuleEditorViewController.xib */; };
4433010929DE28D800A90F42 /* IntroductionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4433010829DE28D800A90F42 /* IntroductionView.swift */; };
4433010C29DE2A9A00A90F42 /* CardStack in Frameworks */ = {isa = PBXBuildFile; productRef = 4433010B29DE2A9A00A90F42 /* CardStack */; };
4439E65C230B534D00C6A23C /* Game+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4439E652230B534D00C6A23C /* Game+CoreDataClass.swift */; };
4439E65D230B534D00C6A23C /* Game+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4439E653230B534D00C6A23C /* Game+CoreDataProperties.swift */; };
4439E65E230B534D00C6A23C /* Decision+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4439E654230B534D00C6A23C /* Decision+CoreDataClass.swift */; };
Expand Down Expand Up @@ -118,6 +120,7 @@
440EF3F12323279D000A7C9F /* ContentSizedTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentSizedTableView.swift; sourceTree = "<group>"; };
4417DC272314867C00A6F96B /* RuleEditorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleEditorViewController.swift; sourceTree = "<group>"; };
4417DC282314867C00A6F96B /* RuleEditorViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RuleEditorViewController.xib; sourceTree = "<group>"; };
4433010829DE28D800A90F42 /* IntroductionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntroductionView.swift; sourceTree = "<group>"; };
4439E652230B534D00C6A23C /* Game+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Game+CoreDataClass.swift"; sourceTree = "<group>"; };
4439E653230B534D00C6A23C /* Game+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Game+CoreDataProperties.swift"; sourceTree = "<group>"; };
4439E654230B534D00C6A23C /* Decision+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Decision+CoreDataClass.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -210,6 +213,7 @@
buildActionMask = 2147483647;
files = (
4407F51729DD21C400119893 /* MarkdownKit in Frameworks */,
4433010C29DE2A9A00A90F42 /* CardStack in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -225,6 +229,14 @@
path = "Rule Editor";
sourceTree = "<group>";
};
4433010729DE28C700A90F42 /* Introduction */ = {
isa = PBXGroup;
children = (
4433010829DE28D800A90F42 /* IntroductionView.swift */,
);
path = Introduction;
sourceTree = "<group>";
};
444358B4230C56FD00A2E004 /* Page List */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -444,6 +456,7 @@
B4E9EFBA230A41AD00C9CA76 /* Views */ = {
isa = PBXGroup;
children = (
4433010729DE28C700A90F42 /* Introduction */,
B4789FEF23188B8E008DBE9F /* Game List */,
444358C1230C7BA800A2E004 /* Playing */,
444358BC230C789900A2E004 /* Editing */,
Expand Down Expand Up @@ -525,6 +538,7 @@
name = GamebookEngine;
packageProductDependencies = (
4407F51629DD21C400119893 /* MarkdownKit */,
4433010B29DE2A9A00A90F42 /* CardStack */,
);
productName = BRGamebookEngine;
productReference = B448874B23063A0D000E2FDD /* GamebookEngine.app */;
Expand Down Expand Up @@ -564,6 +578,7 @@
mainGroup = B448874223063A0D000E2FDD;
packageReferences = (
4407F51529DD21C400119893 /* XCRemoteSwiftPackageReference "MarkdownKit" */,
4433010A29DE2A9A00A90F42 /* XCRemoteSwiftPackageReference "SwiftUI-CardStackView" */,
);
productRefGroup = B448874C23063A0D000E2FDD /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -656,6 +671,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4433010929DE28D800A90F42 /* IntroductionView.swift in Sources */,
444358BF230C794400A2E004 /* PageEditorViewController.swift in Sources */,
B452531D2314C186002F628C /* UserDatabase.swift in Sources */,
B4F7C1482311AEB800EE055C /* PageEditorConsequenceTableViewCell.swift in Sources */,
Expand Down Expand Up @@ -904,7 +920,7 @@
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 2Y9M69QJKZ;
INFOPLIST_FILE = GamebookEngine/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -926,7 +942,7 @@
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 2Y9M69QJKZ;
INFOPLIST_FILE = GamebookEngine/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -979,6 +995,14 @@
minimumVersion = 1.7.0;
};
};
4433010A29DE2A9A00A90F42 /* XCRemoteSwiftPackageReference "SwiftUI-CardStackView" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/dadalar/SwiftUI-CardStackView.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.0.6;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -987,6 +1011,11 @@
package = 4407F51529DD21C400119893 /* XCRemoteSwiftPackageReference "MarkdownKit" */;
productName = MarkdownKit;
};
4433010B29DE2A9A00A90F42 /* CardStack */ = {
isa = XCSwiftPackageProductDependency;
package = 4433010A29DE2A9A00A90F42 /* XCRemoteSwiftPackageReference "SwiftUI-CardStackView" */;
productName = CardStack;
};
/* End XCSwiftPackageProductDependency section */

/* Begin XCVersionGroup section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"revision" : "5056f3305d3499f44d8815530d560b87082e0cf5",
"version" : "1.7.1"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334",
"version" : "1.11.0"
}
},
{
"identity" : "swiftui-cardstackview",
"kind" : "remoteSourceControl",
"location" : "https://github.com/dadalar/SwiftUI-CardStackView.git",
"state" : {
"revision" : "9b45ef54b9e7bfbee46fe4a5982ecf449ac2b47c",
"version" : "0.0.6"
}
}
],
"version" : 2
Expand Down
6 changes: 3 additions & 3 deletions GamebookEngine/Assets/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "create-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "icon-ios-1024@1x.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "magic-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "play-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "share-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "welcome-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
6 changes: 6 additions & 0 deletions GamebookEngine/Data/UserDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import UIKit

extension String {
static let createdIntro = "createdIntro"
static let shownIntroductionScreen = "shownIntroductionScreen"
}

struct UserDatabase {
Expand All @@ -21,6 +22,11 @@ struct UserDatabase {
}

extension UserDefaults {

func shouldShowIntroductoryScreen() -> Bool {
return !bool(forKey: .shownIntroductionScreen)
}

func createIntroGameIfNeeded() {
let status: Bool = bool(forKey: .createdIntro)
if !status, let introURL = Bundle.main.url(forResource: "An Introduction to Gamebook Engine", withExtension: "gbook"),
Expand Down
21 changes: 20 additions & 1 deletion GamebookEngine/Views/Game List/GameListTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

import UIKit
import SwiftUI
import UniformTypeIdentifiers

class GameListTableViewController: UITableViewController {
var games: [Game] = []
Expand Down Expand Up @@ -55,6 +57,7 @@ class GameListTableViewController: UITableViewController {
super.viewDidAppear(animated)

fetchGames()
showIntroductionScreen()
}

override func viewDidLayoutSubviews() {
Expand Down Expand Up @@ -119,7 +122,14 @@ extension GameListTableViewController: GameListGameTableViewCellDelegate, UIDocu
}

@objc fileprivate func importGame() {
let documentPicker = UIDocumentPickerViewController(documentTypes: ["net.amiantos.BRGamebookEngine.gbook"], in: .import)
var documentPicker: UIDocumentPickerViewController!
if #available(iOS 14, *) {
let supportedTypes: [UTType] = [UTType("net.amiantos.BRGamebookEngine.gbook")!]
documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes)
} else {
let supportedTypes: [String] = ["net.amiantos.BRGamebookEngine.gbook"]
documentPicker = UIDocumentPickerViewController(documentTypes: supportedTypes, in: .import)
}
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
present(documentPicker, animated: true, completion: nil)
Expand Down Expand Up @@ -161,6 +171,15 @@ extension GameListTableViewController: GameListGameTableViewCellDelegate, UIDocu
}
}

@objc fileprivate func showIntroductionScreen() {
if UserDatabase.standard.shouldShowIntroductoryScreen() {
let swiftUIViewController = UIHostingController(rootView: IntroductionView())
swiftUIViewController.modalPresentationStyle = .pageSheet
swiftUIViewController.isModalInPresentation = true
present(swiftUIViewController, animated: true, completion: nil)
}
}

fileprivate func showFilePicker(_ sender: UIButton) {
let actionSheet = UIAlertController(title: "Add Game", message: nil, preferredStyle: .actionSheet)
let importAction = UIAlertAction(title: "Import from file", style: .default) { _ in
Expand Down
Loading

0 comments on commit 762fdc7

Please sign in to comment.