-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCSVDataViewController.m
127 lines (107 loc) · 5.17 KB
/
CSVDataViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// CSVDataViewController.m
// CSV Touch
//
// Created by Simon Wigzell on 23/05/2008.
// Copyright 2008 Ozymandias. All rights reserved.
//
#import "CSVDataViewController.h"
#import "CSV_TouchAppDelegate.h"
#import "FilesViewController.h"
#import "FadeAnimator.h"
#import "CSVPreferencesController.h"
#import "HelpPagesViewController.h"
#import "HelpPagesDelegate.h"
@interface CSVDataViewController ()
@property BOOL isPushing;
@end
@implementation CSVDataViewController
- (id) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
[CSV_TouchAppDelegate sharedInstance].navigationController = self;
self.delegate = self;
return self;
}
- (void) showHelp
{
HelpPagesDelegate *delegate = [[HelpPagesDelegate alloc] init];
HelpPagesViewController *controller = [[HelpPagesViewController alloc] initWithDelegate:delegate];
[self pushViewController:controller animated:YES];
}
- (void) show40Notes
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Welcome to 4.0!"
message:@"This is a big update so here are a few new things (check home page for more details):\n\n- Pull to reload all files\n-Long-click to check & reload a single file\n- Load files using the 'Files' app (so e.g. import from DropBox can be done inside the app\n-Pinch-to-zoom in views supporting size changes\n\nNote that due to the large changes, you might have to redo some settings but since all settings are now inside the app and takes effect immediately, this should be simple. I hope!"
okButtonTitle:@"OK"
okHandler:nil];
[self.topViewController presentViewController:alert
animated:YES
completion:nil];
}
- (IBAction)dismissSettingsViewAndShowHelp:(UIStoryboardSegue *)sender
{
[self performSelector:@selector(showHelp) withObject:nil afterDelay:0];
}
// Now, a bunch of things to fix https://stackoverflow.com/questions/34942571/how-to-enable-back-left-swipe-gesture-in-uinavigationcontroller-after-setting-le/43433530#43433530
- (void) viewDidLoad
{
[super viewDidLoad];
self.interactivePopGestureRecognizer.delegate = self;
self.view.backgroundColor = [CSVPreferencesController systemBackgroundColor];
// Show the Add file window in case no files are present
if( [[CSVFileParser files] count] == 0 && ![CSVPreferencesController hasShownHowTo])
{
[self showHelp];
// This is a bit special since it is shown when looking at details, but only if you were already using the app before resizing code changed -> since this is the first time you are running the app, no need to notify about resizing differences
[CSVPreferencesController setHasShown42ResizingNotes];
}
else if( ![CSVPreferencesController hasShown40Notes])
{
[self performSelector:@selector(show40Notes) withObject:nil afterDelay:1];
[CSVPreferencesController setHasShown42ResizingNotes]; // Similar reason as above
}
[CSVPreferencesController setHasShown40Notes]; // Help includes notes
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
// https://stackoverflow.com/questions/34942571/how-to-enable-back-left-swipe-gesture-in-uinavigationcontroller-after-setting-le/43433530#43433530
self.isPushing = YES;
[super pushViewController:viewController animated:animated];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
self.isPushing = NO;
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer == self.interactivePopGestureRecognizer) {
// Disable pop gesture in two situations:
// 1) when the pop animation is in progress
// 2) when user swipes quickly a couple of times and animations don't have time to be performed
return [self.viewControllers count] > 1 && !self.isPushing;
} else {
// default value
return YES;
}
}
// For phasing in view
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
{
if( ([fromVC isKindOfClass:[FilesViewController class]] && [toVC isKindOfClass:[FileDataViewController class]]) ||
([fromVC isKindOfClass:[FileDataViewController class]] && [toVC isKindOfClass:[FilesViewController class]]))
{
return [[FadeAnimator alloc] init];
}
return nil;
}
@end