|
44 | 44 | #import "SeafNavLeftItem.h" |
45 | 45 | #import "SeafHeaderView.h" |
46 | 46 | #import "SeafEditNavRightItem.h" |
| 47 | +#import "SeafLoadingView.h" |
47 | 48 |
|
48 | 49 | #define kCustomTabToolWithTopPadding 15 |
49 | 50 | #define kCustomTabToolButtonHeight 40 |
@@ -75,7 +76,6 @@ - (UITableViewCell *)getSeafDirCell:(SeafDir *)sdir forTableView:(UITableView *) |
75 | 76 | - (UITableViewCell *)getSeafRepoCell:(SeafRepo *)srepo forTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath; |
76 | 77 |
|
77 | 78 | @property (strong) id curEntry; // Currently selected directory entry. |
78 | | -@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *loadingView; |
79 | 79 |
|
80 | 80 | @property (strong) UIBarButtonItem *selectAllItem;// Button to select all items in the directory. |
81 | 81 | @property (strong) UIBarButtonItem *selectNoneItem; |
@@ -136,6 +136,9 @@ - (void)viewDidLoad |
136 | 136 | { |
137 | 137 | [super viewDidLoad]; |
138 | 138 |
|
| 139 | + // Initialize loading view |
| 140 | + self.loadingView = [SeafLoadingView loadingViewWithParentView:self.view]; |
| 141 | + |
139 | 142 | [self.tableView registerNib:[UINib nibWithNibName:@"SeafCell" bundle:nil] |
140 | 143 | forCellReuseIdentifier:@"SeafCell"]; |
141 | 144 | [self.tableView registerNib:[UINib nibWithNibName:@"SeafDirCell" bundle:nil] |
@@ -337,10 +340,7 @@ - (void)editSheet:(id)sender { |
337 | 340 |
|
338 | 341 | - (void)viewWillLayoutSubviews { |
339 | 342 | [super viewWillLayoutSubviews]; |
340 | | - if (self.loadingView.isAnimating) { |
341 | | - CGRect viewBounds = self.view.bounds; |
342 | | - self.loadingView.center = CGPointMake(CGRectGetMidX(viewBounds), CGRectGetMidY(viewBounds)); |
343 | | - } |
| 343 | + [self.loadingView updatePosition]; |
344 | 344 | } |
345 | 345 |
|
346 | 346 |
|
@@ -784,19 +784,19 @@ - (void)refreshView |
784 | 784 |
|
785 | 785 | - (void)showLoadingView |
786 | 786 | { |
787 | | - if (!self.loadingView) { |
788 | | - self.loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
789 | | - self.loadingView.color = [UIColor darkTextColor]; |
790 | | - self.loadingView.hidesWhenStopped = YES; |
791 | | - [self.view addSubview:self.loadingView]; |
792 | | - } |
793 | | - self.loadingView.center = self.view.center; |
794 | | - [self.loadingView startAnimating]; |
| 787 | + // Get the key window for proper centering in the entire screen |
| 788 | + UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; |
| 789 | + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 790 | + // Only show loading view if still in loading state |
| 791 | + if (self.state == STATE_LOADING) { |
| 792 | + [self.loadingView showInView:keyWindow]; |
| 793 | + } |
| 794 | + }); |
795 | 795 | } |
796 | 796 |
|
797 | 797 | - (void)dismissLoadingView |
798 | 798 | { |
799 | | - [self.loadingView stopAnimating]; |
| 799 | + [self.loadingView dismiss]; |
800 | 800 | } |
801 | 801 |
|
802 | 802 | - (void)loadDataFromServerAndRefresh { |
@@ -988,7 +988,6 @@ - (void)editDone:(id)sender |
988 | 988 |
|
989 | 989 | // Restore original title |
990 | 990 | self.customTitleLabel.text = self.directory.name; |
991 | | - _selectedindex = nil; |
992 | 991 |
|
993 | 992 | UIBarButtonItem *customBarButton = [[UIBarButtonItem alloc] initWithCustomView:[SeafNavLeftItem navLeftItemWithDirectory:self.directory target:self action:@selector(backButtonTapped)]]; |
994 | 993 | self.navigationItem.leftBarButtonItem = customBarButton; |
@@ -1059,7 +1058,6 @@ - (void)noneSelected:(BOOL)none |
1059 | 1058 | { |
1060 | 1059 | if (none) { |
1061 | 1060 | // Get done button container view |
1062 | | - _selectedindex = nil; |
1063 | 1061 | UIView *containerView = (UIView *)self.doneItem.customView; |
1064 | 1062 | UILabel *countLabel = [containerView.subviews.lastObject isKindOfClass:[UILabel class]] ? |
1065 | 1063 | (UILabel *)containerView.subviews.lastObject : nil; |
@@ -2926,7 +2924,7 @@ - (void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { |
2926 | 2924 | if (![entry isKindOfClass:[SeafUploadFile class]]) { |
2927 | 2925 | // Select the cell that was long pressed |
2928 | 2926 | [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
2929 | | - |
| 2927 | + _selectedindex = indexPath; |
2930 | 2928 | // Update selection status |
2931 | 2929 | [self noneSelected:NO]; |
2932 | 2930 | [self updateToolButtonsState]; |
|
0 commit comments