-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4786 from vector-im/gil/4497_space_preview_bottom…
…_sheet [Spaces] M10.6 Space preview bottom sheet #4497
- Loading branch information
Showing
27 changed files
with
998 additions
and
33 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
Riot/Assets/Images.xcassets/Spaces/space_type_icon.imageset/Contents.json
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 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "space_type_icon.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "space_type_icon@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "space_type_icon@3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+459 Bytes
Riot/Assets/Images.xcassets/Spaces/space_type_icon.imageset/space_type_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+815 Bytes
Riot/Assets/Images.xcassets/Spaces/space_type_icon.imageset/space_type_icon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.1 KB
Riot/Assets/Images.xcassets/Spaces/space_type_icon.imageset/space_type_icon@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
111 changes: 111 additions & 0 deletions
111
Riot/Modules/Spaces/SpaceDetail/SpaceDetailPresenter.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,111 @@ | ||
// | ||
// Copyright 2021 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 | ||
|
||
/// Presenter for space detail screen | ||
class SpaceDetailPresenter: NSObject { | ||
|
||
// MARK: - Constants | ||
|
||
enum Actions { | ||
case exploreRooms | ||
case exploreMembers | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
public weak var delegate: SpaceDetailPresenterDelegate? | ||
|
||
// MARK: Private | ||
|
||
private weak var presentingViewController: UIViewController? | ||
private var viewModel: SpaceDetailViewModel! | ||
private weak var sourceView: UIView? | ||
private lazy var slidingModalPresenter: SlidingModalPresenter = { | ||
return SlidingModalPresenter() | ||
}() | ||
private weak var selectedSpace: MXSpace? | ||
private var session: MXSession! | ||
private var spaceId: String! | ||
|
||
// MARK: - Public | ||
|
||
func present(forSpaceWithId spaceId: String, | ||
from viewController: UIViewController, | ||
sourceView: UIView?, | ||
session: MXSession, | ||
animated: Bool) { | ||
self.session = session | ||
self.spaceId = spaceId | ||
|
||
self.viewModel = SpaceDetailViewModel(session: session, spaceId: spaceId) | ||
self.viewModel.coordinatorDelegate = self | ||
self.presentingViewController = viewController | ||
self.sourceView = sourceView | ||
self.selectedSpace = session.spaceService.getSpace(withId: spaceId) | ||
|
||
self.show(with: session) | ||
} | ||
|
||
func dismiss(animated: Bool, completion: (() -> Void)?) { | ||
self.presentingViewController?.dismiss(animated: animated, completion: completion) | ||
} | ||
|
||
// MARK: - Private | ||
|
||
private func show(with session: MXSession) { | ||
let viewController = SpaceDetailViewController.instantiate(mediaManager: session.mediaManager, viewModel: self.viewModel) | ||
self.present(viewController, animated: true) | ||
} | ||
|
||
private func present(_ viewController: SpaceDetailViewController, animated: Bool) { | ||
|
||
if UIDevice.current.isPhone { | ||
guard let rootViewController = self.presentingViewController else { | ||
MXLog.error("[SpaceDetailPresenter] present no rootViewController found") | ||
return | ||
} | ||
|
||
slidingModalPresenter.present(viewController, from: rootViewController.presentedViewController ?? rootViewController, animated: true, completion: nil) | ||
} else { | ||
// Configure source view when view controller is presented with a popover | ||
viewController.modalPresentationStyle = .popover | ||
if let sourceView = self.sourceView, let popoverPresentationController = viewController.popoverPresentationController { | ||
popoverPresentationController.sourceView = sourceView | ||
popoverPresentationController.sourceRect = sourceView.bounds | ||
} | ||
|
||
self.presentingViewController?.present(viewController, animated: animated, completion: nil) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - SpaceDetailModelViewModelCoordinatorDelegate | ||
|
||
extension SpaceDetailPresenter: SpaceDetailModelViewModelCoordinatorDelegate { | ||
func spaceDetailViewModelDidCancel(_ viewModel: SpaceDetailViewModelType) { | ||
self.dismiss(animated: true, completion: nil) | ||
} | ||
|
||
func spaceDetailViewModelDidDismiss(_ viewModel: SpaceDetailViewModelType) { | ||
self.delegate?.spaceDetailPresenterDidComplete(self) | ||
} | ||
} | ||
|
||
protocol SpaceDetailPresenterDelegate: AnyObject { | ||
func spaceDetailPresenterDidComplete(_ presenter: SpaceDetailPresenter) | ||
} |
26 changes: 26 additions & 0 deletions
26
Riot/Modules/Spaces/SpaceDetail/SpaceDetailViewAction.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 @@ | ||
// | ||
// Copyright 2021 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 | ||
|
||
/// `SpaceDetailViewController` view actions exposed to view model | ||
enum SpaceDetailViewAction { | ||
case loadData | ||
case join | ||
case leave | ||
case dismiss | ||
case dismissed | ||
} |
Oops, something went wrong.