deanwombourne / scenic Goto Github PK
View Code? Open in Web Editor NEWA lightweight architecture for iOS apps
License: MIT License
A lightweight architecture for iOS apps
License: MIT License
The code is documented enough (imho) and it's pretty simple to understand anyway.
However, we're missing the "How To" part of the docuemntation (the readme is pretty much just the standard pods readme), and we're missing somewhere which says why Scenic is a good architecture framework to use.
I have an app I'm building that I use Scenic in. The app uses UIKit/Scenic to manage navigation but all (or at least most) views are written in SwiftUI. This leaves me with view controllers that are very simple e.g.:
final class LoginViewController: UIViewController {
private var loginView: LoginView! // a SwiftUI view
var viewModel: LoginViewModel! {
didSet {
self.loginView = LoginView(viewModel: self.viewModel)
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.embedChildView(self.loginView)
}
}
I like using this arch because it gives me the best control over navigation and appearance and allows me to quickly prototype/build UIs.
The problem I have is that I end up creating a storyboard file that always has just an empty view controller so scenic can instantiate my VC. I'd like to stop having these files around in my project.
From what I can see, there's two obvious ways of doing this:
init
method, something like: func createViewControllerFromSceneStoryboard(in bundle: Bundle?) -> ViewControllerType {
do {
return try ViewControllerType.instantiateFromStoryboard(named: self.sceneName, bundle: bundle)
} catch {
return ViewControllerType()
}
}
however the try/catch mechanism would have to be obj-c since the exception thrown when instantiating a view controller via a storyboard is in objc.
Scene
that indicates whether to use storyboards or the initialiser. Something like:public enum InitialisationSource {
case storyboard
case constructor
}
in the Scene protocol add var initialisationSource: InitialisationSource { get }
with a default implementation to return .storyboard
for backwards compatibility and then:
func createViewControllerFromSceneStoryboard(in bundle: Bundle?) -> ViewControllerType {
switch self.initialisationSource {
case .constructor:
return ViewControllerType()
case .storyboard:
return ViewControllerType.instantiateFromStoryboard(named: self.sceneName, bundle: bundle)
}
}
Any other options? Happy to make a PR just want to get your opinion on whether this is a change you're likely to accept before I start
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.