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

Commit c220b97

Browse files
authored
Merge pull request #33 from amirdew/feature/optimized-mac
Feature/optimized mac
2 parents db42ec6 + 9224298 commit c220b97

12 files changed

+142
-106
lines changed

CollectionViewPagingLayout.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Pod::Spec.new do |s|
33
s.name = "CollectionViewPagingLayout"
4-
s.version = "0.3.0"
4+
s.version = "0.4.0"
55
s.summary = "Simple layout for making paging effects with UICollectionView."
66

77
s.description = <<-DESC
@@ -13,8 +13,8 @@ Pod::Spec.new do |s|
1313
s.author = { "Amir Khorsandi" => "khorsandi@me.com" }
1414
s.source = { :git => "https://github.com/amirdew/CollectionViewPagingLayout.git", :tag => "#{s.version}" }
1515

16-
s.swift_versions = ["5.1"]
17-
s.ios.deployment_target = "8.0"
16+
s.swift_versions = ["5.3"]
17+
s.ios.deployment_target = "9.0"
1818

1919
s.source_files = "Lib/**/*.swift"
2020

Samples/AppKitGlue/MacApp.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Cocoa
1111
class MacApp: NSObject, AppKitBridge {
1212

1313
func initialise() {
14-
DispatchQueue.main.async {
14+
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
1515
if NSApplication.shared.mainWindow != nil {
1616
self.onMainWindowReady()
1717
}
@@ -27,7 +27,9 @@ class MacApp: NSObject, AppKitBridge {
2727
guard let window = NSApplication.shared.mainWindow else {
2828
return
2929
}
30-
window.minSize = NSSize(width: 1_200, height: 768)
30+
if window.minSize.width < 1200 || window.minSize.height < 768 {
31+
window.minSize = NSSize(width: 1_200, height: 768)
32+
}
3133
window.setFrame(.init(origin: window.frame.origin, size: window.minSize), display: true, animate: true)
3234
}
3335

Samples/PagingLayoutSamples.xcodeproj/project.pbxproj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@
902902
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
903903
GCC_WARN_UNUSED_FUNCTION = YES;
904904
GCC_WARN_UNUSED_VARIABLE = YES;
905-
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
905+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
906906
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
907907
MTL_FAST_MATH = YES;
908908
ONLY_ACTIVE_ARCH = YES;
@@ -957,7 +957,7 @@
957957
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
958958
GCC_WARN_UNUSED_FUNCTION = YES;
959959
GCC_WARN_UNUSED_VARIABLE = YES;
960-
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
960+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
961961
MTL_ENABLE_DEBUG_INFO = NO;
962962
MTL_FAST_MATH = YES;
963963
SDKROOT = iphoneos;
@@ -975,20 +975,22 @@
975975
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
976976
CODE_SIGN_ENTITLEMENTS = "PagingLayoutSamples/Paging Layout.entitlements";
977977
CODE_SIGN_STYLE = Automatic;
978-
CURRENT_PROJECT_VERSION = 2;
978+
CURRENT_PROJECT_VERSION = 1;
979979
DEVELOPMENT_TEAM = 4J5W7CJ2ZV;
980980
INFOPLIST_FILE = PagingLayoutSamples/Info.plist;
981+
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
981982
LD_RUNPATH_SEARCH_PATHS = (
982983
"$(inherited)",
983984
"@executable_path/Frameworks",
984985
);
985-
MARKETING_VERSION = 1.0.0;
986+
MARKETING_VERSION = 1.1.0;
986987
PRODUCT_BUNDLE_IDENTIFIER = app.amir.paginglayout;
987988
PRODUCT_NAME = "Layout Designer";
988989
SUPPORTS_MACCATALYST = YES;
990+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
989991
SWIFT_OBJC_BRIDGING_HEADER = "PagingLayoutSamples/PagingLayoutSamples-Bridging-Header.h";
990992
SWIFT_VERSION = 5.0;
991-
TARGETED_DEVICE_FAMILY = "1,2";
993+
TARGETED_DEVICE_FAMILY = "1,2,6";
992994
};
993995
name = Debug;
994996
};
@@ -1000,20 +1002,22 @@
10001002
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
10011003
CODE_SIGN_ENTITLEMENTS = "PagingLayoutSamples/Paging Layout.entitlements";
10021004
CODE_SIGN_STYLE = Automatic;
1003-
CURRENT_PROJECT_VERSION = 2;
1005+
CURRENT_PROJECT_VERSION = 1;
10041006
DEVELOPMENT_TEAM = 4J5W7CJ2ZV;
10051007
INFOPLIST_FILE = PagingLayoutSamples/Info.plist;
1008+
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
10061009
LD_RUNPATH_SEARCH_PATHS = (
10071010
"$(inherited)",
10081011
"@executable_path/Frameworks",
10091012
);
1010-
MARKETING_VERSION = 1.0.0;
1013+
MARKETING_VERSION = 1.1.0;
10111014
PRODUCT_BUNDLE_IDENTIFIER = app.amir.paginglayout;
10121015
PRODUCT_NAME = "Layout Designer";
10131016
SUPPORTS_MACCATALYST = YES;
1017+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
10141018
SWIFT_OBJC_BRIDGING_HEADER = "PagingLayoutSamples/PagingLayoutSamples-Bridging-Header.h";
10151019
SWIFT_VERSION = 5.0;
1016-
TARGETED_DEVICE_FAMILY = "1,2";
1020+
TARGETED_DEVICE_FAMILY = "1,2,6";
10171021
};
10181022
name = Release;
10191023
};

Samples/PagingLayoutSamples/AppDelegate.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2424
window = UIWindow()
2525
navigationController = UINavigationController()
2626
navigationController.isNavigationBarHidden = true
27-
let mainVC = UIDevice.current.userInterfaceIdiom == .pad ?
27+
let mainVC = UIDevice.current.userInterfaceIdiom != .phone ?
2828
LayoutDesignerViewController.instantiate(viewModel: LayoutDesignerViewModel()) :
2929
MainViewController.instantiate()
3030

31+
#if targetEnvironment(macCatalyst)
32+
if let titlebar = window?.windowScene?.titlebar {
33+
titlebar.titleVisibility = .hidden
34+
titlebar.toolbar = nil
35+
}
36+
#endif
3137
navigationController.setViewControllers([mainVC], animated: false)
3238
window!.rootViewController = navigationController
3339
window!.makeKeyAndVisible()

Samples/PagingLayoutSamples/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
21+
<key>LSApplicationCategoryType</key>
22+
<string>public.app-category.developer-tools</string>
2123
<key>LSRequiresIPhoneOS</key>
2224
<true/>
2325
<key>UILaunchStoryboardName</key>
@@ -40,8 +42,6 @@
4042
<string>UIInterfaceOrientationLandscapeLeft</string>
4143
<string>UIInterfaceOrientationLandscapeRight</string>
4244
</array>
43-
<key>LSApplicationCategoryType</key>
44-
<string>public.app-category.developer-tools</string>
4545
<key>UIUserInterfaceStyle</key>
4646
<string>Light</string>
4747
</dict>

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)