Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2FQ38K642M;
INFOPLIST_FILE = ObjcTextInput/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.icapps.ObjcTextInput;
PRODUCT_BUNDLE_IDENTIFIER = com.charlotteerpels.ObjcTextInput;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "ObjcTextInput/ObjcTextInput-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -346,9 +348,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2FQ38K642M;
INFOPLIST_FILE = ObjcTextInput/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.icapps.ObjcTextInput;
PRODUCT_BUNDLE_IDENTIFIER = com.charlotteerpels.ObjcTextInput;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "ObjcTextInput/ObjcTextInput-Bridging-Header.h";
SWIFT_VERSION = 4.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
Expand Down Expand Up @@ -108,7 +107,7 @@
<!--Change Text View Controller-->
<scene sceneID="4yo-dl-qbi">
<objects>
<viewController id="9H1-QZ-Jfg" customClass="TIIChangeTextViewController" sceneMemberID="viewController">
<viewController storyboardIdentifier="TIIChangeTextViewController" id="9H1-QZ-Jfg" customClass="TIIChangeTextViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="opz-eE-Cz8">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
#import "TIIViewModel.h"
#import <MobileCoreServices/MobileCoreServices.h>

@interface TIIUIViewController () <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDragDelegate,UICollectionViewDropDelegate,TextDelegate>
@interface TIIUIViewController () <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDragDelegate,UICollectionViewDropDelegate,UIViewControllerPreviewingDelegate,TextDelegate>
@property (nonatomic, weak) IBOutlet UICollectionView * collectionView;
@property (nonatomic, strong) TIIViewModel * viewModel;
@property (assign, nonatomic) BOOL isEditing;
@property (nonatomic, strong) UILongPressGestureRecognizer * longPressGesture;
@property (nonatomic, strong) id previewingContext;
@end

@implementation TIIUIViewController
Expand All @@ -36,6 +37,10 @@ - (void)viewDidLoad {
[self.collectionView addGestureRecognizer:self.longPressGesture];

[self.collectionView reloadData];

if([self isForceTouchAvailable]) {
self.previewingContext = [self registerForPreviewingWithDelegate:self sourceView:self.view];
}
}

#pragma mark - UILongPressGesture
Expand Down Expand Up @@ -195,6 +200,43 @@ -(void)collectionView:(UICollectionView *)collectionView performDropWithCoordina
}
}

#pragma mark - UIViewControllerPreviewingDelegate

-(BOOL)isForceTouchAvailable {
BOOL isForceTouchAvailable = NO;

if([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]) {
isForceTouchAvailable = self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable;
}

return isForceTouchAvailable;
}

-(UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location {
CGPoint cellPosition = [self.collectionView convertPoint:location fromView:self.view];
NSIndexPath * indexPath = [self.collectionView indexPathForItemAtPoint:cellPosition];

if(indexPath) {
TIILabelCollectionViewCell * cell = [self.collectionView cellForItemAtIndexPath:indexPath];
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
TIIChangeTextViewController * previewController = [storyboard instantiateViewControllerWithIdentifier:@"TIIChangeTextViewController"];

previewController.originalText = [self.viewModel objectForIndexPath:indexPath];
previewController.itemIndex = indexPath;

previewingContext.sourceRect = [self.view convertRect:cell.frame fromView:self.collectionView];

return previewController;
}

return nil;
}

-(void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
TIIChangeTextViewController * changeTextViewController = viewControllerToCommit;
changeTextViewController.delegate = self;
[self presentViewController:changeTextViewController animated:YES completion:nil];
}

@end

Expand Down