Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.h

Issue 2589803002: Upstream Chrome on iOS source code [6/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_UI_OVERSCROLL_ACTIONS_OVERSCROLL_ACTIONS_CONTROLLER_H _
6 #define IOS_CHROME_BROWSER_UI_OVERSCROLL_ACTIONS_OVERSCROLL_ACTIONS_CONTROLLER_H _
7
8 #import <UIKit/UIKit.h>
9
10 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h"
11 #import "ios/chrome/browser/ui/util/relaxed_bounds_constraints_hittest.h"
12 #import "ios/web/public/web_state/crw_web_controller_observer.h"
13 #import "ios/web/public/web_state/crw_web_view_scroll_view_proxy.h"
14
15 @class OverscrollActionsController;
16
17 namespace ios_internal {
18 // Describe the current state of the overscroll action controller.
19 enum class OverscrollState {
20 NO_PULL_STARTED, // No pull started.
21 STARTED_PULLING, // Started pulling.
22 ACTION_READY // Ready to take action on pull end.
23 };
24
25 // Notification sent when the overscroll actions controller will start
26 // displaying the UI.
27 extern NSString* const kOverscollActionsWillStart;
28 // Notification sent when the overscroll actions controller did stop displaying
29 // the UI.
30 extern NSString* const kOverscollActionsDidEnd;
31 } // namespace ios_internal
32
33 // The delegate of the OverscrollActionsController, it provides the headerView
34 // on which the OverscrollActionsView will be added.
35 // The scrollView is used to control the state of the
36 // OverscrollActionsController.
37 // The delegate must implement the shouldAllowOverscrollActions method in order
38 // to allow overscroll actions.
39 // Finally the overscrollActionsController:didTriggerActionAtIndex: method is
40 // called when an action has been triggered.
41 @protocol OverscrollActionsControllerDelegate<NSObject>
42 // Called when an action has been triggered.
43 // The action index holds the current triggered action which are numbered left
44 // to right.
45 - (void)overscrollActionsController:(OverscrollActionsController*)controller
46 didTriggerAction:(ios_internal::OverscrollAction)action;
47 // Should return true when the delegate wants to enable the overscroll actions.
48 - (BOOL)shouldAllowOverscrollActions;
49 // The toolbar snapshot view that will be used to fade in/out the toolbar.
50 // This snapshot will be animated when performing the pull down animation
51 // revealing the actions.
52 - (UIView*)toolbarSnapshotView;
53 // The header view over which the overscroll action view will be added.
54 - (UIView<RelaxedBoundsConstraintsHitTestSupport>*)headerView;
55 // Called to retrieve the top inset added to the scrollview for the header.
56 - (CGFloat)overscrollActionsControllerHeaderInset:
57 (OverscrollActionsController*)controller;
58 // Called to retrieve the current height of the header.
59 - (CGFloat)overscrollHeaderHeight;
60 @end
61
62 // The OverscrollActionsController controls the display of an
63 // OverscrollActionsView above the headerView provided by the delegate.
64 // Pulling down the scrollview will start showing the OverscrollActionView.
65 // Finally, the headerView frame will be resized in height during the process of
66 // showing the overscrollActionsView.
67 // The OverscrollActionsController can be used in two different modes depending
68 // on what kind of scrollview it's using:
69 // The first mode will use the scrollview provided by the
70 // CRWWebControllerObserver. To use this mode the OverscrollActionsController
71 // must be initialized with a nil scrollview. The -(instancetype)init
72 // initializer will do that for you.
73 // The second mode will use the scrollview provided during initialization and
74 // will ignore calls from the CRWWebControllerObserver.
75 // This second mode will typically be used in native tabs like the error tabs
76 // or the NTP.
77
78 @interface OverscrollActionsController
79 : NSObject<CRWWebControllerObserver, UIScrollViewDelegate>
80
81 // Init the OverscrollActionsController with a nil scrollview.
82 // If the scrollview is nil then the OverscrollActionsController will be
83 // configured to use the scrollview from the CRWWebControllerObserver.
84 - (instancetype)init;
85 // Designated initializer, when initialized with a scrollview, the
86 // OverscrollActionsController will not use the CRWWebControllerObserver to
87 // configure the scrollview, it will directly use the passed scrollview.
88 - (instancetype)initWithScrollView:(UIScrollView*)scrollView;
89
90 // The scrollview the overscroll controller will control.
91 @property(nonatomic, readonly) UIScrollView* scrollView;
92 // The current state of the overscroll controller.
93 @property(nonatomic, assign, readonly)
94 ios_internal::OverscrollState overscrollState;
95 // The delegate must be set for the OverscrollActionsController to work
96 // properly.
97 @property(nonatomic, assign) id<OverscrollActionsControllerDelegate> delegate;
98
99 // Used to clear state maintained by the controller and de-register from
100 // notifications. After this call the controller ceases to function and will
101 // clear its delegate.
102 - (void)invalidate;
103 // Force the controller to switch to NO_PULL_STARTED state.
104 - (void)clear;
105 // Disabling overscroll actions will stop showing the overscroll actions view on
106 // top of the header when the user is pulling the webview's scrollview.
107 // Disable/enableOverscrollActions method calls are ref counted, this means
108 // that calls to disable must be compensated by the same amount of call to
109 // enable in order to reenable overscroll actions.
110 - (void)disableOverscrollActions;
111 // Enabling overscroll actions will reverse the effect of a call to
112 // -disableOverscrollActions.
113 - (void)enableOverscrollActions;
114 // Sets the style of the overscroll actions.
115 - (void)setStyle:(ios_internal::OverscrollStyle)style;
116
117 @end
118
119 #endif // IOS_CHROME_BROWSER_UI_OVERSCROLL_ACTIONS_OVERSCROLL_ACTIONS_CONTROLLE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698