Skip to content

Commit 1975702

Browse files
committed
Editor View Controller for Assignment submission
Fix PopupController bug where popup is dismissed when PickerController is presented. Create SegmentedContainerViewController and build editor view for native text submission with optional title and response context
1 parent 6d545b1 commit 1975702

23 files changed

+822
-286
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
config.txt
2+
**/*.xcuserstate

SakaiClientiOS.xcodeproj/project.pbxproj

Lines changed: 40 additions & 8 deletions
Large diffs are not rendered by default.

SakaiClientiOS.xcworkspace/xcuserdata/pran1999.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,149 @@
1919
landmarkType = "7">
2020
</BreakpointContent>
2121
</BreakpointProxy>
22+
<BreakpointProxy
23+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
24+
<BreakpointContent
25+
shouldBeEnabled = "No"
26+
ignoreCount = "0"
27+
continueAfterRunningActions = "No"
28+
filePath = "LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupportPrivate.m"
29+
timestampString = "569247286.9174809"
30+
startingColumnNumber = "9223372036854775807"
31+
endingColumnNumber = "9223372036854775807"
32+
startingLineNumber = "309"
33+
endingLineNumber = "309"
34+
landmarkName = "-_ln_presentViewController:animated:completion:"
35+
landmarkType = "7">
36+
</BreakpointContent>
37+
</BreakpointProxy>
38+
<BreakpointProxy
39+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
40+
<BreakpointContent
41+
shouldBeEnabled = "No"
42+
ignoreCount = "0"
43+
continueAfterRunningActions = "No"
44+
filePath = "LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupportPrivate.m"
45+
timestampString = "569247288.670122"
46+
startingColumnNumber = "9223372036854775807"
47+
endingColumnNumber = "9223372036854775807"
48+
startingLineNumber = "305"
49+
endingLineNumber = "305"
50+
landmarkName = "-_ln_presentViewController:animated:completion:"
51+
landmarkType = "7">
52+
</BreakpointContent>
53+
</BreakpointProxy>
54+
<BreakpointProxy
55+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
56+
<BreakpointContent
57+
shouldBeEnabled = "No"
58+
ignoreCount = "0"
59+
continueAfterRunningActions = "No"
60+
filePath = "LNPopupController/LNPopupController/Private/LNPopupController.m"
61+
timestampString = "569247391.26176"
62+
startingColumnNumber = "9223372036854775807"
63+
endingColumnNumber = "9223372036854775807"
64+
startingLineNumber = "1255"
65+
endingLineNumber = "1255"
66+
landmarkName = "-closePopupAnimated:completion:"
67+
landmarkType = "7">
68+
</BreakpointContent>
69+
</BreakpointProxy>
70+
<BreakpointProxy
71+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
72+
<BreakpointContent
73+
shouldBeEnabled = "No"
74+
ignoreCount = "0"
75+
continueAfterRunningActions = "No"
76+
filePath = "LNPopupController/LNPopupController/Private/LNPopupController.m"
77+
timestampString = "569247391.262117"
78+
startingColumnNumber = "9223372036854775807"
79+
endingColumnNumber = "9223372036854775807"
80+
startingLineNumber = "1262"
81+
endingLineNumber = "1262"
82+
landmarkName = "-dismissPopupBarAnimated:completion:"
83+
landmarkType = "7">
84+
</BreakpointContent>
85+
</BreakpointProxy>
86+
<BreakpointProxy
87+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
88+
<BreakpointContent
89+
shouldBeEnabled = "No"
90+
ignoreCount = "0"
91+
continueAfterRunningActions = "No"
92+
filePath = "LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupport.m"
93+
timestampString = "569249779.942434"
94+
startingColumnNumber = "9223372036854775807"
95+
endingColumnNumber = "9223372036854775807"
96+
startingLineNumber = "66"
97+
endingLineNumber = "66"
98+
landmarkName = "-dismissPopupBarAnimated:completion:"
99+
landmarkType = "7">
100+
</BreakpointContent>
101+
</BreakpointProxy>
102+
<BreakpointProxy
103+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
104+
<BreakpointContent
105+
shouldBeEnabled = "No"
106+
ignoreCount = "0"
107+
continueAfterRunningActions = "No"
108+
filePath = "LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupport.m"
109+
timestampString = "569249779.942492"
110+
startingColumnNumber = "9223372036854775807"
111+
endingColumnNumber = "9223372036854775807"
112+
startingLineNumber = "65"
113+
endingLineNumber = "65"
114+
landmarkName = "-dismissPopupBarAnimated:completion:"
115+
landmarkType = "7">
116+
</BreakpointContent>
117+
</BreakpointProxy>
118+
<BreakpointProxy
119+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
120+
<BreakpointContent
121+
shouldBeEnabled = "No"
122+
ignoreCount = "0"
123+
continueAfterRunningActions = "No"
124+
filePath = "LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupport.m"
125+
timestampString = "569249779.942543"
126+
startingColumnNumber = "9223372036854775807"
127+
endingColumnNumber = "9223372036854775807"
128+
startingLineNumber = "56"
129+
endingLineNumber = "56"
130+
landmarkName = "-closePopupAnimated:completion:"
131+
landmarkType = "7">
132+
</BreakpointContent>
133+
</BreakpointProxy>
134+
<BreakpointProxy
135+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
136+
<BreakpointContent
137+
shouldBeEnabled = "No"
138+
ignoreCount = "0"
139+
continueAfterRunningActions = "No"
140+
filePath = "LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupport.m"
141+
timestampString = "569249779.942592"
142+
startingColumnNumber = "9223372036854775807"
143+
endingColumnNumber = "9223372036854775807"
144+
startingLineNumber = "51"
145+
endingLineNumber = "51"
146+
landmarkName = "-openPopupAnimated:completion:"
147+
landmarkType = "7">
148+
</BreakpointContent>
149+
</BreakpointProxy>
150+
<BreakpointProxy
151+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
152+
<BreakpointContent
153+
shouldBeEnabled = "No"
154+
ignoreCount = "0"
155+
continueAfterRunningActions = "No"
156+
filePath = "LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupport.m"
157+
timestampString = "569249779.942641"
158+
startingColumnNumber = "9223372036854775807"
159+
endingColumnNumber = "9223372036854775807"
160+
startingLineNumber = "61"
161+
endingLineNumber = "61"
162+
landmarkName = "-dismissPopupBarAnimated:completion:"
163+
landmarkType = "7">
164+
</BreakpointContent>
165+
</BreakpointProxy>
22166
</Breakpoints>
23167
</Bucket>

SakaiClientiOS/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>1.2.0</string>
2121
<key>CFBundleVersion</key>
22-
<string>1566</string>
22+
<string>1681</string>
2323
<key>Fabric</key>
2424
<dict>
2525
<key>APIKey</key>

SakaiClientiOS/Sources/Assignment/AssignmentPageViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111
class AssignmentPageViewController: UIViewController {
1212

1313
private let assignment: Assignment
14-
private var pageView: PageView<AssignmentPageView> = PageView(frame: .zero)
14+
let pageView: PageView<AssignmentPageView> = PageView(frame: .zero)
1515

1616
weak var textViewDelegate: UITextViewDelegate?
1717
weak var scrollViewDelegate: UIScrollViewDelegate?

SakaiClientiOS/Sources/Assignment/AssignmentPagesViewController.swift

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ class AssignmentPagesViewController: UIViewController {
2020
return pageControl
2121
}()
2222
private let pageControlView = UIView()
23-
private let pageController = UIPageViewController(transitionStyle: .scroll,
24-
navigationOrientation: .horizontal,
25-
options: nil)
23+
private let pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
2624

2725
// Even when the current Assignment changes, the popup controller
2826
// instance will be the same but the popup URL will change
2927
private let webController = WebViewController(allowsOptions: false)
30-
private lazy var popupController = WebViewNavigationController(rootViewController: webController)
28+
private let editorController = RichTextEditorViewController()
29+
private lazy var containerController
30+
= SegmentedContainerViewController(segments: [("Web", webController), ("Editor", editorController)])
31+
32+
private lazy var popupController = WebViewNavigationController(rootViewController: containerController)
33+
3134
private let submitPopupBarController = SubmitPopupBarViewController()
3235

3336
private var pendingIndex: Int?
@@ -47,10 +50,6 @@ class AssignmentPagesViewController: UIViewController {
4750
setPage(assignment: assignments[start], index: start)
4851
}
4952

50-
override func loadView() {
51-
view = UIView()
52-
}
53-
5453
required init?(coder aDecoder: NSCoder) {
5554
fatalError("init(coder:) has not been implemented")
5655
}
@@ -76,9 +75,16 @@ class AssignmentPagesViewController: UIViewController {
7675
webController.dismissAction = { [weak self] in
7776
self?.tabBarController?.closePopup(animated: true, completion: nil)
7877
}
78+
editorController.dismissAction = { [weak self] in
79+
self?.tabBarController?.closePopup(animated: true, completion: nil)
80+
}
81+
82+
editorController.delegate = webController
83+
editorController.needsTitleField = false
7984

8085
tabBarController?.popupInteractionStyle = .default
8186
tabBarController?.popupBar.backgroundStyle = .regular
87+
tabBarController?.popupContentView.popupCloseButtonStyle = .none
8288
tabBarController?.popupBar.customBarViewController = submitPopupBarController
8389

8490
submitPopupBarController.titleLabel.text = "DRAG TO SUBMIT"
@@ -103,14 +109,13 @@ class AssignmentPagesViewController: UIViewController {
103109
guard let tabBarController = tabBarController as? TabsController else {
104110
return
105111
}
106-
tabBarController.popupController = nil
107-
// If a new tab is selected, the UITabBarController will handle
108-
// presentation and dismissal of the popup bar
109-
if tabBarController.isMovingToNewTabFromPages {
110-
tabBarController.isMovingToNewTabFromPages = false
112+
113+
let isNavigationPushing = navigationController?.viewControllers.last != self
114+
115+
if isMovingFromParentViewController || isNavigationPushing {
116+
tabBarController.dismissPopupBar(animated: true, completion: nil)
111117
return
112118
}
113-
tabBarController.dismissPopupBar(animated: true, completion: nil)
114119
}
115120

116121
override func viewDidAppear(_ animated: Bool) {
@@ -121,18 +126,23 @@ class AssignmentPagesViewController: UIViewController {
121126
guard let tabBarController = tabBarController as? TabsController else {
122127
return
123128
}
124-
tabBarController.popupController = popupController
125129

126-
tabBarController.presentPopupBar(withContentViewController: popupController,
127-
animated: true,
128-
completion: nil)
129-
// When popping back to PagesController, LNPopupController
130-
// encounters a bug where it is entirely removed from the view
131-
// hierarchy and causes a black space to appear in its place.
132-
// Adding the views back to the tabBarController manually fixes
133-
// the bug.
134-
tabBarController.view.addSubview(tabBarController.popupBar)
135-
tabBarController.view.addSubview(tabBarController.popupContentView)
130+
if tabBarController.popupPresentationState == .hidden ||
131+
tabBarController.popupPresentationState == .closed {
132+
133+
tabBarController.presentPopupBar(withContentViewController: popupController,
134+
animated: true,
135+
completion: nil)
136+
137+
// When popping back to PagesController, LNPopupController
138+
// encounters a bug where it is entirely removed from the view
139+
// hierarchy and causes a black space to appear in its place.
140+
// Adding the views back to the tabBarController manually fixes
141+
// the bug.
142+
tabBarController.view.addSubview(tabBarController.popupBar)
143+
tabBarController.view.addSubview(tabBarController.popupContentView)
144+
tabBarController.popupContentView.popupCloseButtonStyle = .none
145+
}
136146
}
137147
}
138148

@@ -143,7 +153,6 @@ extension AssignmentPagesViewController: UIPageViewControllerDataSource, UIPageV
143153
guard let viewControllerIndex = pages.index(of: viewController) else {
144154
return nil
145155
}
146-
setPopupURL(viewControllerIndex: viewControllerIndex)
147156

148157
let previousIndex = viewControllerIndex - 1
149158
guard previousIndex >= 0 else {
@@ -162,7 +171,6 @@ extension AssignmentPagesViewController: UIPageViewControllerDataSource, UIPageV
162171
guard let viewControllerIndex = pages.index(of: viewController) else {
163172
return nil
164173
}
165-
setPopupURL(viewControllerIndex: viewControllerIndex)
166174

167175
let nextIndex = viewControllerIndex + 1
168176
let assignmentsCount = assignments.count
@@ -190,6 +198,7 @@ extension AssignmentPagesViewController: UIPageViewControllerDataSource, UIPageV
190198
if completed, let index = pendingIndex {
191199
pageControl.currentPage = index
192200
delegate?.pageController(self, didMoveToIndex: index)
201+
setPopupURL(viewControllerIndex: index)
193202
}
194203
}
195204

@@ -208,6 +217,9 @@ extension AssignmentPagesViewController: UIPageViewControllerDataSource, UIPageV
208217
webController.title = assignment.title
209218
webController.setURL(url: url)
210219
webController.setNeedsLoad(to: true)
220+
let instructions = PageView.getInstructionsString(attributedText: assignment.attributedInstructions)
221+
editorController.attributedContext = instructions
222+
editorController.html = ""
211223
}
212224
}
213225

0 commit comments

Comments
 (0)