Skip to content

Commit

Permalink
Merge pull request #12 from keeplo/develop
Browse files Browse the repository at this point in the history
[Release] v0.5.0
  • Loading branch information
Marcorable authored Oct 24, 2023
2 parents 3a58b71 + efae7e3 commit 9c0edcb
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 44 deletions.
14 changes: 7 additions & 7 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
objects = {

/* Begin PBXBuildFile section */
A906931B2AE77C9A00E1A06D /* ViewControllerable in Frameworks */ = {isa = PBXBuildFile; productRef = A906931A2AE77C9A00E1A06D /* ViewControllerable */; };
A923E8202ADE5552008B6D9B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923E81F2ADE5552008B6D9B /* AppDelegate.swift */; };
A923E8222ADE5552008B6D9B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923E8212ADE5552008B6D9B /* SceneDelegate.swift */; };
A923E8242ADE5552008B6D9B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923E8232ADE5552008B6D9B /* ContentView.swift */; };
A923E8292ADE5553008B6D9B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A923E8282ADE5553008B6D9B /* Assets.xcassets */; };
A923E82C2ADE5553008B6D9B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A923E82A2ADE5553008B6D9B /* LaunchScreen.storyboard */; };
A923E8382ADE560F008B6D9B /* NumberingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923E8372ADE560F008B6D9B /* NumberingView.swift */; };
A923E83F2ADE583A008B6D9B /* ControllerableViewModel in Frameworks */ = {isa = PBXBuildFile; productRef = A923E83E2ADE583A008B6D9B /* ControllerableViewModel */; };
A9D298002ADF6A2800115A94 /* CustomAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D297FF2ADF6A2800115A94 /* CustomAlertView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
A90693192AE77C6600E1A06D /* ViewControllerable */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = ViewControllerable; path = ..; sourceTree = "<group>"; };
A923E81C2ADE5552008B6D9B /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
A923E81F2ADE5552008B6D9B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A923E8212ADE5552008B6D9B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -26,7 +27,6 @@
A923E82B2ADE5553008B6D9B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
A923E82D2ADE5553008B6D9B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A923E8372ADE560F008B6D9B /* NumberingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberingView.swift; sourceTree = "<group>"; };
A923E83C2ADE57D6008B6D9B /* ControllerableViewModel */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = ControllerableViewModel; path = ..; sourceTree = "<group>"; };
A9D297FF2ADF6A2800115A94 /* CustomAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -35,7 +35,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A923E83F2ADE583A008B6D9B /* ControllerableViewModel in Frameworks */,
A906931B2AE77C9A00E1A06D /* ViewControllerable in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -86,7 +86,7 @@
A923E83B2ADE57D6008B6D9B /* Packages */ = {
isa = PBXGroup;
children = (
A923E83C2ADE57D6008B6D9B /* ControllerableViewModel */,
A90693192AE77C6600E1A06D /* ViewControllerable */,
);
name = Packages;
sourceTree = "<group>";
Expand Down Expand Up @@ -115,7 +115,7 @@
);
name = Example;
packageProductDependencies = (
A923E83E2ADE583A008B6D9B /* ControllerableViewModel */,
A906931A2AE77C9A00E1A06D /* ViewControllerable */,
);
productName = Example;
productReference = A923E81C2ADE5552008B6D9B /* Example.app */;
Expand Down Expand Up @@ -396,9 +396,9 @@
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
A923E83E2ADE583A008B6D9B /* ControllerableViewModel */ = {
A906931A2AE77C9A00E1A06D /* ViewControllerable */ = {
isa = XCSwiftPackageProductDependency;
productName = ControllerableViewModel;
productName = ViewControllerable;
};
/* End XCSwiftPackageProductDependency section */
};
Expand Down
4 changes: 2 additions & 2 deletions Example/Example/View/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Created by 김용우 on 2023/10/17.
//

import ControllerableViewModel
import ViewControllerable

import SwiftUI

