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

Commit

Permalink
Merge pull request #33 from amirdew/feature/optimized-mac
Browse files Browse the repository at this point in the history
Feature/optimized mac
  • Loading branch information
amirdew committed Dec 6, 2020
2 parents db42ec6 + 9224298 commit c220b97
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 106 deletions.
6 changes: 3 additions & 3 deletions CollectionViewPagingLayout.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "CollectionViewPagingLayout"
s.version = "0.3.0"
s.version = "0.4.0"
s.summary = "Simple layout for making paging effects with UICollectionView."

s.description = <<-DESC
Expand All @@ -13,8 +13,8 @@ Pod::Spec.new do |s|
s.author = { "Amir Khorsandi" => "[email protected]" }
s.source = { :git => "https://github.com/amirdew/CollectionViewPagingLayout.git", :tag => "#{s.version}" }

s.swift_versions = ["5.1"]
s.ios.deployment_target = "8.0"
s.swift_versions = ["5.3"]
s.ios.deployment_target = "9.0"

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

Expand Down
6 changes: 4 additions & 2 deletions Samples/AppKitGlue/MacApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Cocoa
class MacApp: NSObject, AppKitBridge {

func initialise() {
DispatchQueue.main.async {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
if NSApplication.shared.mainWindow != nil {
self.onMainWindowReady()
}
Expand All @@ -27,7 +27,9 @@ class MacApp: NSObject, AppKitBridge {
guard let window = NSApplication.shared.mainWindow else {
return
}
window.minSize = NSSize(width: 1_200, height: 768)
if window.minSize.width < 1200 || window.minSize.height < 768 {
window.minSize = NSSize(width: 1_200, height: 768)
}
window.setFrame(.init(origin: window.frame.origin, size: window.minSize), display: true, animate: true)
}

Expand Down
20 changes: 12 additions & 8 deletions Samples/PagingLayoutSamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -957,7 +957,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand All @@ -975,20 +975,22 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "PagingLayoutSamples/Paging Layout.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 4J5W7CJ2ZV;
INFOPLIST_FILE = PagingLayoutSamples/Info.plist;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = app.amir.paginglayout;
PRODUCT_NAME = "Layout Designer";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OBJC_BRIDGING_HEADER = "PagingLayoutSamples/PagingLayoutSamples-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Debug;
};
Expand All @@ -1000,20 +1002,22 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "PagingLayoutSamples/Paging Layout.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 4J5W7CJ2ZV;
INFOPLIST_FILE = PagingLayoutSamples/Info.plist;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = app.amir.paginglayout;
PRODUCT_NAME = "Layout Designer";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OBJC_BRIDGING_HEADER = "PagingLayoutSamples/PagingLayoutSamples-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Release;
};
Expand Down
8 changes: 7 additions & 1 deletion Samples/PagingLayoutSamples/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window = UIWindow()
navigationController = UINavigationController()
navigationController.isNavigationBarHidden = true
let mainVC = UIDevice.current.userInterfaceIdiom == .pad ?
let mainVC = UIDevice.current.userInterfaceIdiom != .phone ?
LayoutDesignerViewController.instantiate(viewModel: LayoutDesignerViewModel()) :
MainViewController.instantiate()

#if targetEnvironment(macCatalyst)
if let titlebar = window?.windowScene?.titlebar {
titlebar.titleVisibility = .hidden
titlebar.toolbar = nil
}
#endif
navigationController.setViewControllers([mainVC], animated: false)
window!.rootViewController = navigationController
window!.makeKeyAndVisible()
Expand Down
4 changes: 2 additions & 2 deletions Samples/PagingLayoutSamples/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand All @@ -40,8 +42,6 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protocol LayoutDesignerCodePreviewViewControllerDelegate: AnyObject {


class LayoutDesignerCodePreviewViewController: UIViewController, NibBased, ViewModelBased {

// MARK: Properties

var viewModel: LayoutDesignerCodePreviewViewModel! {
Expand Down Expand Up @@ -51,7 +51,7 @@ class LayoutDesignerCodePreviewViewController: UIViewController, NibBased, ViewM
@IBAction private func saveButtonTouched() {
guard let exportURL = viewModel.sampleProjectTempURL else { return }
viewModel.generateSampleProject()
let controller = UIDocumentPickerViewController(url: exportURL, in: UIDocumentPickerMode.exportToService)
let controller = UIDocumentPickerViewController(forExporting: [exportURL])
controller.delegate = self
present(controller, animated: true)
}
Expand Down Expand Up @@ -82,8 +82,12 @@ class LayoutDesignerCodePreviewViewController: UIViewController, NibBased, ViewM
private func configureCodeTypeSegmentedControl() {
codeModeSegmentedControl.backgroundColor = UIColor.black.withAlphaComponent(0.4)
codeModeSegmentedControl.selectedSegmentTintColor = UIColor.white.withAlphaComponent(0.4)
codeModeSegmentedControl.setTitleTextAttributes([.foregroundColor: UIColor.white], for: .normal)
codeModeSegmentedControl.setTitleTextAttributes([.foregroundColor: UIColor.black.withAlphaComponent(0.6)], for: .selected)
codeModeSegmentedControl.setTitleTextAttributes(
[.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: 12)],
for: .normal)
codeModeSegmentedControl.setTitleTextAttributes(
[.foregroundColor: UIColor.black.withAlphaComponent(0.6), .font: UIFont.systemFont(ofSize: 12)],
for: .selected)
codeModeSegmentedControl.selectedSegmentIndex = 0
}

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


Expand All @@ -107,7 +113,7 @@ extension LayoutDesignerCodePreviewViewController: UIDocumentPickerDelegate {
controller.dismiss(animated: true)
viewModel.removeSampleProject()
}

func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
controller.dismiss(animated: true)
viewModel.removeSampleProject()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
<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 @@ -23,11 +24,11 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cvw-J0-JLY">
<rect key="frame" x="20" y="74" width="468" height="731"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<rect key="frame" x="20" y="0.0" width="468" height="825"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<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>
<color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" systemColor="labelColor"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fjt-yc-d4i">
Expand All @@ -41,7 +42,7 @@
</connections>
</button>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="cq9-nr-dyv">
<rect key="frame" x="20" y="20" width="273" height="32"/>
<rect key="frame" x="20" y="52" width="273" height="32"/>
<segments>
<segment title="Full ViewController"/>
<segment title="Options Variable"/>
Expand All @@ -51,7 +52,7 @@
</connections>
</segmentedControl>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4uN-xn-LPG">
<rect key="frame" x="323" y="696" width="150" height="47"/>
<rect key="frame" x="324" y="696" width="149" height="47"/>
<color key="backgroundColor" red="0.12156862745098039" green="0.12549019607843137" blue="0.14117647058823529" alpha="1" colorSpace="calibratedRGB"/>
<inset key="contentEdgeInsets" minX="22" minY="8" maxX="14" maxY="8"/>
<inset key="imageEdgeInsets" minX="-16" minY="0.0" maxX="0.0" maxY="0.0"/>
Expand All @@ -60,9 +61,13 @@
<action selector="copyButtonTouched" destination="-1" eventType="touchUpInside" id="c8D-hO-HDy"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bnx-km-xRg">
<rect key="frame" x="426" y="20" width="47" height="43"/>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bnx-km-xRg">
<rect key="frame" x="434" y="52" width="39" height="35"/>
<color key="backgroundColor" red="0.1215686275" green="0.12549019610000001" blue="0.14117647059999999" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="35" id="izK-Vs-ZPH"/>
<constraint firstAttribute="width" constant="39" id="zcc-jO-KZF"/>
</constraints>
<inset key="contentEdgeInsets" minX="10" minY="8" maxX="10" maxY="8"/>
<state key="normal" image="helpButton"/>
<connections>
Expand All @@ -71,31 +76,37 @@
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="4uN-xn-LPG" secondAttribute="trailing" constant="20" id="1RA-gL-rX8"/>
<constraint firstItem="cq9-nr-dyv" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="E02-Ta-5YT"/>
<constraint firstAttribute="bottom" secondItem="cvw-J0-JLY" secondAttribute="bottom" constant="20" id="Exb-Sd-OqV"/>
<constraint firstAttribute="bottom" secondItem="cvw-J0-JLY" secondAttribute="bottom" id="Exb-Sd-OqV"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="bnx-km-xRg" secondAttribute="trailing" constant="20" id="LcD-un-uOe"/>
<constraint firstItem="bnx-km-xRg" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="20" id="TIy-N7-QSb"/>
<constraint firstItem="bnx-km-xRg" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="TIy-N7-QSb"/>
<constraint firstItem="Fjt-yc-d4i" firstAttribute="top" secondItem="4uN-xn-LPG" secondAttribute="bottom" constant="8" id="ac1-UU-jg0"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="cvw-J0-JLY" secondAttribute="trailing" constant="5" id="aq1-h0-1nT"/>
<constraint firstAttribute="bottom" secondItem="Fjt-yc-d4i" secondAttribute="bottom" constant="28" id="dxV-xX-NJ4"/>
<constraint firstItem="cq9-nr-dyv" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="20" id="lbB-gA-VL5"/>
<constraint firstItem="cvw-J0-JLY" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="30" id="o6K-u6-Is1"/>
<constraint firstItem="cvw-J0-JLY" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="gDQ-1j-x0Z"/>
<constraint firstItem="cq9-nr-dyv" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="lbB-gA-VL5"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="Fjt-yc-d4i" secondAttribute="trailing" constant="20" id="r8k-zT-2qg"/>
<constraint firstItem="cvw-J0-JLY" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="rbb-1j-Vxg"/>
</constraints>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<point key="canvasLocation" x="194.92753623188406" y="176.45089285714286"/>
</view>
</objects>
<resources>
<image name="copyButton" width="26" height="31"/>
<image name="downloadButton" width="25" height="30"/>
<image name="helpButton" width="27" height="27"/>
<systemColor name="labelColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct LayoutDesignerCodePreviewViewModel {
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("SampleProject")
}

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


// MARK: Public functions
Expand Down Expand Up @@ -88,7 +88,7 @@ struct LayoutDesignerCodePreviewViewModel {
\(code.replacingOccurrences(of: "\n", with: "\n "))
// The card view that we apply effects on
// The card view that we apply transforms on
var card: UIView!
override init(frame: CGRect) {
Expand Down
Loading

0 comments on commit c220b97

Please sign in to comment.