Skip to content

Commit 59f951a

Browse files
authored
Merge pull request #18505 from wordpress-mobile/feature/18502-prompts_initial_view
Blogging Prompts List: initial view
2 parents a49ad5d + 0d08668 commit 59f951a

File tree

4 files changed

+202
-9
lines changed

4 files changed

+202
-9
lines changed

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Prompts/DashboardPromptsCardCell.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
5454

5555
private var blog: Blog?
5656

57-
// Used to present the menu sheet for contextual menu.
58-
// NOTE: Remove this once we drop support for iOS 13.
57+
// Used to present:
58+
// - The menu sheet for contextual menu in iOS13.
59+
// - The Blogging Prompts list when selected from the contextual menu.
5960
private weak var presenterViewController: BlogDashboardViewController? = nil
6061

6162
private lazy var containerStackView: UIStackView = {
@@ -330,7 +331,13 @@ private extension DashboardPromptsCardCell {
330331
// MARK: Context menu actions
331332

332333
func viewMoreMenuTapped() {
333-
// TODO.
334+
guard let blog = blog,
335+
let presenterViewController = presenterViewController else {
336+
DDLogError("Failed showing Blogging Prompts from Dashboard card. Missing blog or controller.")
337+
return
338+
}
339+
340+
BloggingPromptsViewController.show(for: blog, from: presenterViewController)
334341
}
335342

336343
func skipMenuTapped() {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="cBt-Sc-5RS">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
7+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<scenes>
11+
<!--Blogging Prompts View Controller-->
12+
<scene sceneID="Zaz-EE-DkY">
13+
<objects>
14+
<viewController storyboardIdentifier="BloggingPromptsViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="cBt-Sc-5RS" customClass="BloggingPromptsViewController" customModule="WordPress" customModuleProvider="target" sceneMemberID="viewController">
15+
<layoutGuides>
16+
<viewControllerLayoutGuide type="top" id="MpO-o7-pbX"/>
17+
<viewControllerLayoutGuide type="bottom" id="uCp-uQ-tOJ"/>
18+
</layoutGuides>
19+
<view key="view" contentMode="scaleToFill" id="gDw-cc-yIW">
20+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
21+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
22+
<subviews>
23+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bno-oB-pDf" customClass="FilterTabBar" customModule="WordPress" customModuleProvider="target">
24+
<rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
25+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
26+
<constraints>
27+
<constraint firstAttribute="height" constant="46" id="mN2-YL-PRM"/>
28+
</constraints>
29+
</view>
30+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="7aR-Vp-g6a">
31+
<rect key="frame" x="0.0" y="46" width="375" height="621"/>
32+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
33+
<connections>
34+
<outlet property="dataSource" destination="cBt-Sc-5RS" id="ACo-bR-be2"/>
35+
<outlet property="delegate" destination="cBt-Sc-5RS" id="hKz-4a-sNu"/>
36+
</connections>
37+
</tableView>
38+
</subviews>
39+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
40+
<constraints>
41+
<constraint firstItem="bno-oB-pDf" firstAttribute="leading" secondItem="gDw-cc-yIW" secondAttribute="leading" id="7Jf-su-8WM"/>
42+
<constraint firstAttribute="trailing" secondItem="bno-oB-pDf" secondAttribute="trailing" id="AgG-aE-VG8"/>
43+
<constraint firstItem="7aR-Vp-g6a" firstAttribute="leading" secondItem="gDw-cc-yIW" secondAttribute="leading" id="Nt5-JK-DbB"/>
44+
<constraint firstItem="uCp-uQ-tOJ" firstAttribute="top" secondItem="7aR-Vp-g6a" secondAttribute="bottom" id="Oly-V9-tho"/>
45+
<constraint firstItem="7aR-Vp-g6a" firstAttribute="top" secondItem="bno-oB-pDf" secondAttribute="bottom" id="Rmm-F3-kCp"/>
46+
<constraint firstAttribute="trailing" secondItem="7aR-Vp-g6a" secondAttribute="trailing" id="htA-bQ-QaF"/>
47+
<constraint firstItem="bno-oB-pDf" firstAttribute="top" secondItem="MpO-o7-pbX" secondAttribute="bottom" id="tfA-U7-Sc2"/>
48+
</constraints>
49+
</view>
50+
<connections>
51+
<outlet property="filterTabBar" destination="bno-oB-pDf" id="fxk-Bw-WWL"/>
52+
<outlet property="tableView" destination="7aR-Vp-g6a" id="E5x-rq-5Mg"/>
53+
</connections>
54+
</viewController>
55+
<placeholder placeholderIdentifier="IBFirstResponder" id="wHe-tJ-scb" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
56+
</objects>
57+
<point key="canvasLocation" x="21.600000000000001" y="272.11394302848578"/>
58+
</scene>
59+
</scenes>
60+
<resources>
61+
<systemColor name="systemBackgroundColor">
62+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
63+
</systemColor>
64+
</resources>
65+
</document>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import UIKit
2+
3+
4+
class BloggingPromptsViewController: UIViewController {
5+
6+
// MARK: - Properties
7+
8+
@IBOutlet private weak var tableView: UITableView!
9+
@IBOutlet private weak var filterTabBar: FilterTabBar!
10+
11+
private var blog: Blog?
12+
13+
// MARK: - Init
14+
15+
class func controllerWithBlog(_ blog: Blog) -> BloggingPromptsViewController {
16+
let controller = BloggingPromptsViewController.loadFromStoryboard()
17+
controller.blog = blog
18+
return controller
19+
}
20+
21+
class func show(for blog: Blog, from presentingViewController: UIViewController) {
22+
let controller = BloggingPromptsViewController.controllerWithBlog(blog)
23+
presentingViewController.navigationController?.pushViewController(controller, animated: true)
24+
}
25+
26+
// MARK: - View
27+
28+
override func viewDidLoad() {
29+
super.viewDidLoad()
30+
title = Strings.viewTitle
31+
configureFilterTabBar()
32+
}
33+
34+
}
35+
36+
// MARK: - Private Helpers
37+
38+
private extension BloggingPromptsViewController {
39+
40+
enum Strings {
41+
static let viewTitle = NSLocalizedString("Prompts", comment: "View title for Blogging Prompts list.")
42+
43+
}
44+
45+
}
46+
47+
// MARK: - Table Methods
48+
49+
extension BloggingPromptsViewController: UITableViewDataSource, UITableViewDelegate {
50+
51+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
52+
// TODO: use fetched prompts count.
53+
return 10
54+
}
55+
56+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
57+
// TODO: use custom prompt cell.
58+
return UITableViewCell()
59+
}
60+
61+
}
62+
63+
// MARK: - Filter Tab Bar Support
64+
65+
private extension BloggingPromptsViewController {
66+
67+
enum PromptFilter: Int, FilterTabBarItem, CaseIterable {
68+
case all
69+
case answered
70+
case notAnswered
71+
72+
var title: String {
73+
switch self {
74+
case .all: return NSLocalizedString("All", comment: "Title of all Blogging Prompts filter.")
75+
case .answered: return NSLocalizedString("Answered", comment: "Title of answered Blogging Prompts filter.")
76+
case .notAnswered: return NSLocalizedString("Not Answered", comment: "Title of unanswered Blogging Prompts filter.")
77+
}
78+
}
79+
}
80+
81+
func configureFilterTabBar() {
82+
WPStyleGuide.configureFilterTabBar(filterTabBar)
83+
filterTabBar.items = PromptFilter.allCases
84+
filterTabBar.addTarget(self, action: #selector(selectedFilterDidChange(_:)), for: .valueChanged)
85+
}
86+
87+
@objc func selectedFilterDidChange(_ filterTabBar: FilterTabBar) {
88+
// TODO:
89+
// - track selected filter changed
90+
// - refresh view for selected filter
91+
}
92+
93+
}
94+
95+
// MARK: - StoryboardLoadable
96+
97+
extension BloggingPromptsViewController: StoryboardLoadable {
98+
static var defaultStoryboardName: String {
99+
return "BloggingPromptsViewController"
100+
}
101+
}

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,10 @@
18351835
989643ED23A0437B0070720A /* WidgetDifferenceCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 989643EA23A0437B0070720A /* WidgetDifferenceCell.swift */; };
18361836
989643EE23A0437B0070720A /* WidgetDifferenceCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 989643EB23A0437B0070720A /* WidgetDifferenceCell.xib */; };
18371837
989643EF23A0437B0070720A /* WidgetDifferenceCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 989643EB23A0437B0070720A /* WidgetDifferenceCell.xib */; };
1838+
98A047722821CEBF001B4E2D /* BloggingPromptsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A047712821CEBF001B4E2D /* BloggingPromptsViewController.swift */; };
1839+
98A047732821CEBF001B4E2D /* BloggingPromptsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A047712821CEBF001B4E2D /* BloggingPromptsViewController.swift */; };
1840+
98A047752821D069001B4E2D /* BloggingPromptsViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 98A047742821D069001B4E2D /* BloggingPromptsViewController.storyboard */; };
1841+
98A047762821D069001B4E2D /* BloggingPromptsViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 98A047742821D069001B4E2D /* BloggingPromptsViewController.storyboard */; };
18381842
98A25BD1203CB25F006A5807 /* SignupEpilogueCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A25BD0203CB25F006A5807 /* SignupEpilogueCell.swift */; };
18391843
98A25BD3203CB278006A5807 /* SignupEpilogueCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 98A25BD2203CB278006A5807 /* SignupEpilogueCell.xib */; };
18401844
98A3C2F0239997DA0048D38D /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93E5283B19A7741A003A1A9C /* NotificationCenter.framework */; };
@@ -6572,6 +6576,8 @@
65726576
989643EA23A0437B0070720A /* WidgetDifferenceCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDifferenceCell.swift; sourceTree = "<group>"; };
65736577
989643EB23A0437B0070720A /* WidgetDifferenceCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WidgetDifferenceCell.xib; sourceTree = "<group>"; };
65746578
98991A1125AE653D00B3BBAC /* WordPress 111.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 111.xcdatamodel"; sourceTree = "<group>"; };
6579+
98A047712821CEBF001B4E2D /* BloggingPromptsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BloggingPromptsViewController.swift; sourceTree = "<group>"; };
6580+
98A047742821D069001B4E2D /* BloggingPromptsViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = BloggingPromptsViewController.storyboard; sourceTree = "<group>"; };
65756581
98A25BD0203CB25F006A5807 /* SignupEpilogueCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignupEpilogueCell.swift; sourceTree = "<group>"; };
65766582
98A25BD2203CB278006A5807 /* SignupEpilogueCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SignupEpilogueCell.xib; sourceTree = "<group>"; };
65776583
98A3C2EF239997DA0048D38D /* WordPressThisWeekWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WordPressThisWeekWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -12287,6 +12293,15 @@
1228712293
path = "Shared Views";
1228812294
sourceTree = "<group>";
1228912295
};
12296+
98A047702821BFB6001B4E2D /* Blogging Prompts */ = {
12297+
isa = PBXGroup;
12298+
children = (
12299+
98A047712821CEBF001B4E2D /* BloggingPromptsViewController.swift */,
12300+
98A047742821D069001B4E2D /* BloggingPromptsViewController.storyboard */,
12301+
);
12302+
path = "Blogging Prompts";
12303+
sourceTree = "<group>";
12304+
};
1229012305
98A3C2F1239997DA0048D38D /* WordPressThisWeekWidget */ = {
1229112306
isa = PBXGroup;
1229212307
children = (
@@ -12742,19 +12757,20 @@
1274212757
AC34397B0E11443300E5D79B /* Blog */ = {
1274312758
isa = PBXGroup;
1274412759
children = (
12745-
C77FC90628009C3C00726F00 /* Onboarding Questions Prompt */,
12746-
3F170D2A2654615900F6F670 /* Blogging Reminders */,
12747-
FA73D7E72798766300DF24B3 /* Site Picker */,
12748-
1716AEFA25F2926C00CF49EC /* My Site */,
1274912760
F1863714253E49B8003D4BEF /* Add Site */,
12750-
3F43603423F368BF001DEE70 /* Blog Details */,
12761+
3F37609B23FD803300F0D87F /* Blog + Me */,
1275112762
FA73D7D7278D9E6300DF24B3 /* Blog Dashboard */,
12763+
3F43603423F368BF001DEE70 /* Blog Details */,
1275212764
3F43603523F368CA001DEE70 /* Blog List */,
1275312765
3F43603623F36962001DEE70 /* Blog Selector */,
12754-
3F37609B23FD803300F0D87F /* Blog + Me */,
12766+
98A047702821BFB6001B4E2D /* Blogging Prompts */,
12767+
3F170D2A2654615900F6F670 /* Blogging Reminders */,
12768+
1716AEFA25F2926C00CF49EC /* My Site */,
12769+
C77FC90628009C3C00726F00 /* Onboarding Questions Prompt */,
1275512770
4395A15E210672C900844E8E /* QuickStart */,
1275612771
E6431DDE1C4E890B00FD8D90 /* Sharing */,
1275712772
FA5C74091C596E69000B528C /* Site Management */,
12773+
FA73D7E72798766300DF24B3 /* Site Picker */,
1275812774
3F43603823F36A76001DEE70 /* Site Settings */,
1275912775
BE6AB7FB1BC62E0B00D980FC /* Style */,
1276012776
);
@@ -15925,6 +15941,7 @@
1592515941
B5C66B741ACF071F00F68370 /* NoteBlockActionsTableViewCell.xib in Resources */,
1592615942
FAE4CA6A2732C094003BFDFE /* QuickStartPromptViewController.xib in Resources */,
1592715943
98DCF4A7275945E00008630F /* ReaderDetailNoCommentCell.xib in Resources */,
15944+
98A047752821D069001B4E2D /* BloggingPromptsViewController.storyboard in Resources */,
1592815945
F5A34D1125DF2F7F00C9654B /* Pacifico-Regular.ttf in Resources */,
1592915946
FA1CEAD425CA9C40005E7038 /* RestoreStatusFailedView.xib in Resources */,
1593015947
1761F17B26209AEE000815EF /* open-source-icon-app-60x60@2x.png in Resources */,
@@ -16587,6 +16604,7 @@
1658716604
FABB20852602FC2C00C8785C /* QuickStartChecklistHeader.xib in Resources */,
1658816605
FABB20862602FC2C00C8785C /* n.caf in Resources */,
1658916606
FABB20882602FC2C00C8785C /* People.storyboard in Resources */,
16607+
98A047762821D069001B4E2D /* BloggingPromptsViewController.storyboard in Resources */,
1659016608
FABB208A2602FC2C00C8785C /* WidgetNoConnectionCell.xib in Resources */,
1659116609
FABB208B2602FC2C00C8785C /* LatestPostSummaryCell.xib in Resources */,
1659216610
FABB208D2602FC2C00C8785C /* RestorePostTableViewCell.xib in Resources */,
@@ -18169,6 +18187,7 @@
1816918187
8B33BC9527A0C14C00DB5985 /* BlogDetailsViewController+QuickActions.swift in Sources */,
1817018188
98812966219CE42A0075FF33 /* StatsTotalRow.swift in Sources */,
1817118189
46D6114F2555DAED00B0B7BB /* SiteCreationAnalyticsHelper.swift in Sources */,
18190+
98A047722821CEBF001B4E2D /* BloggingPromptsViewController.swift in Sources */,
1817218191
B54866CA1A0D7042004AC79D /* NSAttributedString+Helpers.swift in Sources */,
1817318192
C81CCD81243BF7A600A83E27 /* TenorService.swift in Sources */,
1817418193
8B51844525893F140085488D /* FilterBarView.swift in Sources */,
@@ -20017,6 +20036,7 @@
2001720036
FABB210E2602FC2C00C8785C /* SuggestionService.swift in Sources */,
2001820037
FABB210F2602FC2C00C8785C /* WordPress-41-42.xcmappingmodel in Sources */,
2001920038
24351255264DCA08009BB2B6 /* Secrets.swift in Sources */,
20039+
98A047732821CEBF001B4E2D /* BloggingPromptsViewController.swift in Sources */,
2002020040
FABB21102602FC2C00C8785C /* MySiteViewController+FAB.swift in Sources */,
2002120041
FABB21112602FC2C00C8785C /* BaseRestoreOptionsViewController.swift in Sources */,
2002220042
8B4DDF25278F44CC0022494D /* BlogDashboardViewController.swift in Sources */,

0 commit comments

Comments
 (0)