This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
let backgroundGray = Color( | |
red: 0, | |
green: 0, | |
blue: 0, | |
opacity: 0.25 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class MiddleView: UIView { | |
let titleLabel: UILabel = { | |
let label = UILabel() | |
label.font = .systemFont(ofSize: 20.0) | |
label.translatesAutoresizingMaskIntoConstraints = false | |
label.numberOfLines = 1 | |
label.textAlignment = .left | |
label.text = "MIDDLE TITLE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let quantity = CLSQuantityItem(identifier: "Score", title: "Score") | |
quantity.quantity = Double(score) | |
CLSDataStore.shared.mainAppContext.descendant(matchingIdentifierPath: identifierPath) { context, _ in | |
guard let activity = context?.currentActivity else { return } | |
activity.primaryActivityItem = quantity | |
CLSDataStore.shared.save() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftJWT | |
// Your ClassKit Catalog Key ID | |
let header = Header(kid: "<insert key id>") | |
// iss = your Developer Team ID | |
// iat - start time when the JWT is valid | |
// exp - when the JWT expires | |
let claims = ClaimsStandardJWT(iss: "<insert team id>", exp: Date(timeIntervalSinceNow: 3600), iat: Date()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func printJSON() { | |
let rootContext = Context( | |
data: Context.Data( | |
displayOrder: 0, | |
identifierPath: [Bundle.main.bundleIdentifier ?? ""], | |
isAssignable: false, | |
progressReportingCapabilities: [], | |
summary: "Fun tapper games for math and writing!", | |
title: "EduJam", | |
topic: "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidDisappear(_ animated: Bool) { | |
super.viewDidDisappear(animated) | |
CLSDataStore.shared.mainAppContext.descendant(matchingIdentifierPath: [game.identifier]) { context, _ in | |
guard let activity = context?.currentActivity else { return } | |
activity.stop() | |
context?.resignActive() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
CLSDataStore.shared.mainAppContext.descendant(matchingIdentifierPath: [game.identifier]) { context, _ in | |
context?.becomeActive() | |
if let activity = context?.currentActivity { | |
activity.start() | |
} else { | |
context?.createNewActivity().start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, | |
continue userActivity: NSUserActivity, | |
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { | |
guard | |
userActivity.isClassKitDeepLink, | |
let identifierPath = userActivity.contextIdentifierPath, | |
let gameID = identifierPath.last | |
else { return false } | |
let gameVC = GameViewController(gameID: gameID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ClassKit | |
class ActivityCreator: NSObject, CLSDataStoreDelegate { | |
static let shared = ActivityCreator() | |
override init() { | |
super.init() | |
CLSDataStore.shared.delegate = self | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if you want a property to be atomic, we lost that in Swift. This enables that | |
final class Atomic<A> { | |
private let queue = DispatchQueue(label: "Atomic serial queue") | |
private var _value: A | |
init(_ value: A) { | |
self._value = value | |
} | |
var value: A { | |
get { |
NewerOlder