Skip to content

Commit

Permalink
Improve demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaguilar committed Jul 28, 2018
1 parent d44f7df commit 6070f23
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
Binary file added Assets/demo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Example/Markdowner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@
children = (
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
607FACD71AFB9204008FA782 /* ViewController.swift */,
F192440521056C9F0056FD9B /* PreviewViewController.swift */,
607FACD91AFB9204008FA782 /* Main.storyboard */,
607FACDC1AFB9204008FA782 /* Images.xcassets */,
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */,
607FACD31AFB9204008FA782 /* Supporting Files */,
F192440521056C9F0056FD9B /* PreviewViewController.swift */,
);
name = "Example for Markdowner";
path = Markdowner;
Expand Down
24 changes: 14 additions & 10 deletions Example/Markdowner/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,29 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="w35-tI-1dl">
<rect key="frame" x="20" y="84" width="334" height="499"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<rect key="frame" x="20" y="84" width="334" height="507"/>
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wrg-nG-PZb">
<rect key="frame" x="160" y="603" width="54" height="30"/>
<state key="normal" title="Preview"/>
<rect key="frame" x="130" y="611" width="114" height="44"/>
<color key="backgroundColor" red="0.25585709815792007" green="0.62139034532639548" blue="0.81146763392857146" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="contentEdgeInsets" minX="30" minY="13" maxX="30" maxY="13"/>
<state key="normal" title="Preview">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<segue destination="83o-3K-cTG" kind="show" id="bGU-uv-F5r"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.55294117649999996" green="0.84705882349999995" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.93333333333333335" green="0.93333333333333335" blue="0.93333333333333335" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="Wrg-nG-PZb" secondAttribute="bottom" constant="12" id="GYf-Kc-xkR"/>
<constraint firstItem="w35-tI-1dl" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" constant="20" id="Ie0-ML-qYn"/>
<constraint firstItem="Wrg-nG-PZb" firstAttribute="top" secondItem="w35-tI-1dl" secondAttribute="bottom" constant="20" id="Tkr-jj-eiS"/>
<constraint firstItem="Wrg-nG-PZb" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="cgT-Mz-N1L"/>
<constraint firstItem="w35-tI-1dl" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="pns-uB-dNy"/>
<constraint firstItem="w35-tI-1dl" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="20" id="tDT-0g-0v5"/>
<constraint firstItem="w35-tI-1dl" firstAttribute="centerY" secondItem="kh9-bI-dsS" secondAttribute="centerY" id="xWj-uL-mhQ"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="eNo-33-7Yu"/>
Expand All @@ -66,16 +70,16 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="ohe-1C-y5c">
<rect key="frame" x="16" y="94" width="342" height="573"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<rect key="frame" x="16" y="84" width="342" height="583"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" red="0.93333333330000001" green="0.93333333330000001" blue="0.93333333330000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="ohe-1C-y5c" firstAttribute="centerX" secondItem="fgN-1S-u2m" secondAttribute="centerX" id="07m-bo-zD7"/>
<constraint firstItem="ohe-1C-y5c" firstAttribute="top" secondItem="gdM-Hk-Ob7" secondAttribute="bottom" constant="30" id="3va-oJ-NKA"/>
<constraint firstItem="ohe-1C-y5c" firstAttribute="top" secondItem="gdM-Hk-Ob7" secondAttribute="bottom" constant="20" id="3va-oJ-NKA"/>
<constraint firstItem="e10-4W-e3g" firstAttribute="top" secondItem="ohe-1C-y5c" secondAttribute="bottom" id="lYz-JQ-GZn"/>
<constraint firstItem="ohe-1C-y5c" firstAttribute="leading" secondItem="fgN-1S-u2m" secondAttribute="leadingMargin" id="yvb-Pq-5U3"/>
</constraints>
Expand Down
5 changes: 5 additions & 0 deletions Example/Markdowner/PreviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ class PreviewViewController: UIViewController {
} else {
// Fallback on earlier versions
}

// scroll the text view content to the top in the next iteration of the run loop.
DispatchQueue.main.async {
self.textView.setContentOffset(.zero, animated: false)
}
}
}
2 changes: 1 addition & 1 deletion Example/Markdowner/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

wrapperView.addSubview(textView)
textView.frame = wrapperView.bounds
textView.backgroundColor = .clear
textView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
textView.keyboardDismissMode = .onDrag

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ textView.stylesConfiguration = StylesConfiguration(
)
```

Creating custom elements is as simple as subclassing the type `MarkdownElement`, and the calling the function `textView.use(elements: [MarkdownElement])` passing as arguments the list of markdown elements that you want to use. As a guide for creating new elements you could use any of the already implemented ones inside the folder `Markdowner/Classes/Default Elements`.
Creating custom elements is as simple as subclassing the type `MarkdownElement`, and then calling the function `textView.use(elements: [MarkdownElement])` passing as arguments the list of markdown elements that you want to use. As a guide for creating new elements you could use any of the already implemented ones inside the folder `Markdowner/Classes/Default Elements`.

It's important to note that for now `Markdowner` doesn't support initialization from Storyboards.

Expand Down

0 comments on commit 6070f23

Please sign in to comment.