Skip to content

Commit

Permalink
Change challenge description to MarkdownTextView to fix links. (#1328)
Browse files Browse the repository at this point in the history
MarkdownTextView has built-in support for links. It's already used for the markdown descriptions for tasks, so I believe it should be suitable for challenge text as well.

Fixes #1326
Fixes #1270
  • Loading branch information
JBYoshi authored Feb 7, 2024
1 parent cca06f5 commit 52636a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Down
import Habitica_Models

class ChallengeDescriptionTableViewCell: ResizableTableViewCell, ChallengeConfigurable {
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var descriptionLabel: MarkdownTextView!
@IBOutlet weak var caretButton: UIButton!
@IBOutlet weak var marginConstraint: NSLayoutConstraint!

Expand All @@ -26,7 +26,7 @@ class ChallengeDescriptionTableViewCell: ResizableTableViewCell, ChallengeConfig

func configure(with challenge: ChallengeProtocol, userID: String?) {
if let notes = challenge.notes {
descriptionLabel.attributedText = try? Down(markdownString: notes.unicodeEmoji).toHabiticaAttributedString(baseSize: descriptionLabel.font.pointSize)
descriptionLabel.setMarkdownString(notes.unicodeEmoji)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<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>
<objects>
Expand All @@ -25,12 +24,12 @@
<color key="textColor" red="0.30588235289999999" green="0.2901960784" blue="0.3411764706" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fqD-9q-t6S">
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="IPF-W2-yw6" customClass="MarkdownTextView" customModule="Habitica" customModuleProvider="target">
<rect key="frame" x="16" y="40" width="288" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="0.30588235289999999" green="0.2901960784" blue="0.3411764706" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vI1-Ad-fpK">
<rect key="frame" x="280" y="8" width="24" height="24"/>
<state key="normal" image="carret_up"/>
Expand All @@ -40,12 +39,12 @@
</button>
</subviews>
<constraints>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="fqD-9q-t6S" secondAttribute="bottom" constant="7.5" id="6dV-fI-k8o"/>
<constraint firstItem="fqD-9q-t6S" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="AsB-cS-92h"/>
<constraint firstItem="fqD-9q-t6S" firstAttribute="top" secondItem="7yH-Ll-eGO" secondAttribute="bottom" constant="8" id="DPO-t5-bed"/>
<constraint firstAttribute="trailing" secondItem="fqD-9q-t6S" secondAttribute="trailing" constant="16" id="IVa-LU-IJS"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="IPF-W2-yw6" secondAttribute="bottom" constant="7.5" id="BTC-I3-iNi"/>
<constraint firstItem="7yH-Ll-eGO" firstAttribute="top" secondItem="vI1-Ad-fpK" secondAttribute="top" id="QMI-e0-WVI"/>
<constraint firstItem="IPF-W2-yw6" firstAttribute="top" secondItem="7yH-Ll-eGO" secondAttribute="bottom" constant="8" id="V6z-WT-t99"/>
<constraint firstItem="vI1-Ad-fpK" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="c3P-tJ-Fs8"/>
<constraint firstAttribute="trailing" secondItem="IPF-W2-yw6" secondAttribute="trailing" constant="16" id="dfX-Q0-evY"/>
<constraint firstItem="IPF-W2-yw6" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="eee-wg-a9o"/>
<constraint firstItem="7yH-Ll-eGO" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="jDF-I2-3Mo"/>
<constraint firstItem="7yH-Ll-eGO" firstAttribute="centerY" secondItem="vI1-Ad-fpK" secondAttribute="centerY" id="mtf-yx-orH"/>
<constraint firstAttribute="trailing" secondItem="vI1-Ad-fpK" secondAttribute="trailing" constant="16" id="rkm-1D-Q7x"/>
Expand All @@ -55,10 +54,10 @@
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="caretButton" destination="vI1-Ad-fpK" id="Y4e-4Y-tgp"/>
<outlet property="descriptionLabel" destination="fqD-9q-t6S" id="UJe-WE-iXE"/>
<outlet property="marginConstraint" destination="DPO-t5-bed" id="QPQ-b3-FD8"/>
<outlet property="descriptionLabel" destination="IPF-W2-yw6" id="OaB-Te-Qjr"/>
<outlet property="marginConstraint" destination="V6z-WT-t99" id="7kJ-F7-Kj2"/>
</connections>
<point key="canvasLocation" x="-389" y="-68"/>
<point key="canvasLocation" x="-622.39999999999998" y="-61.169415292353825"/>
</tableViewCell>
</objects>
<resources>
Expand Down

0 comments on commit 52636a5

Please sign in to comment.