All Projects → mmackh → Catalyst Helpers

mmackh / Catalyst Helpers

Licence: mit
Unlock missing UIKit functionality with these AppKit helpers

Projects that are alternatives of or similar to Catalyst Helpers

Ohcubeview
A UIScrollView subclass inspired by the Instagram Stories cube animation
Stars: ✭ 48 (-40.74%)
Mutual labels:  uikit
Tailwindcss Sketch Kit
💎 Sketch UI kit for Tailwind CSS
Stars: ✭ 68 (-16.05%)
Mutual labels:  uikit
Lvthemekit
App 多区域皮肤 UIKit Category
Stars: ✭ 75 (-7.41%)
Mutual labels:  uikit
Tap water
【声明:未发布前,勿使用,勿star,预计2020年11月底发布】Flutter tab_bar组件,支持中间带加号按钮的TabBar,支持Lottie动画。iTeaTime(技术清谈)团队出品。Highly customizable tabBar and tabBarController for Flutter
Stars: ✭ 52 (-35.8%)
Mutual labels:  uikit
React Bootstrap With Material Design
React Bootstrap with Material Design - Powerful and free UI KIT
Stars: ✭ 1,119 (+1281.48%)
Mutual labels:  uikit
Fruity
Rusty bindings for Apple libraries
Stars: ✭ 72 (-11.11%)
Mutual labels:  uikit
Vyplayindicator
PlayIndicator inspired by Apple's Music Player.
Stars: ✭ 47 (-41.98%)
Mutual labels:  uikit
Adminkit
laravel和Uikit开发的后台管理系统雏形 自带完整oauth授权管理模块
Stars: ✭ 78 (-3.7%)
Mutual labels:  uikit
Awesome Uikit
Collect JS Frameworks, Web components library and Admin Template.
Stars: ✭ 1,136 (+1302.47%)
Mutual labels:  uikit
Ibanimatable
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
Stars: ✭ 8,585 (+10498.77%)
Mutual labels:  uikit
Katana Ui Swift
UIKit port of React, built on top of Katana.
Stars: ✭ 53 (-34.57%)
Mutual labels:  uikit
Gogrocery
Its an eCommerce app inspired from Amazon , big Basket , grofers ,grocery app , Etc
Stars: ✭ 62 (-23.46%)
Mutual labels:  uikit
Uikit Computer Store Template
Computer store e-commerce template
Stars: ✭ 72 (-11.11%)
Mutual labels:  uikit
Splitflap
A simple split-flap display for your Swift applications
Stars: ✭ 1,047 (+1192.59%)
Mutual labels:  uikit
Dtgradientbutton
Easy way to set gradient background to your buttons.
Stars: ✭ 76 (-6.17%)
Mutual labels:  uikit
Cacao
Pure Swift Cross-platform UIKit (Cocoa Touch) implementation (Supports Linux)
Stars: ✭ 1,040 (+1183.95%)
Mutual labels:  uikit
Screenadaptationkit
🎨iOS rapidScreen Compatible AdapterKit(Deprecate)
Stars: ✭ 70 (-13.58%)
Mutual labels:  uikit
Sizes
View your app on different device and font sizes
Stars: ✭ 1,213 (+1397.53%)
Mutual labels:  uikit
Ios Icon Selector
A drop-in UI component to allow easy selection of alternate icons on iOS.
Stars: ✭ 77 (-4.94%)
Mutual labels:  uikit
Bootstrap Xd
Bootstrap Design Template — Assets Library — for Adobe XD
Stars: ✭ 74 (-8.64%)
Mutual labels:  uikit

Catalyst-Helpers

Unlock missing UIKit functionality with these unsafe AppKit helpers. The overall goal is to let Apple know what functionality is missing in UIKit to build better apps for the Mac.

IPDFMacEventBus & Keyboard Navigation

The fundamental aspect of what sets iOS (excluding tvOS) aparat form macOS is the inability to correctly navigate through views, not only text fields, with a keyboard. I've come to realise that a UIKeyCommand is not enough and sometimes you would simply be better off with keyDown:, which iOS lacks. So I've wrapped NSEvent's addLocalMonitorForEventsMatchingMask - where you are able to choose whether an event actually gets passed to UIKit or not. Always remember to removeMonitor: otherwhise you'll be left with leaks everywhere.

