boilerplate setup completed

This commit is contained in:
Mauro Romito
2022-12-07 19:22:33 +01:00
parent 34ca74d0c2
commit 4543aec25d
8 changed files with 164 additions and 3 deletions
@@ -15,6 +15,7 @@
//
import Foundation
import WysiwygComposer
protocol ComposerLinkActionBridgePresenterDelegate: AnyObject {
@@ -23,12 +24,20 @@ protocol ComposerLinkActionBridgePresenterDelegate: AnyObject {
final class ComposerLinkActionBridgePresenter: NSObject {
private var coordinator: ComposerLinkActionCoordinator?
private var linkAction: LinkActionWrapper
private var linkAction: LinkAction
weak var delegate: ComposerLinkActionBridgePresenterDelegate?
init(linkAction: LinkActionWrapper) {
self.linkAction = linkAction
self.linkAction = linkAction.linkAction
super.init()
}
func present(from viewController: UIViewController, animated: Bool) {
let composerLinkActionCoordinator = ComposerLinkActionCoordinator(linkAction: linkAction)
let presentable = composerLinkActionCoordinator.toPresentable()
viewController.present(presentable, animated: animated, completion: nil)
composerLinkActionCoordinator.start()
coordinator = composerLinkActionCoordinator
}
}
@@ -15,15 +15,24 @@
//
import Foundation
import WysiwygComposer
final class ComposerLinkActionCoordinator: Coordinator, Presentable {
var childCoordinators: [Coordinator] = []
private let hostingController: UIViewController
private let viewModel: ComposerLinkActionViewModel
init(linkAction: LinkAction) {
viewModel = ComposerLinkActionViewModel(initialViewState: .init())
hostingController = VectorHostingController(rootView: ComposerLinkActionView(viewModel: viewModel.context))
}
func start() {
}
func toPresentable() -> UIViewController {
fatalError()
hostingController
}
}
@@ -0,0 +1,31 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
enum MockComposerLinkActionScreenState: MockScreenState, CaseIterable {
var screenType: Any.Type {
ComposerLinkActionView.self
}
var screenView: ([Any], AnyView) {
let viewModel = ComposerLinkActionViewModel(initialViewState: .init())
return (
[viewModel],
AnyView(ComposerLinkActionView(viewModel: viewModel.context))
)
}
}
@@ -0,0 +1,28 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
enum ComposerLinkActionViewAction {
}
enum ComposerLinkActionViewModelResult: Equatable {
}
// MARK: View
struct ComposerLinkActionViewState: BindableState {
}
@@ -0,0 +1,36 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
struct ComposerLinkActionView: View {
@ObservedObject private var viewModel: ComposerLinkActionViewModel.Context
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
init(viewModel: ComposerLinkActionViewModel.Context) {
self.viewModel = viewModel
}
}
struct ComposerLinkActionView_Previews: PreviewProvider {
static let stateRenderer = MockComposerLinkActionScreenState.stateRenderer
static var previews: some View {
stateRenderer.screenGroup()
}
}
@@ -0,0 +1,25 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
typealias ComposerLinkActionViewModelType = StateStoreViewModel<ComposerLinkActionViewState, ComposerLinkActionViewAction>
final class ComposerLinkActionViewModel: ComposerLinkActionViewModelType, ComposerLinkActionViewModelProtocol {
var callback: ((ComposerLinkActionViewModelResult) -> Void)?
}
@@ -0,0 +1,22 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
protocol ComposerLinkActionViewModelProtocol {
var context: ComposerLinkActionViewModelType.Context { get }
var callback: ((ComposerLinkActionViewModelResult) -> Void)? { get set }
}