Skip to content

Commit

Permalink
Merge pull request #5865 from vector-im/ismail/5770_threads_notice
Browse files Browse the repository at this point in the history
Threads notice
  • Loading branch information
ismailgulek authored Mar 31, 2022
2 parents df6f631 + b12f649 commit 69185b0
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ Tap the + to start adding people.";
"threads_empty_tip" = "Tip: Tap a message and use “Thread” to start one.";
"threads_empty_show_all_threads" = "Show all threads";
"message_from_a_thread" = "From a thread";
"threads_notice_title" = "Threads no longer experimental 🎉";
"threads_notice_information" = "All threads created during the experimental period will now be <b>rendered as regular replies</b>.<br/><br/>This will be a one-off transition, as threads are now part of the Matrix specification.";
"threads_notice_done" = "Got it";

"media_type_accessibility_image" = "Image";
"media_type_accessibility_audio" = "Audio";
Expand Down
34 changes: 34 additions & 0 deletions Riot/Categories/UILabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,38 @@ extension UILabel {
self.preferredMaxLayoutWidth = width
}
}

/// Sets an HTML string into the receiver. Does not support custom fonts but considers receiver's font size.
/// - Parameter htmlText: HTML text to be rendered.
@objc func setHTMLFromString(_ htmlText: String) {
let htmlTemplate = """
<!doctype html>
<html>
<head>
<style>
body {
font-family: -apple-system;
font-size: \(font.pointSize)px;
}
p:last-child { display: inline; }
</style>
</head>
<body>
\(htmlText)
</body>
</html>
"""

guard let data = htmlTemplate.data(using: .utf8),
let attributedString = try? NSAttributedString(
data: data,
options: [.documentType: NSAttributedString.DocumentType.html],
documentAttributes: nil
) else {
return
}

self.attributedText = attributedString
}

}
5 changes: 5 additions & 0 deletions Riot/Generated/Storyboards.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ internal enum StoryboardScene {

internal static let initialScene = InitialSceneType<Riot.ThreadListViewController>(storyboard: ThreadListViewController.self)
}
internal enum ThreadsNoticeViewController: StoryboardType {
internal static let storyboardName = "ThreadsNoticeViewController"

internal static let initialScene = InitialSceneType<Riot.ThreadsNoticeViewController>(storyboard: ThreadsNoticeViewController.self)
}
internal enum UserVerificationSessionStatusViewController: StoryboardType {
internal static let storyboardName = "UserVerificationSessionStatusViewController"

Expand Down
12 changes: 12 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7611,6 +7611,18 @@ public class VectorL10n: NSObject {
public static var threadsEmptyTitle: String {
return VectorL10n.tr("Vector", "threads_empty_title")
}
/// Got it
public static var threadsNoticeDone: String {
return VectorL10n.tr("Vector", "threads_notice_done")
}
/// All threads created during the experimental period will now be <b>rendered as regular replies</b>.<br/><br/>This will be a one-off transition, as threads are now part of the Matrix specification.
public static var threadsNoticeInformation: String {
return VectorL10n.tr("Vector", "threads_notice_information")
}
/// Threads no longer experimental 🎉
public static var threadsNoticeTitle: String {
return VectorL10n.tr("Vector", "threads_notice_title")
}
/// Threads
public static var threadsTitle: String {
return VectorL10n.tr("Vector", "threads_title")
Expand Down
5 changes: 4 additions & 1 deletion Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ final class RiotSettings: NSObject {

@UserDefault(key: "hideSpaceBetaAnnounce", defaultValue: false, storage: defaults)
var hideSpaceBetaAnnounce


@UserDefault(key: "threadsNoticeDisplayed", defaultValue: false, storage: defaults)
var threadsNoticeDisplayed

// MARK: - Version check

@UserDefault(key: "versionCheckNextDisplayDateTimeInterval", defaultValue: 0.0, storage: defaults)
Expand Down
35 changes: 35 additions & 0 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ @interface RoomViewController () <UISearchBarDelegate, UIGestureRecognizerDelega
@property (nonatomic, strong) CustomSizedPresentationController *customSizedPresentationController;
@property (nonatomic, strong) RoomParticipantsInviteCoordinatorBridgePresenter *participantsInvitePresenter;
@property (nonatomic, strong) ThreadsCoordinatorBridgePresenter *threadsBridgePresenter;
@property (nonatomic, strong) SlidingModalPresenter *threadsNoticeModalPresenter;
@property (nonatomic, getter=isActivitiesViewExpanded) BOOL activitiesViewExpanded;
@property (nonatomic, getter=isScrollToBottomHidden) BOOL scrollToBottomHidden;
@property (nonatomic, getter=isMissedDiscussionsBadgeHidden) BOOL missedDiscussionsBadgeHidden;
Expand Down Expand Up @@ -658,6 +659,11 @@ - (void)viewDidAppear:(BOOL)animated
}

self.showSettingsInitially = NO;

if (!RiotSettings.shared.threadsNoticeDisplayed && RiotSettings.shared.enableThreads)
{
[self showThreadsNotice];
}
}

- (void)viewDidDisappear:(BOOL)animated
Expand Down Expand Up @@ -6778,6 +6784,35 @@ - (RoomContextualMenuItem *)moreMenuItemWithEvent:(MXEvent*)event andCell:(id<MX

#pragma mark - Threads

- (void)showThreadsNotice
{
if (!self.threadsNoticeModalPresenter)
{
self.threadsNoticeModalPresenter = [SlidingModalPresenter new];
}

[self.threadsNoticeModalPresenter dismissWithAnimated:NO completion:nil];

ThreadsNoticeViewController *threadsNoticeVC = [ThreadsNoticeViewController instantiate];

MXWeakify(self);

threadsNoticeVC.didTapDoneButton = ^{

MXStrongifyAndReturnIfNil(self);

[self.threadsNoticeModalPresenter dismissWithAnimated:YES completion:^{
RiotSettings.shared.threadsNoticeDisplayed = YES;
}];
};

[self.threadsNoticeModalPresenter present:threadsNoticeVC
from:self.presentedViewController?:self
animated:YES
options:SlidingModalPresenter.SpanningOption
completion:nil];
}

- (void)openThreadWithId:(NSString *)threadId
{
if (self.threadsBridgePresenter)
Expand Down
109 changes: 109 additions & 0 deletions Riot/Modules/Threads/Notice/ThreadsNoticeViewController.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Threads Notice View Controller-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController id="Y6W-OH-hqX" customClass="ThreadsNoticeViewController" customModule="Riot" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="rx5-uV-e8E">
<rect key="frame" x="20" y="68" width="374" height="774"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Threads no longer experimental 🎉" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tre-1i-GOd">
<rect key="frame" x="0.0" y="0.0" width="374" height="20.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gEs-ZC-Pju">
<rect key="frame" x="0.0" y="20.5" width="374" height="20"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="xUG-Oh-eyc"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="T3e-J2-hJW">
<rect key="frame" x="0.0" y="40.5" width="374" height="1"/>
<color key="backgroundColor" systemColor="separatorColor"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="cHN-fx-JTR"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SR7-Gf-QRe">
<rect key="frame" x="0.0" y="41.5" width="374" height="682.5"/>
<string key="text">All threads created during the experimental period will now be rendered as regular replies.

This will be one-off transition, as threads are now part of the Matrix specification.</string>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Tmd-wH-3Z2">
<rect key="frame" x="0.0" y="724" width="374" height="50"/>
<color key="backgroundColor" red="0.01176470588" green="0.70196078429999997" blue="0.50588235290000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="PKT-BC-IIR"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Got it">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="8"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="doneButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="Igt-ei-k3e"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="tre-1i-GOd" firstAttribute="width" secondItem="rx5-uV-e8E" secondAttribute="width" id="3Lj-N4-Oap"/>
<constraint firstItem="SR7-Gf-QRe" firstAttribute="width" secondItem="rx5-uV-e8E" secondAttribute="width" id="ljj-10-VgV"/>
</constraints>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="vDu-zF-Fre" firstAttribute="bottom" secondItem="rx5-uV-e8E" secondAttribute="bottom" constant="20" id="Cue-th-wBf"/>
<constraint firstItem="rx5-uV-e8E" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="20" id="qyO-6I-iAJ"/>
<constraint firstItem="rx5-uV-e8E" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" constant="24" id="tmI-9R-Tp7"/>
<constraint firstAttribute="trailing" secondItem="rx5-uV-e8E" secondAttribute="trailing" constant="20" id="um1-A3-OIa"/>
</constraints>
</view>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="doneButton" destination="Tmd-wH-3Z2" id="jKr-iN-taU"/>
<outlet property="informationLabel" destination="SR7-Gf-QRe" id="JJf-SL-bvt"/>
<outlet property="separatorLineView" destination="T3e-J2-hJW" id="6RE-Ns-I8v"/>
<outlet property="titleLabel" destination="tre-1i-GOd" id="vAt-P9-PTT"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="57" y="105"/>
</scene>
</scenes>
<resources>
<systemColor name="separatorColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading

0 comments on commit 69185b0

Please sign in to comment.