IPDFMacEventBusMonitor *monitor = [IPDFMacEventBusMonitor monitorWithType:IPDFMacEventBusTypeKeydown eventHandler:^IPDFMacEventBusEvent *(IPDFMacEventBusEvent *event)
{
    if ([event isTab])
    {
        if (weakSelf.cancel.isFirstResponder)
        {
            [weakSelf.save becomeFirstResponder];
            return nil;
        }

        if (weakSelf.save.isFirstResponder)
        {
            [weakSelf.textField becomeFirstResponder];
            return nil;
        }

        if (weakSelf.textField.isFirstResponder)
        {
            [weakSelf.cancel becomeFirstResponder];
            return nil;
        }
    }

    if ([event isEnter])
    {
        if (weakSelf.cancel.isFirstResponder)
        {
            [weakSelf.cancel sendActionsForControlEvents:UIControlEventTouchUpInside];
            return nil;
        }

        if (weakSelf.save.isFirstResponder)
        {
            [weakSelf.save sendActionsForControlEvents:UIControlEventTouchUpInside];
            return nil;
        }
    }

    if ([event isESC])
    {
        [weakSelf dismissWithCompletionHandler:nil];
        return nil;
    }

    return event;
}];
sheet.monitor = monitor;
[[IPDFMacEventBus sharedBus] addMonitor:monitor];

IPDFMacEventBus & App State Events

InstaPDF doesn't fetch documents in the background, but rather when the window becomes key. At first it was quite confusing not being able to know when this occurs, due to UIApplicationWillEnterForegroundNotification only firing once on launch. I pondered swizzling, but observing notifications is a better solution. Again, remove the monitors to prevent leaks.

[[IPDFMacEventBus sharedBus] addMonitor:[IPDFMacEventBusMonitor monitorWithType:IPDFMacEventBusTypeAppState eventHandler:^IPDFMacEventBusEvent *(IPDFMacEventBusEvent *event)
{
    if (event.appState == IPDFMacEventBusAppStateEventBecomeActive)
    {
        NSLog(@"Become Active");
    }

    if (event.appState == IPDFMacEventBusAppStateEventTerminate)
    {
        NSLog(@"Terminate...");
    }
    return nil;
}]];

Additional Catalyst Workarounds

In addition to the helper classes I created, there were still some visual glitches and other unexpected behaviour in UIKit that will feel foreign on the Mac that cannot be abstracted

Opening Files from Dock Icon & Right-Click Finder "Open In..."

You'll need to swizzle (I prefer https://github.com/steipete/Aspects).

  1. Add appropriate entry to Info.plist, .pdf files in the example below
<array>
	<dict>
		<key>CFBundleTypeExtensions</key>
		<array>
			<string>pdf</string>
		</array>
		<key>CFBundleTypeIconFiles</key>
		<array/>
		<key>CFBundleTypeName</key>
		<string>PDF Document</string>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>LSHandlerRank</key>
		<string>Owner</string>
		<key>LSItemContentTypes</key>
		<array>
			<string>com.adobe.pdf</string>
		</array>
	</dict>
</array>
  1. Declare the appropriate selector to hook in AppDelegate
@interface AppDelegate ()

@end

@interface NSObject (private)

- (void)processOpenURLs:(id)arg1;

@end
  1. Hook the selector and process the files
__weak typeof(self) weakSelf = self;
[[NSNotificationCenter defaultCenter] addObserverForName:@"NSApplicationDidFinishLaunchingNotification" object:nil queue:nil usingBlock:^(NSNotification *note)
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        id app = [NSClassFromString(@"NSApplication") sharedApplication];
        id delegate = [app delegate];

        [delegate aspect_hookSelector:@selector(processOpenURLs:) withOptions:AspectPositionInstead usingBlock:^(id<AspectInfo> aspectInfo, NSArray *fileURLs)
        {
            [weakSelf openFiles:fileURLs];
        } error:nil];
    });
}];

Before the dock would allow me to drag in files, I had to either: run a different project in Xcode after the plist entry or restart the OS. I can't remember which one helped.

Blue highlights in UITableViewCell on selection

Double clicking causes the cell to highlight blue

When embedding a UITableView on the left panel of a UISplitView (self.primaryBackgroundStyle = UISplitViewControllerBackgroundStyleSidebar), the design will mimick NSOutlineView. This design is found in apps such as Xcode, Mail, Finder, etc. The difference between Xcode and Finder for example, is that Finder will not allow the cell to be highlighted, because it cannot become a firstResponder.

NSOutlineView in Finder design

On the Catalyst side of things, a click and subsequent selection of a given cell can cause the blue (or the user's chosen accent color) highlight to shimmer/glitch through. On a double click, the cell will turn blue. There is no apparent way to prevent the cell from changing to a solid color on double click without having to implement your own custom selectedBackgroundView and therefore losing the UIVibrancyEffect on selection.

The workaround is quite simple (took me a while): add a UITapGestureRecognizer (numberOfTapsRequired = 1) to your cell. You'll have to manually create a protocol and then select the cell. Once these measures are implemented, double clicking will no longer turn the cell blue and the behaviour will be indistinguishable from a native app like Finder.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].