Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
marekVrican committed Feb 14, 2023
1 parent 7db1566 commit 84dd955
Show file tree
Hide file tree
Showing 170 changed files with 3,000 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
529 changes: 529 additions & 0 deletions GoodReactor-Sample/GoodReactor-Sample.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,14 @@
{
"pins" : [
{
"identity" : "combineext",
"kind" : "remoteSourceControl",
"location" : "https://github.com/CombineCommunity/CombineExt.git",
"state" : {
"revision" : "d7b896fa9ca8b47fa7bcde6b43ef9b70bf8c1f56",
"version" : "1.8.1"
}
}
],
"version" : 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AppDelegate.swift
// GoodReactor-Sample
//
// Created by GoodRequest on 08/02/2023.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
window = UIWindow()

UINavigationBar.configureAppearance()

AppCoordinator(window: window).start()

return true
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
37 changes: 37 additions & 0 deletions GoodReactor-Sample/GoodReactor-Sample/Application/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.example.plain-text</string>
</array>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>Example Text</string>
<key>UTTypeIdentifier</key>
<string>com.example.plain-text</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>exampletext</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AboutCoordinator.swift
// GoodReactor-Sample
//
// Created by GoodRequest on 08/02/2023.
//

import UIKit

enum AboutStep {}

class AboutCoordinator: Coordinator<AppStep> {

override func start() -> AboutViewController {
super.start()

let aboutViewModel = AboutViewModel(coordinator: self)
let aboutViewController = AboutViewController(viewModel: aboutViewModel)

if rootViewController == nil {
rootViewController = aboutViewController
}

return aboutViewController
}

override func navigate(to stepper: AppStep) -> StepAction {
switch stepper {
case .safari(let url):
return .safari(url)

default:
return .none
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AppCoordinator.swift
// GoodReactor-Sample
//
// Created by GoodRequest on 08/02/2023.
//

import UIKit

enum AppStep {

case home(HomeStep)
case safari(URL)

}

final class AppCoordinator: Coordinator<AppStep> {

// MARK: - Constants

private let window: UIWindow?

// MARK: - Init

init(window: UIWindow?) {
self.window = window
}

@discardableResult
override func start() -> UIViewController? {
super.start()

window?.rootViewController = HomeCoordinator().start()
window?.makeKeyAndVisible()

return window?.rootViewController
}

}
134 changes: 134 additions & 0 deletions GoodReactor-Sample/GoodReactor-Sample/Coordinators/Coordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
//
// Coordinator.swift
// GoodReactor-Sample
//
// Created by GoodRequest on 08/02/2023.
//

import GoodReactor
import Combine
import SafariServices


enum StepAction {

case push(UIViewController)
case safari(URL)
case dismiss
case pop
case popTo(UIViewController)
case popToRoot
case set([UIViewController])
case none

var isModalAction: Bool {
switch self {
case .dismiss, .safari:
return true

default:
return false
}
}

var isNavigationAction: Bool {
switch self {
case .push, .pop, .popTo, .set, .popToRoot:
return true

default:
return false
}
}

}

class Coordinator<Step>: GoodCoordinator<Step> {

@discardableResult
public func start() -> UIViewController? {
$step
.compactMap { $0 }
.sink { [weak self] in
guard let self else { return }

self.navigate(flowAction: self.navigate(to: $0))
}.store(in: &cancellables)

return rootViewController
}

var rootViewController: UIViewController?

var rootNavigationController: UINavigationController? {
return rootViewController as? UINavigationController
}

var navigationController: UINavigationController? {
return rootViewController as? UINavigationController
}

init(rootViewController: UIViewController? = nil, parentCoordinator: Coordinator<Step>? = nil) {
super.init(parentCoordinator: parentCoordinator)

self.parentCoordinator = parentCoordinator
self.rootViewController = rootViewController
}

@discardableResult
func navigate(to stepper: Step) -> StepAction {
return .none
}

private func navigate(flowAction: StepAction) {
if flowAction.isModalAction == true {
guard let viewController = rootViewController else {
assertionFailure("Coordinator without root view controller")
return
}

switch flowAction {
case .dismiss:
viewController.dismiss(animated: true, completion: nil)

case .safari(let url):
let safariViewController = SFSafariViewController(url: url)
return viewController.present(safariViewController, animated: true, completion: nil)


default:
break
}
} else if flowAction.isNavigationAction == true {
guard let viewController = rootNavigationController else {
assertionFailure("Coordinator without navigation view controller")
return
}

switch flowAction {
case .push(let controller):
viewController.pushViewController(controller, animated: true)

case .pop:
viewController.popViewController(animated: true)

case .popTo(let controller):
viewController.popToViewController(controller, animated: true)

case .popToRoot:
rootNavigationController?.popToRootViewController(animated: true)

case .set(let controllers):
viewController.setViewControllers(controllers, animated: true)

default:
break
}
}
}

func perform(step: Step) {
self.step = step
}

}
Loading

0 comments on commit 84dd955

Please sign in to comment.