@@ -327,13 +327,8 @@ - (void)viewDidLoad
327
327
{
328
328
[super viewDidLoad ];
329
329
330
- if ([Feature enabled: FeatureFlagMySiteDashboard]) {
331
- _tableView = [[IntrinsicTableView alloc ] initWithFrame: CGRectZero style: UITableViewStyleInsetGrouped];
332
- self.tableView .scrollEnabled = false ;
333
- } else {
334
- _tableView = [[UITableView alloc ] initWithFrame: CGRectZero style: UITableViewStyleInsetGrouped];
335
- }
336
-
330
+ _tableView = [[IntrinsicTableView alloc ] initWithFrame: CGRectZero style: UITableViewStyleInsetGrouped];
331
+ self.tableView .scrollEnabled = false ;
337
332
self.tableView .delegate = self;
338
333
self.tableView .dataSource = self;
339
334
self.tableView .translatesAutoresizingMaskIntoConstraints = false ;
@@ -377,8 +372,6 @@ - (void)viewDidLoad
377
372
name: NSManagedObjectContextObjectsDidChangeNotification
378
373
object: context];
379
374
380
- [self configureBlogDetailHeader ];
381
- [self .headerView setBlog: _blog];
382
375
[self startObservingQuickStart ];
383
376
[self addMeButtonToNavigationBarWithEmail: self .blog.account.email meScenePresenter: self .meScenePresenter];
384
377
@@ -390,24 +383,10 @@ - (void)viewDidLoad
390
383
391
384
}
392
385
393
- // / Resizes the `tableHeaderView` as necessary whenever its size changes.
394
386
- (void )viewDidLayoutSubviews {
395
387
[super viewDidLayoutSubviews ];
396
388
397
389
[self .createButtonCoordinator presentingTraitCollectionWillChange: self .traitCollection newTraitCollection: self .traitCollection];
398
-
399
- if ([Feature enabled: FeatureFlagMySiteDashboard]) {
400
- return ;
401
- }
402
-
403
- UIView *headerView = self.tableView .tableHeaderView ;
404
-
405
- CGSize size = [self .tableView.tableHeaderView systemLayoutSizeFittingSize: UILayoutFittingCompressedSize];
406
- if (headerView.frame .size .height != size.height ) {
407
- headerView.frame = CGRectMake (headerView.frame .origin .x , headerView.frame .origin .y , headerView.frame .size .width , size.height );
408
-
409
- self.tableView .tableHeaderView = headerView;
410
- }
411
390
}
412
391
413
392
- (void )viewWillAppear : (BOOL )animated
@@ -1094,98 +1073,6 @@ - (BOOL)shouldDisplayLinkToWPAdmin
1094
1073
return [defaultAccount.dateCreated compare: hideWPAdminDate] == NSOrderedAscending;
1095
1074
}
1096
1075
1097
- #pragma mark - Configuration
1098
-
1099
- - (void )configureBlogDetailHeader
1100
- {
1101
- if ([Feature enabled: FeatureFlagMySiteDashboard]) {
1102
- return ;
1103
- }
1104
-
1105
- BlogDetailHeaderView *headerView = [self configureHeaderView ];
1106
- headerView.delegate = self;
1107
-
1108
- self.headerView = headerView;
1109
-
1110
- self.tableView .tableHeaderView = headerView;
1111
-
1112
- [self .headerView setTranslatesAutoresizingMaskIntoConstraints: NO ];
1113
- [NSLayoutConstraint activateConstraints: @[
1114
- [self .headerView.leadingAnchor constraintEqualToAnchor: self .view.leadingAnchor],
1115
- [self .headerView.trailingAnchor constraintEqualToAnchor: self .view.trailingAnchor]
1116
- ]];
1117
- }
1118
-
1119
- #pragma mark BlogDetailHeaderViewDelegate
1120
-
1121
- - (void )siteIconTapped
1122
- {
1123
- if (![self siteIconShouldAllowDroppedImages ]) {
1124
- // Gracefully ignore the tap for users that can not upload files or
1125
- // blogs that do not have capabilities since those will not support the REST API icon update
1126
- return ;
1127
- }
1128
- [WPAnalytics track: WPAnalyticsStatSiteSettingsSiteIconTapped];
1129
-
1130
- [NoticesDispatch lock ];
1131
-
1132
- if (![Feature enabled: FeatureFlagSiteIconCreator]) {
1133
- [self showUpdateSiteIconAlert ];
1134
- }
1135
-
1136
- if (@available (iOS 14.0 , *)) {
1137
- [self showSiteIconSelectionAlert ];
1138
- } else {
1139
- [self showUpdateSiteIconAlert ];
1140
- }
1141
- }
1142
-
1143
- - (void )siteIconReceivedDroppedImage : (UIImage *)image
1144
- {
1145
- if (![self siteIconShouldAllowDroppedImages ]) {
1146
- // Gracefully ignore the drop for users that can not upload files or
1147
- // blogs that do not have capabilities since those will not support the REST API icon update
1148
- self.headerView .updatingIcon = NO ;
1149
- return ;
1150
- }
1151
- [self presentCropViewControllerForDroppedSiteIcon: image];
1152
- }
1153
-
1154
- - (BOOL )siteIconShouldAllowDroppedImages
1155
- {
1156
- if (!self.blog .isAdmin || !self.blog .isUploadingFilesAllowed ) {
1157
- return NO ;
1158
- }
1159
-
1160
- return YES ;
1161
- }
1162
-
1163
- - (void )siteTitleTapped
1164
- {
1165
- [self showSiteTitleSettings ];
1166
- }
1167
-
1168
- - (void )siteSwitcherTapped
1169
- {
1170
- BlogListViewController* blogListViewController = [[BlogListViewController alloc ] initWithMeScenePresenter: self .meScenePresenter];
1171
- __weak __typeof (self) weakSelf = self;
1172
- blogListViewController.blogSelected = ^(BlogListViewController* blogListViewController, Blog *blog) {
1173
- [weakSelf switchToBlog: blog];
1174
- [blogListViewController dismissViewControllerAnimated: true completion: nil ];
1175
- };
1176
-
1177
- UINavigationController* navigationController = [[UINavigationController alloc ] initWithRootViewController: blogListViewController];
1178
- navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
1179
- [self presentViewController: navigationController animated: true completion: nil ];
1180
-
1181
- [WPAnalytics trackEvent: WPAnalyticsEventMySiteSiteSwitcherTapped];
1182
- }
1183
-
1184
- - (void )visitSiteTapped
1185
- {
1186
- [self showViewSiteFromSource: BlogDetailsNavigationSourceButton];
1187
- }
1188
-
1189
1076
#pragma mark Site Switching
1190
1077
1191
1078
- (void )switchToBlog : (Blog*)blog
@@ -1206,205 +1093,6 @@ - (void)showInitialDetailsForBlog
1206
1093
[self showDetailViewForSubsection: BlogDetailsSubsectionStats];
1207
1094
}
1208
1095
1209
- #pragma mark Site Icon Update Management
1210
-
1211
- - (void )showUpdateSiteIconAlert
1212
- {
1213
- UIAlertController *updateIconAlertController = [UIAlertController alertControllerWithTitle: nil
1214
- message: nil
1215
- preferredStyle: UIAlertControllerStyleActionSheet];
1216
-
1217
- updateIconAlertController.popoverPresentationController .sourceView = self.headerView .blavatarImageView .superview ;
1218
- updateIconAlertController.popoverPresentationController .sourceRect = self.headerView .blavatarImageView .frame ;
1219
- updateIconAlertController.popoverPresentationController .permittedArrowDirections = UIPopoverArrowDirectionAny;
1220
-
1221
- [updateIconAlertController addDefaultActionWithTitle: NSLocalizedString(@" Change Site Icon" , @" Change site icon button" )
1222
- handler: ^(UIAlertAction *action) {
1223
- [NoticesDispatch unlock ];
1224
- [self updateSiteIcon ];
1225
- }];
1226
- if (self.blog .hasIcon ) {
1227
- [updateIconAlertController addDestructiveActionWithTitle: NSLocalizedString(@" Remove Site Icon" , @" Remove site icon button" )
1228
- handler: ^(UIAlertAction *action) {
1229
- [NoticesDispatch unlock ];
1230
- [self removeSiteIcon ];
1231
- }];
1232
- }
1233
- [updateIconAlertController addCancelActionWithTitle: NSLocalizedString(@" Cancel" , @" Cancel button" )
1234
- handler: ^(UIAlertAction *action) {
1235
- [NoticesDispatch unlock ];
1236
- [self startAlertTimer ];
1237
- }];
1238
-
1239
- [self presentViewController: updateIconAlertController animated: YES completion: nil ];
1240
- }
1241
-
1242
- - (void )showSiteIconSelectionAlert
1243
- {
1244
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle: nil
1245
- message: nil
1246
- preferredStyle: UIAlertControllerStyleActionSheet];
1247
-
1248
- alertController.popoverPresentationController .sourceView = self.headerView .blavatarImageView .superview ;
1249
- alertController.popoverPresentationController .sourceRect = self.headerView .blavatarImageView .frame ;
1250
- alertController.popoverPresentationController .permittedArrowDirections = UIPopoverArrowDirectionAny;
1251
-
1252
- [alertController setTitle: NSLocalizedString(@" Update Site Icon" , @" Title for sheet displayed allowing user to update their site icon" )];
1253
-
1254
- [alertController addDefaultActionWithTitle: NSLocalizedString(@" Choose Image From My Device" , @" Button allowing the user to choose an image from their device to use as their site icon" )
1255
- handler: ^(UIAlertAction *action) {
1256
- [NoticesDispatch unlock ];
1257
- [self updateSiteIcon ];
1258
- }];
1259
-
1260
- [alertController addDefaultActionWithTitle: NSLocalizedString(@" Create With Emoji" , @" Button allowing the user to create a site icon by choosing an emoji character" )
1261
- handler: ^(UIAlertAction *action) {
1262
- [NoticesDispatch unlock ];
1263
- [self showEmojiPicker ];
1264
- }];
1265
-
1266
- [alertController addDestructiveActionWithTitle: NSLocalizedString(@" Remove Site Icon" , @" Remove site icon button" )
1267
- handler: ^(UIAlertAction *action) {
1268
- [NoticesDispatch unlock ];
1269
- [self removeSiteIcon ];
1270
- }];
1271
-
1272
- [alertController addCancelActionWithTitle: NSLocalizedString(@" Cancel" , @" Cancel button" )
1273
- handler: ^(UIAlertAction *action) {
1274
- [NoticesDispatch unlock ];
1275
- [self startAlertTimer ];
1276
- }];
1277
-
1278
- [self presentViewController: alertController animated: YES completion: nil ];
1279
- }
1280
-
1281
- - (void )presentCropViewControllerForDroppedSiteIcon : (UIImage *)image
1282
- {
1283
- self.imageCropViewController = [[ImageCropViewController alloc ] initWithImage: image];
1284
- self.imageCropViewController .maskShape = ImageCropOverlayMaskShapeSquare;
1285
- self.imageCropViewController .shouldShowCancelButton = YES ;
1286
-
1287
- __weak __typeof (self) weakSelf = self;
1288
- self.imageCropViewController .onCancel = ^(void ) {
1289
- [weakSelf dismissViewControllerAnimated: YES completion: nil ];
1290
- weakSelf.headerView .updatingIcon = NO ;
1291
- };
1292
-
1293
- self.imageCropViewController .onCompletion = ^(UIImage *image, BOOL modified) {
1294
- [weakSelf dismissViewControllerAnimated: YES completion: nil ];
1295
- [weakSelf uploadDroppedSiteIcon: image onCompletion: ^{
1296
- weakSelf.headerView .blavatarImageView .image = image;
1297
- weakSelf.headerView .updatingIcon = NO ;
1298
- }];
1299
- };
1300
- UINavigationController *navController = [[UINavigationController alloc ] initWithRootViewController: self .imageCropViewController];
1301
- navController.modalPresentationStyle = UIModalPresentationFormSheet;
1302
- [self presentViewController: navController animated: YES completion: nil ];
1303
- }
1304
-
1305
- - (void )uploadDroppedSiteIcon : (UIImage *)image onCompletion : (void (^)(void ))completion
1306
- {
1307
- if (self.blog .objectID == nil ) {
1308
- return ;
1309
- }
1310
-
1311
- __weak __typeof (self) weakSelf = self;
1312
- MediaService *mediaService = [[MediaService alloc ] initWithManagedObjectContext: [ContextManager sharedInstance ].mainContext];
1313
- NSProgress *mediaCreateProgress;
1314
- [mediaService createMediaWith: image blog: self .blog post: nil progress: &mediaCreateProgress thumbnailCallback: nil completion: ^(Media *media, NSError *error) {
1315
- if (media == nil || error != nil ) {
1316
- return ;
1317
- }
1318
- NSProgress *uploadProgress;
1319
- [mediaService uploadMedia: media
1320
- automatedRetry: false
1321
- progress: &uploadProgress
1322
- success: ^{
1323
- [weakSelf updateBlogIconWithMedia: media];
1324
- completion ();
1325
- } failure: ^(NSError * _Nonnull error) {
1326
- [weakSelf showErrorForSiteIconUpdate ];
1327
- completion ();
1328
- }];
1329
- }];
1330
- }
1331
-
1332
- - (void )updateSiteIcon
1333
- {
1334
- self.siteIconPickerPresenter = [[SiteIconPickerPresenter alloc ]initWithBlog:self .blog];
1335
- __weak __typeof (self) weakSelf = self;
1336
- self.siteIconPickerPresenter .onCompletion = ^(Media *media, NSError *error) {
1337
- if (error) {
1338
- [weakSelf showErrorForSiteIconUpdate ];
1339
- } else if (media) {
1340
- [weakSelf updateBlogIconWithMedia: media];
1341
- } else {
1342
- // If no media and no error the picker was canceled
1343
- [weakSelf dismissViewControllerAnimated: YES completion: nil ];
1344
- }
1345
- weakSelf.siteIconPickerPresenter = nil ;
1346
- [weakSelf startAlertTimer ];
1347
- };
1348
- self.siteIconPickerPresenter .onIconSelection = ^() {
1349
- weakSelf.headerView .updatingIcon = YES ;
1350
- [weakSelf dismissViewControllerAnimated: YES completion: nil ];
1351
- };
1352
- [self .siteIconPickerPresenter presentPickerFrom: self ];
1353
- }
1354
-
1355
- - (void )removeSiteIcon
1356
- {
1357
- self.headerView .updatingIcon = YES ;
1358
- self.blog .settings .iconMediaID = @0 ;
1359
- [self updateBlogSettingsAndRefreshIcon ];
1360
- [WPAnalytics track: WPAnalyticsStatSiteSettingsSiteIconRemoved];
1361
- }
1362
-
1363
- - (void )refreshSiteIcon
1364
- {
1365
- [self .headerView refreshIconImage ];
1366
- }
1367
-
1368
- - (void )toggleSpotlightForSiteTitle
1369
- {
1370
- [self .headerView toggleSpotlightOnSiteTitle ];
1371
- }
1372
-
1373
- - (void )toggleSpotlightOnHeaderView
1374
- {
1375
- [self .headerView toggleSpotlightOnSiteTitle ];
1376
- [self .headerView toggleSpotlightOnSiteIcon ];
1377
- }
1378
-
1379
- - (void )updateBlogIconWithMedia : (Media *)media
1380
- {
1381
- [[QuickStartTourGuide shared ] completeSiteIconTourForBlog: self .blog];
1382
-
1383
- self.blog .settings .iconMediaID = media.mediaID ;
1384
- [self updateBlogSettingsAndRefreshIcon ];
1385
- }
1386
-
1387
- - (void )updateBlogSettingsAndRefreshIcon
1388
- {
1389
- BlogService *blogService = [[BlogService alloc ] initWithManagedObjectContext: self .blog.managedObjectContext];
1390
- [blogService updateSettingsForBlog: self .blog
1391
- success: ^{
1392
- [blogService syncBlog: self .blog
1393
- success: ^{
1394
- self.headerView .updatingIcon = NO ;
1395
- [self .headerView refreshIconImage ];
1396
- } failure: nil ];
1397
- } failure: ^(NSError *error){
1398
- [self showErrorForSiteIconUpdate ];
1399
- }];
1400
- }
1401
-
1402
- - (void )showErrorForSiteIconUpdate
1403
- {
1404
- [SVProgressHUD showDismissibleErrorWithStatus: NSLocalizedString(@" Icon update failed" , @" Message to show when site icon update failed" )];
1405
- self.headerView .updatingIcon = NO ;
1406
- }
1407
-
1408
1096
#pragma mark - Table view data source
1409
1097
1410
1098
- (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView
@@ -1908,9 +1596,7 @@ - (void)showViewSiteFromSource:(BlogDetailsNavigationSource)source
1908
1596
1909
1597
[self presentViewController: navController
1910
1598
animated: YES
1911
- completion: ^(void ) {
1912
- [self toggleSpotlightOnHeaderView ];
1913
- }];
1599
+ completion: nil ];
1914
1600
1915
1601
QuickStartTourGuide *guide = [QuickStartTourGuide shared ];
1916
1602
0 commit comments