Skip to content

Commit

Permalink
Merge pull request #7 from vdshko/develop
Browse files Browse the repository at this point in the history
Version 1.0
  • Loading branch information
vdshko authored Jul 16, 2022
2 parents a4e15ed + d786cf4 commit da53cfd
Show file tree
Hide file tree
Showing 69 changed files with 2,864 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.DS_Store
# Build generated
build/
DerivedData/
Package.resolved

# Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

# Other
*.moved-aside
*.xcuserstate

# Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# Playgrounds
timeline.xctimeline
playground.xcworkspace

# CocoaPods
Pods/

# Carthage
Carthage/Build
Carthage/Checkouts

# development

logs/*
tmp/*

# AppCode

.idea/

# fastlane

**/fastlane/report.xml
**/fastlane/README.md
**/fastlane/Preview.html
**/fastlane/screenshots/**/*.png
**/fastlane/test_output
sonar-reports/*

## GitLab CI

.bundle/
vendor/

Brewfile.lock.json
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# TicTacToe
TicTacToe game - written using SwiftUI in tandem with AppState-MVVM architecture.

![Simulator Screen Shot - iPhone 13 Pro - 2022-07-17 at 02 16 05](https://user-images.githubusercontent.com/43936569/179374991-ae75f492-7650-4951-a96d-c9721fc07608.png)
![Simulator Screen Shot - iPhone 13 Pro - 2022-07-17 at 02 17 08](https://user-images.githubusercontent.com/43936569/179374994-2648aaab-ac0d-4f12-bead-57f989227abb.png)
![Simulator Screen Shot - iPhone 13 Pro - 2022-07-17 at 02 17 45](https://user-images.githubusercontent.com/43936569/179374995-721c4d92-48ff-4d31-a9aa-9ce16814b5d7.png)
![Simulator Screen Shot - iPhone 13 Pro - 2022-07-17 at 02 17 52](https://user-images.githubusercontent.com/43936569/179374997-a018fb96-5dab-4630-97e1-ae1ff387c3fb.png)
20 changes: 20 additions & 0 deletions TicTacToe/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
platform :ios, '15.0'
use_frameworks!

install! 'cocoapods', :warn_for_unused_master_specs_repo => false

target 'TicTacToe' do
# swiftlint; https://github.com/realm/SwiftLint
pod 'SwiftLint', '0.47.1', :inhibit_warnings => true

# swiftgen; https://github.com/SwiftGen/SwiftGen
pod 'SwiftGen', '6.5.1', :inhibit_warnings => true
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
end
end
end
20 changes: 20 additions & 0 deletions TicTacToe/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PODS:
- SwiftGen (6.5.1)
- SwiftLint (0.47.1)

DEPENDENCIES:
- SwiftGen (= 6.5.1)
- SwiftLint (= 0.47.1)

SPEC REPOS:
trunk:
- SwiftGen
- SwiftLint

SPEC CHECKSUMS:
SwiftGen: a6d22010845f08fe18fbdf3a07a8e380fd22e0ea
SwiftLint: f80f1be7fa96d30e0aa68e58d45d4ea1ccaac519

PODFILE CHECKSUM: 02dddcbd0b277315d4c485d5b5b7d944279ea87b

COCOAPODS: 1.11.3
802 changes: 802 additions & 0 deletions TicTacToe/TicTacToe.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A1E72F86284CD7AF00869321"
BuildableName = "Tic Tac Toe.app"
BlueprintName = "TicTacToe"
ReferencedContainer = "container:TicTacToe.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A1E72F96284CD7B100869321"
BuildableName = "TicTacToeTests.xctest"
BlueprintName = "TicTacToeTests"
ReferencedContainer = "container:TicTacToe.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A1E72F86284CD7AF00869321"
BuildableName = "Tic Tac Toe.app"
BlueprintName = "TicTacToe"
ReferencedContainer = "container:TicTacToe.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A1E72F86284CD7AF00869321"
BuildableName = "Tic Tac Toe.app"
BlueprintName = "TicTacToe"
ReferencedContainer = "container:TicTacToe.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
10 changes: 10 additions & 0 deletions TicTacToe/TicTacToe.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
33 changes: 33 additions & 0 deletions TicTacToe/TicTacToe/App/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// AppDelegate.swift
// TicTacToe
//
// Created by Vlad Shkodich on 15.07.2022.
//

import UIKit
import SwiftUI

final class AppDelegate: NSObject, UIApplicationDelegate {

static var orientationLock = UIInterfaceOrientationMask.portrait

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return AppDelegate.orientationLock
}
}

extension View {

func unlockRotation() -> some View {
onAppear {
AppDelegate.orientationLock = UIInterfaceOrientationMask.all
UIViewController.attemptRotationToDeviceOrientation()
}
.onDisappear {
AppDelegate.orientationLock = UIInterfaceOrientationMask.portrait
UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
}
}
}
32 changes: 32 additions & 0 deletions TicTacToe/TicTacToe/App/TicTacToeApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// TicTacToeApp.swift
// TicTacToe
//
// Created by Vlad Shkodich on 05.06.2022.
//

import SwiftUI

@main
struct TicTacToeApp: App {

@UIApplicationDelegateAdaptor var appDelegate: AppDelegate

var body: some Scene {
WindowGroup {
MainView(viewModel: .init(diContainer: diContainer()))
}
}

private func diContainer() -> DIContainer {
let appState: AppState = AppState()
let services: DIContainer.Services = DIContainer.Services(
gameProgressService: GameProgressServiceImpl(
appState: appState,
aiEngine: AIEngineImpl()
)
)

return DIContainer(appState: appState, services: services)
}
}
16 changes: 16 additions & 0 deletions TicTacToe/TicTacToe/Common/AppState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// AppState.swift
// TicTacToe
//
// Created by Vlad Shkodich on 05.06.2022.
//

import Combine

final class AppState: ObservableObject {

@Published var gameBoard: [Move?] = Array(repeating: nil, count: 9)
@Published var isProfileShown: Bool = false

var gameType: GameType = GameType.singlePlayer
}
59 changes: 59 additions & 0 deletions TicTacToe/TicTacToe/Common/CancelBag.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// CancelBag.swift
// TicTacToe
//
// Created by Vlad Shkodich on 07.06.2022.
//

import Combine
import class Foundation.NSLock

final class CancelBag {

private var subscriptions: Set<AnyCancellable> = Set<AnyCancellable>()
private let lock: NSLock = NSLock()

deinit {
cancelAll()
}

func insert(_ cancellable: AnyCancellable) {
lock.lock()
defer {
lock.unlock()
}
subscriptions.insert(cancellable)
}

func contains(_ cancellable: AnyCancellable) -> Bool {
lock.lock()
defer {
lock.unlock()
}
return subscriptions.contains(cancellable)
}

func contains(where predicate: (AnyCancellable) throws -> Bool) rethrows -> Bool {
lock.lock()
defer {
lock.unlock()
}
return try subscriptions.contains(where: predicate)
}

func cancel(_ cancellable: AnyCancellable) {
lock.lock()
defer {
lock.unlock()
}
subscriptions.remove(cancellable)
}

func cancelAll() {
lock.lock()
defer {
lock.unlock()
}
subscriptions.removeAll()
}
}
Loading

0 comments on commit da53cfd

Please sign in to comment.