-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Update experiment/test - `swift-programmatic-modal/AdaptiveModal`.
- Loading branch information
1 parent
5e816df
commit 8bd29c3
Showing
11 changed files
with
301 additions
and
42 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...atic-modal/AdaptiveModal/AdaptiveModalManager+UIViewControllerAnimatedTransitioning.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// AdaptiveModalManager+UIViewControllerAnimatedTransitioning.swift | ||
// swift-programmatic-modal | ||
// | ||
// Created by Dominic Go on 6/8/23. | ||
// | ||
|
||
import UIKit | ||
|
||
extension AdaptiveModalManager: UIViewControllerAnimatedTransitioning { | ||
|
||
func transitionDuration( | ||
using transitionContext: UIViewControllerContextTransitioning? | ||
) -> TimeInterval { | ||
// to be implemented | ||
return 1; | ||
}; | ||
|
||
func animateTransition( | ||
using transitionContext: UIViewControllerContextTransitioning | ||
) { | ||
//TBA | ||
}; | ||
}; |
39 changes: 39 additions & 0 deletions
39
...atic-modal/AdaptiveModal/AdaptiveModalManager+UIViewControllerTransitioningDelegate.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// AdaptiveModalManager+UIViewControllerTransitioningDelegate.swift | ||
// swift-programmatic-modal | ||
// | ||
// Created by Dominic Go on 6/8/23. | ||
// | ||
|
||
import UIKit | ||
|
||
|
||
extension AdaptiveModalManager: UIViewControllerTransitioningDelegate { | ||
|
||
func animationController( | ||
forPresented presented: UIViewController, | ||
presenting: UIViewController, | ||
source: UIViewController | ||
) -> UIViewControllerAnimatedTransitioning? { | ||
return nil; | ||
}; | ||
|
||
func animationController( | ||
forDismissed dismissed: UIViewController | ||
) -> UIViewControllerAnimatedTransitioning? { | ||
return nil; | ||
}; | ||
|
||
func presentationController( | ||
forPresented presented: UIViewController, | ||
presenting: UIViewController?, | ||
source: UIViewController | ||
) -> UIPresentationController? { | ||
|
||
return AdaptiveModalPresentationController( | ||
presentedViewController: presented, | ||
presenting: presenting, | ||
modalManager: 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
26 changes: 26 additions & 0 deletions
26
experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalPresentationController.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// AdaptiveModalPresentationController.swift | ||
// swift-programmatic-modal | ||
// | ||
// Created by Dominic Go on 6/8/23. | ||
// | ||
|
||
import UIKit | ||
|
||
class AdaptiveModalPresentationController: UIPresentationController { | ||
|
||
weak var modalManager: AdaptiveModalManager!; | ||
|
||
init( | ||
presentedViewController: UIViewController, | ||
presenting presentingViewController: UIViewController?, | ||
modalManager: AdaptiveModalManager | ||
) { | ||
super.init( | ||
presentedViewController: presentedViewController, | ||
presenting: presentingViewController | ||
); | ||
|
||
self.modalManager = modalManager; | ||
} | ||
}; |
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
74 changes: 74 additions & 0 deletions
74
experiments/swift-programmatic-modal/Test/AdaptiveModalPresentationTestViewController.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// AdaptiveModalPresentationTest.swift | ||
// swift-programmatic-modal | ||
// | ||
// Created by Dominic Go on 6/7/23. | ||
// | ||
|
||
import UIKit | ||
|
||
class TestViewController: UIViewController { | ||
override func viewDidLoad() { | ||
self.view.backgroundColor = .white; | ||
}; | ||
}; | ||
|
||
class AdaptiveModalPresentationTestViewController : UIViewController { | ||
|
||
lazy var adaptiveModalManager = AdaptiveModalManager( | ||
modalConfig: AdaptiveModalConfigTestPresets.test03.config | ||
); | ||
|
||
override func viewDidLoad() { | ||
self.view.backgroundColor = .white; | ||
|
||
let dummyBackgroundView: UIView = { | ||
let imageView = UIImageView( | ||
image: UIImage(named: "DummyBackgroundImage2") | ||
); | ||
|
||
imageView.contentMode = .scaleAspectFill; | ||
return imageView; | ||
}(); | ||
|
||
self.view.addSubview(dummyBackgroundView); | ||
dummyBackgroundView.translatesAutoresizingMaskIntoConstraints = false; | ||
|
||
NSLayoutConstraint.activate([ | ||
dummyBackgroundView.topAnchor .constraint(equalTo: self.view.topAnchor ), | ||
dummyBackgroundView.bottomAnchor .constraint(equalTo: self.view.bottomAnchor ), | ||
dummyBackgroundView.leadingAnchor .constraint(equalTo: self.view.leadingAnchor ), | ||
dummyBackgroundView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor), | ||
]); | ||
|
||
let presentButton: UIButton = { | ||
let button = UIButton(); | ||
button.setTitle("Present View Controller", for: .normal); | ||
|
||
button.addTarget( | ||
self, | ||
action: #selector(self.onPressButtonPresentViewController(_:)), | ||
for: .touchUpInside | ||
); | ||
|
||
return button; | ||
}(); | ||
|
||
self.view.addSubview(presentButton); | ||
presentButton.translatesAutoresizingMaskIntoConstraints = false; | ||
|
||
NSLayoutConstraint.activate([ | ||
presentButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), | ||
presentButton.centerYAnchor.constraint(equalTo: self.view.centerYAnchor) | ||
]); | ||
}; | ||
|
||
override func viewDidLayoutSubviews() { | ||
|
||
}; | ||
|
||
@objc func onPressButtonPresentViewController(_ sender: UIButton) { | ||
let testVC = TestViewController(); | ||
self.present(testVC, animated: true); | ||
}; | ||
}; |
Oops, something went wrong.