diff --git a/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift b/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift index 924cb5027f18..aa16c9d8743e 100644 --- a/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift +++ b/WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift @@ -13,6 +13,7 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag { case siteIconCreator case unifiedCommentsAndNotificationsList case recommendAppToOthers + case newCommentEdit /// Returns a boolean indicating if the feature is enabled var enabled: Bool { @@ -43,6 +44,8 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag { return true case .recommendAppToOthers: return BuildConfiguration.current ~= [.localDeveloper, .a8cBranchTest] + case .newCommentEdit: + return false } } @@ -91,6 +94,8 @@ extension FeatureFlag { return "Unified List for Comments and Notifications" case .recommendAppToOthers: return "Recommend App to Others" + case .newCommentEdit: + return "New Comment Edit" } } diff --git a/WordPress/Classes/ViewRelated/Comments/CommentViewController.m b/WordPress/Classes/ViewRelated/Comments/CommentViewController.m index 3c31b766c4e4..8c23c6a3611f 100644 --- a/WordPress/Classes/ViewRelated/Comments/CommentViewController.m +++ b/WordPress/Classes/ViewRelated/Comments/CommentViewController.m @@ -654,20 +654,29 @@ - (void)spamAction - (void)editComment { - EditCommentViewController *editViewController = [EditCommentViewController newEditViewController]; - editViewController.content = [self.comment contentForEdit]; - - __typeof(self) __weak weakSelf = self; - editViewController.onCompletion = ^(BOOL hasNewContent, NSString *newContent) { - [self dismissViewControllerAnimated:YES completion:^{ - if (hasNewContent) { - [weakSelf updateCommentForNewContent:newContent]; - } - }]; - }; + UINavigationController *navController; + + if ([Feature enabled:FeatureFlagNewCommentEdit]) { + EditCommentTableViewController *editViewController = [[EditCommentTableViewController alloc] init]; + navController = [[UINavigationController alloc] initWithRootViewController:editViewController]; + navController.modalPresentationStyle = UIModalPresentationFullScreen; + } else { + EditCommentViewController *editViewController = [EditCommentViewController newEditViewController]; + editViewController.content = [self.comment contentForEdit]; + + __typeof(self) __weak weakSelf = self; + editViewController.onCompletion = ^(BOOL hasNewContent, NSString *newContent) { + [self dismissViewControllerAnimated:YES completion:^{ + if (hasNewContent) { + [weakSelf updateCommentForNewContent:newContent]; + } + }]; + }; + + navController = [[UINavigationController alloc] initWithRootViewController:editViewController]; + navController.modalPresentationStyle = UIModalPresentationFormSheet; + } - UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:editViewController]; - navController.modalPresentationStyle = UIModalPresentationFormSheet; navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; navController.navigationBar.translucent = NO; diff --git a/WordPress/Classes/ViewRelated/Comments/EditCommentTableViewController.swift b/WordPress/Classes/ViewRelated/Comments/EditCommentTableViewController.swift new file mode 100644 index 000000000000..d20da9983d4b --- /dev/null +++ b/WordPress/Classes/ViewRelated/Comments/EditCommentTableViewController.swift @@ -0,0 +1,88 @@ +import Foundation + + +class EditCommentTableViewController: UITableViewController { + + // MARK: - Properties + + private let sectionHeaders = + [NSLocalizedString("Name", comment: "Header for a comment author's name, shown when editing a comment.").localizedUppercase, + NSLocalizedString("Comment", comment: "Header for a comment's content, shown when editing a comment.").localizedUppercase, + NSLocalizedString("Web Address", comment: "Header for a comment author's web address, shown when editing a comment.").localizedUppercase, + NSLocalizedString("Email Address", comment: "Header for a comment author's email address, shown when editing a comment.").localizedUppercase] + + // MARK: - Init + + required convenience init() { + self.init(style: .insetGrouped) + } + + override init(style: UITableView.Style) { + super.init(style: style) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - View + + override func viewDidLoad() { + super.viewDidLoad() + setupNavBar() + } + + // MARK: - UITableViewDelegate + + override func numberOfSections(in tableView: UITableView) -> Int { + return sectionHeaders.count + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 1 + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return sectionHeaders[safe: section] + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + // TODO: return custom cell + return UITableViewCell() + } + + override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { + // Make sure no SectionFooter is rendered + return CGFloat.leastNormalMagnitude + } + + override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { + // Make sure no SectionFooter is rendered + return nil + } + +} + +private extension EditCommentTableViewController { + + // MARK: - View Config + + func setupNavBar() { + title = NSLocalizedString("Edit Comment", comment: "View title when editing a comment.") + navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancelButtonTapped)) + navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(doneButtonTapped)) + } + + // MARK: - Nav bar button actions + + @objc func cancelButtonTapped(sender: UIBarButtonItem) { + // TODO: discard changes + dismiss(animated: true) + } + + @objc func doneButtonTapped(sender: UIBarButtonItem) { + // TODO: save changes + dismiss(animated: true) + } + +} diff --git a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationDetailsViewController.swift b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationDetailsViewController.swift index 5df2edb93a4d..320f24d845ca 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationDetailsViewController.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationDetailsViewController.swift @@ -1223,20 +1223,30 @@ private extension NotificationDetailsViewController { } func displayCommentEditorWithBlock(_ block: FormattableCommentContent) { - let editViewController = EditCommentViewController.newEdit() - editViewController?.content = block.text - editViewController?.onCompletion = { (hasNewContent, newContent) in - self.dismiss(animated: true, completion: { - guard hasNewContent else { - return - } - let newContent = newContent ?? "" - self.updateComment(with: block, content: newContent) - }) + + var navController: UINavigationController + + if FeatureFlag.newCommentEdit.enabled { + let editViewController = EditCommentTableViewController() + navController = UINavigationController(rootViewController: editViewController) + navController.modalPresentationStyle = .fullScreen + } else { + let editViewController = EditCommentViewController.newEdit() + editViewController?.content = block.text + editViewController?.onCompletion = { (hasNewContent, newContent) in + self.dismiss(animated: true, completion: { + guard hasNewContent else { + return + } + let newContent = newContent ?? "" + self.updateComment(with: block, content: newContent) + }) + } + + navController = UINavigationController(rootViewController: editViewController!) + navController.modalPresentationStyle = .formSheet } - let navController = UINavigationController(rootViewController: editViewController!) - navController.modalPresentationStyle = .formSheet navController.modalTransitionStyle = .coverVertical navController.navigationBar.isTranslucent = false diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index a562ae04e732..80642d027d2b 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -1586,6 +1586,8 @@ 98906508237CC1DF00218CD2 /* WidgetTwoColumnCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 989064FE237CC1DE00218CD2 /* WidgetTwoColumnCell.xib */; }; 98906509237CC1DF00218CD2 /* WidgetTwoColumnCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 989064FE237CC1DE00218CD2 /* WidgetTwoColumnCell.xib */; }; 98921EF721372E12004949AA /* MediaCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98921EF621372E12004949AA /* MediaCoordinator.swift */; }; + 9895401126C1F39300EDEB5A /* EditCommentTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9895401026C1F39300EDEB5A /* EditCommentTableViewController.swift */; }; + 9895401226C1F39300EDEB5A /* EditCommentTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9895401026C1F39300EDEB5A /* EditCommentTableViewController.swift */; }; 9895B6E021ED49160053D370 /* TopTotalsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9895B6DF21ED49160053D370 /* TopTotalsCell.xib */; }; 989643E223A02F080070720A /* WidgetUnconfiguredCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 989064FB237CC1DE00218CD2 /* WidgetUnconfiguredCell.swift */; }; 989643E423A02F4E0070720A /* UIColor+MurielColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435B762122973D0600511813 /* UIColor+MurielColors.swift */; }; @@ -6248,6 +6250,7 @@ 989064FD237CC1DE00218CD2 /* WidgetTwoColumnCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WidgetTwoColumnCell.swift; sourceTree = ""; }; 989064FE237CC1DE00218CD2 /* WidgetTwoColumnCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WidgetTwoColumnCell.xib; sourceTree = ""; }; 98921EF621372E12004949AA /* MediaCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaCoordinator.swift; sourceTree = ""; }; + 9895401026C1F39300EDEB5A /* EditCommentTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditCommentTableViewController.swift; sourceTree = ""; }; 9895B6DF21ED49160053D370 /* TopTotalsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TopTotalsCell.xib; sourceTree = ""; }; 989643EA23A0437B0070720A /* WidgetDifferenceCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDifferenceCell.swift; sourceTree = ""; }; 989643EB23A0437B0070720A /* WidgetDifferenceCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WidgetDifferenceCell.xib; sourceTree = ""; }; @@ -12403,6 +12406,7 @@ 313AE49B19E3F20400AAFABE /* CommentViewController.h */, 313AE49C19E3F20400AAFABE /* CommentViewController.m */, B0AC50B3251E959B0039E022 /* CommentViewController.swift */, + 9895401026C1F39300EDEB5A /* EditCommentTableViewController.swift */, 2906F80F110CDA8900169D56 /* EditCommentViewController.h */, 2906F810110CDA8900169D56 /* EditCommentViewController.m */, 328CEC5D23A532BA00A6899E /* FullScreenCommentReplyViewController.swift */, @@ -17325,6 +17329,7 @@ 400A2C772217A8A0000A8A59 /* VisitsSummaryStatsRecordValue+CoreDataClass.swift in Sources */, D8212CB320AA6861008E8AE8 /* ReaderFollowAction.swift in Sources */, F5D399302541F25B0058D0AB /* SheetActions.swift in Sources */, + 9895401126C1F39300EDEB5A /* EditCommentTableViewController.swift in Sources */, 8B7F51C924EED804008CF5B5 /* ReaderTracker.swift in Sources */, E6F2788421BC1A4A008B4DB5 /* PlanFeature.swift in Sources */, 3F421DF524A3EC2B00CA9B9E /* Spotlightable.swift in Sources */, @@ -19769,6 +19774,7 @@ FABB23F12602FC2C00C8785C /* DefaultStockPhotosService.swift in Sources */, FABB23F22602FC2C00C8785C /* Animator.swift in Sources */, FABB23F32602FC2C00C8785C /* SiteStatsDashboardViewController.swift in Sources */, + 9895401226C1F39300EDEB5A /* EditCommentTableViewController.swift in Sources */, FABB23F42602FC2C00C8785C /* MediaSettings.swift in Sources */, FABB23F52602FC2C00C8785C /* DomainCreditRedemptionSuccessViewController.swift in Sources */, FABB23F62602FC2C00C8785C /* ActivityLogDetailViewController.m in Sources */,