Skip to content

Commit 58de1c7

Browse files
committed
🌲 Update
1 parent 72898d5 commit 58de1c7

File tree

11 files changed

+195
-17
lines changed

11 files changed

+195
-17
lines changed

FluidInterfaceKit-Demo/Book.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ let book = Book(title: "MyBook") {
4949
return controller
5050
}
5151

52+
BookNavigationLink(title: "App") {
53+
BookPresent(title: "Launch") {
54+
let controller = DemoApplicationController()
55+
controller.modalPresentationStyle = .fullScreen
56+
return controller
57+
}
58+
59+
}
60+
5261
BookPush(title: "ControlCenter") {
5362
DemoControlCenterViewController()
5463
}
@@ -75,3 +84,18 @@ let book = Book(title: "MyBook") {
7584
}
7685
}
7786
}
87+
88+
func makeButtonView(title: String, onTap: @escaping () -> Void) -> UIView {
89+
let button = UIButton(type: .system)
90+
button.setTitle(title, for: .normal)
91+
button.onTap {
92+
onTap()
93+
}
94+
95+
return AnyView { _ in
96+
VStackBlock {
97+
button
98+
}
99+
.padding(10)
100+
}
101+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import CompositionKit
2+
import FluidInterfaceKit
3+
import MondrianLayout
4+
import UIKit
5+
import ResultBuilderKit
6+
7+
final class DemoApplicationController: FluidSwitchController {
8+
9+
override func viewDidLoad() {
10+
super.viewDidLoad()
11+
12+
setViewController(AppTabBarController())
13+
}
14+
15+
}
16+
17+
final class AppTabBarController: UITabBarController {
18+
19+
override func viewDidLoad() {
20+
super.viewDidLoad()
21+
view.backgroundColor = .white
22+
23+
viewControllers = [
24+
UINavigationController(rootViewController: AppSearchViewController()),
25+
UINavigationController(rootViewController: AppOtherController()),
26+
]
27+
28+
tabBar.backgroundColor = .black
29+
}
30+
31+
}
32+
33+
final class AppSearchViewController: CodeBasedViewController {
34+
35+
override init() {
36+
super.init()
37+
title = "Search"
38+
}
39+
40+
override func viewDidLoad() {
41+
super.viewDidLoad()
42+
43+
view.backgroundColor = .neon(.cyan)
44+
45+
let list = VGridView(numberOfColumns: 1)
46+
47+
Mondrian.buildSubviews(on: view) {
48+
ZStackBlock(alignment: .attach(.all)) {
49+
list
50+
.viewBlock
51+
}
52+
.container(respectingSafeAreaEdges: .all)
53+
}
54+
55+
list.setContents(
56+
buildArray {
57+
58+
makeButtonView(
59+
title: "Open",
60+
onTap: { [unowned self] in
61+
62+
}
63+
)
64+
65+
}
66+
)
67+
68+
}
69+
70+
}
71+
72+
final class AppOtherController: CodeBasedViewController {
73+
74+
override init() {
75+
super.init()
76+
title = "Other"
77+
}
78+
79+
override func viewDidLoad() {
80+
super.viewDidLoad()
81+
82+
view.backgroundColor = .neon(.blue)
83+
}
84+
}

FluidInterfaceKit-Demo/DemoListViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private final class DetailViewController: UIViewController, ViewControllerFluidC
138138

139139
}
140140
.padding(.horizontal, 24)
141-
.respectSafeArea(edges: .all)
141+
.container(respectingSafeAreaEdges: .all)
142142

143143
}
144144

FluidInterfaceKit-Demo/DemoTransitionViewController.swift

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import CompositionKit
22
import FluidInterfaceKit
33
import Foundation
44
import MondrianLayout
5+
import ResultBuilderKit
56
import StorybookKit
67
import UIKit
78

@@ -20,7 +21,7 @@ final class DemoTransitionViewController: FluidStackController {
2021
override func viewDidLoad() {
2122
super.viewDidLoad()
2223

23-
view.backgroundColor = .white
24+
view.backgroundColor = .systemBackground
2425

2526
let list = VGridView(numberOfColumns: 1)
2627

@@ -29,17 +30,29 @@ final class DemoTransitionViewController: FluidStackController {
2930
list
3031
.viewBlock
3132
}
33+
.container(respectingSafeAreaEdges: .all)
3234
}
3335

34-
list.setContents([
35-
Self.makeCell(
36-
title: "fade",
37-
onTap: { [unowned self] in
36+
list.setContents(
37+
buildArray {
3838

39-
_display(transition: .popup())
40-
}
41-
)
42-
])
39+
Self.makeCell(
40+
title: "popup",
41+
onTap: { [unowned self] in
42+
43+
_display(transition: .popup())
44+
}
45+
)
46+
47+
Self.makeCell(
48+
title: "push",
49+
onTap: { [unowned self] in
50+
51+
_display(transition: .pushIdiom())
52+
}
53+
)
54+
}
55+
)
4356

4457
}
4558

FluidInterfaceKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
4B1561C52773732000C4DE07 /* DemoPresentationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1561C42773732000C4DE07 /* DemoPresentationViewController.swift */; };
1313
4B34DEED2789FC00002D820E /* DemoTransitionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B34DEEC2789FC00002D820E /* DemoTransitionViewController.swift */; };
1414
4B425A0F278F3A780062B4C5 /* DemoPictureInPictureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B425A0E278F3A780062B4C5 /* DemoPictureInPictureController.swift */; };
15+
4B4F93BA27908DC100490A21 /* DemoApplicationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B4F93B927908DC100490A21 /* DemoApplicationViewController.swift */; };
1516
4B5ED7D4278C3D6B00D30EE7 /* DemoContextMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5ED7D3278C3D6B00D30EE7 /* DemoContextMenuViewController.swift */; };
1617
4B658D0F276A59F700A17878 /* Wrap in Frameworks */ = {isa = PBXBuildFile; productRef = 4B658D0E276A59F700A17878 /* Wrap */; };
1718
4B959B092764F77E0003FFB6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B959B082764F77E0003FFB6 /* AppDelegate.swift */; };
@@ -46,6 +47,7 @@
4647
4B2CCB88278DD21400EAB928 /* Descriptors */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Descriptors; path = submodules/Descriptors; sourceTree = "<group>"; };
4748
4B34DEEC2789FC00002D820E /* DemoTransitionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoTransitionViewController.swift; sourceTree = "<group>"; };
4849
4B425A0E278F3A780062B4C5 /* DemoPictureInPictureController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoPictureInPictureController.swift; sourceTree = "<group>"; };
50+
4B4F93B927908DC100490A21 /* DemoApplicationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoApplicationViewController.swift; sourceTree = "<group>"; };
4951
4B5ED7D3278C3D6B00D30EE7 /* DemoContextMenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoContextMenuViewController.swift; sourceTree = "<group>"; };
5052
4B959B062764F77E0003FFB6 /* FluidInterfaceKit-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "FluidInterfaceKit-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
5153
4B959B082764F77E0003FFB6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -129,6 +131,7 @@
129131
4BB7B9CE277AF6170014B62A /* TranslationVelocityPlaygroundViewController.swift */,
130132
4B037C56277B4CAD00D06150 /* ScalingVelocityPlaygroundViewController.swift */,
131133
4BDDF27E277F7BFA00636B00 /* ViewModel.swift */,
134+
4B4F93B927908DC100490A21 /* DemoApplicationViewController.swift */,
132135
);
133136
path = "FluidInterfaceKit-Demo";
134137
sourceTree = "<group>";
@@ -245,6 +248,7 @@
245248
4BB7B9CF277AF6170014B62A /* TranslationVelocityPlaygroundViewController.swift in Sources */,
246249
4B959B0D2764F77E0003FFB6 /* ViewController.swift in Sources */,
247250
4BBDECD32766241200982229 /* UIControl+Closure.swift in Sources */,
251+
4B4F93BA27908DC100490A21 /* DemoApplicationViewController.swift in Sources */,
248252
4BE193592765B1290008626E /* DemoThreadsMessagesViewController.swift in Sources */,
249253
4BCD46532775BF8600B060C6 /* AnimatorPlaygroundViewController.swift in Sources */,
250254
4B959B092764F77E0003FFB6 /* AppDelegate.swift in Sources */,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import UIKit
2+
3+
extension AnyAddingTransition {
4+
5+
public static func pushIdiom(
6+
duration: TimeInterval = 0.6
7+
) -> Self {
8+
9+
return .init { context in
10+
11+
context.toViewController.view.transform = .init(translationX: context.toViewController.view.bounds.width, y: 0)
12+
context.toViewController.view.alpha = 0.02
13+
14+
let animator = UIViewPropertyAnimator(duration: duration, dampingRatio: 1) {
15+
16+
context.toViewController.view.transform = .identity
17+
if let fromViewController = context.fromViewController {
18+
fromViewController.view.transform = .init(translationX: -fromViewController.view.bounds.width, y: 0)
19+
}
20+
context.toViewController.view.alpha = 1
21+
22+
}
23+
24+
animator.addCompletion { _ in
25+
context.notifyCompleted()
26+
}
27+
28+
animator.startAnimation()
29+
30+
}
31+
32+
}
33+
34+
35+
}

FluidInterfaceKit/ViewController/FluidStackController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ open class FluidStackController: UIViewController {
376376
private func viewControllerState(viewController: UIViewController) -> TransitionContext? {
377377
viewControllerStateMap.object(forKey: viewController)
378378
}
379+
379380
}
380381

381382
public struct FluidStackControllerContext {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import UIKit
2+
3+
open class FluidSwitchController: UIViewController {
4+
5+
public private(set) var currentDisplayViewController: UIViewController?
6+
7+
public func setViewController(_ viewController: UIViewController) {
8+
9+
if let currentDisplayViewController = currentDisplayViewController {
10+
currentDisplayViewController.willMove(toParent: nil)
11+
currentDisplayViewController.view.removeFromSuperview()
12+
currentDisplayViewController.removeFromParent()
13+
}
14+
15+
addChild(viewController)
16+
view.addSubview(viewController.view)
17+
viewController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
18+
viewController.didMove(toParent: self)
19+
currentDisplayViewController = viewController
20+
}
21+
22+
}

FluidInterfaceKit/ViewController/FluidTabBarController.swift

Lines changed: 0 additions & 5 deletions
This file was deleted.

submodules/CompositionKit

0 commit comments

Comments
 (0)