struct FirstView: ControllerableView {
struct FirstView: View, ViewControllerable {

var stateView: StateView

Expand Down
4 changes: 2 additions & 2 deletions Example/Example/View/CustomAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by 김용우 on 2023/10/18.
//

import ControllerableViewModel
import ViewControllerable

import SwiftUI

Expand All @@ -15,7 +15,7 @@ struct AlertItem {
let completion: () -> Void
}

struct CustomAlert: ControllerableView {
struct CustomAlert: View, ViewControllerable {

var stateView: StateView
let item : AlertItem
Expand Down
4 changes: 2 additions & 2 deletions Example/Example/View/NumberingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by 김용우 on 2023/10/17.
//

import ControllerableViewModel
import ViewControllerable

import SwiftUI

Expand All @@ -28,7 +28,7 @@ final class NumberingViewModel: ObservableObject {

}

struct NumberingView: ControllerableView {
struct NumberingView: View, ViewControllerable {

var stateView: StateView = .init()

Expand Down
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
import PackageDescription

let package = Package(
name: "ControllerableViewModel",
name: "ViewControllerable",
platforms: [
.iOS(.v15)
],
products: [
.library(
name: "ControllerableViewModel",
targets: ["ControllerableViewModel"]),
name: "ViewControllerable",
targets: ["ViewControllerable"]),
],
targets: [
.target(
name: "ControllerableViewModel",
name: "ViewControllerable",
dependencies: []),
.testTarget(
name: "ControllerableViewModelTests",
dependencies: ["ControllerableViewModel"]),
name: "ViewControllerableTests",
dependencies: ["ViewControllerable"]),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import SwiftUI

public class HostingController<View: ControllerableView>: UIHostingController<View> {
public class HostingController<Content: ViewControllerable & View>: UIHostingController<Content> {

public override func loadView() {
super.loadView()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// File.swift
// ViewControllerable.swift
//
//
// Created by 김용우 on 2023/10/19.
//

import SwiftUI

public extension ControllerableView {
public extension ViewControllerable {

var viewController: UIViewController {
let viewController = HostingController(rootView: self)
Expand All @@ -26,7 +26,7 @@ public extension ControllerableView {
}

// MARK: - Navigation
public extension ControllerableView {
public extension ViewControllerable {

private var window: UIWindow? {
if #available(iOS 16.0, *) {
Expand All @@ -39,7 +39,7 @@ public extension ControllerableView {
}
}

func push(view: some ControllerableView) {
func push(view: some ViewControllerable) {
stateView.viewController?.navigationController?.pushViewController(view.viewController, animated: true)
}

Expand All @@ -51,14 +51,14 @@ public extension ControllerableView {
stateView.viewController?.navigationController?.popToRootViewController(animated: true)
}

func restack(views: [any ControllerableView]) {
func restack(views: [some ViewControllerable]) {
self.popToRoot()
let viewControllers = views.compactMap({ $0.viewController })
stateView.viewController?.navigationController?.viewControllers.append(contentsOf: viewControllers)
}

func present(
view: some ControllerableView,
view: some ViewControllerable,
to presentationStyle: UIModalPresentationStyle? = nil,
by transitionStyle: UIModalTransitionStyle? = nil,
with detents: [UISheetPresentationController.Detent]? = nil
Expand All @@ -82,7 +82,7 @@ public extension ControllerableView {
}

func presentAlert(
view: some ControllerableView,
view: some ViewControllerable,
to presentationStyle: UIModalPresentationStyle? = .overFullScreen,
by transitionStyle: UIModalTransitionStyle? = .crossDissolve
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// ControllerableView.swift
// ViewControllerable.swift
//
//
// Created by 김용우 on 2023/10/17.
//

import SwiftUI

public protocol ControllerableView: View {
public protocol ViewControllerable where Self: View {

var stateView: StateView { get set }

Expand All @@ -20,18 +20,18 @@ public protocol ControllerableView: View {
func viewDidDisappear()

// MARK: Navigation
func push(view: some ControllerableView)
func push(view: some ViewControllerable)
func pop()
func popToRoot()
func restack(views: [any ControllerableView])
func restack(views: [some ViewControllerable])
func present(
view: some ControllerableView,
view: some ViewControllerable,
to presentationStyle: UIModalPresentationStyle?,
by transitionStyle: UIModalTransitionStyle?,
with detents: [UISheetPresentationController.Detent]?
)
func presentAlert(
view: some ControllerableView,
view: some ViewControllerable,
to presentationStyle: UIModalPresentationStyle?,
by transitionStyle: UIModalTransitionStyle?
)
Expand Down

This file was deleted.

8 changes: 8 additions & 0 deletions Tests/ViewControllerableTests/ViewControllerableTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import XCTest
@testable import ViewControllerable

final class ViewControllerableTests: XCTestCase {
func testExample() throws {
XCTAssertEqual("Hello, World!", "Hello, World!")
}
}

0 comments on commit 9c0edcb

Please sign in to comment.