mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 12:46:58 +02:00
Edits history: Improve temporary UX a bit
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Template Screen View Controller-->
|
||||
<!--Edit History View Controller-->
|
||||
<scene sceneID="mt5-wz-YKA">
|
||||
<objects>
|
||||
<viewController extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="V8j-Lb-PgC" customClass="EditHistoryViewController" customModule="Riot" customModuleProvider="target" sceneMemberID="viewController">
|
||||
@@ -27,8 +27,8 @@
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="voD-3Q-ryt">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="500"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="A message" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bxI-mu-qng">
|
||||
<rect key="frame" x="20" y="86" width="335" height="108"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="A message" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bxI-mu-qng">
|
||||
<rect key="frame" x="20" y="86" width="335" height="250"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<nil key="textColor"/>
|
||||
@@ -37,9 +37,9 @@
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DOt-5E-FjF">
|
||||
<rect key="frame" x="104" y="368" width="167" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="OK"/>
|
||||
<state key="normal" title="Load more"/>
|
||||
<connections>
|
||||
<action selector="okButtonAction:" destination="V8j-Lb-PgC" eventType="touchUpInside" id="uvI-tt-Nfj"/>
|
||||
<action selector="loadMoreButtonAction:" destination="V8j-Lb-PgC" eventType="touchUpInside" id="uvI-tt-Nfj"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
@@ -79,8 +79,8 @@
|
||||
<viewLayoutGuide key="safeArea" id="bFg-jh-JZB"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="loadMoreButton" destination="DOt-5E-FjF" id="ktw-U4-efQ"/>
|
||||
<outlet property="messageLabel" destination="bxI-mu-qng" id="pbX-aZ-inC"/>
|
||||
<outlet property="okButton" destination="DOt-5E-FjF" id="ktw-U4-efQ"/>
|
||||
<outlet property="scrollView" destination="9U2-KL-ZVA" id="ojG-2y-X7b"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
|
||||
@@ -33,7 +33,7 @@ final class EditHistoryViewController: UIViewController {
|
||||
@IBOutlet private weak var scrollView: UIScrollView!
|
||||
|
||||
@IBOutlet private weak var messageLabel: UILabel!
|
||||
@IBOutlet private weak var okButton: UIButton!
|
||||
@IBOutlet private weak var loadMoreButton: UIButton!
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@@ -105,8 +105,8 @@ final class EditHistoryViewController: UIViewController {
|
||||
// TODO:
|
||||
self.messageLabel.textColor = theme.textPrimaryColor
|
||||
|
||||
self.okButton.backgroundColor = theme.backgroundColor
|
||||
theme.applyStyle(onButton: self.okButton)
|
||||
self.loadMoreButton.backgroundColor = theme.backgroundColor
|
||||
theme.applyStyle(onButton: self.loadMoreButton)
|
||||
}
|
||||
|
||||
private func registerThemeServiceDidChangeThemeNotification() {
|
||||
@@ -118,11 +118,11 @@ final class EditHistoryViewController: UIViewController {
|
||||
}
|
||||
|
||||
private func setupViews() {
|
||||
let cancelBarButtonItem = MXKBarButtonItem(title: VectorL10n.cancel, style: .plain) { [weak self] in
|
||||
self?.cancelButtonAction()
|
||||
let closeBarButtonItem = MXKBarButtonItem(title: "Close", style: .plain) { [weak self] in
|
||||
self?.closeButtonAction()
|
||||
}
|
||||
|
||||
self.navigationItem.rightBarButtonItem = cancelBarButtonItem
|
||||
self.navigationItem.rightBarButtonItem = closeBarButtonItem
|
||||
|
||||
self.scrollView.keyboardDismissMode = .interactive
|
||||
|
||||
@@ -136,6 +136,8 @@ final class EditHistoryViewController: UIViewController {
|
||||
self.renderLoading()
|
||||
case .loaded(let messages, let addedCount):
|
||||
self.renderLoaded(messages: messages, addedCount: addedCount)
|
||||
case .allLoaded:
|
||||
self.renderAllLoaded()
|
||||
case .error(let error):
|
||||
self.render(error: error)
|
||||
}
|
||||
@@ -148,8 +150,13 @@ final class EditHistoryViewController: UIViewController {
|
||||
private func renderLoaded(messages: [EditHistoryMessage], addedCount: Int) {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
|
||||
let calendar = Calendar.current
|
||||
|
||||
let attributedText = NSMutableAttributedString()
|
||||
for message in messages {
|
||||
let time=calendar.dateComponents([.hour, .minute], from: Date())
|
||||
attributedText.append(NSAttributedString(string: "\(time.hour!):\(time.minute!)"))
|
||||
attributedText.append(NSAttributedString(string: " - "))
|
||||
attributedText.append(message.message)
|
||||
attributedText.append(NSAttributedString(string: "\n"))
|
||||
}
|
||||
@@ -157,6 +164,10 @@ final class EditHistoryViewController: UIViewController {
|
||||
self.messageLabel.attributedText = attributedText
|
||||
self.messageLabel.isHidden = false
|
||||
}
|
||||
|
||||
private func renderAllLoaded() {
|
||||
self.loadMoreButton.isHidden = true
|
||||
}
|
||||
|
||||
private func render(error: Error) {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
@@ -166,11 +177,11 @@ final class EditHistoryViewController: UIViewController {
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction private func okButtonAction(_ sender: Any) {
|
||||
self.viewModel.process(viewAction: .close)
|
||||
@IBAction private func loadMoreButtonAction(_ sender: Any) {
|
||||
self.viewModel.process(viewAction: .loadMore)
|
||||
}
|
||||
|
||||
private func cancelButtonAction() {
|
||||
private func closeButtonAction() {
|
||||
self.viewModel.process(viewAction: .close)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,13 @@
|
||||
import Foundation
|
||||
|
||||
final class EditHistoryViewModel: EditHistoryViewModelType {
|
||||
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private enum Pagination {
|
||||
static let count: UInt = 2
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -74,7 +80,7 @@ final class EditHistoryViewModel: EditHistoryViewModelType {
|
||||
}
|
||||
|
||||
self.update(viewState: .loading)
|
||||
self.operation = self.aggregations.replaceEvents(forEvent: self.eventId, inRoom: self.roomId, from: self.nextBatch, limit: 10, success: { [weak self] (response) in
|
||||
self.operation = self.aggregations.replaceEvents(forEvent: self.eventId, inRoom: self.roomId, from: self.nextBatch, limit: Pagination.count, success: { [weak self] (response) in
|
||||
guard let sself = self else {
|
||||
return
|
||||
}
|
||||
@@ -84,6 +90,10 @@ final class EditHistoryViewModel: EditHistoryViewModelType {
|
||||
|
||||
sself.process(editEvents: response.chunk)
|
||||
|
||||
if sself.nextBatch == nil {
|
||||
sself.update(viewState: .allLoaded)
|
||||
}
|
||||
|
||||
}, failure: { [weak self] error in
|
||||
guard let sself = self else {
|
||||
return
|
||||
|
||||
@@ -22,5 +22,6 @@ import Foundation
|
||||
enum EditHistoryViewState {
|
||||
case loading
|
||||
case loaded(messages: [EditHistoryMessage], addedCount: Int)
|
||||
case allLoaded
|
||||
case error(Error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user