Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit df44973

Browse files
committed
Optimize font size and view size with new look
1 parent f43cbde commit df44973

7 files changed

+114
-90
lines changed

Samples/PagingLayoutSamples/Modules/LayoutDesigner/Code/LayoutDesignerCodePreviewViewController.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protocol LayoutDesignerCodePreviewViewControllerDelegate: AnyObject {
1616

1717

1818
class LayoutDesignerCodePreviewViewController: UIViewController, NibBased, ViewModelBased {
19-
19+
2020
// MARK: Properties
2121

2222
var viewModel: LayoutDesignerCodePreviewViewModel! {
@@ -51,7 +51,7 @@ class LayoutDesignerCodePreviewViewController: UIViewController, NibBased, ViewM
5151
@IBAction private func saveButtonTouched() {
5252
guard let exportURL = viewModel.sampleProjectTempURL else { return }
5353
viewModel.generateSampleProject()
54-
let controller = UIDocumentPickerViewController(url: exportURL, in: UIDocumentPickerMode.exportToService)
54+
let controller = UIDocumentPickerViewController(forExporting: [exportURL])
5555
controller.delegate = self
5656
present(controller, animated: true)
5757
}
@@ -82,8 +82,12 @@ class LayoutDesignerCodePreviewViewController: UIViewController, NibBased, ViewM
8282
private func configureCodeTypeSegmentedControl() {
8383
codeModeSegmentedControl.backgroundColor = UIColor.black.withAlphaComponent(0.4)
8484
codeModeSegmentedControl.selectedSegmentTintColor = UIColor.white.withAlphaComponent(0.4)
85-
codeModeSegmentedControl.setTitleTextAttributes([.foregroundColor: UIColor.white], for: .normal)
86-
codeModeSegmentedControl.setTitleTextAttributes([.foregroundColor: UIColor.black.withAlphaComponent(0.6)], for: .selected)
85+
codeModeSegmentedControl.setTitleTextAttributes(
86+
[.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: 12)],
87+
for: .normal)
88+
codeModeSegmentedControl.setTitleTextAttributes(
89+
[.foregroundColor: UIColor.black.withAlphaComponent(0.6), .font: UIFont.systemFont(ofSize: 12)],
90+
for: .selected)
8791
codeModeSegmentedControl.selectedSegmentIndex = 0
8892
}
8993

@@ -96,6 +100,8 @@ class LayoutDesignerCodePreviewViewController: UIViewController, NibBased, ViewM
96100
codeTextView.attributedText = viewModel?.getHighlightedText(
97101
addViewControllerInCode: codeModeSegmentedControl.selectedSegmentIndex == 0
98102
)
103+
codeTextView.contentInset = .init(top: 40 + view.safeAreaInsets.top, left: 0, bottom: 200 + view.safeAreaInsets.bottom, right: 0)
104+
codeTextView.contentOffset = .init(x: 0, y: -codeTextView.contentInset.top)
99105
}
100106

101107

@@ -107,7 +113,7 @@ extension LayoutDesignerCodePreviewViewController: UIDocumentPickerDelegate {
107113
controller.dismiss(animated: true)
108114
viewModel.removeSampleProject()
109115
}
110-
116+
111117
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
112118
controller.dismiss(animated: true)
113119
viewModel.removeSampleProject()

Samples/PagingLayoutSamples/Modules/LayoutDesigner/Code/LayoutDesignerCodePreviewViewController.xib

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
66
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
7+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
78
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
89
</dependencies>
910
<objects>
@@ -23,11 +24,11 @@
2324
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2425
<subviews>
2526
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cvw-J0-JLY">
26-
<rect key="frame" x="20" y="74" width="468" height="731"/>
27-
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
27+
<rect key="frame" x="20" y="0.0" width="468" height="825"/>
28+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
2829
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
29-
<color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
30-
<fontDescription key="fontDescription" type="system" pointSize="14"/>
30+
<color key="textColor" systemColor="labelColor"/>
31+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
3132
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
3233
</textView>
3334
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fjt-yc-d4i">
@@ -41,7 +42,7 @@
4142
</connections>
4243
</button>
4344
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="cq9-nr-dyv">
44-
<rect key="frame" x="20" y="20" width="273" height="32"/>
45+
<rect key="frame" x="20" y="52" width="273" height="32"/>
4546
<segments>
4647
<segment title="Full ViewController"/>
4748
<segment title="Options Variable"/>
@@ -51,7 +52,7 @@
5152
</connections>
5253
</segmentedControl>
5354
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4uN-xn-LPG">
54-
<rect key="frame" x="323" y="696" width="150" height="47"/>
55+
<rect key="frame" x="324" y="696" width="149" height="47"/>
5556
<color key="backgroundColor" red="0.12156862745098039" green="0.12549019607843137" blue="0.14117647058823529" alpha="1" colorSpace="calibratedRGB"/>
5657
<inset key="contentEdgeInsets" minX="22" minY="8" maxX="14" maxY="8"/>
5758
<inset key="imageEdgeInsets" minX="-16" minY="0.0" maxX="0.0" maxY="0.0"/>
@@ -60,9 +61,13 @@
6061
<action selector="copyButtonTouched" destination="-1" eventType="touchUpInside" id="c8D-hO-HDy"/>
6162
</connections>
6263
</button>
63-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bnx-km-xRg">
64-
<rect key="frame" x="426" y="20" width="47" height="43"/>
64+
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bnx-km-xRg">
65+
<rect key="frame" x="434" y="52" width="39" height="35"/>
6566
<color key="backgroundColor" red="0.1215686275" green="0.12549019610000001" blue="0.14117647059999999" alpha="1" colorSpace="calibratedRGB"/>
67+
<constraints>
68+
<constraint firstAttribute="height" constant="35" id="izK-Vs-ZPH"/>
69+
<constraint firstAttribute="width" constant="39" id="zcc-jO-KZF"/>
70+
</constraints>
6671
<inset key="contentEdgeInsets" minX="10" minY="8" maxX="10" maxY="8"/>
6772
<state key="normal" image="helpButton"/>
6873
<connections>
@@ -71,31 +76,37 @@
7176
</connections>
7277
</button>
7378
</subviews>
79+
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
7480
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
7581
<constraints>
7682
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="4uN-xn-LPG" secondAttribute="trailing" constant="20" id="1RA-gL-rX8"/>
7783
<constraint firstItem="cq9-nr-dyv" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="E02-Ta-5YT"/>
78-
<constraint firstAttribute="bottom" secondItem="cvw-J0-JLY" secondAttribute="bottom" constant="20" id="Exb-Sd-OqV"/>
84+
<constraint firstAttribute="bottom" secondItem="cvw-J0-JLY" secondAttribute="bottom" id="Exb-Sd-OqV"/>
7985
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="bnx-km-xRg" secondAttribute="trailing" constant="20" id="LcD-un-uOe"/>
80-
<constraint firstItem="bnx-km-xRg" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="20" id="TIy-N7-QSb"/>
86+
<constraint firstItem="bnx-km-xRg" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="TIy-N7-QSb"/>
8187
<constraint firstItem="Fjt-yc-d4i" firstAttribute="top" secondItem="4uN-xn-LPG" secondAttribute="bottom" constant="8" id="ac1-UU-jg0"/>
8288
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="cvw-J0-JLY" secondAttribute="trailing" constant="5" id="aq1-h0-1nT"/>
8389
<constraint firstAttribute="bottom" secondItem="Fjt-yc-d4i" secondAttribute="bottom" constant="28" id="dxV-xX-NJ4"/>
84-
<constraint firstItem="cq9-nr-dyv" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="20" id="lbB-gA-VL5"/>
85-
<constraint firstItem="cvw-J0-JLY" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="30" id="o6K-u6-Is1"/>
90+
<constraint firstItem="cvw-J0-JLY" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="gDQ-1j-x0Z"/>
91+
<constraint firstItem="cq9-nr-dyv" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="lbB-gA-VL5"/>
8692
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="Fjt-yc-d4i" secondAttribute="trailing" constant="20" id="r8k-zT-2qg"/>
8793
<constraint firstItem="cvw-J0-JLY" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="rbb-1j-Vxg"/>
8894
</constraints>
8995
<nil key="simulatedTopBarMetrics"/>
9096
<nil key="simulatedBottomBarMetrics"/>
9197
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
92-
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
9398
<point key="canvasLocation" x="194.92753623188406" y="176.45089285714286"/>
9499
</view>
95100
</objects>
96101
<resources>
97102
<image name="copyButton" width="26" height="31"/>
98103
<image name="downloadButton" width="25" height="30"/>
99104
<image name="helpButton" width="27" height="27"/>
105+
<systemColor name="labelColor">
106+
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
107+
</systemColor>
108+
<systemColor name="systemBackgroundColor">
109+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
110+
</systemColor>
100111
</resources>
101112
</document>

Samples/PagingLayoutSamples/Modules/LayoutDesigner/Code/LayoutDesignerCodePreviewViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct LayoutDesignerCodePreviewViewModel {
1818
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("SampleProject")
1919
}
2020

21-
private let highlighter = SyntaxHighlighter(format: AttributedStringOutputFormat(theme: .sundellsColors(withFont: Font(size: 14))))
21+
private let highlighter = SyntaxHighlighter(format: AttributedStringOutputFormat(theme: .sundellsColors(withFont: Font(size: 12))))
2222

2323

2424
// MARK: Public functions
@@ -88,7 +88,7 @@ struct LayoutDesignerCodePreviewViewModel {
8888
8989
\(code.replacingOccurrences(of: "\n", with: "\n "))
9090
91-
// The card view that we apply effects on
91+
// The card view that we apply transforms on
9292
var card: UIView!
9393
9494
override init(frame: CGRect) {

0 commit comments

Comments
 (0)