@@ -9,6 +9,7 @@ import UIKit
99import WebKit
1010import ScrollableSegmentedControl
1111import UIKit. UIPrinter
12+ import FirebaseAnalytics
1213
1314// taken from: https://developer.apple.com/documentation/uikit/view_controllers/building_a_document_browser-based_app
1415class DocumentViewController : UIViewController , DocumentDelegate {
@@ -39,6 +40,7 @@ class DocumentViewController: UIViewController, DocumentDelegate {
3940 @IBOutlet weak var toolbar : UIToolbar !
4041 @IBOutlet weak var toolbarDefaultHeight : NSLayoutConstraint !
4142 @IBOutlet weak var toolbarFullscreenHeight : NSLayoutConstraint !
43+ @IBOutlet weak var menuButton : UIBarButtonItem !
4244
4345 private var isFullscreen = false
4446
@@ -101,11 +103,25 @@ class DocumentViewController: UIViewController, DocumentDelegate {
101103 }
102104
103105 func showWebsite( ) {
106+ Analytics . logEvent ( " menu_help " , parameters: nil )
107+
104108 UIApplication . shared. openURL ( URL ( string: " https://opendocument.app " ) !)
105109 }
106110
107111 func toggleFullscreen( ) {
108112 isFullscreen = !isFullscreen
113+
114+ let event : String
115+ if ( isFullscreen) {
116+ event = " menu_fullscreen_enter "
117+ } else {
118+ event = " menu_fullscreen_leave "
119+ }
120+ Analytics . logEvent ( event, parameters: nil )
121+
122+ let topInset = isFullscreen ? 0 : 8
123+ menuButton. imageInsets = UIEdgeInsets ( top: CGFloat ( topInset) , left: 0 , bottom: 0 , right: 0 )
124+
109125 setNeedsStatusBarAppearanceUpdate ( )
110126 }
111127
@@ -132,10 +148,13 @@ class DocumentViewController: UIViewController, DocumentDelegate {
132148 alert. addAction ( UIAlertAction ( title: " Help!? " , style: . default, handler: { ( _) in
133149 self . showWebsite ( )
134150 } ) )
151+ alert. addAction ( UIAlertAction ( title: " Cancel " , style: . cancel, handler: nil ) )
135152 self . present ( alert, animated: true , completion: nil )
136153 }
137154
138155 func printDocument( ) {
156+ Analytics . logEvent ( " menu_print " , parameters: nil )
157+
139158 let printController = UIPrintInteractionController . shared
140159 let printInfo : UIPrintInfo = UIPrintInfo ( dictionary: nil )
141160
0 commit comments